-- 主界面 local TestView = class("TestView", cc.UIView) function TestView:ctor() TestView.super.ctor(self) local ui = loadUI("res/ui/ui_test.ui") self.ui = ui self:addChild(ui) end function TestView:onEnter() for i = 1,18 do self.ui.Items["Button_"..i]:registerClick(function () self:onClickButton(i) end); end self.ui.Items.Button_close:registerClick(handler(self, self.onClickButtonClose)); self.clientConfig = table.loadFromLocFile("ClientConfig.lua") or {} logD("clientConfig:",table.tostring(self.clientConfig)) end function TestView:onClickButtonClose() self:removeFromParent(); end function TestView:onClickButton(idx) if tostring(idx) == "18" then error("test error") return end self:initShare(idx) end function TestView:initShare(idx) idx = tonumber(idx) local config = import("luaScript.Config.MultiWechatConfig") if config and config[idx] then local info = config[idx] app.plugin:initWxShare(info.appId, info.appKey); --复制一下 local name = "复制内容: appId:"..tostring(info.appId).." appKey:"..tostring(info.appKey); copyStringToClipboard(name) --拉起分享 local imagePath = cc.FileUtils:getInstance():getWritablePath().."icon.png" local shareInfo = {} shareInfo.scene = "talk" shareInfo.contentType = "url" shareInfo.url = app.config.Setting.appDownloadUrl shareInfo.title = "测试分享" shareInfo.description = "测试分享" shareInfo.image = imagePath shareInfo.imageWidth = 100 app.plugin:shareGame(shareInfo) end end return TestView