require("luaScript.test") --主界面 local MainView = class("MainView", cc.UIView) local PluginConfig = require("preload.PluginConfig") local targetPlatform = cc.Application:getInstance():getTargetPlatform() local IS_FIRST_LOGIN = true local IS_FIRST_TanHongBao = true local IS_FIRST_Change = true --openData是json decode后数据 --原来的subGameID和roomid弃用,为了能打开俱乐部,原有的打开方式不变 function MainView:ctor(openData) MainView.super.ctor(self) if type(openData) == "number" then self.openData = {gameId = openData} else self.openData = openData end self._lastAddressCode = cc.UserDefault:getInstance():getIntegerForKey("address_code_" .. getCurrentPlatform()) self:loadUI() end function MainView:loadUI() local ui = loadUI("res/ui/ui_dating/ui_dating.ui") self.ui = ui self:addChild(ui) self.bgpropid = nil --设置默认背景 self:setDefaultBG() end function MainView:onEnter() MainView.super.onEnter(self) setInClubRoom(false) self:initClubName() self:initButton() self:initBottomBar(); -- 版本信息 self:initVersion() -- 玩家信息 self:initPlayerInfo() -- 滚动公告 startScrollTips(self.ui.Items.Text, 80, app.user.scroll, self.ui.Items.Layout_Text) -- 子游戏列表获取成功后更新列表 self:initSubGameList() self:initOpenClub() self:initOpenCoin() self:initOpenMatch() self:initBindEvent() self:initTopBar(); -- 请求活动数据 if not isReviewVersion() then if app.config.ModuleConfig.IsSupportHongBaoKa then app.php:requestGetActivityInfo() end end --请求茶馆列表数据 app.club_php:requestClubList() --获取活动数据 if not isReviewVersion() then self:initActivity() end -- 针对审核版本的特殊处理,软著/苹果审核 self:initReviewVersion() -- 显示项目自己的公告 self:showProjectNotice(IS_FIRST_LOGIN) self:showForceIdentity(); end function MainView:initNewWetChat(endCallback) if tonumber(app.user.authorize) == 0 then if not app.plugin:isSupportWeiXin() then logD("未安装【微信】,不需要绑定二次授权") return; end logD("MainView:initNewWetChat()") --绑定标志 app.user.bindWeiXinTwice = true PluginConfig.WeiXin = PluginConfig.WeiXinNew logD(table.tostring(PluginConfig.WeiXin)) --启动登录微信 app.plugin:loginWeiXin() else if endCallback then endCallback() end end --如果是二次授权,去掉队列继续 self:bindEvent(app, "showConfirmDialogNotClose",function () if endCallback then endCallback() end end) end function MainView:onWetChatBindRequest(event) local request = event.request if request then logD("MainView:onWetChatBindRequest:",table.tostring(request)) self.ui:sendMsg(app.user, "requestBindPhoneNum", request) end end function MainView:onExit() MainView.super.onExit(self) IS_FIRST_LOGIN = false end -- 软著/苹果审核 function MainView:initReviewVersion() if not isReviewVersion() then return end -- 左侧按钮全部隐藏 self.ui.Items.Layout_Left:setVisible(false) end --初始化是否打开俱乐部界面 function MainView:initOpenClub() -- 是否打开茶馆大厅 if app.club_php.clubID and app.club_php.clubID > 0 then local view = import("luaScript.Views.Club.ClubMain"):new(); view:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(view) end cc.UserDefault:getInstance():setBoolForKey("firstLogin",false) end --打开金币场 function MainView:initOpenCoin() if self.openData and self.openData.isCoin then local view = import("luaScript.Views.Coin.CoinView"):new(self.openData.gameId,self.openData.gameRule) view:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(view) end end --打开比赛场 function MainView:initOpenMatch() if self.openData and self.openData.isMatch then local view = import("luaScript.Views.Match.MatchMainView"):new(self.openData.gameId,self.openData.gameRule) view:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(view) end end --初始化事件绑定 function MainView:initBindEvent() self:bindEvent(app.user, "onBindResponse", handler(self, self.onPhoneBindResponse)) -- 监听APP从后台回来的消息 logD("MainView add onMainViewLoginSuccessed") self:bindEvent(app.user, "onMainViewLoginSuccessed" , handler(self, self.onLoginSuccessed)) self:bindEvent(app, "applicationWillEnterForeground" , handler(self, self.onLoginSuccessed)) --收到禁止同桌结果事件 self:bindEvent(app.club , "onClubNotSameDeskResponse" , handler(self , self.onClubNotSameDeskResponse)) --绑定消息通知回调 self:bindEvent(app.club_php , GAME_EVENT.CLUB_INVITE , handler(self , self.onClubIniteEvent)) --整点领取奖励 self:bindEvent(app, "onResponseGetJiangli", handler(self, self.onResponseGetJiangli)); self:bindEvent(app, "onGetHongBaoKaInfoResponse", handler(self, self.onGetHongBaoKaInfoResponse)); --背景发生变化 self:bindEvent(app , "onBagOperateResponse" , handler(self , self.onLoadDTBG)); self:bindEvent(app,"PHP_LGIN_SUCCESSED",handler(self , self.onLoadDTBG)) --注销账号提醒 self:bindEvent(app,"LOGOUT_TIPS",handler(self , self.onLogOutTips)) -- 玩家自行修改地区 self:bindEvent(app, GAME_EVENT.EVENT_CHANGE_ADDRESS, handler(self, self.onEventChangeAddress)) --绑定获取茶馆列表消息 self:bindEvent(app.club_php , GAME_EVENT.CLUB_LIST , handler(self , self.onGetClubResult)); --监听退出,更新按钮信息 self:bindEvent(app , GAME_EVENT.CLUB_MAIN_CLOSE , handler(self , self.onUpdateBtnInfo)); --绑定微信 self:bindEvent(app.user, "onWetChatBindRequest", handler(self, self.onWetChatBindRequest)) end --初始按钮事件 function MainView:initButton() -- 点击玩家头像 self.ui.Items.ImageView_Head:registerClick(handler(self, self.onClickPlayerHead)) -- 按钮 - 兑换金币 self.ui.Items.Button_AddGold:registerClick(handler(self, self.OnClickButtonAddGold)) -- 暂不提供兑换金币服务 self.ui.Items.Button_AddGold:setVisible(false) -- 按钮 -兑换红包券 self.ui.Items.ImageView_HongBao:registerClick(handler(self, self.OnClickButtonAddHB)) self.ui.Items.Button_AddHongBao:registerClick(handler(self, self.OnClickButtonAddHB)) self.ui.Items.Layout_HongBaoKa:setVisible(app.config.ModuleConfig.IsSupportHongBaoKa) if isReviewVersion() then self.ui.Items.Layout_HongBaoKa:setVisible(false) end -- 按钮 - 向右滑动 self.ui.Items.Button_Right:registerClick(handler(self , self.onClickButtonRight)) self.ui.Items.Button_Right:setVisible(false) -- 按钮 - 邀请码 self.ui.Items.Button_Yaoqing:registerClick(handler(self , self.onClickButtonInviteCode)) self.ui.Items.Button_Yaoqing:setVisible(false) -- 按钮 - 绑定手机号码 self.ui.Items.Button_PhoneNum:registerClick(handler(self , self.onClickButtonBindPhone)) self.ui.Items.Button_PhoneNum:setVisible(false) self:onPhoneBindResponse() self.ui.Items.Button_daili:registerClick(handler(self, self.onClickButtonDaiLi)) -- 按钮 - 茶馆 self.ui.Items.Button_Club:registerClick(handler(self , self.onClickButtonClub)) self.ui.Items.Button_Club_Join:registerClick(handler(self , self.onClickButtonJoinClub)) self.ui.Items.Button_Club_Show:registerClick(handler(self , self.onEnterClub)) self.ui.Items.Button_Club_Show:setVisible(false) -- 按钮 - 金币场 self.ui.Items.Button_Gold:registerClick(handler(self , self.onClickButtonGold)) -- 按钮 - 测试 self.ui.Items.Button_test:registerClick(handler(self , self.onClickTest)) self.ui.Items.Button_test:setVisible(isDebug()) --领取现金 self.ui.Items.Button_PrizeCash:registerClick(handler(self , self.onClickPrizeCash)) self.ui.Items.Button_PrizeCash:setVisible(app.config.ModuleConfig.IsSupportInviteNewFriend); --创建房间 self.ui.Items.Button_Create:registerClick(handler(self , self.onClickMoreGame)) --复制ID self.ui.Items.Button_copy:registerClick(handler(self , self.onCopyID)) -- 兑换金币 self.ui.Items.ImageView_Gold:setVisible(false) --按钮 --倒计时 self.ui.Items.ImageView_Daojishi:registerClick(handler(self,self.onClickLingQu)) self:initDaojishi() self.ui.Items.Button_Back:setVisible(false) self.ui.Items.Layout_Touch:setVisible(false) self:initDiamondButtons(); self.ui.Items.Layout__:registerClick(function() self:onClickButtonDiamondArrow(false); end) self.ui.Items.Layout_Top_Right:requestDoLayout(); self.ui.Items.Layout_Top_Right:doLayout(); -- self.ui.Items.Layout_menu:requestDoLayout() -- self.ui.Items.Layout_menu:doLayout() self:initMainViewAnimMation(); end -- ========================================== 专用钻石、房卡 start ======================================================= --- MainView:isOpenSpecialDiamond 专用钻石/房卡 function MainView:isOpenSpecialDiamond() return false; end --- MainView:initDiamondButtons 初始化专用房卡 function MainView:initDiamondButtons() self.ui.Items.Layout_Diamond:setTouchEnabled(true); self.ui.Items.Layout_Diamond:setVisible(false) self.ui.Items.ListView_Game_Diamond:setAutoSize(true) self.ui.Items.ListView_Game_Diamond:hideAllBar() self.ui.Items.Button_AddDiamand:setVisible(false) self.ui.Items.Button_Diamond_Arrow:setVisible(false) self.ui.Items.Item_Diamond:setVisible(false) self.ui.Items.Text_Tip:setVisible(false) local isOpenSpecialDiamond = self:isOpenSpecialDiamond() self.ui.Items.Button_AddDiamand:setVisible(not isOpenSpecialDiamond) self.ui.Items.Button_Diamond_Arrow:setVisible(isOpenSpecialDiamond) if isOpenSpecialDiamond then -- 开启专用钻石,点击弹出专用钻石框 self.ui.Items.Button_Diamond_Arrow:registerClick(handler(self, self.onClickButtonDiamondArrow)); self.ui.Items.ImageView_Diamand:registerClick(handler(self, self.onClickButtonDiamondArrow)); else -- 未开启专用钻石,点击进入商城 self.ui.Items.Button_AddDiamand:registerClick(handler(self, self.OnClickButtonAddDiamand)) self.ui.Items.ImageView_Diamand:registerClick(handler(self, self.OnClickButtonAddDiamand)) end end --- MainView:onClickButtonDiamondArrow 显示专用钻石 -- @param isShow 是否显示,可选参数 function MainView:onClickButtonDiamondArrow(isShow) local diamondLayout = self.ui.Items.Layout_Diamond; if type(isShow) == "boolean" then diamondLayout:setVisible(isShow); else local isVisible = diamondLayout:isVisible(); diamondLayout:setVisible(not isVisible); if not isVisible then -- 打开的时候请求数据 app.php:requestDiamondSpecial(handler(self, self.updateGameDiamond)); end end end --- MainView:updateGameDiamond 更新专用钻石 -- @param data = { -- {gameName ="红中麻将",diamond = 100 }, -- {gameName ="来宾麻将",diamond = 100 }, -- } function MainView:updateGameDiamond(data) self.ui.Items.ListView_Game_Diamond:removeAllItems() if not (data and #data > 0) then self.ui.Items.Text_Tip:setVisible(true) return ; end self.ui.Items.Text_Tip:setVisible(false) for k,v in pairs(data) do local gameConfig = app.serverConfigs.subGameList[v.game_id] if gameConfig then local item = self.ui.Items.Item_Diamond:getCopied() local items = getUIItems(item) items.Text_Game_Name:setText(gameConfig.gameName) items.Text_Game_Diamond:setText(v.roomcard) item:setVisible(true) self.ui.Items.ListView_Game_Diamond:pushBackCustomItem(item) end end end -- ========================================== 专用钻石、房卡 end ======================================================= function MainView:setDefaultBG() if not app.config.ModuleConfig.IsSupportPropShop then return end local bgpid = cc.UserDefault:getInstance():getIntegerForKey("mybgpropid") if bgpid and bgpid > 99 then self.bgpropid = bgpid self.ui.Items.ImageView_BG:loadTexture(string.format("res/ui/zy_dating/dating/dating_di_%d.jpg",bgpid)) end end --更换桌面背景 function MainView:onLoadDTBG() if not app.php.mypropdata then return end local ischange = false for k,v in pairs(app.php.mypropdata) do if v.prop_id and v.prop_id >= 200 and v.prop_id < 300 then self.bgpropid = v.prop_id cc.UserDefault:getInstance():setIntegerForKey("mybgpropid",self.bgpropid) cc.UserDefault:getInstance():flush() self.ui.Items.ImageView_BG:loadTexture(string.format("res/ui/zy_dating/dating/dating_di_%d.jpg",v.prop_id)) ischange = true end end if not ischange then self.bgpropid = nil cc.UserDefault:getInstance():setIntegerForKey("mybgpropid",0) cc.UserDefault:getInstance():flush() self.ui.Items.ImageView_BG:loadTexture("res/ui/zy_dating/dating/img_dating_bg.jpg") --原来的底图 end end --- -- 初始化顶部工具栏 -- function MainView:initTopBar() if not app.config.ModuleConfig.IsSupportAddressSelector then return end if isReviewVersion() then return end local AddressSelector = require("luaScript.Views.Main.AddressSelector.AddressSelector") if AddressSelector and not self.addressSelector then self.addressSelector = AddressSelector:new(self.ui.Items.Layout_Top_Right) end end --- MainView:initBottomBar 初始化底部工具栏 function MainView:initBottomBar() if self.bottomBarView then return ; end local BottomBarView = require("luaScript.Views.Main.BottomBar.BottomView"); if BottomBarView then self.bottomBarView = BottomBarView:new(); self:addChild(self.bottomBarView); end end --- MainView:initMainViewAnimMation 初始化主界面动画 function MainView:initMainViewAnimMation() -- self:initRechargeViewAnimation(); self:initMoreGameAnimation(); self:initBindPhoneAnimation(); self:initHongBaoKaAnimation(); end -- --- MainView:initRechargeViewAnimation 初始化商城动画 -- function MainView:initRechargeViewAnimation () -- local effect = createAnimationByPlist("res/ui/zy_dating/dating/shop_animation.plist","dt_shangcheng-animation3_%d.png",0,40,0.5) -- self.ui.Items.Button_ShangCheng:addChild(effect) -- local size = self.ui.Items.Button_ShangCheng:getContentSize() -- effect:setPosition(cc.p(size.width/2+20,size.height/2+10)) -- end --- MainView:initMoreGameAnimation 初始化更多游戏提示动画 function MainView:initMoreGameAnimation () local seq = cc.Sequence:create( cc.ScaleTo:create(0.16,0.95), cc.ScaleTo:create(0.16,1), cc.ScaleTo:create(0.16,0.95), cc.ScaleTo:create(0.16,1), cc.ScaleTo:create(0.16,0.95), cc.ScaleTo:create(0.16,1), cc.DelayTime:create(3.0) ) self.ui.Items.ImageView_More_Tip:runAction(cc.RepeatForever:create(seq)) end --- MainView:initBindPhoneAnimation 初始化绑定手机提示动画(送18888红包券) function MainView:initBindPhoneAnimation () if not app.config.ModuleConfig.IsSupportHongBaoKa then self.ui.Items.ImageView_phone_tip:setVisible(false); self.ui.Items.Button_PhoneNum:loadTextureNormal("res/ui/zy_dating/dating/btn_phone_old.png", 0); return ; end local seq2 = cc.Sequence:create( cc.RotateTo:create(0.15,0), cc.RotateTo:create(0.15,-6), cc.RotateTo:create(0.16,0), cc.RotateTo:create(0.16,-6), cc.DelayTime:create(1.5) ) self.ui.Items.ImageView_phone_tip:runAction(cc.RepeatForever:create(seq2)) end --- MainView:initHongBaoKaAnimation 红包券动画 function MainView:initHongBaoKaAnimation () local seq2 = cc.Sequence:create( cc.RotateTo:create(0.05,0), cc.RotateTo:create(0.05,-6), cc.RotateTo:create(0.06,0), cc.RotateTo:create(0.06,6), cc.RotateTo:create(0.05,0), cc.RotateTo:create(0.05,-6), cc.RotateTo:create(0.06,0), cc.RotateTo:create(0.06,6), cc.RotateTo:create(0.05,0), cc.DelayTime:create(1) ) self.ui.Items.ImageView_HongBaoKa:runAction(cc.RepeatForever:create(seq2)) --整点领取 self.ui.Items.Image_ZhengDianLingQu:runAction( cc.RepeatForever:create( cc.Sequence:create( cc.ScaleTo:create(0.16,0.95), cc.ScaleTo:create(0.16,1), cc.ScaleTo:create(0.16,0.95), cc.ScaleTo:create(0.16,1), cc.ScaleTo:create(0.16,0.95), cc.ScaleTo:create(0.16,1), cc.DelayTime:create(3.0) ) ) ) end --监听是否切换到后台 function MainView:onApplicationWillEnterForeground() -- 请求活动数据 if app.config.ModuleConfig.IsSupportHongBaoKa then app.php:requestGetActivityInfo() end --重新初始化倒计时 self:initDaojishi() end function MainView:initDaojishi() local Text_offtime = self.ui.Items.Text_time Text_offtime:setText("可领取") self.singtype = 1 --是否可领取 1 可领取 3不可领取 if not self.actiyData then self.ui.Items.ImageView_Daojishi:setVisible(false) return end self.ui.Items.ImageView_Daojishi:setVisible(true) self.singtype = self.actiyData.active if self.singtype == 1 or self.singtype == 2 then return end if Text_offtime then Text_offtime:stopAllActions() Text_offtime:runAction(cc.RepeatForever:create(cc.Sequence:create(cc.CallFunc:create(function() local curM=tonumber(os.date("%M",os.time())) local curS=tonumber(os.date("%S",os.time())) local limit = 3600 - (curM*60 + curS) Text_offtime:setText(formatTimeToStr(limit)) if limit <= 1 then Text_offtime:setText("可领取") self.singtype = 1 Text_offtime:stopAllActions() else Text_offtime:setText(formatTimeToStr(limit)) end end),cc.DelayTime:create(1)))) end end -- 初始化游戏版本信息 function MainView:initVersion() if isReviewVersion() then self.ui.Items.Layout_Version:setVisible(false) return end self.ui.Items.Text_Type:setVisible(isDebug()) local appVersionNum = getAppVersionNum() local resVersion = loadVersion() self.ui.Items.Text_Version:setText("文明游戏,拒绝赌博 "..appVersionNum.."."..resVersion) end function MainView:initPlayerInfo() -- 初始化头像大小 local nodeHeadImage = self.ui.Items.ImageView_Head; self.head = {} self.head.width = nodeHeadImage:getContentSize().width self.head.height = nodeHeadImage:getContentSize().height logD("self.head = ", table.tostring(self.head)); logD("MainView:initPlayerInfo() userInfo = ", tostring(app.user.userInfo)) local userInfo = json.decode(app.user.userInfo); -- 昵称 local nickname = getSubStringNickname(userInfo.nickname) self.ui.Items.Text_Name:setText(nickname or tostring("未知昵称")) -- ID local id = tonumber(app.user.loginInfo.uid) or 0 self.ui.Items.Text_ID:setText(string.format("ID:%07d", id)) if app.user.loginInfo.curCardNum then -- 房卡数量 self.ui.Items.Text_Diamand:bind(app.user.loginInfo, "curCardNum", function() self.ui.Items.Text_Diamand:setString(tostring(app.user.loginInfo.curCardNum)) end) end --金币数量 self.ui.Items.Text_Gold:bind(app.user.loginInfo, "curJingbiNum", function() local num = tonumber(app.user.loginInfo.curJingbiNum) or 0 num = num + 2000 local str if num > 100000 then str = tostring(math.floor(num / 1000) / 10).."W" else str = tostring(num) end self.ui.Items.Text_Gold:setString(str) end) --红包卡数量 self.ui.Items.Text_HongBao:bind(app.user.loginInfo, "curLiquanNum", function() local strLiquanNum = tonumber(app.user.loginInfo.curLiquanNum) if strLiquanNum >= 10000 then local num = string.format("%.2f",app.user.loginInfo.curLiquanNum/10000) strLiquanNum = ""..num.."万" end self.ui.Items.Text_HongBao:setString(tostring(strLiquanNum)) end) -- 头像 local nodeHead = self.ui.Items.ImageView_Head; setPlayerHeadImage(app.user.loginInfo.uid, userInfo.headimgurl, nodeHead) end -- 初始化活动信息 function MainView:initActivity() --默认弹出活动界面 self:bindEvent(app, "onGetActivityInfoResponse", handler(self, self.showActivityOnEnter)); -- 分享成功后通知此层关闭分享界面 -- self:bindEvent(app , "shareSuccCallback" , handler(self , self.shareSuccCallback)); --关闭通知界面后弹出活动界面 -- self:bindEvent(app, "onCloseTongZhiSucc", handler(self, self.onCloseTongZhiSucc)); --关闭代理招募后弹出活动界面 -- self:bindEvent(app, "onCloseDaiLiZhaoMu", handler(self, self.onCloseDaiLiZhaoMu)); self:bindEvent(app, GAME_EVENT.ACTIVITY_CLOSE, handler(self, self.onActivityClose)); -- 请求活动数据 app.serverConfigs:requestMissionList() end -- 初始化游戏列表 function MainView:initSubGameList() self:bindEvent(app.serverConfigs, "getSubGameListSuccessed", handler(self, self.updateSubGameList)) self:updateSubGameList() 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 --logD(table.tostring(gameList)) for i = 1, 10 do local game = gameList[i] if game then if 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 function MainView:createWebGameItem(webGame) local gameLayout = cc.Layout:create() gameLayout:setSize(cc.size(152,188)) local webGameIcon = cc.ImageView:create() webGameIcon:setAutoSize(false) webGameIcon:setSize(cc.size(134,156)) setImageFromUrl(webGameIcon,webGame.icon) webGameIcon:registerClick(function() playBtnEffect() if not app.serverConfigs:isOpenWebGame(webGame.gameId) then showTooltip("敬请期待!") return end webGameIcon:setTouchEnabled(false) app.serverConfigs:requestWebGameUrl(webGame.gameId,function (url, orientation) if webGameIcon and not tolua.isnull(webGameIcon) then webGameIcon:setTouchEnabled(true) if not url or url =="" then showTooltip("敬请期待!") return end local function openWebGame () local targetPlatform = cc.Application:getInstance():getTargetPlatform() if targetPlatform == 3 then --判断是V开头的手机,一般是VIVO,比如V1901A local machineType = getLocalizedModel() if string.find(machineType,"V") == 1 then local index = string.find(url,"sc") if index then local params=string.sub(url,1,index-2) app.plugin:callUrl(params); else app.plugin:callUrl(url); end else logD("lwq_testtest_", webGame.gameId) if webGame.gameId == 10010 then -- 热爱三国 app.plugin:callUrl(url) else local view = import("luaScript.Views.Main.WebViews.WebGameView"):new(webGame.gameId, url, orientation) view:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(view,nil,true) end end else if webGame.gameId == 10010 then -- 热爱三国 app.plugin:callUrl(url) else local view = import("luaScript.Views.Main.WebViews.WebGameView"):new(webGame.gameId, url, orientation) view:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(view,nil,true) end end end if webGame.gameId == 10006 then local str = "根据剑荡江湖运营合作计划,公司将于3月10日停服,届时游戏将无法登录。给您带了的不便,深表歉意。点击确定继续游戏。"; showConfirmDialog(str, function () openWebGame() end) elseif webGame.gameId == 10009 then if isWin32Platform() then showTooltip("请在手机上操作") return end app.plugin:callUrl(url); else openWebGame() end end end) end) if app.serverConfigs:isNewWebGame(webGame.gameId) then local newIcon = cc.ImageView:create() newIcon:loadTexture("res/ui/zy_dating/dating/img_newTag.png") webGameIcon:addChild(newIcon) newIcon:setPosition(cc.p(40,125)) end local size = gameLayout:getContentSize() webGameIcon:setPosition(cc.p(size.width/2,size.height/2)) gameLayout:addChild(webGameIcon) self.ui.Items.Layout_Page:addChild(gameLayout) end -- 进入子游戏 function MainView:onClickSubGame(gameId) --[[if gameId == GAME_IDS.More or gameId == GAME_IDS.hejiangDaEr then--暂时屏蔽合江大贰 showTooltip("开发中...") return end--]] cc.UserDefault:getInstance():setBoolForKey("firstLogin",false) -- 打开对应的创建界面 local gameConfig = getSubGameConfig(gameId) if not gameConfig then showTooltip("开发中") return end app.gameId = gameId -- app.subGameManager:saveToFile(gameId) local gameData = {} gameData.gameId = gameId gameData.defaultPlayType = nil local createView = import("luaScript.Views.CreateRoom.CreateRoomBase"):new(gameData) createView:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(createView) -- self:updateSubGameList() end -- 兑换金币 function MainView:OnClickButtonAddGold() playBtnEffect() local view = import("luaScript.Views.Main.ExchangeView"):new() view:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(view) end -- 充值房卡 function MainView:OnClickButtonAddDiamand() playBtnEffect() local view = import("luaScript.Views.Main.RechargeView"):new(nil,nil,nil,self.bgpropid) view:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(view) end --- MainView:onClickLingQu 倒计时领取红包券 function MainView:onClickLingQu() --已经领取 playBtnEffect() if self.singtype == 3 then local view = import("luaScript.Views.Main.HongBaoKa.HongBaoKaSDJLView"):new() view:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(view) return end if not self.actiyData then return end if not app.php.islogin then return end --请求整点奖励 app.php:requestZhengDianJiangli() self.actiyData.active = 3 --开启倒计时 self:initDaojishi() end --- MainView:onResponseGetJiangli 领取奖励回复 -- @param result function MainView:onResponseGetJiangli(result) local addNum = result.data.add --显示获得红包卡动画 local view = import("luaScript.Views.Main.HongBaoKa.GetHongBaoKaEffect"):new(addNum,1) view:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(view, 200, true) end --- MainView:onGetHongBaoKaInfoResponse 收到红包券数据 function MainView:onGetHongBaoKaInfoResponse () if not app.php.activityData then return end self.actiyData = app.php.activityData[""..11] --再初始化一遍时间 self:initDaojishi() end --兑换红包卡 function MainView:OnClickButtonAddHB() playBtnEffect() local view = import("luaScript.Views.Main.HongBaoKa.MainHongBaoKaView"):new() view:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(view) end --活动分享成功 function MainView:shareSuccCallback() if (not tolua.isnull(self.activityshareview)) then self.activityshareview:removeFromParent() self.activityshareview = nil end end -- 设置 function MainView:onClickButtonEmail() playBtnEffect() showTooltip("开发中...") end -- 快速开始 function MainView:onClickButtonStart() playBtnEffect() local view = import("luaScript.Views.Main.JoinRoomView"):new() view:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(view) --从大厅进入游戏时清空保存的茶馆id及桌子下标 app.club_php.clubID = 0; app.club_php.tableIdx = 0 if cc.Application:getInstance():getTargetPlatform() == 0 then showTooltip("PC版快速进入房间") view:onClickTest(); end end -- 向右滑动 function MainView:onClickButtonRight() self.ui.Items.ScrollView:scrollBy(cc.p(-480,0),0.5,true) end -- 邀请码 function MainView:onClickButtonInviteCode() playBtnEffect() local view = import("luaScript.Views.Main.InviteCodeView"):new() view:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(view) end -- 绑定手机号 function MainView:onClickButtonBindPhone() playBtnEffect() local view = import("luaScript.Views.Main.PhoneBindView"):new() view:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(view) end function MainView:onClickButtonDaiLi() playBtnEffect() local view = import("luaScript.Views.Main.DaiLiView"):new() view:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(view) end -- 显示玩家信息的界面 function MainView:onClickPlayerHead() playBtnEffect() local view = import("luaScript.Views.Main.MainSettingView"):new() view:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(view) end --进入茶馆 function MainView:onEnterClub() local clubId = self.ui.Items.Button_Club_Show:getTag() if app.club_php:getCestIsOpen(clubId) then showTooltip("赛事结束,下一轮敬请期待!") return end --[[local view = import("luaScript.Views.Club.ClubTable"):new(clubId) view:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(view)--]] -- 是否打开茶馆大厅 app.club_php.clubID = clubId local view = import("luaScript.Views.Club.ClubMain"):new(); view:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(view) end -- 茶馆 function MainView:onClickButtonClub() playBtnEffect() local view = import("luaScript.Views.Club.ClubMain"):new(); view:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(view) --重新进入茶馆大厅时清空保存的茶馆id及桌子下标 app.club_php.clubID = 0; app.club_php.tableIdx = 0 cc.UserDefault:getInstance():setBoolForKey("firstLogin",false) end -- 茶馆 function MainView:onClickButtonJoinClub() playBtnEffect() local view = import("luaScript.Views.Club.ClubJoin"):new() view:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(view) cc.UserDefault:getInstance():setBoolForKey("firstLogin",false) end --获取茶馆列表结果 function MainView:onGetClubResult() local clubList = app.club_php.clubList if clubList and table.nums(clubList) > 0 and table.nums(self.operClubList) >= 0 then -- 排序 local tNewOperTimeList = {} for clubID,operTime in pairs(self.operClubList) do tNewOperTimeList[operTime] = clubID; end if table.nums(tNewOperTimeList) > 0 then for time, gid in pairsByKeysEx(tNewOperTimeList) do local curClub = clubList[tonumber(gid)] if curClub then local strClubName = getShortNameByLength(curClub.clubName, 6) self.ui.Items.Text_clubname:setText(strClubName) self.ui.Items.Button_Club_Show:setVisible(true) self.ui.Items.Button_Club_Show:setTag(tonumber(gid)) self.ui.Items.Button_Club_Join:setVisible(false) break end end else for k,v in pairsByKeys(clubList) do self.ui.Items.Button_Club_Show:setVisible(true) self.ui.Items.Button_Club_Show:setTag(tonumber(v.clubId)) self.ui.Items.Button_Club_Join:setVisible(false) local strClubName = getShortNameByLength(v.clubName, 6) if strClubName then self.ui.Items.Text_clubname:setText(strClubName) end break end end else self.ui.Items.Button_Club_Show:setVisible(false) self.ui.Items.Button_Club_Join:setVisible(true) end end -- 金币场 function MainView:onClickButtonGold() playBtnEffect() if not app.config.ModuleConfig.IsSupportCoin then showTooltip("敬请期待") return ; end local view = import("luaScript.Views.Coin.CoinView"):new(); view:setAnchorPoint(cc.p(0.5, 0.5)); app:showWaitDialog(view); end -- 启动游戏时弹出活动界面 function MainView:showActivityOnEnter() --如果是亲友圈房间内解散回来,再次打开俱乐部的情况则不弹窗了 if app.club_php.clubID and app.club_php.clubID > 0 then return end --每次登陆弹出通知弹窗 -- local firstLogin = cc.UserDefault:getInstance():getBoolForKey("firstLogin") if IS_FIRST_LOGIN then -- if cc.Application:getInstance():getTargetPlatform() ~= 0 then local viewName = app.serverConfigs:popConfig() if viewName then local viewClass = import(viewName) if viewClass then -- view存在,正常弹出 execInMainViewQueue(function(endCallback) local view = viewClass:new(endCallback) view:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(view) end) else -- view不存在,继续弹出下一个窗口 app:dispatchEvent(GAME_EVENT.ACTIVITY_CLOSE) end end -- end end end function MainView:onActivityClose() local viewName = app.serverConfigs:popConfig() if viewName then local view = import(viewName):new() view:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(view) end end function MainView:onLoginSuccessed() logD("MainView:onMainViewLoginSuccessed()") local roomId = nil local code = nil --"9024926188961793" --回放码 local str = copyStringFromClipboard() logD("MainView:onMainViewLoginSuccessed() str = ", str) -- showTooltip(str) --如果第一个是~!开头则代表是浏览器传的参数 if string.find(str,"~!")==1 then local baseStr=string.sub(str,3,string.len(str)) baseStr=base64.decode(baseStr) local params=json.decode(decodeURI(baseStr)) dump(params,"MainView:onMainViewLoginSuccessed params") if params then logD("do somthing!") if params.tableId then roomId = params.tableId end if params.code then code = params.code end end -- return else -- 检测玩家剪贴板里面是否有房间号, --如果有,查询这个房间号对应的游戏ID --如果没查到则不处理 --如果查到了,则判断游戏是否已安装 --未安装则提示安装,已安装则直接进入 roomId = getRoomIdFromCopyString(str) end -- local roomId = getRoomIdFromCopyString(str) logD("MainView:onMainViewLoginSuccessed() roomId = ", roomId) if roomId then local function onQueryRoomResponse(gameId, roomId) logD("MainView:onQueryRoomResponse() gameId = ", gameId) logD("MainView:onQueryRoomResponse() roomId = ", roomId) if not gameId or tonumber(gameId) <= 0 then return end copyStringToClipboard("") -- 检查这个子游戏是否已安装 if app.subGameManager then local function requestJoinRoom() app.hall:requestJoinRoom(gameId, roomId) end if not app.subGameManager:isInstaller(gameId) then requestDownloadSubGame(gameId, requestJoinRoom, true) else requestJoinRoom(); end end end app.hall:queryRoomId(tonumber(roomId), onQueryRoomResponse); end if code then copyStringToClipboard("") local view = import("luaScript.Views.ZhanJi.ZhanJiViewBase"):new(-1,nil,code) view:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(view) end --重新初始化倒计时 self:initDaojishi() end function MainView:onPhoneBindResponse(event) local phonenum = app.user.phonenum if phonenum and phonenum ~= "" then self.ui.Items.Button_PhoneNum:setVisible(false) end logD("MainView:onPhoneBindResponse") if not event then logD("MainView:onPhoneBindResponse not even") return end local response = event.response; local errCode = response.ret logD("MainView:onPhoneBindResponse errCode:",errCode); if errCode == BIND_TYPE_RESULT.WEIXIN or errCode == BIND_TYPE_RESULT.WEIXIN_TWICE_BIND then self:initPlayerInfo() end end function MainView:onClickTest() local view = import("luaScript.Views.TestView"):new() view:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(view) end function MainView:onClubNotSameDeskResponse(event) local playerInfo = json.decode(event.userInfo) setIsRoomGamedata(nil) local str = string.format("管理员已设置该牌桌 %s 玩家与您禁止同桌!",playerInfo.nickname) showConfirmDialog(str) end function MainView:onClubIniteEvent(event) --房间邀请通知 local content = event.content local clubId = event.clubId local viewType = type(self.inviteView) if self.inviteView and viewType == "userdata" then --提示框已存在 return end local function closeCallback() --关闭提示框时清空数据,用于下次弹出 self.inviteView = nil end self.inviteView = import("luaScript.Views.Club.ClubInviteRoomNew"):new(clubId, content, closeCallback) self.inviteView:setAnchorPoint(cc.p(0.5, 0.5)) -- app:showView(self.inviteView) app:showWaitDialog(self.inviteView,0) end function MainView:onClickMoreGame() playBtnEffect() --showTooltip("开发中...") local createView = import("luaScript.Views.CreateRoom.CreateRoomBase"):new() createView:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(createView) end function MainView:onCopyID() playBtnEffect() copyStringToClipboard(tostring(app.user.loginInfo.uid)) showTooltip("复制成功!") end --增加地区按钮 function MainView:onClickDiqu() showTooltip("开发中...") end function MainView:onClickPrizeCash() playBtnEffect() local view = import("luaScript.Views.Main.MainInviteNewFriend"):new(); view:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(view) end function MainView:onEventChangeAddress(event) local data = event.data; if not data then return end local address = data.address local addressCode = data.addressCode if self._lastAddressCode ~= addressCode or IS_FIRST_Change then IS_FIRST_Change = false self._lastAddressCode = addressCode app.waitDialogManager:showWaitNetworkDialog("请稍等...") app.serverConfigs:requestGameList(addressCode) -- self:updateSubGameList() end end --- -- 初始化上次使用俱乐部的名字 -- function MainView:initClubName() self:loadOperClubList() self.ui.Items.Text_clubname:setText("未加入" .. (app.club_php:getCestIsOpen(app.club_php.clubID) and PLN.CLUB_CEST_NAME or PLN.CLUB_NAME)) end function MainView:getSubGameListReview() local gameList = {} return gameList; end -- 从本地读取玩家上次的选择 function MainView:loadOperClubList() local fileName = "OperateClubList.data" local fileString = loadStringFromFile(fileName) if fileString then self.operClubList = json.decode(fileString) or {} else self.operClubList = {} end end function MainView:onUpdateBtnInfo() self:loadOperClubList() self:onGetClubResult() end -- 显示项目自己的公告,每个项目的公告可能是不一样的 -- isFirstLogin : 是否首次进入大厅 function MainView:showProjectNotice(isFirstLogin) end function MainView:showForceIdentity() if not isWin32Platform() then local isRealname = app.user.isRealname; if isRealname == 0 then local view = import("luaScript.Views.Main.ForceShiMingView"):new() view:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(view, 255, nil, 999) else --实名后判断是否满18岁 local isAdult = app.user.isAdult; if isAdult == 0 then local view = import("luaScript.Views.Main.ShiMingRejectView"):new() view:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(view, 255, nil, 999) end end end end function MainView:onLogOutTips() local view = import("luaScript.Views.Main.LogOut.LogOutTips"):new() view:setAnchorPoint(cc.p(0.5,0.5)) app:showWaitDialog(view,nil,false) end return MainView