243 lines
		
	
	
		
			7.9 KiB
		
	
	
	
		
			Lua
		
	
		
		
			
		
	
	
			243 lines
		
	
	
		
			7.9 KiB
		
	
	
	
		
			Lua
		
	
| 
								 | 
							
								local SelfRecruitRecharge = quick_class("SelfRecruitRecharge")  --充值回馈
							 | 
						||
| 
								 | 
							
								local allData = {}
							 | 
						||
| 
								 | 
							
								local itemsGrid = {}--item重复利用
							 | 
						||
| 
								 | 
							
								local this = SelfRecruitRecharge
							 | 
						||
| 
								 | 
							
								local parent 
							 | 
						||
| 
								 | 
							
								local endtime = 0
							 | 
						||
| 
								 | 
							
								local rechargeNum 
							 | 
						||
| 
								 | 
							
								local curtype = 0
							 | 
						||
| 
								 | 
							
								function SelfRecruitRecharge:ctor(mainPanel, gameObject)
							 | 
						||
| 
								 | 
							
								    self.mainPanel = mainPanel
							 | 
						||
| 
								 | 
							
								    self.gameObject = gameObject
							 | 
						||
| 
								 | 
							
								    self:InitComponent(gameObject)
							 | 
						||
| 
								 | 
							
								    self:BindEvent()
							 | 
						||
| 
								 | 
							
								end
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								function SelfRecruitRecharge:InitComponent(gameObject)
							 | 
						||
| 
								 | 
							
								    this.timeObj = Util.GetGameObject(gameObject, "time")
							 | 
						||
| 
								 | 
							
								    this.time = Util.GetGameObject(gameObject, "time/timeText"):GetComponent("Text")
							 | 
						||
| 
								 | 
							
								    -- this.text1 = Util.GetGameObject(gameObject, "bg1/Text"):GetComponent("Text")
							 | 
						||
| 
								 | 
							
								    -- this.text2 = Util.GetGameObject(gameObject, "bg1/Text2"):GetComponent("Text")
							 | 
						||
| 
								 | 
							
								    this.itemPre = Util.GetGameObject(gameObject, "ItemPre")
							 | 
						||
| 
								 | 
							
								    this.scrollItem = Util.GetGameObject(gameObject, "grid")
							 | 
						||
| 
								 | 
							
								    local rootHight = this.scrollItem.transform.rect.height
							 | 
						||
| 
								 | 
							
								    local width = this.scrollItem.transform.rect.width
							 | 
						||
| 
								 | 
							
								    this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, this.scrollItem.transform,
							 | 
						||
| 
								 | 
							
								            this.itemPre, nil, Vector2.New(width, rootHight), 1, 1, Vector2.New(0, 0))
							 | 
						||
| 
								 | 
							
								    this.ScrollView.moveTween.MomentumAmount = 1
							 | 
						||
| 
								 | 
							
								    this.ScrollView.moveTween.Strength = 2
							 | 
						||
| 
								 | 
							
								end
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								--绑定事件(用于子类重写)
							 | 
						||
| 
								 | 
							
								function SelfRecruitRecharge:BindEvent()
							 | 
						||
| 
								 | 
							
								    
							 | 
						||
| 
								 | 
							
								end
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								--添加事件监听(用于子类重写)
							 | 
						||
| 
								 | 
							
								function SelfRecruitRecharge:AddListener()
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								end
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								--移除事件监听(用于子类重写)
							 | 
						||
| 
								 | 
							
								function SelfRecruitRecharge:RemoveListener()
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								end
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								local sortingOrder = 0
							 | 
						||
| 
								 | 
							
								--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
							 | 
						||
| 
								 | 
							
								function SelfRecruitRecharge:OnShow(_sortingOrder,_parent,_type)
							 | 
						||
| 
								 | 
							
								    curtype = ActivityTypeDef.SelfRecruitRecharge
							 | 
						||
| 
								 | 
							
								    rechargeNum = VipManager.GetChargedNum()--已经充值的金额
							 | 
						||
| 
								 | 
							
								    sortingOrder = _sortingOrder
							 | 
						||
| 
								 | 
							
								    parent =  _parent
							 | 
						||
| 
								 | 
							
								    SelfRecruitRecharge:Refresh()
							 | 
						||
| 
								 | 
							
								end
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								function SelfRecruitRecharge:Refresh()
							 | 
						||
| 
								 | 
							
								    SelfRecruitRecharge:OnShowData()
							 | 
						||
| 
								 | 
							
								    this:SetTime()
							 | 
						||
| 
								 | 
							
								    CheckRedPointStatus(RedPointType.SelfRecruitRecharge) --自选招募真充回馈
							 | 
						||
| 
								 | 
							
								end
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								function SelfRecruitRecharge:SetTime()
							 | 
						||
| 
								 | 
							
								    if self.timer then
							 | 
						||
| 
								 | 
							
								        self.timer:Stop()
							 | 
						||
| 
								 | 
							
								        self.timer = nil
							 | 
						||
| 
								 | 
							
								    end 
							 | 
						||
| 
								 | 
							
								    local timeDown = endtime
							 | 
						||
| 
								 | 
							
								    this.time.text = GetLanguageStrById(12321)..TimeToDHMS(timeDown)
							 | 
						||
| 
								 | 
							
								    self.timer = Timer.New(function()
							 | 
						||
| 
								 | 
							
								        timeDown = timeDown - 1
							 | 
						||
| 
								 | 
							
								        if timeDown < 1 then
							 | 
						||
| 
								 | 
							
								            self.timer:Stop()
							 | 
						||
| 
								 | 
							
								            self.timer = nil
							 | 
						||
| 
								 | 
							
								            this.time.text = GetLanguageStrById(12321)..TimeToDHMS(0)
							 | 
						||
| 
								 | 
							
								            return 
							 | 
						||
| 
								 | 
							
								        end
							 | 
						||
| 
								 | 
							
								        this.time.text = GetLanguageStrById(12321)..TimeToDHMS(timeDown)
							 | 
						||
| 
								 | 
							
								    end, 1, -1, true)
							 | 
						||
| 
								 | 
							
								    self.timer:Start()
							 | 
						||
| 
								 | 
							
								end
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								function SelfRecruitRecharge:OnShowData()   
							 | 
						||
| 
								 | 
							
								    this.timeObj:SetActive(true)
							 | 
						||
| 
								 | 
							
								    allData = OperatingManager.InitLeiJiChongZhiData(curtype)
							 | 
						||
| 
								 | 
							
								    if allData then
							 | 
						||
| 
								 | 
							
								        endtime = ActivityGiftManager.GetTaskEndTime(curtype) - GetTimeStamp()
							 | 
						||
| 
								 | 
							
								        this.SortData(allData)
							 | 
						||
| 
								 | 
							
								        -- local itemList = {}
							 | 
						||
| 
								 | 
							
								        allData[#allData+1] = {}
							 | 
						||
| 
								 | 
							
								        this.ScrollView:SetData(allData, function (index, go)
							 | 
						||
| 
								 | 
							
								            if index == #allData then
							 | 
						||
| 
								 | 
							
								                go:SetActive(false)
							 | 
						||
| 
								 | 
							
								                return
							 | 
						||
| 
								 | 
							
								            end
							 | 
						||
| 
								 | 
							
								            go:SetActive(true)
							 | 
						||
| 
								 | 
							
								            this:SingleDataShow(go, allData[index])
							 | 
						||
| 
								 | 
							
								            -- itemList[index] = go
							 | 
						||
| 
								 | 
							
								        end)
							 | 
						||
| 
								 | 
							
								        -- DelayCreation(itemList)
							 | 
						||
| 
								 | 
							
								    else
							 | 
						||
| 
								 | 
							
								        parent.OnPageTabChange(1)
							 | 
						||
| 
								 | 
							
								        PopupTipPanel.ShowTipByLanguageId(12320)
							 | 
						||
| 
								 | 
							
								        return
							 | 
						||
| 
								 | 
							
								    end
							 | 
						||
| 
								 | 
							
								  --  CheckRedPointStatus(RedPointType.DynamicActRecharge)
							 | 
						||
| 
								 | 
							
								end
							 | 
						||
| 
								 | 
							
								local typeIndex = {
							 | 
						||
| 
								 | 
							
								    [0] = 2,
							 | 
						||
| 
								 | 
							
								    [1] = 3,
							 | 
						||
| 
								 | 
							
								    [2] = 1,
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								function SelfRecruitRecharge:SortData()
							 | 
						||
| 
								 | 
							
								    if allData == nil then
							 | 
						||
| 
								 | 
							
								        return
							 | 
						||
| 
								 | 
							
								    end
							 | 
						||
| 
								 | 
							
								    table.sort(allData, function(a,b)
							 | 
						||
| 
								 | 
							
								        if typeIndex[a.state] == typeIndex[b.state] then
							 | 
						||
| 
								 | 
							
								            return a.id < b.id
							 | 
						||
| 
								 | 
							
								        else
							 | 
						||
| 
								 | 
							
								            return typeIndex[a.state] < typeIndex[b.state]
							 | 
						||
| 
								 | 
							
								        end
							 | 
						||
| 
								 | 
							
								    end)
							 | 
						||
| 
								 | 
							
								end
							 | 
						||
| 
								 | 
							
								local type = {
							 | 
						||
| 
								 | 
							
								    [0] = {text = GetLanguageStrById(10023)},
							 | 
						||
| 
								 | 
							
								    [1] = {text = GetLanguageStrById(10350)},
							 | 
						||
| 
								 | 
							
								    [2] = {text = GetLanguageStrById(10022)},
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								--刷新每一条的显示数据
							 | 
						||
| 
								 | 
							
								function this:SingleDataShow(pre,value)
							 | 
						||
| 
								 | 
							
								    if pre == nil or value == nil then
							 | 
						||
| 
								 | 
							
								        return
							 | 
						||
| 
								 | 
							
								    end
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    --绑定组件
							 | 
						||
| 
								 | 
							
								    local go = pre
							 | 
						||
| 
								 | 
							
								    go:SetActive(true)
							 | 
						||
| 
								 | 
							
								    local sConFigData = value
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    local num = Util.GetGameObject(go, "context/num"):GetComponent("Text")
							 | 
						||
| 
								 | 
							
								    -- this:NumToNum(num, sConFigData.value)
							 | 
						||
| 
								 | 
							
								    local cur = sConFigData.progress > sConFigData.value and sConFigData.value or sConFigData.progress
							 | 
						||
| 
								 | 
							
								    local target = sConFigData.value
							 | 
						||
| 
								 | 
							
									--根据配置显示充值积分或充值金额文本
							 | 
						||
| 
								 | 
							
									if GetChannelConfig().RechargeNum_Mode == 1 then
							 | 
						||
| 
								 | 
							
										Util.GetGameObject(go, "context/title"):GetComponent("Text").text = GetLanguageStrById(50426)
							 | 
						||
| 
								 | 
							
										num.text = sConFigData.value / 10
							 | 
						||
| 
								 | 
							
										Util.GetGameObject(go, "context/progress"):GetComponent("Text").text = "("..cur / 10 .."/"..(target / 10)..")"
							 | 
						||
| 
								 | 
							
									else
							 | 
						||
| 
								 | 
							
										Util.GetGameObject(go, "context/title"):GetComponent("Text").text = GetLanguageStrById(50427)
							 | 
						||
| 
								 | 
							
										num.text = sConFigData.value
							 | 
						||
| 
								 | 
							
										Util.GetGameObject(go, "context/progress"):GetComponent("Text").text = "("..cur .."/"..target..")"
							 | 
						||
| 
								 | 
							
									end
							 | 
						||
| 
								 | 
							
									Util.GetGameObject(go, "context/Slider/Image"):GetComponent("Image").fillAmount = cur/target
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    local reward = Util.GetGameObject(go.gameObject, "scrollView/grid")
							 | 
						||
| 
								 | 
							
								    if not itemsGrid  then
							 | 
						||
| 
								 | 
							
								        itemsGrid = {}
							 | 
						||
| 
								 | 
							
								    end
							 | 
						||
| 
								 | 
							
								    if not itemsGrid[pre] then
							 | 
						||
| 
								 | 
							
								        itemsGrid[pre] = {}
							 | 
						||
| 
								 | 
							
								    end
							 | 
						||
| 
								 | 
							
								    for _, item in pairs(itemsGrid[pre]) do
							 | 
						||
| 
								 | 
							
								        item.gameObject:SetActive(false)
							 | 
						||
| 
								 | 
							
								    end
							 | 
						||
| 
								 | 
							
								    for k,v in ipairs(sConFigData.reward) do
							 | 
						||
| 
								 | 
							
								        if not itemsGrid[pre][k] then
							 | 
						||
| 
								 | 
							
								            itemsGrid[pre][k] = SubUIManager.Open(SubUIConfig.ItemView,reward.transform)
							 | 
						||
| 
								 | 
							
								        end
							 | 
						||
| 
								 | 
							
								        itemsGrid[pre][k]:OnOpen(false, {v[1],v[2]}, 0.55, false)
							 | 
						||
| 
								 | 
							
								        itemsGrid[pre][k].gameObject:SetActive(true)
							 | 
						||
| 
								 | 
							
								    end
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    local lingquButton = Util.GetGameObject(go.gameObject, "btnBuy")  
							 | 
						||
| 
								 | 
							
								    local state = sConFigData.state
							 | 
						||
| 
								 | 
							
								    local red = Util.GetGameObject(lingquButton.gameObject, "redPoint")
							 | 
						||
| 
								 | 
							
								    red:SetActive(state == 2)
							 | 
						||
| 
								 | 
							
								   
							 | 
						||
| 
								 | 
							
								    Util.GetGameObject(lingquButton.gameObject, "price"):GetComponent("Text").text = type[state].text
							 | 
						||
| 
								 | 
							
								    -- lingquButton:GetComponent("Image").sprite = Util.LoadSprite(type[state].sprite)
							 | 
						||
| 
								 | 
							
								    lingquButton:GetComponent("Button").enabled = (state ~= 1)
							 | 
						||
| 
								 | 
							
								    Util.SetGray(lingquButton.gameObject,state == 1)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    Util.AddOnceClick(lingquButton, function()
							 | 
						||
| 
								 | 
							
								        if state == 2 then
							 | 
						||
| 
								 | 
							
								            local curActivityId = ActivityGiftManager.GetActivityIdByType(curtype)
							 | 
						||
| 
								 | 
							
								            NetManager.GetActivityRewardRequest(sConFigData.id, curActivityId,function(drop)    
							 | 
						||
| 
								 | 
							
								                UIManager.OpenPanel(UIName.RewardItemPopup, drop, 1)
							 | 
						||
| 
								 | 
							
								                this.Refresh()
							 | 
						||
| 
								 | 
							
								            end)
							 | 
						||
| 
								 | 
							
								        elseif state == 0 then
							 | 
						||
| 
								 | 
							
								            if sConFigData.jump then
							 | 
						||
| 
								 | 
							
								                JumpManager.GoJump(sConFigData.jump)
							 | 
						||
| 
								 | 
							
								            end
							 | 
						||
| 
								 | 
							
								        end    
							 | 
						||
| 
								 | 
							
								    end)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								end
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								--界面打开时调用(用于子类重写)
							 | 
						||
| 
								 | 
							
								function SelfRecruitRecharge:OnOpen()
							 | 
						||
| 
								 | 
							
								end
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								function this.RechargeSuccessFunc(id)
							 | 
						||
| 
								 | 
							
								end
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								function SelfRecruitRecharge:OnClose()
							 | 
						||
| 
								 | 
							
								end
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								--界面销毁时调用(用于子类重写)
							 | 
						||
| 
								 | 
							
								function SelfRecruitRecharge:OnDestroy()
							 | 
						||
| 
								 | 
							
								    if self.timer then
							 | 
						||
| 
								 | 
							
								        self.timer:Stop()
							 | 
						||
| 
								 | 
							
								        self.timer = nil
							 | 
						||
| 
								 | 
							
								    end 
							 | 
						||
| 
								 | 
							
								    sortingOrder = 0
							 | 
						||
| 
								 | 
							
								    allData = {}
							 | 
						||
| 
								 | 
							
								    itemsGrid = {}
							 | 
						||
| 
								 | 
							
								end
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								function SelfRecruitRecharge:OnHide()
							 | 
						||
| 
								 | 
							
								    if self.timer then
							 | 
						||
| 
								 | 
							
								        self.timer:Stop()
							 | 
						||
| 
								 | 
							
								        self.timer = nil
							 | 
						||
| 
								 | 
							
								    end 
							 | 
						||
| 
								 | 
							
								    sortingOrder = 0
							 | 
						||
| 
								 | 
							
								end
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								--- 将一段时间转换为天时分秒
							 | 
						||
| 
								 | 
							
								function SelfRecruitRecharge:TimeToDHMS(second)
							 | 
						||
| 
								 | 
							
								    local day = math.floor(second / (24 * 3600))
							 | 
						||
| 
								 | 
							
								    local minute = math.floor(second / 60) % 60
							 | 
						||
| 
								 | 
							
								    local sec = second % 60
							 | 
						||
| 
								 | 
							
								    local hour = math.floor(math.floor(second - day * 24 * 3600 - sec - minute * 60) / 3600)
							 | 
						||
| 
								 | 
							
								    if day <= 0 and hour <= 0 then
							 | 
						||
| 
								 | 
							
								        return string.format(GetLanguageStrById(12231),minute, sec)
							 | 
						||
| 
								 | 
							
								    else
							 | 
						||
| 
								 | 
							
								        return string.format(GetLanguageStrById(12232),day, hour)
							 | 
						||
| 
								 | 
							
								    end
							 | 
						||
| 
								 | 
							
								end
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								return SelfRecruitRecharge
							 |