local UIGrowthFundPanel = UIViewClass() function UIGrowthFundPanel:OnOpened(context) self:RegistSystemEvent(EventID.UI_Fund_RefreshPanel, self.RefreshFundUI) self.welfareType = context.fundID self:RefreshFundUI() end function UIGrowthFundPanel:OnButtonClicked(comp) if comp == self.btn_Price then --购买基金 if self.fundData == nil then MDL.Currency.GetOrderIDReq(self.fundConfig.IAPID, MDL.Currency.PayType.Fund, self.fundConfig.ID) else CTL.Tips.AddTipsMsg(Const_IDS.IDS_Fund_Button_Paid) end end end function UIGrowthFundPanel:RefreshFundUI() self.fundData = MDL.GrowthFund.GetGrowFundByFundID(self.welfareType) -- 服务器传来的数据 self.fundConfig = DataSheetManager.PreferentialOrder:GetDataByID(self.welfareType) -- 基金数据 self.iapConfig = DataSheetManager.IAP:GetDataByIndex(self.fundConfig.IAPID) -- iap数据 self.fundItemConfigs = MDL.GrowthFund.GetActivitiesItemListByID(self.welfareType) if self.loc_Title.CurState == 0 then -- 中文 UIUtils.SetLocalizationImage(self.img_Title, self.fundConfig.TitleResource) -- 标题图片 UIUtils.SetLabel(self.txt_Discount, string.FormatByIdsId(Const_IDS.IDS_Fund_OffTitle, self.fundConfig.FundReturnPer)) -- 返利百分比 else UIUtils.SetLabelText(self.txt_Title, Const_IDS[self.fundConfig.ActivityName]) UIUtils.SetLabel(self.txt_Discount2, string.FormatByIdsId(Const_IDS.IDS_Fund_OffTitle, self.fundConfig.FundReturnPer)) -- 返利百分比 end self.txt_Price.text = MDL.Currency.GetFullyIAPPrice(self.fundConfig.IAPID) self.state_price:SetState(self.fundData == nil and 0 or self.fundData.BuyState) UTL.Item.SetCurrencyImageIcon(self.img_CurrencyIcon1, self.iapConfig.Item_Condition_Table[1].GetID) -- 立得物品图片 UIUtils.SetLabel(self.txt_Get, self.iapConfig.Item_Condition_Table[1].GetAmount) -- 立得物品数量 if self.iapConfig.Item_Condition_Table and self.iapConfig.Item_Condition_Table[2] then UIUtils.SetActive(self.group_Integral, true) UTL.Item.SetCurrencyImageIcon(self.img_CurrencyIcon3, self.iapConfig.Item_Condition_Table[2].GetID) -- 充值积分图标 UIUtils.SetLabel(self.txt_Integral, self.iapConfig.Item_Condition_Table[2].GetAmount) -- 立即获得充值积分数量 else UIUtils.SetActive(self.group_Integral, false) end UTL.Item.SetCurrencyImageIcon(self.img_CurrencyIcon2, DataSheetManager.FundReward:GetDataByID(self.fundItemConfigs[1].ID).Item_Table[1].ItemID) -- 总返还物品图片 UIUtils.SetLabel(self.txt_Rebate, MDL.GrowthFund.GetAllRebateCountByFundID(self.welfareType)) -- 总返还物品价格 if self.Loop_Fund.Count > 0 then self.Loop_Fund:ClearCells() end local itemDataList = {} for k,v in ipairs(self.fundItemConfigs) do local state = MDL.GrowthFund.BuyStateType.No if self.fundData then for i = 1, #self.fundData.FundSubInfos do if self.fundData.FundSubInfos[i].Id == v.ID then state = self.fundData.FundSubInfos[i].State break end end end table.insert(itemDataList, {info = v, state = state}) self.Loop_Fund:AddData({info = v, state = state}, 0) end if itemDataList then for k,v in ipairs(itemDataList) do if v.state == MDL.GrowthFund.SubItemStateType.Finished or v.state == MDL.GrowthFund.SubItemStateType.Doing then self.Loop_Fund:MoveIndex(k - 1) break end end end if MDL.Currency.IsNotShowRechargeButton() then UIUtils.SetActive(self.btn_Price, false) end end --region ------------滑动组件相关------------------- function UIGrowthFundPanel:OnCellInit(scrollRect, index, cellTable, data) local rewardConfig = DataSheetManager.FundReward:GetDataByID(data.info.FundRewardID) local triggerData = DataSheetManager.TriggerID:GetDataByID(data.info.TriggerID).Unlock_Table[1] local isTreasure = #rewardConfig.Item_Table == 1 and true or false cellTable.cell_stateSwitch:SetState(isTreasure and 0 or 1) -- 策划需求奖励第一个默认为元宝,在此处显示 UTL.Item.SetCurrencyImageIcon(cellTable.img_CurrencyIcon, rewardConfig.Item_Table[1].ItemID) -- 物品图片 UIUtils.SetLabel(cellTable.txt_Amount, rewardConfig.Item_Table[1].ItemNum) -- 物品数量 if isTreasure then UIUtils.SetImageByAssetBundle(cellTable.img_Box, data.info.BackPic) -- 宝箱图片 else -- 策划需求奖励第一个默认为元宝,需要单独在元宝位置显示,不在此处显示,Item_Table 奖励从第二个开始展示 for i = 2, #rewardConfig.Item_Table do local contentItem = cellTable.group_Item[i - 1] local itemData = rewardConfig.Item_Table[i] if not contentItem then contentItem = self:InstantiateCellCollection(cellTable.cell.gameObject, cellTable.group_Item, self.itemTemplate_Reward.gameObject) end UTL.Item.SetItemCell(contentItem, itemData.ItemID, itemData.ItemNum) UIUtils.SetActive(contentItem.gameObject, true) end for i = #rewardConfig.Item_Table, #cellTable.group_Item do UIUtils.SetActive(cellTable.group_Item[i].gameObject, false) end end local curCount, configCount if triggerData.UnlockCondition == LuaConst.TriggerType.Team_Level then -- 等级 local isUnlock = MDL.Unlock.IsComplete(triggerData.UnlockCondition, tonumber(triggerData.UnlockConditionParamA)) curCount = UTL.Item.GetNobilityByTeamLevel(MDL.Player.GetRoleLevel()) -- 爵位转换 configCount = UTL.Item.GetNobilityByTeamLevel(tonumber(triggerData.UnlockConditionParamA)) -- 爵位转换 if self.fundData == nil then data.state = MDL.Unlock.IsComplete(triggerData.UnlockCondition, tonumber(triggerData.UnlockConditionParamA)) and MDL.GrowthFund.SubItemStateType.Finished or MDL.GrowthFund.SubItemStateType.Doing end curCount = isUnlock and UTL.Color.FormatGreenColor(curCount) or UTL.Color.FormatRedColor(curCount) elseif triggerData.UnlockCondition == LuaConst.TriggerType.OfficialPosition_Level then -- 官职 local isUnlock = MDL.Unlock.IsComplete(triggerData.UnlockCondition, tonumber(triggerData.UnlockConditionParamA)) for i, v in DataSheetManager.OfficialPosition:GetEnumerator() do if v.GradeID == tonumber(triggerData.UnlockConditionParamA) then configCount = UIUtils.GetLocalizedTxt(Const_IDS[v.Name1]) break end end local titleData = MDL.OfficialPosition.GetCurTitleData() if titleData then curCount = UIUtils.GetLocalizedTxt(Const_IDS[titleData.Name1]) else curCount = UIUtils.GetLocalizedTxt(Const_IDS.IDS_OfficialPosition_Civilian) end if self.fundData == nil then data.state = isUnlock and MDL.GrowthFund.SubItemStateType.Finished or MDL.GrowthFund.SubItemStateType.Doing end curCount = isUnlock and UTL.Color.FormatGreenColor(curCount) or UTL.Color.FormatRedColor(curCount) end UIUtils.SetLabelText(cellTable.lab_Level, Const_IDS[data.info.Title]) if Localization.IsAllChinese() then UIUtils.SetLabel(cellTable.txt_Level, string.format("%s/%s", curCount, configCount)) else UIUtils.SetLabel(cellTable.txt_Level, string.format("Lv.%s/%s", curCount, configCount)) end if self.fundData == nil then -- 未购买基金,无论是否达到条件都显示暗色按钮 cellTable.state_receive:SetState(MDL.GrowthFund.SubItemStateType.Doing) cellTable.state_TextUnreceive:SetState(data.state) else cellTable.state_TextUnreceive:SetState(0) cellTable.state_receive:SetState(data.state) end UIUtils.SetActive(cellTable.img_Arrow, index + 1 ~= #self.fundItemConfigs) end function UIGrowthFundPanel:OnCellClicked(scrollRect, index, cellTable, target, data) if target == cellTable.btn_Receive then -- 领取按钮 MDL.GrowthFund.FundGetAwardRequest(self.welfareType, data.info.ID) else for i,v in ipairs(cellTable.group_Item) do if v.event_Click == target then local rewardConfig = DataSheetManager.FundReward:GetDataByID(data.info.FundRewardID) UTL.ItemTips.ShowCommonTipsById(rewardConfig.Item_Table[i + 1].ItemID) break end end end end --endregion return UIGrowthFundPanel