KLJoinInfoItem.lua 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. ---@class KLJoinInfoItem:UIKmlLuaPanelBase
  2. ---@field view KLJoinInfoItemView
  3. ---@field unionInfo UnionProto.UnionListInfo
  4. ---@field parent KLUnionJoinPanel
  5. local KLJoinInfoItem = class(UIKmlLuaPanelBase)
  6. local this =KLJoinInfoItem
  7. ---创建时调用一次
  8. function this:Init()
  9. self.unionInfo = self.args.info
  10. self.parent = self.args.parent
  11. end
  12. ---创建或者刷新界面数据时调用
  13. function this:Refresh()
  14. GUI:Text_setString(self.view.union_name, self.unionInfo.unionName)
  15. GUI:Text_setString(self.view.union_level, tostring(self.unionInfo.unionLevel))
  16. GUI:Text_setString(self.view.union_num, string.format("%s/%s", self.unionInfo.unionNum, self.unionInfo.maxNum))
  17. self:RefreshStatus()
  18. end
  19. ---注册UI事件和服务器消息
  20. function this:RegistEvents()
  21. GUI:AddOnClickEvent(self.view.datalist_panel_btn_, self, self.datalist_panel_btn_)
  22. GUI:AddOnClickEvent(self.view.apply_to_join, self, self.apply_to_join)
  23. end
  24. function this:datalist_panel_btn_()
  25. if self.parent then
  26. self.parent:ChildOnClick(self)
  27. end
  28. self:SetChoiceBg(true)
  29. ---@type KLUnionSummaryInfoPanel
  30. local panel = GUI:UIPanel_Open("dev/ui/Union/Panel/KLUnionSummaryInfo/KLUnionSummaryInfoPanel", nil, nil, {unionId=self.unionInfo.unionId}, false)
  31. end
  32. function this:SetChoiceBg(val)
  33. GUI:SetActive(self.view.union_choice_bg_, val)
  34. end
  35. function this:apply_to_join()
  36. if InfoManager.loranSiegeInfo:GetIsOpen() then
  37. SL:TipMessage(SL:GetConfig("cfg_string",16005).text ,1, NoticeType.NoticeMid)
  38. return
  39. end
  40. SL.Union:ReqApplyJoinUnionMessage(self.unionInfo.unionId)
  41. end
  42. function this:SetStatus(status)
  43. self.unionInfo.state = status
  44. self:RefreshStatus()
  45. end
  46. function this:RefreshStatus()
  47. if self.unionInfo.state == 0 then
  48. GUI:setVisible(self.view.btn_grey_bg, false)
  49. GUI:Text_setString(self.view.btn_text, "申请")
  50. elseif self.unionInfo.state == 1 then
  51. GUI:setVisible(self.view.btn_grey_bg, true)
  52. GUI:Text_setString(self.view.btn_text, "已申请")
  53. elseif self.unionInfo.state == 2 then
  54. GUI:setVisible(self.view.btn_grey_bg, true)
  55. GUI:Text_setString(self.view.btn_text, "已满员")
  56. end
  57. end
  58. function this:Close()
  59. end
  60. return this