|
|
-
- --vip认证礼包
- VipActiveGiftView = VipActiveGiftView or BaseClass(BaseView)
-
- function VipActiveGiftView:__init()
- self.base_file = "gift"
- self.layout_file = "VipActiveGiftView"
- self.layer_name = "Top"
- self.click_bg_toClose = false
- self.destroy_imm = true
- self.use_background = true
- self.is_set_zdepth = true
- self.close_mode = CloseMode.CloseDestroy
- self.model = GiftModel:getInstance()
- self.model:setIsOpenView(true)
-
- self.award_list = {}
-
- self.load_callback = function ()
- self:LoadSuccess()
- self:addEvents()
- end
-
- self.open_callback = function ()
- self:SetData()
- end
-
- self.close_callback = function ()
-
- end
-
- self.destroy_callback = function ()
- self:DestroySuccess()
- end
- end
-
- function VipActiveGiftView:Open(type_id, goods_id)
- self.goods_id = goods_id
- self.type_id = type_id
- if not goods_id or not type_id then
- return
- end
- BaseView.Open(self)
- end
-
- function VipActiveGiftView:DestroySuccess()
- for _, item in pairs(self.award_list) do
- item:ReleaseObj()
- end
- self.award_list = {}
- self.wechat_num = nil
- end
-
- function VipActiveGiftView:LoadSuccess()
- self.copy_text_go,
- self.getBtn
- = GetChildGameObjects(self.transform, {
- "textGroup/copy",
- "getBtn"
- })
-
- self.des_text
- = GetChildTexts(self.transform, {
- "textGroup/desText"
- })
-
- self.grid_layout = self:GetChild("ScrollView/Viewport/Content"):GetComponent("GridLayoutGroup")
- self.grid_layout.enabled = false
- self.input_text = self:GetChild("InputField"):GetComponent("InputField")
-
- self.item_content
- = GetChildTransforms(self.transform, {
- "ScrollView/Viewport/Content",
- })
-
- end
-
- function VipActiveGiftView:addEvents()
- local function click_func(target)
- if target == self.copy_text_go then
- if self.content == nil then
- Message.show("复制失败")
- return
- end
- SetSystemClipboard(self.content)
- elseif target == self.getBtn then
- if Trim(self.input_text.text) == "" then
- Message.show("请输入卡号")
- return
- end
- WelfareModel:getInstance():Fire(WelfareModel.REQUEST_CCMD_EVENT, 41715, tostring(self.input_text.text), self.goods_id)
- self:Close()
- end
- end
- AddClickEvent(self.copy_text_go, click_func)
- AddClickEvent(self.getBtn, click_func, 2)
- end
-
- function VipActiveGiftView:SetData()
- local cfg
- if ClientConfig.vip_gift_data then
- local table = StrToTable(ClientConfig.vip_gift_data)
- if table then
- for _, v in pairs(table) do
- if tonumber(v.goods_id) == self.type_id then
- cfg = v
- break
- end
- end
- end
- end
- if cfg then
- self:SetRewardShow(cfg)
- self:SetConcactWay(cfg.content)
- end
-
- end
-
- --展示奖励
- function VipActiveGiftView:SetRewardShow(cfg)
- if cfg then
- local list = cfg.reward_list
- if #list <= 4 then
- self.grid_layout.enabled = true
- else
- self.item_content.sizeDelta = Vector2(#list * 110, 110)
- end
- for i, v in ipairs(list) do
- local item = self.award_list[i]
- if not item then
- item = UIObjPool:getInstance():PopItem(UIObjPool.UIType.AwardItem, self.item_content)
- self.award_list[i] = item
- end
- item:SetData(tonumber(v[2]), tonumber(v[3]))
- item:SetPosition((i - 1) * 110 + 42, -51.5)
- end
- end
-
- end
-
- function VipActiveGiftView:SetConcactWay(content)
- self.content = content
- if content then
- self.des_text.text = "请联系<color=#f14041>"..content .."</color>"
- end
- end
|