源战役客户端
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

146 linhas
3.8 KiB

4 semanas atrás
  1. --vip认证礼包
  2. VipActiveGiftView = VipActiveGiftView or BaseClass(BaseView)
  3. function VipActiveGiftView:__init()
  4. self.base_file = "gift"
  5. self.layout_file = "VipActiveGiftView"
  6. self.layer_name = "Top"
  7. self.click_bg_toClose = false
  8. self.destroy_imm = true
  9. self.use_background = true
  10. self.is_set_zdepth = true
  11. self.close_mode = CloseMode.CloseDestroy
  12. self.model = GiftModel:getInstance()
  13. self.model:setIsOpenView(true)
  14. self.award_list = {}
  15. self.load_callback = function ()
  16. self:LoadSuccess()
  17. self:addEvents()
  18. end
  19. self.open_callback = function ()
  20. self:SetData()
  21. end
  22. self.close_callback = function ()
  23. end
  24. self.destroy_callback = function ()
  25. self:DestroySuccess()
  26. end
  27. end
  28. function VipActiveGiftView:Open(type_id, goods_id)
  29. self.goods_id = goods_id
  30. self.type_id = type_id
  31. if not goods_id or not type_id then
  32. return
  33. end
  34. BaseView.Open(self)
  35. end
  36. function VipActiveGiftView:DestroySuccess()
  37. for _, item in pairs(self.award_list) do
  38. item:ReleaseObj()
  39. end
  40. self.award_list = {}
  41. self.wechat_num = nil
  42. end
  43. function VipActiveGiftView:LoadSuccess()
  44. self.copy_text_go,
  45. self.getBtn
  46. = GetChildGameObjects(self.transform, {
  47. "textGroup/copy",
  48. "getBtn"
  49. })
  50. self.des_text
  51. = GetChildTexts(self.transform, {
  52. "textGroup/desText"
  53. })
  54. self.grid_layout = self:GetChild("ScrollView/Viewport/Content"):GetComponent("GridLayoutGroup")
  55. self.grid_layout.enabled = false
  56. self.input_text = self:GetChild("InputField"):GetComponent("InputField")
  57. self.item_content
  58. = GetChildTransforms(self.transform, {
  59. "ScrollView/Viewport/Content",
  60. })
  61. end
  62. function VipActiveGiftView:addEvents()
  63. local function click_func(target)
  64. if target == self.copy_text_go then
  65. if self.content == nil then
  66. Message.show("复制失败")
  67. return
  68. end
  69. SetSystemClipboard(self.content)
  70. elseif target == self.getBtn then
  71. if Trim(self.input_text.text) == "" then
  72. Message.show("请输入卡号")
  73. return
  74. end
  75. WelfareModel:getInstance():Fire(WelfareModel.REQUEST_CCMD_EVENT, 41715, tostring(self.input_text.text), self.goods_id)
  76. self:Close()
  77. end
  78. end
  79. AddClickEvent(self.copy_text_go, click_func)
  80. AddClickEvent(self.getBtn, click_func, 2)
  81. end
  82. function VipActiveGiftView:SetData()
  83. local cfg
  84. if ClientConfig.vip_gift_data then
  85. local table = StrToTable(ClientConfig.vip_gift_data)
  86. if table then
  87. for _, v in pairs(table) do
  88. if tonumber(v.goods_id) == self.type_id then
  89. cfg = v
  90. break
  91. end
  92. end
  93. end
  94. end
  95. if cfg then
  96. self:SetRewardShow(cfg)
  97. self:SetConcactWay(cfg.content)
  98. end
  99. end
  100. --展示奖励
  101. function VipActiveGiftView:SetRewardShow(cfg)
  102. if cfg then
  103. local list = cfg.reward_list
  104. if #list <= 4 then
  105. self.grid_layout.enabled = true
  106. else
  107. self.item_content.sizeDelta = Vector2(#list * 110, 110)
  108. end
  109. for i, v in ipairs(list) do
  110. local item = self.award_list[i]
  111. if not item then
  112. item = UIObjPool:getInstance():PopItem(UIObjPool.UIType.AwardItem, self.item_content)
  113. self.award_list[i] = item
  114. end
  115. item:SetData(tonumber(v[2]), tonumber(v[3]))
  116. item:SetPosition((i - 1) * 110 + 42, -51.5)
  117. end
  118. end
  119. end
  120. function VipActiveGiftView:SetConcactWay(content)
  121. self.content = content
  122. if content then
  123. self.des_text.text = "请联系<color=#f14041>"..content .."</color>"
  124. end
  125. end