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.

778 lines
22 KiB

  1. require("luaScript.test")
  2. -- 主界面
  3. local MainReview = class("MainReview", cc.UIView)
  4. local targetPlatform = cc.Application:getInstance():getTargetPlatform()
  5. local IS_FIRST_LOGIN = true
  6. -- subGameId : 要打开的子游戏的界面
  7. function MainReview:ctor(subGameId, club_room_id)
  8. MainReview.super.ctor(self)
  9. self.subGameId = subGameId
  10. self.club_room_id = club_room_id
  11. --是否正在显示通知界面标志
  12. self.isShowTongZHiView = false
  13. self:loadUI()
  14. end
  15. function MainReview:loadUI()
  16. local ui = loadUI("res/ui/ui_dating/ui_dating_review.ui")
  17. self.ui = ui
  18. self:addChild(ui)
  19. end
  20. function MainReview:onEnter()
  21. MainReview.super.onEnter(self)
  22. self:initButton()
  23. -- 版本信息
  24. self:initVersion()
  25. -- 玩家信息
  26. self:initPlayerInfo()
  27. -- 滚动公告
  28. startScrollTips(self.ui.Items.Text, 80, app.user.scroll, self.ui.Items.Layout_Text)
  29. -- 子游戏列表获取成功后更新列表
  30. self:initSubGameList()
  31. self:initOpenClub()
  32. self:initReviewAndRuanZhu()
  33. self:initBindEvent()
  34. end
  35. --初始化是否打开俱乐部界面
  36. function MainReview:initOpenClub()
  37. if self.subGameId then
  38. -- 是否打开茶馆大厅
  39. if app.club_php.clubID and app.club_php.clubID > 0 then
  40. local view = import("luaScript.Views.Club.ClubMain"):new();
  41. view:setAnchorPoint(cc.p(0.5, 0.5))
  42. app:showWaitDialog(view)
  43. end
  44. cc.UserDefault:getInstance():setBoolForKey("firstLogin",false)
  45. end
  46. end
  47. --初始化审核 软著相关
  48. function MainReview:initReviewAndRuanZhu()
  49. -- 活动信息
  50. -- 苹果审核模式
  51. if not isIOSReviewVersion() then
  52. self:initActivity()
  53. end
  54. -- 软著模式
  55. if isRuanZhu() then
  56. self:initWithRuanZhuVersion()
  57. end
  58. -- 苹果审核模式
  59. if isIOSReviewVersion() then
  60. self:initWithIosReviewVersion()
  61. end
  62. end
  63. --初始化事件绑定
  64. function MainReview:initBindEvent()
  65. --self:bindEvent(app.user, "onPhoneBindResponse", handler(self, self.onPhoneBindResponse))
  66. -- 监听APP从后台回来的消息
  67. logD("MainReview add onMainViewLoginSuccessed")
  68. self:bindEvent(app.user, "onMainViewLoginSuccessed" , handler(self, self.onLoginSuccessed))
  69. self:bindEvent(app, "applicationWillEnterForeground" , handler(self, self.onLoginSuccessed))
  70. --收到禁止同桌结果事件
  71. self:bindEvent(app.club , "onClubNotSameDeskResponse" , handler(self , self.onClubNotSameDeskResponse))
  72. --绑定消息通知回调
  73. self:bindEvent(app.club_php , GAME_EVENT.CLUB_INVITE , handler(self , self.onClubIniteEvent))
  74. end
  75. --初始按钮事件
  76. function MainReview:initButton()
  77. -- 点击玩家头像
  78. self.ui.Items.ImageView_Head:registerClick(handler(self, self.onClickPlayerHead))
  79. -- 按钮 - 兑换金币
  80. self.ui.Items.Button_AddGold:registerClick(handler(self, self.OnClickButtonAddGold))
  81. -- 暂不提供兑换金币服务
  82. self.ui.Items.Button_AddGold:setVisible(false)
  83. -- 按钮 - 充值房卡
  84. self.ui.Items.Button_AddDiamand:registerClick(handler(self, self.OnClickButtonAddDiamand))
  85. self.ui.Items.ImageView_Diamand:registerClick(handler(self, self.OnClickButtonAddDiamand))
  86. -- 按钮 - 商城
  87. self.ui.Items.Button_ShangCheng:registerClick(handler(self , self.onClickButtonShop))
  88. local effect = createAnimationByPlist("res/ui/zy_dating/dating/shop_animation.plist","dt_shangcheng-animation3_%d.png",0,40,0.5)
  89. self.ui.Items.Button_ShangCheng:addChild(effect)
  90. local size = self.ui.Items.Button_ShangCheng:getContentSize()
  91. effect:setPosition(cc.p(size.width/2+20,size.height/2+10))
  92. -- 按钮 - 活动
  93. --self.ui.Items.Button_HuoDong:registerClick(handler(self , self.onClickButtonActive))
  94. -- 按钮 - 战绩
  95. self.ui.Items.Button_zhanji:registerClick(handler(self , self.onClickZhanji))
  96. -- 按钮 - 玩法
  97. self.ui.Items.Button_wanfa:registerClick(handler(self , self.onClickWanfa))
  98. -- 按钮 - 邮箱
  99. --self.ui.Items.Button_email:registerClick(handler(self , self.onClickButtonEmail))
  100. -- 按钮 - 实名认证
  101. self.ui.Items.Button_ShiMing:registerClick(handler(self , self.onClickButtonShiMing))
  102. -- 按钮 - 快速开始
  103. self.ui.Items.Button_Start:registerClick(handler(self , self.onClickButtonStart))
  104. -- 按钮 - 向右滑动
  105. self.ui.Items.Button_Right:registerClick(handler(self , self.onClickButtonRight))
  106. self.ui.Items.Button_Right:setVisible(false)
  107. -- 按钮 - 邀请码
  108. --self.ui.Items.Button_Yaoqing:registerClick(handler(self , self.onClickButtonInviteCode))
  109. --self.ui.Items.Button_Yaoqing:setVisible(false)
  110. -- 按钮 - 绑定手机号码
  111. --self.ui.Items.Button_PhoneNum:registerClick(handler(self , self.onClickButtonBindPhone))
  112. --self:onPhoneBindResponse()
  113. -- 按钮 - 茶馆
  114. self.ui.Items.Button_Club:registerClick(handler(self , self.onClickButtonClub))
  115. -- 按钮 - 金币场
  116. --self.ui.Items.Button_Gold:registerClick(handler(self , self.onClickButtonGold))
  117. -- 按钮 - 招代理
  118. --self.ui.Items.Button_daili:registerClick(handler(self , self.onClickButtonKeFu))
  119. -- 按钮 - 测试
  120. --self.ui.Items.Button_test:registerClick(handler(self , self.onClickTest))
  121. --self.ui.Items.Button_test:setVisible(targetPlatform == 0)
  122. --更多
  123. --self.ui.Items.Button_More:registerClick(handler(self , self.onClickMore))
  124. --self.ui.Items.Layout_More:setVisible(false)
  125. --举报
  126. self.ui.Items.Button_JuBao:registerClick(handler(self , self.onClickJuBao))
  127. --领取现金
  128. --self.ui.Items.Button_PrizeCash:registerClick(handler(self , self.onClickPrizeCash))
  129. --创建房间
  130. self.ui.Items.Button_Create:registerClick(handler(self , self.onClickMoreGame))
  131. --分享
  132. --self.ui.Items.Button_fenxiang:registerClick(handler(self , self.onClickShare))
  133. -- 兑换金币
  134. self.ui.Items.ImageView_Gold:setVisible(false)
  135. --隐藏专用房卡
  136. self.ui.Items.Layout_Diamond:setVisible(false)
  137. self.ui.Items.Button_Diamond_Arrow:setVisible(false)
  138. local seq = cc.Sequence:create(
  139. cc.ScaleTo:create(0.16,0.95),
  140. cc.ScaleTo:create(0.16,1),
  141. cc.ScaleTo:create(0.16,0.95),
  142. cc.ScaleTo:create(0.16,1),
  143. cc.ScaleTo:create(0.16,0.95),
  144. cc.ScaleTo:create(0.16,1),
  145. cc.DelayTime:create(3.0)
  146. )
  147. self.ui.Items.ImageView_More_Tip:runAction(cc.RepeatForever:create(seq))
  148. end
  149. -- 软著模式
  150. function MainReview:initWithRuanZhuVersion()
  151. -- 茶馆按钮
  152. self.ui.Items.Button_Club:setTouchEnabled(false)
  153. -- 比赛按钮
  154. --self.ui.Items.Button_Gold:setTouchEnabled(false)
  155. --修改图片
  156. self.ui.Items.Button_Club:loadTextureNormal("dating_btn_club_ruanzhu.png",1)
  157. --self.ui.Items.Button_Gold:loadTextureNormal("dating_btn_bisai_ruanzhu.png",1)
  158. end
  159. -- 苹果审核模式
  160. function MainReview:initWithIosReviewVersion()
  161. -- 兑换金币
  162. self.ui.Items.ImageView_Gold:setVisible(false)
  163. -- 版本号
  164. self.ui.Items.Layout_Version:setVisible(false)
  165. -- 比赛按钮
  166. --self.ui.Items.Button_Gold:setTouchEnabled(false)
  167. --活动
  168. --self.ui.Items.Layout_HuoDong:setVisible(false)
  169. --实名
  170. --self.ui.Items.Layout_ShiMing:setVisible(false)
  171. -- 重新布局
  172. self.ui.Items.Layout_menu:requestDoLayout()
  173. self.ui.Items.Layout_menu:doLayout()
  174. end
  175. -- 初始化游戏版本信息
  176. function MainReview:initVersion()
  177. if isIOSReviewVersion() then
  178. self.ui.Items.Layout_Version:setVisible(false)
  179. return
  180. end
  181. self.ui.Items.Text_Type:setVisible(isDebug())
  182. local appVersionNum = getAppVersionNum()
  183. local resVersion = loadVersion()
  184. self.ui.Items.Text_Version:setText("文明游戏,拒绝赌博 "..appVersionNum.."."..resVersion)
  185. end
  186. function MainReview:initPlayerInfo()
  187. -- 初始化头像大小
  188. local nodeHeadImage = self.ui.Items.ImageView_Head;
  189. self.head = {}
  190. self.head.width = nodeHeadImage:getContentSize().width
  191. self.head.height = nodeHeadImage:getContentSize().height
  192. logD("self.head = ", table.tostring(self.head));
  193. logD("MainReview:initPlayerInfo() userInfo = ", tostring(app.user.userInfo))
  194. local userInfo = json.decode(app.user.userInfo);
  195. -- 昵称
  196. local nickname = getSubStringNickname(userInfo.nickname)
  197. self.ui.Items.Text_Name:setText(nickname or tostring("未知昵称"))
  198. -- ID
  199. local id = tonumber(app.user.loginInfo.uid) or 0
  200. self.ui.Items.Text_ID:setText(string.format("ID:%07d", id))
  201. -- 房卡数量
  202. self.ui.Items.Text_Diamand:bind(app.user.loginInfo, "curCardNum", function()
  203. self.ui.Items.Text_Diamand:setString(tostring(app.user.loginInfo.curCardNum))
  204. end)
  205. --金币数量
  206. self.ui.Items.Text_Gold:bind(app.user.loginInfo, "curJingbiNum", function()
  207. local num = tonumber(app.user.loginInfo.curJingbiNum) or 0
  208. num = num + 2000
  209. local str
  210. if num > 100000 then
  211. str = tostring(math.floor(num / 1000) / 10).."W"
  212. else
  213. str = tostring(num)
  214. end
  215. self.ui.Items.Text_Gold:setString(str)
  216. end)
  217. -- 头像
  218. local nodeHead = self.ui.Items.ImageView_Head;
  219. setPlayerHeadImage(app.user.loginInfo.uid, userInfo.headimgurl, nodeHead)
  220. end
  221. -- 初始化活动信息
  222. function MainReview:initActivity()
  223. --默认弹出活动界面
  224. self:bindEvent(app, "onGetActivityInfoResponse", handler(self, self.showActivityOnEnter));
  225. -- 分享成功后通知此层关闭分享界面
  226. -- self:bindEvent(app , "shareSuccCallback" , handler(self , self.shareSuccCallback));
  227. --关闭通知界面后弹出活动界面
  228. -- self:bindEvent(app, "onCloseTongZhiSucc", handler(self, self.onCloseTongZhiSucc));
  229. --关闭代理招募后弹出活动界面
  230. -- self:bindEvent(app, "onCloseDaiLiZhaoMu", handler(self, self.onCloseDaiLiZhaoMu));
  231. self:bindEvent(app, GAME_EVENT.ACTIVITY_CLOSE, handler(self, self.onActivityClose));
  232. -- 请求活动数据
  233. app.serverConfigs:requestMissionList()
  234. end
  235. -- 初始化游戏列表
  236. function MainReview:initSubGameList()
  237. self:bindEvent(app.serverConfigs, "getSubGameListSuccessed", handler(self, self.updateSubGameList))
  238. self:updateSubGameList()
  239. end
  240. function MainReview:updateSubGameList()
  241. local page = self.ui.Items.Layout_Page
  242. page:removeAllChildren()
  243. local gameList = app.serverConfigs:getGameList()
  244. -- dump(gameList,"------gameList-------")
  245. for i = 1, 10 do
  246. local game = gameList[i]
  247. if 10 == i then
  248. game = gameList[#gameList]
  249. end
  250. if game then
  251. if game.gameType=="sub" then
  252. local uiSubGame = import("luaScript.Views.Main.MainViewGameIcon"):new(game.gameId)
  253. page:addChild(uiSubGame.ui)
  254. end
  255. end
  256. end
  257. end
  258. function MainReview:createWebGameItem(webGame)
  259. local gameLayout = cc.Layout:create()
  260. gameLayout:setSize(cc.size(152,188))
  261. local webGameIcon = cc.ImageView:create()
  262. webGameIcon:setAutoSize(false)
  263. webGameIcon:setSize(cc.size(134,156))
  264. setImageFromUrl(webGameIcon,webGame.icon)
  265. webGameIcon:registerClick(function()
  266. playBtnEffect()
  267. if not app.serverConfigs:isOpenWebGame(webGame.gameId) then
  268. showTooltip("敬请期待!")
  269. return
  270. end
  271. webGameIcon:setTouchEnabled(false)
  272. app.serverConfigs:requestWebGameUrl(webGame.gameId,function (url)
  273. if webGameIcon and not tolua.isnull(webGameIcon) then
  274. webGameIcon:setTouchEnabled(true)
  275. if not url or url =="" then
  276. showTooltip("敬请期待!")
  277. return
  278. end
  279. local view = import("luaScript.Views.Main.WebViews.WebGameView"):new(webGame.gameId,url)
  280. view:setAnchorPoint(cc.p(0.5, 0.5))
  281. app:showWaitDialog(view,nil,true)
  282. end
  283. end)
  284. end)
  285. if app.serverConfigs:isNewWebGame(webGame.gameId) then
  286. local newIcon = cc.ImageView:create()
  287. newIcon:loadTexture("res/ui/zy_dating/dating/img_newTag.png")
  288. webGameIcon:addChild(newIcon)
  289. newIcon:setPosition(cc.p(40,125))
  290. end
  291. local size = gameLayout:getContentSize()
  292. webGameIcon:setPosition(cc.p(size.width/2,size.height/2))
  293. gameLayout:addChild(webGameIcon)
  294. self.ui.Items.Layout_Page:addChild(gameLayout)
  295. end
  296. -- 进入子游戏
  297. function MainReview:onClickSubGame(gameId)
  298. --[[if gameId == GAME_IDS.More or gameId == GAME_IDS.hejiangDaEr then--暂时屏蔽合江大贰
  299. showTooltip("开发中...")
  300. return
  301. end--]]
  302. cc.UserDefault:getInstance():setBoolForKey("firstLogin",false)
  303. -- 打开对应的创建界面
  304. local gameConfig = getSubGameConfig(gameId)
  305. if not gameConfig then
  306. showTooltip("开发中")
  307. return
  308. end
  309. app.gameId = gameId
  310. -- app.subGameManager:saveToFile(gameId)
  311. local gameData = {}
  312. gameData.gameId = gameId
  313. gameData.defaultPlayType = nil
  314. local createView = import("luaScript.Views.CreateRoom.CreateRoomBase"):new(gameData)
  315. createView:setAnchorPoint(cc.p(0.5, 0.5))
  316. app:showWaitDialog(createView)
  317. -- self:updateSubGameList()
  318. end
  319. -- 兑换金币
  320. function MainReview:OnClickButtonAddGold()
  321. playBtnEffect()
  322. local view = import("luaScript.Views.Main.ExchangeView"):new()
  323. view:setAnchorPoint(cc.p(0.5, 0.5))
  324. app:showWaitDialog(view)
  325. end
  326. -- 充值房卡
  327. function MainReview:OnClickButtonAddDiamand()
  328. playBtnEffect()
  329. local view = import("luaScript.Views.Main.RechargeView"):new()
  330. view:setAnchorPoint(cc.p(0.5, 0.5))
  331. app:showWaitDialog(view)
  332. end
  333. -- 商城
  334. function MainReview:onClickButtonShop()
  335. playBtnEffect()
  336. -- showTooltip("敬请期待!")
  337. -- do return end
  338. local view = import("luaScript.Views.Main.RechargeView"):new()
  339. view:setAnchorPoint(cc.p(0.5, 0.5))
  340. app:showWaitDialog(view)
  341. end
  342. -- 活动
  343. function MainReview:onClickButtonActive()
  344. --showTooltip("暂无活动")
  345. --do return end
  346. playBtnEffect()
  347. local missions = app.serverConfigs.missions;
  348. if #missions<1 then --or table.nums(activityData) < 1
  349. -- showTooltip("暂无活动")
  350. return
  351. end
  352. self.isShowTongZHiView = true
  353. local view = import("luaScript.Views.Activity.ActivityMainView"):new()
  354. view:setAnchorPoint(cc.p(0.5, 0.5))
  355. app:showWaitDialog(view)
  356. end
  357. --活动分享成功
  358. function MainReview:shareSuccCallback()
  359. if (not tolua.isnull(self.activityshareview)) then
  360. self.activityshareview:removeFromParent()
  361. self.activityshareview = nil
  362. end
  363. end
  364. -- 设置
  365. function MainReview:onClickButtonEmail()
  366. playBtnEffect()
  367. showTooltip("开发中...")
  368. end
  369. -- 客服
  370. function MainReview:onClickButtonKeFu()
  371. playBtnEffect()
  372. local view = import("luaScript.Views.Main.DaiLiView"):new()
  373. view:setAnchorPoint(cc.p(0.5, 0.5))
  374. app:showWaitDialog(view)
  375. end
  376. -- 快速开始
  377. function MainReview:onClickButtonStart()
  378. playBtnEffect()
  379. local view = import("luaScript.Views.Main.JoinRoomView"):new()
  380. view:setAnchorPoint(cc.p(0.5, 0.5))
  381. app:showWaitDialog(view)
  382. --从大厅进入游戏时清空保存的茶馆id及桌子下标
  383. app.club_php.clubID = 0;
  384. app.club_php.tableIdx = 0
  385. end
  386. -- 向右滑动
  387. function MainReview:onClickButtonRight()
  388. self.ui.Items.ScrollView:scrollBy(cc.p(-480,0),0.5,true)
  389. end
  390. -- 实名认证
  391. function MainReview:onClickButtonShiMing()
  392. playBtnEffect()
  393. local view = import("luaScript.Views.Main.ShiMingView"):new(self.ShiMingRenZhengData,self)
  394. view:setAnchorPoint(cc.p(0.5, 0.5))
  395. app:showWaitDialog(view)
  396. end
  397. -- 邀请码
  398. function MainReview:onClickButtonInviteCode()
  399. playBtnEffect()
  400. local view = import("luaScript.Views.Main.InviteCodeView"):new()
  401. view:setAnchorPoint(cc.p(0.5, 0.5))
  402. app:showWaitDialog(view)
  403. end
  404. -- 绑定手机号
  405. function MainReview:onClickButtonBindPhone()
  406. playBtnEffect()
  407. local view = import("luaScript.Views.Main.PhoneBindView"):new()
  408. view:setAnchorPoint(cc.p(0.5, 0.5))
  409. app:showWaitDialog(view)
  410. end
  411. -- 显示玩家信息的界面
  412. function MainReview:onClickPlayerHead()
  413. playBtnEffect()
  414. local view = import("luaScript.Views.Main.MainSettingView"):new()
  415. view:setAnchorPoint(cc.p(0.5, 0.5))
  416. app:showWaitDialog(view)
  417. end
  418. -- 茶馆
  419. function MainReview:onClickButtonClub()
  420. playBtnEffect()
  421. local view = import("luaScript.Views.Club.ClubMain"):new();
  422. view:setAnchorPoint(cc.p(0.5, 0.5))
  423. app:showWaitDialog(view)
  424. --重新进入茶馆大厅时清空保存的茶馆id及桌子下标
  425. app.club_php.clubID = 0;
  426. app.club_php.tableIdx = 0
  427. cc.UserDefault:getInstance():setBoolForKey("firstLogin",false)
  428. end
  429. -- 金币场
  430. function MainReview:onClickButtonGold()
  431. playBtnEffect()
  432. showTooltip("开发中...")
  433. end
  434. -- 战绩
  435. function MainReview:onClickZhanji()
  436. playBtnEffect()
  437. local view = import("luaScript.Views.ZhanJi.ZhanJiViewBase"):new(-1);
  438. view:setAnchorPoint(cc.p(0.5, 0.5))
  439. app:showWaitDialog(view)
  440. end
  441. --玩法
  442. function MainReview:onClickWanfa()
  443. playBtnEffect()
  444. local view = import("luaScript.Views.Main.HelpView"):new(-1)
  445. view:setAnchorPoint(cc.p(0.5, 0.5))
  446. app:showWaitDialog(view)
  447. end
  448. -- 启动游戏时弹出活动界面
  449. function MainReview:showActivityOnEnter()
  450. --每次登陆弹出通知弹窗
  451. -- local firstLogin = cc.UserDefault:getInstance():getBoolForKey("firstLogin")
  452. if IS_FIRST_LOGIN then
  453. -- if cc.Application:getInstance():getTargetPlatform() ~= 0 then
  454. local viewName = app.serverConfigs:popConfig()
  455. local viewName = app.serverConfigs:popConfig()
  456. if viewName then
  457. local view = import(viewName):new()
  458. view:setAnchorPoint(cc.p(0.5, 0.5))
  459. app:showWaitDialog(view)
  460. end
  461. IS_FIRST_LOGIN = false
  462. -- end
  463. end
  464. end
  465. function MainReview:onActivityClose()
  466. local viewName = app.serverConfigs:popConfig()
  467. if viewName then
  468. local view = import(viewName):new()
  469. view:setAnchorPoint(cc.p(0.5, 0.5))
  470. app:showWaitDialog(view)
  471. end
  472. end
  473. --[[
  474. function MainReview:onCloseDaiLiZhaoMu()
  475. local firstLogin = cc.UserDefault:getInstance():getBoolForKey("firstLogin")
  476. if firstLogin then
  477. local activityData = app.php.activityData;
  478. if not activityData or table.nums(activityData) < 1 then
  479. return
  480. end
  481. local view = import("luaScript.Views.Activity.ActivityMainView"):new()
  482. view:setAnchorPoint(cc.p(0.5, 0.5))
  483. app:showWaitDialog(view)
  484. end
  485. cc.UserDefault:getInstance():setBoolForKey("firstLogin",false)
  486. end
  487. function MainReview:onCloseLaXin()
  488. local firstLogin = cc.UserDefault:getInstance():getBoolForKey("firstLogin")
  489. if firstLogin then
  490. local view = import("luaScript.Views.Activity.ActivityMainView"):new()
  491. view:setAnchorPoint(cc.p(0.5, 0.5))
  492. app:showWaitDialog(view)
  493. end
  494. cc.UserDefault:getInstance():setBoolForKey("firstLogin",false)
  495. end
  496. function MainReview:onCloseTongZhiSucc()
  497. local activityData = app.php.activityData;
  498. if not activityData then
  499. return
  500. end
  501. self.attyData = app.php.activityData["7"]--type7分享活动
  502. if not self.attyData then
  503. return
  504. end
  505. local isShared = (self.attyData.active == 3)--进度,1进行中,2等待领取 3已完成并领取奖励
  506. local firstLogin = cc.UserDefault:getInstance():getBoolForKey("firstLogin")
  507. if firstLogin and (not isShared) then--每次登陆且没有领取过分享奖励就弹出分享奖励
  508. --self:onClickButtonActive()
  509. self.activityshareview = import("luaScript.Views.Main.Activity.ActivityShareView"):new(7,true)
  510. self.activityshareview.ui.Items.Layout:setAnchorPoint(cc.p(0.5, 0.5))
  511. local winSize = getWinSize()
  512. self.activityshareview.ui.Items.Layout:setContentSize(winSize)
  513. self.activityshareview.ui.Items.Layout_share:setPositionY(-30)
  514. app:showWaitDialog(self.activityshareview, 200, false)
  515. end
  516. cc.UserDefault:getInstance():setBoolForKey("firstLogin",false)
  517. end
  518. ]]--
  519. function MainReview:onLoginSuccessed()
  520. logD("MainReview:onMainViewLoginSuccessed()")
  521. local roomId = nil
  522. local code = nil --"9024926188961793" --回放码
  523. local str = copyStringFromClipboard()
  524. logD("MainReview:onMainViewLoginSuccessed() str = ", str)
  525. -- showTooltip(str)
  526. --如果第一个是~!开头则代表是浏览器传的参数
  527. if string.find(str,"~!")==1 then
  528. local baseStr=string.sub(str,3,string.len(str))
  529. baseStr=base64.decode(baseStr)
  530. local params=json.decode(decodeURI(baseStr))
  531. dump(params,"MainReview:onMainViewLoginSuccessed params")
  532. if params then
  533. logD("do somthing!")
  534. if params.roomid then
  535. roomId = params.roomid
  536. end
  537. if params.code then
  538. code = params.code
  539. end
  540. end
  541. -- return
  542. else
  543. -- 检测玩家剪贴板里面是否有房间号,
  544. --如果有,查询这个房间号对应的游戏ID
  545. --如果没查到则不处理
  546. --如果查到了,则判断游戏是否已安装
  547. --未安装则提示安装,已安装则直接进入
  548. roomId = getRoomIdFromCopyString(str)
  549. end
  550. -- local roomId = getRoomIdFromCopyString(str)
  551. logD("MainReview:onMainViewLoginSuccessed() roomId = ", roomId)
  552. if roomId then
  553. local function onQueryRoomResponse(gameId, roomId)
  554. logD("MainReview:onQueryRoomResponse() gameId = ", gameId)
  555. logD("MainReview:onQueryRoomResponse() roomId = ", roomId)
  556. if not gameId or tonumber(gameId) <= 0 then
  557. return
  558. end
  559. copyStringToClipboard("")
  560. -- 检查这个子游戏是否已安装
  561. if app.subGameManager then
  562. local function requestJoinRoom()
  563. app.hall:requestJoinRoom(gameId, roomId)
  564. end
  565. if not app.subGameManager:isInstaller(gameId) then
  566. requestDownloadSubGame(gameId, requestJoinRoom, true)
  567. else
  568. requestJoinRoom();
  569. end
  570. end
  571. end
  572. app.hall:queryRoomId(tonumber(roomId), onQueryRoomResponse);
  573. end
  574. if code then
  575. copyStringToClipboard("")
  576. local view = import("luaScript.Views.ZhanJi.ZhanJiViewBase"):new(-1,nil,code)
  577. view:setAnchorPoint(cc.p(0.5, 0.5))
  578. app:showWaitDialog(view)
  579. end
  580. end
  581. --[[
  582. function MainReview:onPhoneBindResponse(event)
  583. local phonenum = app.user.phonenum
  584. if phonenum and phonenum ~= "" then
  585. self.ui.Items.Button_PhoneNum:setVisible(false)
  586. end
  587. end
  588. ]]
  589. function MainReview:onClickTest()
  590. -- onTest();
  591. local view = import("luaScript.Views.Main.GameManagerView"):new()
  592. view:setAnchorPoint(cc.p(0.5, 0.5))
  593. app:showWaitDialog(view)
  594. end
  595. function MainReview:onClubNotSameDeskResponse(event)
  596. local playerInfo = json.decode(event.userInfo)
  597. setIsRoomGamedata(nil)
  598. local str = string.format("管理员已设置该牌桌 %s 玩家与您禁止同桌!",playerInfo.nickname)
  599. showConfirmDialog(str)
  600. end
  601. function MainReview:onClubIniteEvent(event)
  602. --房间邀请通知
  603. local content = event.content
  604. local clubId = event.clubId
  605. local viewType = type(self.inviteView)
  606. if self.inviteView and viewType == "userdata" then
  607. --提示框已存在
  608. return
  609. end
  610. local function closeCallback()
  611. --关闭提示框时清空数据,用于下次弹出
  612. self.inviteView = nil
  613. end
  614. self.inviteView = import("luaScript.Views.Club.ClubInviteRoomNew"):new(clubId, content, closeCallback)
  615. self.inviteView:setAnchorPoint(cc.p(0.5, 0.5))
  616. app:showWaitDialog(self.inviteView)
  617. end
  618. function MainReview:onClickMoreGame()
  619. playBtnEffect()
  620. --showTooltip("开发中...")
  621. local createView = import("luaScript.Views.CreateRoom.CreateRoomBase"):new()
  622. createView:setAnchorPoint(cc.p(0.5, 0.5))
  623. app:showWaitDialog(createView)
  624. end
  625. --增加地区按钮
  626. function MainReview:onClickDiqu()
  627. showTooltip("开发中...")
  628. end
  629. --更多
  630. function MainReview:onClickMore()
  631. playBtnEffect()
  632. self.ui.Items.Layout_More:setVisible(not self.ui.Items.Layout_More:isVisible())
  633. end
  634. --举报
  635. function MainReview:onClickJuBao()
  636. playBtnEffect()
  637. -- showTooltip("开发中...")
  638. local url = string.format("http://cnapi.dingdingqipai.com/index-cn.php?action=report.show&uid=%s&app=%s",app.user.loginInfo.uid,getAppId())
  639. logD(url)
  640. app.plugin:callUrl(url)
  641. end
  642. function MainReview:onClickPrizeCash()
  643. playBtnEffect()
  644. local view = import("luaScript.Views.Main.MainInviteNewFriend"):new();
  645. view:setAnchorPoint(cc.p(0.5, 0.5))
  646. app:showWaitDialog(view)
  647. end
  648. return MainReview