local UIRechargeView = UIViewClass() local EventSystem = require('Event/EventSystem') local RechargeIndex = 2000 -- IAP 表中 ID 2000 以下 表示充值 function UIRechargeView:OnOpened(context) self:InitData() self:RegistSystemEvent(EventID.UI_Shop_Recharge, self.InitData) if GameAppInfo.IsChinesePackage() then UIUtils.SetActive(self.txt_Prompt, true) UIUtils.SetLabelText(self.txt_Prompt, Const_IDS.IDS_Store_IAP_Anti_addiction) else UIUtils.SetActive(self.txt_Prompt, false) end UIUtils.SetActive(self.btn_JPLaw1, false) UIUtils.SetActive(self.btn_JPLaw2, GameAppInfo.IsJapanesePackage()) end function UIRechargeView:InitData() local isShowBigIAP,iapData = self:GetIapData() if isShowBigIAP then self.state_Num:SetState(1) self.RechargeScroll = self.condition_RechargeBig.RechargeScroll self.txt_Prompt = self.condition_RechargeBig.txt_Prompt else self.state_Num:SetState(0) self.RechargeScroll = self.condition_Recharge.RechargeScroll self.txt_Prompt = self.condition_Recharge.txt_Prompt end self.RechargeScroll:ClearCells() for i, v in ipairs(iapData) do self.RechargeScroll:AddData(v, 0) end end --检查是否需要显示大额 IAP(国服、满足一定条件) function UIRechargeView:GetIapData() local iapData = {} local isShowBigIAP = false for i, v in DataSheetManager.IAP:GetEnumerator() do if v.Index < RechargeIndex then --先判断是否按渠道显示 if MDL.Shop.IsShowIapConfigByChannel(v) then --在判断是否大额显示 if v.ShowCondition > 0 and GameAppInfo.IsChinesePackage() and (UNITY_IOS or UNITY_ANDROID or UNITY_EDITOR) then if MDL.Unlock.IsTriggerIdComplete(v.ShowCondition) then isShowBigIAP = true table.insert(iapData,v) end else table.insert(iapData,v) end end end end return isShowBigIAP,iapData end function UIRechargeView:OnCellInit(scrollRect, index, cellTable, data) --Item_Condition_Table这个配置是个数组,其意义是每一项都是充值赠送的道具 --其中每一项的FirstPresent字段表示首充赠送,CommonPresent表示非首充所赠,每一项只能表示一个类型的道具 --原来的逻辑只取了第一项数据去判断,明显不符合配置的意义 --应该遍历整个数组,收集首充和非首充的赠品显示,但是目前由于UI上只能显示一种赠品,因此遍历逻辑定位到第一个目标就跳出了 local isFirstPay = MDL.Shop.IsFirstPay(data.Index) local itemArray = data.Item_Condition_Table local targetNum = 0 if isFirstPay then local isReset = CTL.Currency.FirstPayIsReset() for _, v in ipairs(itemArray) do if v.FirstPresent > 0 then targetNum = v.FirstPresent if isReset then UTL.Item.MoneyIcon(cellTable.icon, v.AfterResetFirstItemID) else UTL.Item.MoneyIcon(cellTable.icon, v.PresentCoinItemID) end break end end UIUtils.SetLabelText(cellTable.txt_Info, Const_IDS.IDS_Store_IAP_First) else for _, v in ipairs(itemArray) do if v.CommonPresent > 0 then targetNum = v.CommonPresent UTL.Item.MoneyIcon(cellTable.icon, v.PresentCoinItemID2) break end end UIUtils.SetLabelText(cellTable.txt_Info, Const_IDS.IDS_Store_IAP_Common) end UIUtils.SetActive(cellTable.bg2, targetNum > 0) UIUtils.SetActive(cellTable.group_Info, targetNum > 0) cellTable.txt_InfoNum.text = targetNum cellTable.txt_Jade.text = itemArray[1].GetAmount --这里有个潜规则,充值所获的龙玉写死在第一列的获取中 --cellTable.txt_Money RMB价格 cellTable.txt_Money.text = MDL.Currency.GetFullyIAPPrice(data.Index) UIUtils.SetImageByAssetBundle(cellTable.img, data.Icon) end function UIRechargeView:OnCellClicked(scrollRect, index, cellTable, target, data) if MDL.Currency.IsNotShowRechargeButton() then return end MDL.Currency.GetOrderIDReq(data.Index, MDL.Currency.PayType.Common) end function UIRechargeView:OnButtonClicked(comp) if comp == self.btn_JPLaw1 then SDKUtil.LoadFundSettlement() self:StartRepeatFunc(self.ResetTimer, 3, 1) elseif comp == self.btn_JPLaw2 then SDKUtil.LoadCommodityTrading() self:StartRepeatFunc(self.ResetTimer, 3, 1) elseif comp == self.btn_AccumulatedCharge then EventSystem.Dispatch(EventID.UI_PayMall_OpenSpecificView, {tabId = CTL.PayMall.ShopTabType.TotalTopUp}) end end --日本异步接口只等待3秒 否则判定为网络差 弹失败tips function UIRechargeView:ResetTimer() CTL.Setting.SetJPPanelState(false) end return UIRechargeView