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

288 lines
9.9 KiB

  1. SupremeVipActivateView = SupremeVipActivateView or BaseClass(BaseView)
  2. local SupremeVipActivateView = SupremeVipActivateView
  3. function SupremeVipActivateView:__init()
  4. self.base_file = "supremeVip"
  5. self.layout_file = "SupremeVipActivateView"
  6. self.layer_name = "Activity"
  7. self.destroy_imm = true
  8. self.use_background = true
  9. self.change_scene_close = true
  10. self.hide_maincancas = false --是否隐藏主界面
  11. self.append_to_ctl_queue = false --是否要添加进界面堆栈
  12. self.need_show_money = false --是否要显示顶部的金钱栏
  13. self.is_set_zdepth = true
  14. self.choose_index = 1
  15. self.model = SupremeVipModel:getInstance()
  16. self.mainVo = RoleManager.Instance.mainRoleInfo
  17. if self.model.login_red then
  18. self.model.login_red = false
  19. self.model:Fire(SupremeVipConst.UPDATE_SUPREME_VIP_MAIN_BUTTON_RED)
  20. end
  21. self.load_callback = function ()
  22. self:LoadSuccess()
  23. self:AddEvent()
  24. end
  25. self.open_callback = function ( )
  26. self:UpdateView()
  27. end
  28. self.destroy_callback = function ( )
  29. self:DestroySuccess()
  30. end
  31. end
  32. function SupremeVipActivateView:Open( index )
  33. --self.data = data
  34. self.choose_index = index or self.choose_index
  35. BaseView.Open(self)
  36. end
  37. function SupremeVipActivateView:LoadSuccess()
  38. local nodes = {
  39. "sloganImg:img", "bg:raw",
  40. "closeBtn:obj", "price:tmp", "price2:tmp",
  41. "activateBtn:obj",
  42. "rightTitle:tmp", "rightdes:tmp",
  43. "rightBigIcon:img",
  44. "ScrollView", "ScrollView/Viewport/Content",
  45. "tabCon/smallTab3:img", "tabCon/smallTab7:img", "tabCon/smallTab6:img", "tabCon/smallTab4:img", "tabCon/smallTab1:img", "tabCon/smallTab2:img", "tabCon/smallTab5:img",
  46. "activateBtn/rightBtnEffect",
  47. "extraEffect",
  48. "iconEffect",
  49. }
  50. self:GetChildren(nodes)
  51. self:AddUIEffect("ui_effect_shouchong05_2", self.rightBtnEffect, self.layer_name, nil, 1, false,nil,nil,nil,nil,nil,nil,nil,UIPartical.RenderingOther_List.UIBackward)
  52. -- local function bg_back_func( ... )
  53. -- if self.background_wnd and self.background_wnd:GetComponent("RawImageExtend") then
  54. -- self:MoveUIToBack(self.background_wnd:GetComponent("RawImageExtend"))
  55. -- end
  56. -- self:MoveUIToBack(self.bg_raw)
  57. -- end
  58. -- if self.background_wnd then
  59. -- bg_back_func()
  60. -- else
  61. -- self.bg_back_func = bg_back_func
  62. -- end
  63. -- self.icon_canvas = self.rightBigIcon:GetComponent(typeof(UnityEngine.Canvas))
  64. -- self.icon_canvas.sortingOrder = self:GetCurrLayerDepth("Activity") + 40
  65. -- -- self:AddUIEffect("ui_guizutequan", self.rightBigIcon, "Activity", Vector3(-4,-30.5,0), 1, false,nil,nil,nil,nil,nil,UIPartical.RenderingOther_List.UIBackward)
  66. -- self:AddUIEffect("ui_guizutequan", self.iconEffect, "Activity", Vector3(-4,-30.5,0), 1, true,nil,nil,nil,nil,nil,nil)
  67. lua_resM:setOutsideRawImage(self, self.bg_raw, GameResPath.GetViewBigBg("supremeVip_activate_view"))
  68. lua_resM:setOutsideImageSprite(self, self.sloganImg_img, GameResPath.GetSupremeVipIcon("supremeVip_des_4_pointfilter"), true)
  69. self.sup_vip_type = RoleManager.Instance.mainRoleInfo.sup_vip_type
  70. self.price_tmp.text = self.model:GetActivateSupremeVipCost()
  71. self.price2_tmp.text = "4998"
  72. SetAnchoredPositionY(self.rightBigIcon,30)
  73. SetAnchoredPositionY(self.iconEffect,30)
  74. if self.tween_id then
  75. TweenLite.Stop(self.tween_id)
  76. self.tween_id = nil
  77. end
  78. -- self.tween_id =TweenLite.to(self, self.rightBigIcon,TweenLite.UiAnimationType.ANCHORED_POSY,37, 1.8, nil,TweenFunc.PINGPONG,true)
  79. end
  80. function SupremeVipActivateView:AddEvent()
  81. local on_click = function ( click_obj )
  82. if self.closeBtn_obj == click_obj then
  83. self:Close()
  84. elseif self.activateBtn_obj == click_obj then--激活
  85. local limit_vip = self.model:GetSupremeIconOpenVipLv()
  86. if self.mainVo.vip_flag and self.mainVo.vip_flag >= limit_vip then
  87. if self.model:IsForeverSupremeVip() or self.model:IsMomentSupremeVip() then
  88. Message.show("已经是贵族了","fault")
  89. else
  90. local ok_function = function()
  91. self.model:Fire(SupremeVipConst.REQUEST_CCMD_EVENT,45102,0)--请求激活一阶贵族
  92. end
  93. local cost = self.model:GetActivateSupremeVipCost()
  94. if RoleManager.Instance.mainRoleInfo.jin>=cost then--够钱直接买
  95. ok_function()
  96. return
  97. end
  98. local function use_function( toggle_tip_data,call_fun_sum )
  99. GlobalEventSystem:Fire(EventName.OPEN_COM_TOGGLE_TIP_VIEW, toggle_tip_data)
  100. end
  101. local function recharge_open_call_back( )
  102. self:Close()
  103. end
  104. local buy_tip_data = {
  105. gold_type = 1,--货币类型
  106. cost_price = cost,--消耗金额
  107. ok_callback = ok_function,--成功
  108. no_need_toggle = true,
  109. -- toggle_function = toggle_function,--多选
  110. recharge_open_call_back = recharge_open_call_back,
  111. togglePriceStr = HtmlColorTxt(cost, ColorUtil.YELLOW_DARK).." 激活贵族?",
  112. use_function = use_function,--最终调用
  113. }
  114. CustomActivityModel:getInstance():BuyTips(buy_tip_data)
  115. -- local jump_recharge_callback = function()
  116. -- self:Close()
  117. -- end
  118. -- local data = {
  119. -- titleText = "激活贵族",
  120. -- price = cost,
  121. -- priceText = " "..HtmlColorTxt(cost, ColorUtil.YELLOW_DARK).." 激活贵族?",
  122. -- ok_callback = ok_function,
  123. -- insufficientText = "",
  124. -- no_need_toggle = true,
  125. -- jump_recharge_callback = jump_recharge_callback,
  126. -- -- toggle_function = toggle_function,
  127. -- }
  128. -- GlobalEventSystem:Fire(EventName.OPEN_COM_TOGGLE_TIP_VIEW, data)
  129. end
  130. else
  131. Message.show("升到VIP"..limit_vip.."才能激活贵族哦","fault")
  132. end
  133. end
  134. end
  135. AddClickEvent(self.closeBtn_obj, on_click,1)
  136. AddClickEvent(self.activateBtn_obj, on_click,1)
  137. end
  138. function SupremeVipActivateView:ChangeShowSupremeRight(index)
  139. self.choose_index = index
  140. self.rightTitle_tmp.text = string.format("特权%s:%s",index,SupremeVipConst.SupremeVipRight[index].name)
  141. self.rightdes_tmp.text = SupremeVipConst.SupremeVipRight[index].des
  142. -- if index == 1 then
  143. -- lua_resM:setOutsideImageSprite(self, self.rightBigIcon_img, GameResPath.GetSkillIcon("109101"), true)
  144. -- else
  145. -- lua_resM:setOutsideImageSprite(self, self.rightBigIcon_img, GameResPath.GetSupremeVipIcon("supremeVip_right_big_icon_"..index), true)
  146. -- end
  147. if self.choose_index == 3 then
  148. self:AddUIEffect("ui_guizutequan_godstone", self.extraEffect, "Activity", Vector3(-4,-30.5,0), 1, false,-1,nil,nil,nil,nil)
  149. lua_resM:setImageSprite(self, self.rightBigIcon_img, "uiComponent_asset","com_empty")
  150. elseif self.choose_index == 4 then
  151. self:AddUIEffect("ui_guizutequan_nojump", self.extraEffect, "Activity", Vector3(-4,-30.5,0), 1, false,-1,nil,nil,nil,nil)
  152. lua_resM:setImageSprite(self, self.rightBigIcon_img, "uiComponent_asset","com_empty")
  153. else
  154. self:ClearUIEffect(self.extraEffect)
  155. lua_resM:setOutsideImageSprite(self, self.rightBigIcon_img, GameResPath.GetSupremeVipIcon("supremeVip_right_big_icon_"..index), true)
  156. end
  157. end
  158. function SupremeVipActivateView:UpdateView()
  159. local click_callback = function(index)
  160. self:ChangeShowSupremeRight(index)
  161. self:UpdateRightItemPos(index)
  162. self:AutoChangeIndex()
  163. self:UpdateSmallTab()
  164. end
  165. if not self.item_list_com then
  166. self.item_list_com = self:AddUIComponent(UI.ItemListCreator)
  167. end
  168. local info = {
  169. data_list = {{},{},{},{},{},{},{}},
  170. item_con = self.Content,
  171. item_class = SupremeVipRightItem,
  172. item_width = 162,
  173. item_height = 46,
  174. -- space_x = 0,
  175. space_y = 8,
  176. start_x = 116,
  177. start_y = -33-8,
  178. scroll_view = self.ScrollView,
  179. -- create_frequency = 0.01,
  180. reuse_item_num = 7,
  181. on_update_item = function(item, i, v)
  182. item:SetData(i,click_callback)
  183. self.item_list_com:IterateItems(function( item, i )
  184. item:OnClick(1)
  185. end)
  186. end,
  187. final_callback = function()
  188. self.item_list_com:IterateItems(function( item, i )
  189. item:OnClick(1)
  190. end)
  191. end,
  192. }
  193. self.item_list_com:UpdateItems(info)
  194. self.icon_canvas = self.rightBigIcon:GetComponent(typeof(UnityEngine.Canvas))
  195. self.icon_canvas.sortingOrder = self:GetCurrLayerDepth("Activity") + 40
  196. -- self:AddUIEffect("ui_guizutequan", self.rightBigIcon, "Activity", Vector3(-4,-30.5,0), 1, false,nil,nil,nil,nil,nil,UIPartical.RenderingOther_List.UIBackward)
  197. self:AddUIEffect("ui_guizutequan", self.iconEffect, "Activity", Vector3(-4,-30.5,0), 1, true,nil,nil,nil,nil,nil,nil)
  198. end
  199. function SupremeVipActivateView:UpdateRightItemPos(index)
  200. if self.item_list_com then
  201. self.item_list_com:IterateItems(function( item, i )
  202. local pos_y = -33
  203. if i < index then
  204. pos_y = pos_y - (i-1)*(46+8)
  205. elseif i == index then
  206. pos_y = pos_y - (i-1)*(46+8) -8
  207. elseif i > index then
  208. pos_y = pos_y - (i-2)*(46+8) -8-8 -55
  209. end
  210. item:SetAnchoredPosition(116,pos_y)
  211. end)
  212. end
  213. SetSizeDeltaY(self.Content,(46+5)*7+33-8+30)
  214. -- SetAnchoredPositionY(self.Content,33+(index-1)*(46+22)+10)
  215. end
  216. function SupremeVipActivateView:AutoChangeIndex()
  217. if self.delay_handler then
  218. TimerQuest.CancelQuest(GlobalTimerQuest, self.delay_handler)
  219. self.delay_handler = nil
  220. end
  221. local function delay_method( )
  222. local next_index = self.choose_index < 7 and self.choose_index+1 or 1
  223. self.item_list_com:IterateItems(function( item, i )
  224. item:OnClick(next_index)
  225. end)
  226. local pos_y = 0
  227. if next_index == 6 then
  228. pos_y = 32
  229. elseif next_index == 7 then
  230. pos_y = 32
  231. end
  232. SetAnchoredPositionY(self.Content,pos_y)
  233. end
  234. self.delay_handler = setTimeout(delay_method, 6)
  235. end
  236. function SupremeVipActivateView:UpdateSmallTab( )
  237. for i=1,7 do
  238. if i == self.choose_index then
  239. lua_resM:setImageSprite(self, self["smallTab"..i.."_img"], "supremeVip_asset","supremeVip_small_tab_2")
  240. else
  241. lua_resM:setImageSprite(self, self["smallTab"..i.."_img"], "supremeVip_asset","supremeVip_small_tab_1")
  242. end
  243. end
  244. end
  245. function SupremeVipActivateView:DestroySuccess( )
  246. if self.tween_id then
  247. TweenLite.Stop(self.tween_id)
  248. self.tween_id = nil
  249. end
  250. if self.delay_handler then
  251. TimerQuest.CancelQuest(GlobalTimerQuest, self.delay_handler)
  252. self.delay_handler = nil
  253. end
  254. self:ClearUIEffect(self.iconEffect)
  255. self:ClearUIEffect(self.extraEffect)
  256. end