require("luaScript.test") -- 主界面 local MainView = class("MainView", require("core.luaScript.Views.Main.MainView")) local targetPlatform = cc.Application:getInstance():getTargetPlatform() function MainView:ctor(...) MainView.super.ctor(self,...) self.weixinAuthTime = 0 self.lastSendLogin = 0; end function MainView:onEnter() MainView.super.onEnter(self) self.ui.Items.Button_daili:setVisible(false) if G_LayerMain then G_LayerMain:showBoard(true) G_LayerMain:showFloat(true) end end function MainView:onClickButtonDaiLi() playBtnEffect() if isWin32Platform() then showTooltip("请在手机上操作") return end -- local url = "http://cs.zxtycest.com/addons/kefu/index/mobile?gameid=47" local url = "http://cs.zxtycest.com/addons/kefu?gameid=47" app.plugin:callUrl(url); end function MainView:getSubGameListReview() local gameList = { [1] = {sort = 1, gameType = "sub", gameId = 13}, [2] = {sort = 2, gameType = "sub", gameId = 42}, [3] = {sort = 3, gameType = "sub", gameId = 43}, [4] = {sort = 4, gameType = "sub", gameId = 51}, [5] = {sort = 5, gameType = "sub", gameId = 52}, [6] = {sort = 6, gameType = "sub", gameId = 54}, [7] = {sort = 7, gameType = "sub", gameId = 58}, [8] = {sort = 8, gameType = "sub", gameId = 28}, [9] = {sort = 9, gameType = "sub", gameId = 45}, [10] = {sort = 10, gameType = "sub", gameId = 46}, } return gameList; end -- 显示项目自己的公告,每个项目的公告可能是不一样的 -- isFirstLogin : 是否首次进入大厅 function MainView:showProjectNotice(isFirstLogin) if isFirstLogin and not isWin32Platform() then --设置密码 execInMainViewQueue(function(endCallback) local userInfo = json.decode(app.user.userInfo); logD("yhj userInfo.password :",userInfo.password) if not userInfo.password or userInfo.password == "" or string.len(userInfo.password) < 5 then local view = import("luaScript.Views.Main.SetPasswordView"):new(endCallback, false) view:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(view) else if endCallback then endCallback() end end end) --二次授权 execInMainViewQueue(function(endCallback) if not app.plugin:isSupportWeiXin() then local text = "未安装【微信】,是否前往下载【微信】?" local okBtnImage = "res/ui/zy_tongyong/zy_button/btn_like_xiazai.png" local okCallBack = function() app.plugin:callUrl("http://weixin.qq.com/"); end local cancelCallBack = function() end showConfirmDialog(text, okCallBack, cancelCallBack, 26, okBtnImage) return; end local function onOk() local timeNow = os.time(); if timeNow - self.weixinAuthTime <= 10 then showTooltip("点击太过频繁,请稍后再试") return end self.weixinAuthTime = timeNow; self:initNewWetChat(endCallback) end local message = "登录授权过期,点击重新授权"; if tonumber(app.user.authorize) == 0 then showConfirmDialogNotClose(message, onOk, nil, nil, nil, nil, true) else if endCallback then endCallback() end end end) --绑定手机 execInMainViewQueue(function(endCallback) local userInfo = json.decode(app.user.userInfo); logD("yhj userInfo.phonenum:",userInfo.phonenum) if not userInfo.phonenum or userInfo.phonenum == "" then local view = import("luaScript.Views.Main.PhoneBindView"):new(endCallback) view:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(view) else if endCallback then endCallback() end end end) --强制更新 -- execInMainViewQueue(function(endCallback) -- if (cc.Application:getInstance():getTargetPlatform() == 4 or cc.Application:getInstance():getTargetPlatform() == 5) -- and getAppVersionNum() == 200 then -- local content = { -- "强制更新\n", -- "1.基于平台升级,为了便于操作,系统已帮你把用户ID("..tostring(app.user.loginInfo.uid)..")复制到手机剪贴板,玩家可以选择截图保存\n", -- "-.请牢固你的用户ID和密码,密码不知道可以找客服重置\n", -- "-.请牢固你的用户ID和密码,密码不知道可以找客服重置\n", -- "-.请牢固你的用户ID和密码,密码不知道可以找客服重置\n", -- "IOS 用户更新后,将短暂无法使用微信登录,请使用ID/手机号 + 密码登录形式进入游戏\n", -- } -- local txt = "" -- for k,v in ipairs(content) do -- txt = txt..v -- end -- local function onOk() -- local url = "http://gamedown.onewaygame.cn/index.php/Index/game.html?gameid=1586871474" -- app.plugin:callUrl(url); -- end -- local view = import("luaScript.Views.Main.NoticeTextView"):new(txt,onOk) -- view:setAnchorPoint(cc.p(0.5,0.5)) -- app:showWaitDialog(view,0) -- --拷贝用户ID -- copyStringToClipboard(tostring(app.user.loginInfo.uid)) -- return -- end -- end) --普通授权 -- if cc.Application:getInstance():getTargetPlatform() == 3 then -- execInMainViewQueue(function(endCallback) -- if not app.plugin:isSupportWeiXin() then -- local text = "未安装【微信】,是否前往下载【微信】?" -- local okBtnImage = "res/ui/zy_tongyong/zy_button/btn_like_xiazai.png" -- local okCallBack = function() -- app.plugin:callUrl("http://weixin.qq.com/"); -- end -- local cancelCallBack = function() -- end -- showConfirmDialog(text, okCallBack, cancelCallBack, 26, okBtnImage) -- return; -- end -- local visible = app.user.unionid == "?" -- if visible then -- local message = "请更新您的微信信息"; -- local function onOk() -- local timeNow = os.time(); -- if timeNow - self.lastSendLogin <= 10 then -- showTooltip("点击太过频繁,请稍后再试") -- return -- end -- --绑定标志 -- app.user.bindWeiXinIng = true -- --启动登录微信 -- app.plugin:loginWeiXin() -- end -- showConfirmDialogNotClose(message, onOk) -- --普通授权,去掉队列继续 -- self:bindEvent(app, "showConfirmDialogNotClose",function () -- if endCallback then -- endCallback() -- end -- end) -- else -- if endCallback then -- endCallback() -- end -- end -- end) -- end end end function MainView:updateSubGameList() local page = self.ui.Items.Layout_Page page:removeAllChildren() local regionCode = cc.UserDefault:getInstance():getIntegerForKey("address_code_" .. app.config.RomSetting.Platform) local gameList = app.serverConfigs:getGameList(regionCode) if isReviewVersion() then gameList = self:getSubGameListReview() end -- 插入天梯 -- local tiantiInfo = {} -- tiantiInfo = { -- gameType = "tianti", -- } -- table.insert(gameList, 1, tiantiInfo) for i = 1, 10 do local game = gameList[i] if game then if game.gameType=="tianti" then local uiSubGame = import("luaScript.Views.Main.MainViewTiantiIcon"):new(game.gameId) page:addChild(uiSubGame.ui) elseif game.gameType=="sub" then local gameGroupConfig = app.serverConfigs:getGameGroupConfig(game.gameId, regionCode) if gameGroupConfig then gameGroupConfig.games = {} if game.data then for k,v in ipairs(game.data) do table.insert(gameGroupConfig.games,v.gameId) end end local uiSubGame = import("luaScript.Views.Main.MainViewGameIconGroup"):new(gameGroupConfig) page:addChild(uiSubGame.ui) else local uiSubGame = import("luaScript.Views.Main.MainViewGameIcon"):new(game.gameId) page:addChild(uiSubGame.ui) end else local gameGroupConfig = app.serverConfigs:getWebGameGroupConfig(game.gameId) if gameGroupConfig then if game.data then for k,v in ipairs(game.data) do table.insert(gameGroupConfig.games,v.gameId) end end local uiSubGame = import("luaScript.Views.Main.MainViewGameIconGroup"):new(gameGroupConfig) page:addChild(uiSubGame.ui) else local isInGroup = app.serverConfigs:isWebGameInGroup(game.gameId) if not isInGroup then -- 如果已经在合集里了,就不再显示了 self:createWebGameItem(game) end end end end end end return MainView