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

132 lines
4.7 KiB

  1. SupremeVipBuyView = SupremeVipBuyView or BaseClass(BaseView)
  2. local SupremeVipBuyView = SupremeVipBuyView
  3. function SupremeVipBuyView:__init()
  4. self.base_file = "supremeVip"
  5. self.layout_file = "SupremeVipBuyView"
  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 = true --是否隐藏主界面
  11. -- self.append_to_ctl_queue = true --是否要添加进界面堆栈
  12. self.need_show_money = false --是否要显示顶部的金钱栏
  13. self.is_set_zdepth = true
  14. self.model = SupremeVipModel:getInstance()
  15. if self.model.login_red then
  16. self.model.login_red = false
  17. self.model:Fire(SupremeVipConst.UPDATE_SUPREME_VIP_MAIN_BUTTON_RED)
  18. end
  19. self.load_callback = function ()
  20. self:LoadSuccess()
  21. self:AddEvent()
  22. end
  23. self.open_callback = function ( )
  24. self:UpdateView()
  25. end
  26. self.destroy_callback = function ( )
  27. self:DestroySuccess()
  28. end
  29. end
  30. function SupremeVipBuyView:Open( )
  31. --self.data = data
  32. BaseView.Open(self)
  33. end
  34. function SupremeVipBuyView:LoadSuccess()
  35. self.nodes = {
  36. "titleImg:img", "bg:raw", "way1:img", "way2:img",
  37. "chargeBtn:obj",
  38. "buyBtn:obj",
  39. "closeBtn:obj", "proImg:img", "pro_text:tmp",
  40. }
  41. self:GetChildren(self.nodes)
  42. self.chargeDayCheck = {}
  43. self.chargeDayBg = {}
  44. self.chargeDayNum = {}
  45. self.chargeDayImg = {}
  46. for i=1,7 do
  47. self.chargeDayCheck[i] = self:GetChild("chargeDayCon/dayItem"..i.."/checkImg").gameObject
  48. self.chargeDayBg[i] = self:GetChild("chargeDayCon/dayItem"..i.."/dayBg"):GetComponent("Image")
  49. self.chargeDayNum[i] = self:GetChild("chargeDayCon/dayItem"..i.."/dayNum"):GetComponent("Image")
  50. self.chargeDayImg[i] = self:GetChild("chargeDayCon/dayItem"..i.."/dayImg"):GetComponent("Image")
  51. end
  52. lua_resM:setOutsideRawImage(self, self.bg_raw, GameResPath.GetViewBigBg("supremeVip_buy_view"))
  53. lua_resM:setOutsideImageSprite(self, self.way1_img, GameResPath.GetSupremeVipIcon("way_1"), true)
  54. lua_resM:setOutsideImageSprite(self, self.way2_img, GameResPath.GetSupremeVipIcon("way_2"), true)
  55. lua_resM:setOutsideImageSprite(self, self.titleImg_img, GameResPath.GetSupremeVipIcon("supremeVip_title_4"), true)
  56. self.model:Fire(SupremeVipConst.REQUEST_CCMD_EVENT,45101)--请求自己的贵族信息
  57. end
  58. function SupremeVipBuyView:AddEvent()
  59. local on_click = function ( click_obj )
  60. if self.closeBtn_obj == click_obj then
  61. self:Close()
  62. elseif self.chargeBtn_obj == click_obj then
  63. if not self.model:IsForeverSupremeVip() then
  64. self:Close()
  65. OpenFun.Open(450,1)
  66. else
  67. Message.show("已经是二阶贵族了","fault")
  68. end
  69. elseif self.buyBtn_obj == click_obj then
  70. -- if not self.model:IsForeverSupremeVip() then
  71. -- local cost = self.model:GetActivateForeverSupremeVipCost() or 1980
  72. -- Alert.show("是否花费"..cost.."彩钻激活永久贵族?", Alert.Type.Two, function()
  73. -- self.model:Fire(SupremeVipConst.REQUEST_CCMD_EVENT,45102,1)
  74. -- end, nil, "是", "否")
  75. -- else
  76. -- Message.show("已经是永久贵族了")
  77. -- end
  78. if not self.model:IsForeverSupremeVip() then
  79. self:Close()
  80. OpenFun.Open(450,1)
  81. else
  82. Message.show("已经是二阶贵族了","fault")
  83. end
  84. end
  85. end
  86. AddClickEvent(self.closeBtn_obj, on_click)
  87. AddClickEvent(self.chargeBtn_obj, on_click)
  88. AddClickEvent(self.buyBtn_obj, on_click)
  89. --贵族信息变更,这里要刷新充值天数
  90. local function update_charge_day()
  91. if self.is_loaded then
  92. self:UpdateView()
  93. end
  94. end
  95. self:BindEvent(self.model, SupremeVipConst.REFRESH_SUPREME_VIP_DATA, update_charge_day)
  96. end
  97. function SupremeVipBuyView:UpdateView()
  98. local chargeDay = self.model:GetChargeDay()
  99. for i=1,7 do
  100. self.chargeDayCheck[i]:SetActive(i<=chargeDay)
  101. if i<=chargeDay then
  102. lua_resM:setImageSprite(self, self.chargeDayBg[i], "supremeVip_asset","supremeVip_tab_choose_bg",false)
  103. lua_resM:setImageSprite(self, self.chargeDayNum[i], "supremeVip_asset","supremeVip_day_"..i,true)
  104. lua_resM:setImageSprite(self, self.chargeDayImg[i], "supremeVip_asset","supremeVip_day_select",true)
  105. else
  106. lua_resM:setImageSprite(self, self.chargeDayBg[i], "supremeVip_asset","supremeVip_tab_nomal_bg",false)
  107. lua_resM:setImageSprite(self, self.chargeDayNum[i], "supremeVip_asset","supremeVip_day_"..i.."_normal",true)
  108. lua_resM:setImageSprite(self, self.chargeDayImg[i], "supremeVip_asset","supremeVip_day_normal",true)
  109. end
  110. end
  111. local cur_price = self.model.total_charge or 0
  112. local max_recharge = self.model:GetActivateForeverSupremeVipCost() or 1980
  113. local cur_recharge = cur_price < max_recharge and cur_price or max_recharge
  114. self.proImg_img.fillAmount = cur_recharge < max_recharge and cur_recharge/max_recharge or 1
  115. self.pro_text_tmp.text = cur_recharge.."/"..max_recharge
  116. end
  117. function SupremeVipBuyView:DestroySuccess( )
  118. end