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

167 lines
4.7 KiB

  1. SupremeVipTabItem = SupremeVipTabItem or BaseClass(BaseItem)
  2. local SupremeVipTabItem = SupremeVipTabItem
  3. function SupremeVipTabItem:__init()
  4. self.base_file = "supremeVip"
  5. self.layout_file = "SupremeVipTabItem"
  6. self.model = SupremeVipModel:getInstance()
  7. self.have_supreme_vip_right = false --是否拥有此项特权功能
  8. self:Load()
  9. end
  10. function SupremeVipTabItem:Load_callback()
  11. self.nodes = {
  12. "touch_bg/leftBg/leftDes:tmp",
  13. "touch_bg/titleImg:obj",
  14. "touch_bg/leftBg/leftNum:tmp",
  15. "touch_bg/selectBg:obj",
  16. "touch_bg/bg:obj:img",
  17. "touch_bg/leftBg:obj",
  18. "touch_bg/redDot:obj",
  19. "touch_bg:obj",
  20. "touch_bg/get_bg:obj",
  21. "touch_bg/tabIcon:img",
  22. "touch_bg/tabName:img",
  23. "touch_bg/clock:obj",
  24. }
  25. self:GetChildren(self.nodes)
  26. self:AddEvents()
  27. if self.need_refreshData then
  28. self:UpdateView()
  29. end
  30. if self.need_reclick then
  31. self:SetSelected(self.selected)
  32. end
  33. end
  34. function SupremeVipTabItem:AddEvents( )
  35. local on_click = function ( click_obj )
  36. if self.touch_bg_obj == click_obj then
  37. self.click_callback(self.index)
  38. end
  39. end
  40. AddClickEvent(self.touch_bg_obj, on_click)
  41. --刷新兑换剩余次数
  42. local function update_exchange_rest_counts()
  43. self:UpdateExchangeRestCounts()
  44. end
  45. self:BindEvent(self.model, SupremeVipConst.REFRESH_EXCHANGE_REST_COUNTS,update_exchange_rest_counts)
  46. --刷新红点
  47. local function on_update_red(tab_id)
  48. if self.is_loaded then
  49. self:UpdateRedDot()
  50. end
  51. end
  52. self:BindEvent(self.model, SupremeVipConst.ANS_UPDATE_RED_DOT,on_update_red)
  53. end
  54. function SupremeVipTabItem:UpdateRedDot( )
  55. if not self.is_loaded or not self.redDot_obj then return end
  56. local red = false
  57. local show_clock = false
  58. if self.index == 1 then
  59. red = self.model:GetDailyGiftRed() or self.model:GetSevenLoginRed() or false
  60. elseif self.index == 2 then
  61. red = self.model:GetDiamondExchangeRed() or false
  62. elseif self.index == 3 then
  63. -- red = self.model:GetTrainDrugExchangeRed()
  64. elseif self.index == 4 then
  65. red = self.model:GetShopRed() or false
  66. if not red then--如果没有红点,检查下是不是应该占时钟标志
  67. show_clock = self.model:GetMoneyLeftRed() or false
  68. end
  69. end
  70. self.redDot_obj:SetActive(red)
  71. self.clock_obj:SetActive(show_clock)
  72. end
  73. function SupremeVipTabItem:UpdateView( )
  74. self:UpdateExchangeRestCounts()
  75. self:UpdateRedDot()
  76. self.titleImg_obj:SetActive(self.index == 2 or self.index == 3)
  77. local rest_daily_gift_counts = self.model:GetExchangeRestCount(SupremeVipConst.ExchangeType.DailyGift)--拿到剩余的兑换次数
  78. -- self.get_bg_obj:SetActive(false)
  79. -- if not self.model:IsForeverSupremeVip() then -- 一阶贵族
  80. -- else
  81. -- if rest_daily_gift_counts == 2 then
  82. -- elseif rest_daily_gift_counts == 1 then
  83. -- else
  84. -- self.get_bg_obj:SetActive(self.index == 1)
  85. -- end
  86. -- end
  87. -- local sup_vip_type = RoleManager.Instance.mainRoleInfo.sup_vip_type
  88. -- self:SetGray((self.index == 2 or self.index == 3) and sup_vip_type < 2)
  89. lua_resM:setImageSprite(self, self.tabIcon_img, "supremeVip_asset","supremeVip_tab_icon_"..self.index,true)
  90. end
  91. --刷新兑换剩余次数
  92. function SupremeVipTabItem:UpdateExchangeRestCounts( )
  93. if self.exchange_type ~= 0 then
  94. self.leftBg_obj:SetActive(true)
  95. local sup_vip_type = RoleManager.Instance.mainRoleInfo.sup_vip_type
  96. if sup_vip_type == 2 then
  97. local num = self.model:GetExchangeRestCount(self.exchange_type)
  98. local num_color = num == 0 and ColorUtil.RED_DARK or ColorUtil.GREEN_TIPS
  99. self.leftDes_tmp.text = string.format("今日剩余:<%s>%s</color>", num_color, num)
  100. else
  101. self.leftDes_tmp.text = ""
  102. end
  103. else
  104. self.leftBg_obj:SetActive(false)
  105. end
  106. end
  107. function SupremeVipTabItem:SetData(index,click_callback)
  108. self.index = index
  109. self.click_callback = click_callback
  110. if self.index == 2 then
  111. self.exchange_type = SupremeVipConst.ExchangeType.Diamond
  112. elseif self.index == 3 then
  113. self.exchange_type = SupremeVipConst.ExchangeType.TrainDrug
  114. else
  115. self.exchange_type = 0
  116. end
  117. if self.is_loaded then
  118. self.need_refreshData = false
  119. self:UpdateView()
  120. else
  121. self.need_refreshData = true
  122. end
  123. end
  124. function SupremeVipTabItem:SetSelected(bool)
  125. self.selected = bool
  126. if self.is_loaded then
  127. self.need_reclick = false
  128. self.selectBg_obj:SetActive(bool)
  129. self.bg_obj:SetActive(not bool)
  130. if bool then
  131. lua_resM:setImageSprite(self, self.tabName_img, "supremeVip_asset","supremeVip_tab_name_"..self.index.."_2",true)
  132. else
  133. lua_resM:setImageSprite(self, self.tabName_img, "supremeVip_asset","supremeVip_tab_name_"..self.index.."_1",true)
  134. end
  135. else
  136. self.need_reclick = true
  137. end
  138. end
  139. --一阶贵族时候要置灰永久特权贵族的按钮
  140. function SupremeVipTabItem:SetGray(bool)
  141. SetImageGray(self.bg_img,bool)
  142. end
  143. function SupremeVipTabItem:__delete( )
  144. end