您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

265 行
8.2 KiB

  1. require("luaScript.test")
  2. -- 主界面
  3. local MainView = class("MainView", require("core.luaScript.Views.Main.MainView"))
  4. local targetPlatform = cc.Application:getInstance():getTargetPlatform()
  5. function MainView:ctor(...)
  6. MainView.super.ctor(self,...)
  7. self.weixinAuthTime = 0
  8. self.lastSendLogin = 0;
  9. end
  10. function MainView:onEnter()
  11. MainView.super.onEnter(self)
  12. self.ui.Items.Button_daili:setVisible(false)
  13. if G_LayerMain then
  14. G_LayerMain:showBoard(true)
  15. G_LayerMain:showFloat(true)
  16. end
  17. end
  18. function MainView:onClickButtonDaiLi()
  19. playBtnEffect()
  20. if isWin32Platform() then
  21. showTooltip("请在手机上操作")
  22. return
  23. end
  24. -- local url = "http://cs.zxtycest.com/addons/kefu/index/mobile?gameid=47"
  25. local url = "http://cs.zxtycest.com/addons/kefu?gameid=47"
  26. app.plugin:callUrl(url);
  27. end
  28. function MainView:getSubGameListReview()
  29. local gameList = {
  30. [1] = {sort = 1, gameType = "sub", gameId = 13},
  31. [2] = {sort = 2, gameType = "sub", gameId = 42},
  32. [3] = {sort = 3, gameType = "sub", gameId = 43},
  33. [4] = {sort = 4, gameType = "sub", gameId = 51},
  34. [5] = {sort = 5, gameType = "sub", gameId = 52},
  35. [6] = {sort = 6, gameType = "sub", gameId = 54},
  36. [7] = {sort = 7, gameType = "sub", gameId = 58},
  37. [8] = {sort = 8, gameType = "sub", gameId = 28},
  38. [9] = {sort = 9, gameType = "sub", gameId = 45},
  39. [10] = {sort = 10, gameType = "sub", gameId = 46},
  40. }
  41. return gameList;
  42. end
  43. -- 显示项目自己的公告,每个项目的公告可能是不一样的
  44. -- isFirstLogin : 是否首次进入大厅
  45. function MainView:showProjectNotice(isFirstLogin)
  46. if isFirstLogin and not isWin32Platform() then
  47. --设置密码
  48. execInMainViewQueue(function(endCallback)
  49. local userInfo = json.decode(app.user.userInfo);
  50. logD("yhj userInfo.password :",userInfo.password)
  51. if not userInfo.password or userInfo.password == "" or string.len(userInfo.password) < 5 then
  52. local view = import("luaScript.Views.Main.SetPasswordView"):new(endCallback, false)
  53. view:setAnchorPoint(cc.p(0.5, 0.5))
  54. app:showWaitDialog(view)
  55. else
  56. if endCallback then
  57. endCallback()
  58. end
  59. end
  60. end)
  61. --二次授权
  62. execInMainViewQueue(function(endCallback)
  63. if not app.plugin:isSupportWeiXin() then
  64. local text = "未安装【微信】,是否前往下载【微信】?"
  65. local okBtnImage = "res/ui/zy_tongyong/zy_button/btn_like_xiazai.png"
  66. local okCallBack = function()
  67. app.plugin:callUrl("http://weixin.qq.com/");
  68. end
  69. local cancelCallBack = function()
  70. end
  71. showConfirmDialog(text, okCallBack, cancelCallBack, 26, okBtnImage)
  72. return;
  73. end
  74. local function onOk()
  75. local timeNow = os.time();
  76. if timeNow - self.weixinAuthTime <= 10 then
  77. showTooltip("点击太过频繁,请稍后再试")
  78. return
  79. end
  80. self.weixinAuthTime = timeNow;
  81. self:initNewWetChat(endCallback)
  82. end
  83. local message = "登录授权过期,点击重新授权";
  84. if tonumber(app.user.authorize) == 0 then
  85. showConfirmDialogNotClose(message, onOk, nil, nil, nil, nil, true)
  86. else
  87. if endCallback then
  88. endCallback()
  89. end
  90. end
  91. end)
  92. --绑定手机
  93. execInMainViewQueue(function(endCallback)
  94. local userInfo = json.decode(app.user.userInfo);
  95. logD("yhj userInfo.phonenum:",userInfo.phonenum)
  96. if not userInfo.phonenum or userInfo.phonenum == "" then
  97. local view = import("luaScript.Views.Main.PhoneBindView"):new(endCallback)
  98. view:setAnchorPoint(cc.p(0.5, 0.5))
  99. app:showWaitDialog(view)
  100. else
  101. if endCallback then
  102. endCallback()
  103. end
  104. end
  105. end)
  106. --强制更新
  107. -- execInMainViewQueue(function(endCallback)
  108. -- if (cc.Application:getInstance():getTargetPlatform() == 4 or cc.Application:getInstance():getTargetPlatform() == 5)
  109. -- and getAppVersionNum() == 200 then
  110. -- local content = {
  111. -- "强制更新\n",
  112. -- "1.基于平台升级,为了便于操作,系统已帮你把用户ID("..tostring(app.user.loginInfo.uid)..")复制到手机剪贴板,玩家可以选择截图保存\n",
  113. -- "-.请牢固你的用户ID和密码,密码不知道可以找客服重置\n",
  114. -- "-.请牢固你的用户ID和密码,密码不知道可以找客服重置\n",
  115. -- "-.请牢固你的用户ID和密码,密码不知道可以找客服重置\n",
  116. -- "IOS 用户更新后,将短暂无法使用微信登录,请使用ID/手机号 + 密码登录形式进入游戏\n",
  117. -- }
  118. -- local txt = ""
  119. -- for k,v in ipairs(content) do
  120. -- txt = txt..v
  121. -- end
  122. -- local function onOk()
  123. -- local url = "http://gamedown.onewaygame.cn/index.php/Index/game.html?gameid=1586871474"
  124. -- app.plugin:callUrl(url);
  125. -- end
  126. -- local view = import("luaScript.Views.Main.NoticeTextView"):new(txt,onOk)
  127. -- view:setAnchorPoint(cc.p(0.5,0.5))
  128. -- app:showWaitDialog(view,0)
  129. -- --拷贝用户ID
  130. -- copyStringToClipboard(tostring(app.user.loginInfo.uid))
  131. -- return
  132. -- end
  133. -- end)
  134. --普通授权
  135. -- if cc.Application:getInstance():getTargetPlatform() == 3 then
  136. -- execInMainViewQueue(function(endCallback)
  137. -- if not app.plugin:isSupportWeiXin() then
  138. -- local text = "未安装【微信】,是否前往下载【微信】?"
  139. -- local okBtnImage = "res/ui/zy_tongyong/zy_button/btn_like_xiazai.png"
  140. -- local okCallBack = function()
  141. -- app.plugin:callUrl("http://weixin.qq.com/");
  142. -- end
  143. -- local cancelCallBack = function()
  144. -- end
  145. -- showConfirmDialog(text, okCallBack, cancelCallBack, 26, okBtnImage)
  146. -- return;
  147. -- end
  148. -- local visible = app.user.unionid == "?"
  149. -- if visible then
  150. -- local message = "请更新您的微信信息";
  151. -- local function onOk()
  152. -- local timeNow = os.time();
  153. -- if timeNow - self.lastSendLogin <= 10 then
  154. -- showTooltip("点击太过频繁,请稍后再试")
  155. -- return
  156. -- end
  157. -- --绑定标志
  158. -- app.user.bindWeiXinIng = true
  159. -- --启动登录微信
  160. -- app.plugin:loginWeiXin()
  161. -- end
  162. -- showConfirmDialogNotClose(message, onOk)
  163. -- --普通授权,去掉队列继续
  164. -- self:bindEvent(app, "showConfirmDialogNotClose",function ()
  165. -- if endCallback then
  166. -- endCallback()
  167. -- end
  168. -- end)
  169. -- else
  170. -- if endCallback then
  171. -- endCallback()
  172. -- end
  173. -- end
  174. -- end)
  175. -- end
  176. end
  177. end
  178. function MainView:updateSubGameList()
  179. local page = self.ui.Items.Layout_Page
  180. page:removeAllChildren()
  181. local regionCode = cc.UserDefault:getInstance():getIntegerForKey("address_code_" .. app.config.RomSetting.Platform)
  182. local gameList = app.serverConfigs:getGameList(regionCode)
  183. if isReviewVersion() then
  184. gameList = self:getSubGameListReview()
  185. end
  186. -- 插入天梯
  187. -- local tiantiInfo = {}
  188. -- tiantiInfo = {
  189. -- gameType = "tianti",
  190. -- }
  191. -- table.insert(gameList, 1, tiantiInfo)
  192. for i = 1, 10 do
  193. local game = gameList[i]
  194. if game then
  195. if game.gameType=="tianti" then
  196. local uiSubGame = import("luaScript.Views.Main.MainViewTiantiIcon"):new(game.gameId)
  197. page:addChild(uiSubGame.ui)
  198. elseif game.gameType=="sub" then
  199. local gameGroupConfig = app.serverConfigs:getGameGroupConfig(game.gameId, regionCode)
  200. if gameGroupConfig then
  201. gameGroupConfig.games = {}
  202. if game.data then
  203. for k,v in ipairs(game.data) do
  204. table.insert(gameGroupConfig.games,v.gameId)
  205. end
  206. end
  207. local uiSubGame = import("luaScript.Views.Main.MainViewGameIconGroup"):new(gameGroupConfig)
  208. page:addChild(uiSubGame.ui)
  209. else
  210. local uiSubGame = import("luaScript.Views.Main.MainViewGameIcon"):new(game.gameId)
  211. page:addChild(uiSubGame.ui)
  212. end
  213. else
  214. local gameGroupConfig = app.serverConfigs:getWebGameGroupConfig(game.gameId)
  215. if gameGroupConfig then
  216. if game.data then
  217. for k,v in ipairs(game.data) do
  218. table.insert(gameGroupConfig.games,v.gameId)
  219. end
  220. end
  221. local uiSubGame = import("luaScript.Views.Main.MainViewGameIconGroup"):new(gameGroupConfig)
  222. page:addChild(uiSubGame.ui)
  223. else
  224. local isInGroup = app.serverConfigs:isWebGameInGroup(game.gameId)
  225. if not isInGroup then
  226. -- 如果已经在合集里了,就不再显示了
  227. self:createWebGameItem(game)
  228. end
  229. end
  230. end
  231. end
  232. end
  233. end
  234. return MainView