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.

66 lines
1.5 KiB

  1. -- 主界面
  2. local TestView = class("TestView", cc.UIView)
  3. function TestView:ctor()
  4. TestView.super.ctor(self)
  5. local ui = loadUI("res/ui/ui_test.ui")
  6. self.ui = ui
  7. self:addChild(ui)
  8. end
  9. function TestView:onEnter()
  10. for i = 1,18 do
  11. self.ui.Items["Button_"..i]:registerClick(function ()
  12. self:onClickButton(i)
  13. end);
  14. end
  15. self.ui.Items.Button_close:registerClick(handler(self, self.onClickButtonClose));
  16. self.clientConfig = table.loadFromLocFile("ClientConfig.lua") or {}
  17. logD("clientConfig:",table.tostring(self.clientConfig))
  18. end
  19. function TestView:onClickButtonClose()
  20. self:removeFromParent();
  21. end
  22. function TestView:onClickButton(idx)
  23. if tostring(idx) == "18" then
  24. error("test error")
  25. return
  26. end
  27. self:initShare(idx)
  28. end
  29. function TestView:initShare(idx)
  30. idx = tonumber(idx)
  31. local config = import("luaScript.Config.MultiWechatConfig")
  32. if config and config[idx] then
  33. local info = config[idx]
  34. app.plugin:initWxShare(info.appId, info.appKey);
  35. --复制一下
  36. local name = "复制内容: appId:"..tostring(info.appId).." appKey:"..tostring(info.appKey);
  37. copyStringToClipboard(name)
  38. --拉起分享
  39. local imagePath = cc.FileUtils:getInstance():getWritablePath().."icon.png"
  40. local shareInfo = {}
  41. shareInfo.scene = "talk"
  42. shareInfo.contentType = "url"
  43. shareInfo.url = app.config.Setting.appDownloadUrl
  44. shareInfo.title = "测试分享"
  45. shareInfo.description = "测试分享"
  46. shareInfo.image = imagePath
  47. shareInfo.imageWidth = 100
  48. app.plugin:shareGame(shareInfo)
  49. end
  50. end
  51. return TestView