-- 下载界面 local MainUnionBelong = class("MainUnionBelong", cc.UIView) local LoginConfig = require("luaScript.Views.Login.LoginConfig") function MainUnionBelong:ctor() MainUnionBelong.super.ctor(self); end function MainUnionBelong:onEnter() MainUnionBelong.super.onEnter(self) local ui = loadUI("res/ui/ui_dating/ui_dating_club_belong.ui") self.ui = ui self:addChild(ui) self:initView() self:registerButton() app.club_php:requestClubBelong() app.club_php:requestClubBelongList() self:bindEvent(app.club_php, GAME_EVENT.CLUB_UNION_CLUB_BELONG, handler(self, self.onClubBelongEvent)) self:bindEvent(app.club_php, GAME_EVENT.CLUB_UNION_CLUB_BELONG_LIST, handler(self, self.onClubBelongList)) end function MainUnionBelong:setDefault() self.ui.Items.Button:setVisible(false) self.ui.Items.Button_up:setVisible(false) self.ui.Items.Layout_select:setVisible(false) self.ui.Items.Layout_Set:setVisible(false) self.ui.Items.Layout_Show:setVisible(false) self.ui.Items.Layout_club_item:setVisible(false) end function MainUnionBelong:initView() self:setDefault() self.ui.Items.ScrollView_Select:hideAllBar() self.ui.Items.ScrollView_Select:getInnerContainer():setAutoSize(true) self.ui.Items.Text:setText(PLN.CLUB_UNION_BELONG_1) self.ui.Items.Text_1:setText(PLN.CLUB_UNION_BELONG_2) self.ui.Items.Text_2:setText(PLN.CLUB_UNION_BELONG_3) end function MainUnionBelong:registerButton() -- 关闭 self.ui.Items.Button_Close:registerClick(handler(self , self.onClickClose)) --更换归属CLUB self.ui.Items.Button_Change:registerClick(handler(self , self.onClickChangeClub)) --下啦 self.ui.Items.Button_down:registerClick(handler(self , self.onClickMenu)) self.ui.Items.Button_up:registerClick(handler(self , self.onClickMenu)) self.ui.Items.ImageView_5:registerClick(handler(self , self.onClickMenu)) --选择新的亲友圈 self.ui.Items.Button:registerClick(handler(self , self.onClickSelect)) end function MainUnionBelong:onClickClose() playBtnCloseEffect() self:removeFromParent() end function MainUnionBelong:onClickChangeClub() playBtnEffect() self:setDefault() self.ui.Items.Layout_Set:setVisible(true) end function MainUnionBelong:onClickMenu() playBtnEffect() self.ui.Items.Button_down:setVisible(not self.ui.Items.Button_down:isVisible()) self.ui.Items.Button_up:setVisible(not self.ui.Items.Button_up:isVisible()) self.ui.Items.Layout_select:setVisible(not self.ui.Items.Layout_select:isVisible()) end function MainUnionBelong:onClickSelect() playBtnEffect() if self.selectClubId then app.club_php:requestClubSetBelong(self.selectClubId,function () app.club_php:requestClubBelong() end) else showTooltip("self.selectClubId not exist") end end function MainUnionBelong:onClubBelongEvent(data) if not data then return end self:setDefault() local result = data.result local bindInfo = result.bindInfo if bindInfo then self.ui.Items.Layout_Show:setVisible(true) local name = getShortNameByLength(bindInfo.gname,5) 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)) 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)) -- 头像 local headurl = bindInfo.ownericon local uid = bindInfo.owner local sex = bindInfo.ownersex local cliext = bindInfo.groupext.cliext local nodeHead = self.ui.Items.ImageView_head local headSize = nodeHead:getContentSize() if not cliext or not cliext.is_hideCreator or (cliext and cliext.is_hideCreator == 1) then nodeHead:loadTexture("res/ui/zy_club/club_main/club_main_default_img.png") else setPlayerHeadImage(uid, headurl, nodeHead) end end end function MainUnionBelong:onClubBelongList(data) if not data then return end local list = data.result.list if list then for k,v in pairsByKeys(list) do local gid = v.gid local gname = getShortNameByLength(v.gname,5) local layout = self.ui.Items.Layout_club_item:getCopied() layout.Items = getUIItems(layout) layout.Items.Text_name:setText(tostring(gname).."(ID:"..tostring(gid)..")") layout:registerClick(function () self.ui.Items.Text_2:setText(tostring(gname).."(ID:"..tostring(gid)..")") self.selectClubId = tonumber(gid) self:onClickMenu() self.ui.Items.Button:setVisible(true) end) self.ui.Items.ScrollView_Select:addChild(layout) end self.ui.Items.ScrollView_Select:requestDoLayout() self.ui.Items.ScrollView_Select:doLayout() self.ui.Items.ScrollView_Select:jumpToTopOnSizeChanged() end end return MainUnionBelong;