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.

144 lines
4.6 KiB

  1. -- 下载界面
  2. local MainUnionBelong = class("MainUnionBelong", cc.UIView)
  3. local LoginConfig = require("luaScript.Views.Login.LoginConfig")
  4. function MainUnionBelong:ctor()
  5. MainUnionBelong.super.ctor(self);
  6. end
  7. function MainUnionBelong:onEnter()
  8. MainUnionBelong.super.onEnter(self)
  9. local ui = loadUI("res/ui/ui_dating/ui_dating_club_belong.ui")
  10. self.ui = ui
  11. self:addChild(ui)
  12. self:initView()
  13. self:registerButton()
  14. app.club_php:requestClubBelong()
  15. app.club_php:requestClubBelongList()
  16. self:bindEvent(app.club_php, GAME_EVENT.CLUB_UNION_CLUB_BELONG, handler(self, self.onClubBelongEvent))
  17. self:bindEvent(app.club_php, GAME_EVENT.CLUB_UNION_CLUB_BELONG_LIST, handler(self, self.onClubBelongList))
  18. end
  19. function MainUnionBelong:setDefault()
  20. self.ui.Items.Button:setVisible(false)
  21. self.ui.Items.Button_up:setVisible(false)
  22. self.ui.Items.Layout_select:setVisible(false)
  23. self.ui.Items.Layout_Set:setVisible(false)
  24. self.ui.Items.Layout_Show:setVisible(false)
  25. self.ui.Items.Layout_club_item:setVisible(false)
  26. end
  27. function MainUnionBelong:initView()
  28. self:setDefault()
  29. self.ui.Items.ScrollView_Select:hideAllBar()
  30. self.ui.Items.ScrollView_Select:getInnerContainer():setAutoSize(true)
  31. self.ui.Items.Text:setText(PLN.CLUB_UNION_BELONG_1)
  32. self.ui.Items.Text_1:setText(PLN.CLUB_UNION_BELONG_2)
  33. self.ui.Items.Text_2:setText(PLN.CLUB_UNION_BELONG_3)
  34. end
  35. function MainUnionBelong:registerButton()
  36. -- 关闭
  37. self.ui.Items.Button_Close:registerClick(handler(self , self.onClickClose))
  38. --更换归属CLUB
  39. self.ui.Items.Button_Change:registerClick(handler(self , self.onClickChangeClub))
  40. --下啦
  41. self.ui.Items.Button_down:registerClick(handler(self , self.onClickMenu))
  42. self.ui.Items.Button_up:registerClick(handler(self , self.onClickMenu))
  43. self.ui.Items.ImageView_5:registerClick(handler(self , self.onClickMenu))
  44. --选择新的亲友圈
  45. self.ui.Items.Button:registerClick(handler(self , self.onClickSelect))
  46. end
  47. function MainUnionBelong:onClickClose()
  48. playBtnCloseEffect()
  49. self:removeFromParent()
  50. end
  51. function MainUnionBelong:onClickChangeClub()
  52. playBtnEffect()
  53. self:setDefault()
  54. self.ui.Items.Layout_Set:setVisible(true)
  55. end
  56. function MainUnionBelong:onClickMenu()
  57. playBtnEffect()
  58. self.ui.Items.Button_down:setVisible(not self.ui.Items.Button_down:isVisible())
  59. self.ui.Items.Button_up:setVisible(not self.ui.Items.Button_up:isVisible())
  60. self.ui.Items.Layout_select:setVisible(not self.ui.Items.Layout_select:isVisible())
  61. end
  62. function MainUnionBelong:onClickSelect()
  63. playBtnEffect()
  64. if self.selectClubId then
  65. app.club_php:requestClubSetBelong(self.selectClubId,function ()
  66. app.club_php:requestClubBelong()
  67. end)
  68. else
  69. showTooltip("self.selectClubId not exist")
  70. end
  71. end
  72. function MainUnionBelong:onClubBelongEvent(data)
  73. if not data then
  74. return
  75. end
  76. self:setDefault()
  77. local result = data.result
  78. local bindInfo = result.bindInfo
  79. if bindInfo then
  80. self.ui.Items.Layout_Show:setVisible(true)
  81. local name = getShortNameByLength(bindInfo.gname,5)
  82. self.ui.Items.Text_clubname:setText((app.club_php:getCestIsOpen(app.club_php.clubID) and PLN.CLUB_CEST_NAME or PLN.CLUB_NAME).."名称:"..tostring(name))
  83. self.ui.Items.Text_clubid:setText((app.club_php:getCestIsOpen(app.club_php.clubID) and PLN.CLUB_CEST_NAME or PLN.CLUB_NAME).."ID:"..tostring(bindInfo.gid))
  84. -- 头像
  85. local headurl = bindInfo.ownericon
  86. local uid = bindInfo.owner
  87. local sex = bindInfo.ownersex
  88. local cliext = bindInfo.groupext.cliext
  89. local nodeHead = self.ui.Items.ImageView_head
  90. local headSize = nodeHead:getContentSize()
  91. if not cliext or not cliext.is_hideCreator or (cliext and cliext.is_hideCreator == 1) then
  92. nodeHead:loadTexture("res/ui/zy_club/club_main/club_main_default_img.png")
  93. else
  94. setPlayerHeadImage(uid, headurl, nodeHead)
  95. end
  96. end
  97. end
  98. function MainUnionBelong:onClubBelongList(data)
  99. if not data then
  100. return
  101. end
  102. local list = data.result.list
  103. if list then
  104. for k,v in pairsByKeys(list) do
  105. local gid = v.gid
  106. local gname = getShortNameByLength(v.gname,5)
  107. local layout = self.ui.Items.Layout_club_item:getCopied()
  108. layout.Items = getUIItems(layout)
  109. layout.Items.Text_name:setText(tostring(gname).."(ID:"..tostring(gid)..")")
  110. layout:registerClick(function ()
  111. self.ui.Items.Text_2:setText(tostring(gname).."(ID:"..tostring(gid)..")")
  112. self.selectClubId = tonumber(gid)
  113. self:onClickMenu()
  114. self.ui.Items.Button:setVisible(true)
  115. end)
  116. self.ui.Items.ScrollView_Select:addChild(layout)
  117. end
  118. self.ui.Items.ScrollView_Select:requestDoLayout()
  119. self.ui.Items.ScrollView_Select:doLayout()
  120. self.ui.Items.ScrollView_Select:jumpToTopOnSizeChanged()
  121. end
  122. end
  123. return MainUnionBelong;