You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.3 KiB

  1. ---
  2. -- ================================================================
  3. -- 文件名: IGameCommon.lua
  4. -- 描述: 子游戏引用大厅接口
  5. -- 作者: Administrator
  6. -- 创建日期: 2020-2-18
  7. -- 更新日期: 2020-2-18
  8. -- 备注:
  9. -- ================================================================
  10. --
  11. local IGameCommon = {};
  12. --[[
  13. 获取分享的二维码图片
  14. ]]
  15. function IGameCommon.getShareCRCodeTexture(callback)
  16. local clientConfig = app.serverConfigs.clientConfig
  17. local crCodeUrl = clientConfig and clientConfig.qrcode or ""
  18. if crCodeUrl == "" then
  19. showTooltip("未配置二维码地址")
  20. return
  21. end
  22. --download
  23. local urlfile = convertIconUrl(crCodeUrl)
  24. local fileName = getImageNameFromUrl(urlfile)
  25. local fullPath = cc.FileUtils:getInstance():getWritablePath()..fileName;
  26. local isExist = cc.FileSystem:fileExists(fullPath)
  27. if not isExist then
  28. getImageFromUrlWithTime(crCodeUrl, fileName, nil, function()
  29. local texture = loadTextureFromFile(fileName)
  30. if not texture then
  31. logD("IGameCommon getShareCRCodeTexture not found")
  32. return
  33. end
  34. if callback then
  35. callback(texture)
  36. end
  37. end)
  38. else
  39. local texture = loadTextureFromFile(fileName)
  40. if not texture then
  41. logD("IGameCommon getShareCRCodeTexture not found")
  42. return
  43. end
  44. if callback then
  45. callback(texture)
  46. end
  47. end
  48. end
  49. return IGameCommon;