源战役客户端
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.

147 lines
5.2 KiB

  1. GuildPositionApplyItem = GuildPositionApplyItem or BaseClass(BaseItem)
  2. local GuildPositionApplyItem = GuildPositionApplyItem
  3. function GuildPositionApplyItem:__init(parent_wnd,prefab_asset,layer_name)
  4. self.base_file = "guild"
  5. self.layout_file = "GuildPositionApplyItem"
  6. self.parent_wnd = parent_wnd
  7. self.layer_name = layer_name
  8. self.model = GuildModel:getInstance()
  9. self.bg_pos_x = {
  10. [2] = 0,
  11. [4] = -6,
  12. [3] = -4,
  13. }
  14. self:Load()
  15. end
  16. function GuildPositionApplyItem:Load_callback()
  17. local nodes = {
  18. "bg:img",
  19. "pos_icon:img",
  20. "apply_scroll:obj", "apply_scroll/Viewport/apply_con",
  21. "auth_scroll", "auth_scroll/Viewport/auth_con", "auth_scroll/Viewport/auth_con/pos_auth:tmp",
  22. "cur_num:tmp", "pos_tips:tmp", "line:obj",
  23. "apply_btn:obj:imgex",
  24. }
  25. self:GetChildren(nodes)
  26. self:AddEvents()
  27. if self.need_refreshData then
  28. self:UpdateView()
  29. end
  30. end
  31. function GuildPositionApplyItem:AddEvents( )
  32. local function click_event(target)
  33. if target == self.apply_btn_obj then
  34. self:OnClickApplyBtn()
  35. end
  36. end
  37. AddClickEvent(self.apply_btn_obj, click_event, LuaSoundManager.SOUND_UI.SWITCH)
  38. end
  39. function GuildPositionApplyItem:SetData( data, show_line )
  40. self.data = data
  41. self.show_line = show_line
  42. if self.is_loaded then
  43. self.need_refreshData = false
  44. self:UpdateView()
  45. else
  46. self.need_refreshData = true
  47. end
  48. end
  49. function GuildPositionApplyItem:UpdateView( )
  50. local position = self.data.pos
  51. SetAnchoredPositionX(self.bg, self.bg_pos_x[position] or 0)
  52. local cur_mem_num = self.model:GetMemberNum(position)
  53. local mem_max_num = self.model:GetPositionNum(position)
  54. self.cur_num_tmp.text = string.format("人数 <size=22>%s/%s</size>", cur_mem_num, mem_max_num)
  55. lua_resM:setImageSprite(self, self.bg_img, "guildPosApply_asset", "guild_apply_pos".. position)
  56. lua_resM:setImageSprite(self, self.pos_icon_img, "guild_asset", "guild_apply_pos_icon".. position .. "_pointfilter", true)
  57. if cur_mem_num == mem_max_num then
  58. self.pos_tips_tmp.text = "职位已满,无法申请,可以联系团长或副团长进行职位分配操作"
  59. if self.apply_scroll_obj.activeSelf then
  60. self.apply_scroll_obj:SetActive(false)
  61. end
  62. else
  63. self:UpdateApplyList()
  64. end
  65. self:UpdatePosAuthData()
  66. self.line_obj:SetActive(self.show_line)
  67. end
  68. -- 加载职位权限
  69. function GuildPositionApplyItem:UpdatePosAuthData( )
  70. local auth_data = GuildModel.PosApplyDesc[self.data.pos]
  71. self.auth_item_creator = self.auth_item_creator or self:AddUIComponent(UI.ItemListCreator)
  72. local info = {
  73. data_list = auth_data,
  74. item_con = self.auth_con,
  75. scroll_view = self.auth_scroll,
  76. prefab_ab_name = "guild",
  77. prefab_res_name = "GuildPositionApplyMemItem", -- 改了tmp之后小点不能直接打了,得换成这个节点创建内容了
  78. item_height = 24,
  79. create_frequency = 0.01,
  80. alignment = UnityEngine.TextAnchor.UpperLeft,
  81. child_names = {"apply_time:tmp", "name:tmp", },
  82. on_update_item = function(item, i, v)
  83. item.name_tmp.text = v
  84. item.apply_time_tmp.text = ""
  85. end,
  86. }
  87. self.auth_item_creator:UpdateItems(info)
  88. end
  89. -- 创建更新当前职位的申请人信息
  90. function GuildPositionApplyItem:UpdateApplyList( )
  91. local apply_list = self.model:GetPositionApplyList(self.data.pos)
  92. local empty = IsTableEmpty(apply_list)
  93. if empty then -- 空列表
  94. if self.apply_scroll_obj.activeSelf then
  95. self.apply_scroll_obj:SetActive(false)
  96. end
  97. self.pos_tips_tmp.text = "当前职位空缺,快申请成为社团干部吧"
  98. else
  99. if not self.apply_scroll_obj.activeSelf then
  100. self.apply_scroll_obj:SetActive(true)
  101. end
  102. self.apply_item_creator = self.apply_item_creator or self:AddUIComponent(UI.ItemListCreator)
  103. local info = {
  104. data_list = apply_list,
  105. item_con = self.apply_con,
  106. scroll_view = self.apply_scroll,
  107. prefab_ab_name = "guild",
  108. prefab_res_name = "GuildPositionApplyMemItem",
  109. item_height = 24,
  110. create_frequency = 0.01,
  111. alignment = UnityEngine.TextAnchor.UpperLeft,
  112. child_names = {"apply_time:tmp", "name:tmp", },
  113. on_update_item = function(item, i, v)
  114. item.name_tmp.text = v.name
  115. item.apply_time_tmp.text = TimeUtil:GetTimeStrByServerTime( v.time )
  116. end,
  117. }
  118. self.apply_item_creator:UpdateItems(info)
  119. end
  120. -- 更新申请按钮
  121. local position_num = self.model:GetMemberNum(self.data.pos)
  122. local position_total_num = self.model:GetPositionNum(self.data.pos)
  123. self.apply_btn_imgex.gray = position_num >= position_total_num
  124. end
  125. -- 申请职位
  126. function GuildPositionApplyItem:OnClickApplyBtn()
  127. if self.apply_btn_imgex.gray then
  128. Message.show("职位人数已满")
  129. else
  130. -- 发送职位申请协议
  131. self.model:Fire(GuildModel.REQUEST_CCMD_EVENT, 40018, self.data.pos)
  132. end
  133. end
  134. function GuildPositionApplyItem:__delete( )
  135. end