/** @format */ import {BaseUI} from './BaseUI' import {Data, Mgr} from '../GameControl' import {ccUtils} from '../utils/ccUtils' import {list, node, observer, render} from '../mobx/observer' import {msgCmd} from '../proto/msg_cmd' import {advGiftBuy, shopBuy, shopBuyRsp, shopDataRsp, shopNotify, speedUpBuy} from '../proto/game' import List from '../uiutils/List' import {GiftConfig, IGiftConfig} from '../config/GiftConfig' import {IItemshopConfig, ItemshopConfig} from '../config/ItemshopConfig' import {IIntegralshopConfig, IntegralshopConfig} from '../config/IntegralshopConfig' import { AD_ID, DIS_ID, EVENT, GOODS, Language, LANGUAGE_TYPE, LIMIT_TYPE, LOCAL, MOD, QUALITY_COLOR, SHOP_TYPE, SPEND_TYPE, } from '../enums/Enum' import {GoodsConfig} from '../config/GoodsConfig' import {i18nLabel} from '../uiutils/i18nLabel' import {UI} from '../enums/UI' import {idNum} from '../proto/typedef' import {DataConfig} from '../config/DataConfig' import {IRewardNty, IShopItemPop} from '../interface/UIInterface' import {CenterGridCell} from '../cell/CenterGridCell' import {SOUND} from '../enums/Sound' import {AdvertisementConfig} from '../config/AdvertisementConfig' const {ccclass, property} = cc._decorator interface shopItem { buyNum: number spend: SPEND_TYPE price: number currency: number remain: number cfg: IGiftConfig | IItemshopConfig | IIntegralshopConfig } interface shopTipData { list: shopItem[] name: string redActive: boolean } enum SHOP_POINTS_TYPE { relic = 120, //遗迹 } @ccclass @observer export class ShopUI extends BaseUI { @list('bottom1/daily_list') dailyList: List @list('bottom1/gift_list') giftList: List @list('bottom1/relic_list') relicList: List @node('bottom1') bottomBox: cc.Node @node('bottom1/resource_list') resourceList: cc.Node @node('bottom1/resource_list/shop_bottom_4') resourceItem: cc.Node @node('tipToggle_box') tipToggleBox: cc.Node @node('tipToggle_box/toggle_item') tipToggleItem: cc.Node @node('toggle_box') toggleBox: cc.Node @node('block1') refreshBox: cc.Node @node('toggle_box/tog_relic') togRelic: cc.Node //遗迹商店选项 selStoreType: number selModType: number = MOD.dailyGift //没有默认值 给一个默认值、 如果onShow args为空就会为空 allListName: string[] = ['gift_list', 'daily_list', 'resource_list', 'relic_list'] giftAllData: Map = new Map() dailyAllData: shopItem[] = [] resourceAllData: shopItem[] = [] relicAllData: shopItem[] = [] //免费广告节点 freeNodeMap: Map = new Map() checkMod: MOD | null adIDs: Map = new Map() onShow(args: MOD, fromUI: number) { this.checkMod = args Mgr.net.add(msgCmd.cmd_shop_data_rsp, this, this.onShopRsp) Mgr.net.add(msgCmd.cmd_shop_buy_rsp, this, this.onBuyRsp) Mgr.net.add(msgCmd.cmd_shop_notify, this, this.onNotifyRsp) Mgr.net.send(msgCmd.cmd_shop_data) //设置toggles this.initToggles() //广告位ID Object.values(AdvertisementConfig).forEach(v => { if (v.parameter) { this.adIDs.set(v.parameter, v.ID) } }) Mgr.event.add(EVENT.goodsChangeSync, this, this.initUI) } onHide(): any { Mgr.event.removeAll(this) } initToggles(selStore?: SHOP_TYPE) { this.selStoreType = selStore == null ? SHOP_TYPE.gift : selStore this.checkStore() if (this.selModType == MOD.dailyGift) { //对底部页签初始化 ccUtils.setTogglesChecked(0, this.tipToggleBox) } ccUtils.setTogglesChecked(this.selStoreType - 1, this.toggleBox) Mgr.ui.show( UI.CurrencyUI, this.selStoreType == SHOP_TYPE.relic ? [GOODS.relicCoin] : [GOODS.coin, GOODS.diamond], ) } getAdID(id) { let adID = this.adIDs.get(id) if (!adID) cc.error('没有找到广告ID') return adID } //红点系统 redActiveControl() { let redActive: boolean[] = [false, false, false, false] let freeGift = [] let freeDaily = [] //检测礼包商店红点状态 //确定左侧大类页签红点状态 this.giftAllData.forEach(value => { let list = value.list let modRed = [] for (let i = 0; i < list.length; i++) { if (list[i].spend == SPEND_TYPE.adFree) { let inTime = Mgr.global.getAdInfo(this.getAdID(list[i].cfg.ID)).inTime modRed.push(list[i].remain > 0 && !inTime) } } //一旦对应mod(页签)有红点则返回真 value.redActive = modRed.includes(true) freeGift.push(value.redActive) }) //礼品商店一旦有免费可购买商品则返回真 redActive[SHOP_TYPE.gift - 1] = freeGift.includes(true) //确定每日商店红点状态 let dailyArr = this.dailyAllData for (let i = 0; i < dailyArr.length; i++) { if (dailyArr[i].spend == SPEND_TYPE.adFree) { let inTime = Mgr.global.getAdInfo(this.getAdID(dailyArr[i].cfg.ID)).inTime freeDaily.push(dailyArr[i].remain > 0 && !inTime) } } //每日商店一旦有买免费可购买商品返回真 redActive[SHOP_TYPE.daily - 1] = freeDaily.includes(true) //显示左侧toggle红点状态 let children = this.toggleBox.children for (let i = 0; i < children.length; i++) { cc.find('red_dots', children[i]).active = redActive[i] } Data.main.modRedMap.set( UI.ShopUI, redActive.some(v => v), ) } //动态根据此时选择商店类型显示列表 checkStore() { for (let i = 0; i < this.allListName.length; i++) { cc.find(this.allListName[i], this.bottomBox).active = i + 1 == this.selStoreType } } //动态根据此时mod返回数据 checkModData(index): shopItem { let allData = [this.dailyAllData, this.resourceAllData, this.relicAllData] return this.selStoreType == SHOP_TYPE.gift ? this.giftAllData.get(this.selModType).list[index] : allData[this.selStoreType - 2][index] } //确定购买方式 checkPurMethod(node: cc.Node, item: shopItem, button: cc.Node) { let free = cc.find('free', node) let recharge = cc.find('recharge', node) let resource = cc.find('resource', node) free.active = item.spend == SPEND_TYPE.adFree recharge.active = item.spend == SPEND_TYPE.recharge resource.active = item.spend == SPEND_TYPE.resource if (free.active) { let label = this.selStoreType == SHOP_TYPE.gift ? LANGUAGE_TYPE.free : `${Mgr.i18n.getLabel(LANGUAGE_TYPE.free)}${item.remain}/${item.cfg.num}` ccUtils.setLabel(label, free, 'lb') this.storeAdData(node, free) } if (recharge.active) { cc.find('time', node).active = false ccUtils.setLabel(Mgr.i18n.getMoneyLabel(item.price), recharge, 'lb') cc.find('lb', recharge).active = item.remain > 0 ccUtils.setSpriteGray(item.remain <= 0, button) ccUtils.setBtnInteract(item.remain > 0, button) } if (resource.active) { let payIconUrl = `Public/goods/${GoodsConfig[item.currency].icon}` cc.find('time', node).active = false let isEnable = Data.user.goods.get(item.currency) >= item.price ccUtils.setLabel(item.price.toString(), resource, 'lb') let color = this.selStoreType == SHOP_TYPE.gift ? '#000D20' : '#FFFFFF' ccUtils.setColor(isEnable ? color : '#FF2525', resource, 'lb') this.loadTexImg(payIconUrl, resource, 'icon') cc.find('icon', resource).active = item.remain > 0 cc.find('lb', resource).active = item.remain > 0 ccUtils.setSpriteGray(isEnable && item.remain <= 0, button) ccUtils.setBtnInteract(isEnable && item.remain > 0, button) } cc.find('sold', node).active = item.remain <= 0 } //存入存在观看广告的节点数据 storeAdData(node: cc.Node, free: cc.Node) { let array = this.freeNodeMap.get(this.selModType) || [] let index = node['index'] if (!array.includes(node)) { array.push(node) } let isShopGift = this.selStoreType == SHOP_TYPE.gift let item: shopItem = this.checkModData(index) let inTime = Mgr.global.getAdInfo(this.getAdID(item.cfg.ID)).inTime let button = isShopGift ? cc.find('btn_blue', node) : node let interact = item.remain > 0 && !inTime ccUtils.setSpriteGray(isShopGift && !interact, button) ccUtils.setSpriteGray(!interact, free, 'icon') //显示点击状态 ccUtils.setBtnInteract(interact, button) this.freeNodeMap.set(this.selModType, array) cc.find('icon', free).active = interact cc.find('lb', free).active = interact cc.find('time', node).active = inTime cc.find('red_dots', node).active = interact //刷新 if (inTime) { this.showUpdateRemain() } } //初始化底部页签 initTipItem(type: number, len: number) { this.tipToggleBox.active = len > 0 if (len == 0) return ccUtils.instantChildren(this.tipToggleItem, len, this.tipToggleBox) let data: number[] = [], map = null switch (type) { case SHOP_TYPE.gift: data = [MOD.dailyGift, MOD.weekGift, MOD.noviceGift] map = this.giftAllData break default: return } let children = this.tipToggleBox.children, index = 0 map.forEach(value => { ccUtils.setLabel(value.name, children[index], 'paging3/label') ccUtils.setLabel(value.name, children[index], 'paging4/label') children[index]['mod'] = data[index] cc.find('red_dots', children[index]).active = value.redActive index += 1 }) //置换Layout顺序 l->r this.tipToggleBox.getComponent(cc.Layout).horizontalDirection = cc.Layout.HorizontalDirection.LEFT_TO_RIGHT } initUI() { //当args不为空时,进入对应商店 if (this.checkMod != null) { let selStore: SHOP_TYPE = SHOP_TYPE.gift switch (this.checkMod) { case MOD.giftStore: selStore = SHOP_TYPE.gift this.selModType = MOD.giftStore break case MOD.dailyGift: selStore = SHOP_TYPE.gift this.selModType = MOD.dailyGift break case MOD.weekGift: selStore = SHOP_TYPE.gift this.selModType = MOD.weekGift break case MOD.noviceGift: selStore = SHOP_TYPE.gift this.selModType = MOD.noviceGift break case MOD.dailyStore: selStore = SHOP_TYPE.daily break case MOD.resourceStore: selStore = SHOP_TYPE.resource break case MOD.relicStore: selStore = SHOP_TYPE.relic break } this.initToggles(selStore) this.checkMod = null } switch (this.selStoreType) { //初始化礼包商店 case SHOP_TYPE.gift: this.initTipItem(SHOP_TYPE.gift, this.giftAllData.size) let selType = this.giftAllData.get(this.selModType) if (!selType) { selType = this.giftAllData.get(MOD.dailyGift) this.selModType = MOD.dailyGift } this.giftList.numItems = selType.list.length if (this.selModType != MOD.noviceGift) this.handleGetAwardRemainTime() break //初始化日常商店 case SHOP_TYPE.daily: this.initTipItem(SHOP_TYPE.daily, 0) this.handleGetAwardRemainTime() this.dailyList.numItems = this.dailyAllData.length this.selModType = MOD.dailyStore break //初始化资源商店 case SHOP_TYPE.resource: this.initTipItem(SHOP_TYPE.resource, 0) ccUtils.instantChildren(this.resourceItem, this.resourceAllData.length, this.resourceList) this.initResourceItem() break //初始化积分商店 case SHOP_TYPE.relic: this.initTipItem(SHOP_TYPE.relic, 0) this.relicList.numItems = this.relicAllData.length break } //检查资源商店是否当前开启 this.refreshBox.active = this.selModType == MOD.dailyGift || this.selModType == MOD.weekGift || this.selModType == MOD.dailyStore } //初始化礼包页签内容 initGiftItem(node: cc.Node, index: number) { node['index'] = index let data = this.giftAllData.get(this.selModType).list[index] let cfg = data.cfg as IGiftConfig //初始化上方购买次数 let num = data.remain + data.buyNum let purchaseTimeInfo = this.selModType == MOD.dailyGift ? LANGUAGE_TYPE.dailyPurchase : this.selModType == MOD.weekGift ? LANGUAGE_TYPE.weeklyPurchase : LANGUAGE_TYPE.novicePurchase cc.find('prop_info', node) .getComponent(i18nLabel) .init(data.remain == 0 ? LANGUAGE_TYPE.noBuyTime : LANGUAGE_TYPE.readyBuyTime, [ Mgr.i18n.getLabel(purchaseTimeInfo), data.remain.toString(), num.toString(), ]) //初始化商品数量 let library = Mgr.goods.getIdNumByCfgArr(cfg.library) let iconBox = cc.find('icon_box', node) let centerGrid = iconBox.getComponent(CenterGridCell) let goods = centerGrid.init(library.length) Mgr.goods.initGoods( library, goods.map(goodsParent => cc.find('goods', goodsParent)), this, ) //确定购买方式 let button = data.spend == SPEND_TYPE.adFree ? cc.find('btn_blue', node) : cc.find('btn_yellow', node) cc.find('btn_blue', node).active = data.spend == SPEND_TYPE.adFree cc.find('btn_yellow', node).active = !(data.spend == SPEND_TYPE.adFree) //确认购买方式 adFree: 广告/recharge: 付费/resource: 资源 this.checkPurMethod(node, data, button) //红点显示 if (data.spend == SPEND_TYPE.recharge || data.spend == SPEND_TYPE.resource) { cc.find('red_dots', node).active = false } } //初始化日常商店 initDailyItem(node: cc.Node, index: number) { node['index'] = index let data = this.dailyAllData[index], cfg = data.cfg as IItemshopConfig, goodsInfo = Mgr.goods.getGoodShowInfo(cfg.item[0]) //显示商品名称 ccUtils.setLabel(goodsInfo.name, node, 'prop_lb') //根据品质显示颜色 ccUtils.setColor(QUALITY_COLOR[goodsInfo.quality], node, 'prop_lb') //显示商品图标 Mgr.goods.initGoods([{id: cfg.item[0], num: cfg.item[1]}], [cc.find('good_item/goods', node)], this) //显示折扣 let discountNode = cc.find('discount_bottom', node) discountNode.active = data.price > 0 if (discountNode.active) { if (Mgr.storage.getString(LOCAL.selectLanguage) == Language.en) { ccUtils.setLabel(cfg.discount * 10 + '%', discountNode, 'num_lb') } else { ccUtils.setLabel(cfg.discount.toString(), discountNode, 'num_lb') } } //显示block中购买次数 this.checkPurMethod(node, data, node) } //初始化资源商店 initResourceItem() { let children = this.resourceList.children for (let index = 0; index < children.length; index++) { let block = cc.find('block1', children[index]), discount_bottom = cc.find('discount_bottom', children[index]), button = cc.find('btn_yellow', children[index]), cfg = this.resourceAllData[index].cfg as IGiftConfig, buyNum = this.resourceAllData[index].buyNum, library = Mgr.goods.getIdNumByCfgArr(cfg.library) children[index]['index'] = index //填入获得钻石 ccUtils.setLabel(library[0].num.toString(), block, 'label') //是否显示首充双倍 discount_bottom.active = buyNum == 0 if (discount_bottom.active) { ccUtils.setLabel(`+${library[0].num}`, discount_bottom, 'charge_lb') } //初始化钻石图标 this.loadTexImg(`StoreUI/diamond_${cfg.parameter[0]}`, children[index], 'icon') //显示购买金额 ccUtils.setLabel(Mgr.i18n.getMoneyLabel(cfg.spend), button, 'lb') } } initPointsItem(node: cc.Node, index: number) { let data = this.relicAllData[index] let cfg = data.cfg as IIntegralshopConfig, goodsInfo = Mgr.goods.getGoodShowInfo(cfg.item[0]), limitNode = cc.find('prop_info', node) node['index'] = index //显示商品名称 ccUtils.setLabel(goodsInfo.name, node, 'prop_lb') //根据品质显示颜色 ccUtils.setColor(QUALITY_COLOR[goodsInfo.quality], node, 'prop_lb') //显示商品图标 Mgr.goods.initGoods([{id: cfg.item[0], num: cfg.item[1]}], [cc.find('good_item/goods', node)], this) limitNode.active = cfg.limit == LIMIT_TYPE.daily || cfg.limit == LIMIT_TYPE.weekly if (limitNode.active) { //显示限购类型 let purchaseTimeInfo = cfg.limit == LIMIT_TYPE.daily ? LANGUAGE_TYPE.dailyPurchase : LANGUAGE_TYPE.weeklyPurchase limitNode .getComponent(i18nLabel) .init(data.remain == 0 ? LANGUAGE_TYPE.noBuyTime : LANGUAGE_TYPE.readyBuyTime, [ Mgr.i18n.getLabel(purchaseTimeInfo), data.remain.toString(), cfg.num.toString(), ]) } this.checkPurMethod(node, data, node) } //UI或者其他函数======================================= //网络事件======================================= onShopRsp(data: shopDataRsp) { //数据初始化 this.giftAllData.clear() this.dailyAllData = [] this.resourceAllData = [] this.relicAllData = [] let allBuyData: Map = new Map() //填入购买记录 for (let i = SHOP_TYPE.gift; i <= SHOP_TYPE.relic; i++) { allBuyData.set(i, data.list[i - 1].list) } //初始化礼品商店&&资源商店 //查看新手商店用品是否卖尽 let giftBuy = allBuyData.get(SHOP_TYPE.gift) let resourceBuy = allBuyData.get(SHOP_TYPE.resource) let allNovice: boolean[] = [] let limit = 1 let name = '' for (let id in GiftConfig) { let list: shopItem[] = [], type: MOD = MOD.dailyGift, hasBuy = 0 switch (GiftConfig[id].type) { case MOD.dailyGift: type = MOD.dailyGift limit = GiftConfig[id].daylimit hasBuy = giftBuy.find(value => value.id == parseInt(id))?.num || 0 name = Mgr.i18n.getLabel(LANGUAGE_TYPE.dailyGift) break case MOD.weekGift: type = MOD.weekGift limit = GiftConfig[id].weeklimit hasBuy = giftBuy.find(value => value.id == parseInt(id))?.num || 0 name = Mgr.i18n.getLabel(LANGUAGE_TYPE.weeklyGift) break case MOD.noviceGift: type = MOD.noviceGift hasBuy = giftBuy.find(value => value.id == parseInt(id))?.num || 0 allNovice.push(limit - hasBuy > 0) name = Mgr.i18n.getLabel(LANGUAGE_TYPE.noviceGift) break case MOD.resourceStore: type = MOD.resourceStore hasBuy = resourceBuy.find(value => value.id == parseInt(id))?.num || 0 limit = Number.POSITIVE_INFINITY break default: continue } let cfg = GiftConfig[id] //初始化存入对象 let item: shopItem = { buyNum: hasBuy, cfg: cfg, spend: cfg.spendtype, price: cfg.spendtype == SPEND_TYPE.resource ? cfg.num : cfg.spend, currency: cfg.spend, remain: limit - hasBuy, } //若是资源商店物品,则数据存入资源商店,否则为礼包商店 if (type == MOD.resourceStore) { this.resourceAllData.push(item) } else { list = this.giftAllData.get(type)?.list || [] list.push(item) this.giftAllData.set(type, {redActive: false, list: list, name: name}) } } //检查新手商店物品是否售尽 if (allNovice.every(item => item == false)) { this.giftAllData.delete(MOD.noviceGift) } //对礼包商店商品排序 this.giftAllData.forEach((value: shopTipData) => { value.list.sort((a: shopItem, b: shopItem) => a.cfg.sort - b.cfg.sort) }) //对资源商店进行排序 this.resourceAllData.sort((a: shopItem, b: shopItem) => a.cfg.sort - b.cfg.sort) //初始化每日商店 let dailyBuy = allBuyData.get(SHOP_TYPE.daily) for (let index = 0; index < dailyBuy.length; index++) { let id = dailyBuy[index].id, hasBuy = dailyBuy.find(value => value.id == id)?.num || 0, cfg = ItemshopConfig[id] let item: shopItem = { buyNum: hasBuy, cfg: cfg, spend: cfg.price[0] == 0 ? SPEND_TYPE.adFree : SPEND_TYPE.resource, price: cfg.price[0] == 0 ? 0 : cfg.price[1], currency: cfg.price[0] == 0 ? 0 : cfg.price[0], remain: cfg.num - hasBuy, } this.dailyAllData.push(item) } //对每日商店商品进行排序 this.dailyAllData.sort((a: shopItem, b: shopItem) => { return a.cfg.sort - b.cfg.sort }) //初始化遗迹商店 let relicBuy = allBuyData.get(SHOP_TYPE.relic) for (let id in IntegralshopConfig) { if (IntegralshopConfig[id].module == SHOP_POINTS_TYPE.relic) { let hasBuy = relicBuy.find(value => value.id == parseInt(id))?.num || 0 let cfg = IntegralshopConfig[id] let item: shopItem = { buyNum: hasBuy, cfg: cfg, spend: cfg.price[0] == 0 ? SPEND_TYPE.adFree : SPEND_TYPE.resource, price: cfg.price[0] == 0 ? 0 : cfg.price[1], currency: cfg.price[0] == 0 ? 0 : cfg.price[0], remain: cfg.limit == LIMIT_TYPE.free ? Infinity : cfg.num - hasBuy, } this.relicAllData.push(item) } } //对遗迹商店进行排序 this.resourceAllData.sort((a: shopItem, b: shopItem) => a.cfg.sort - b.cfg.sort) this.redActiveControl() this.initUI() } onBuyRsp(data: shopBuyRsp) { this.redActiveControl() this.initUI() } onNotifyRsp(data: shopNotify) { let list = [this.dailyAllData, this.resourceAllData, this.relicAllData] let array = this.selStoreType == SHOP_TYPE.gift ? this.giftAllData.get(this.selModType)?.list : list[this.selStoreType - 2] //对数据进行更新 for (let i = 0; i < array.length; i++) { if (array[i].cfg.ID == data.id) { array[i].buyNum += data.num array[i].remain -= data.num } //当新手礼包购尽时,直接跳转至每日礼包(daily gift) if (this.selModType == MOD.noviceGift) { //新手商店是否全部购买 if (array.every(item => item.remain == 0)) { this.giftAllData.delete(MOD.noviceGift) this.selModType = MOD.dailyGift //对底部页签初始化 ccUtils.setTogglesChecked(0, this.tipToggleBox) } } } this.initUI() } //触发事件======================================= @render showUpdateRemain() { let time = Data.main.serverTime, list = this.freeNodeMap.get(this.selModType) || [] //查看节点是否挂载再当前MOD上 list.forEach(node => { let data = this.checkModData(node['index']) let info = data.cfg.ID, remain = data.remain, ads = Mgr.global.getAdInfo(this.getAdID(info)), grayInteract = remain <= 0 || ads.inTime, isShopGift = this.selStoreType == SHOP_TYPE.gift cc.find('red_dots', node).active = !grayInteract //显示灰色状态 let free = cc.find('free', node) let button = isShopGift ? cc.find('btn_blue', node) : node ccUtils.setSpriteGray(isShopGift && grayInteract, button) ccUtils.setSpriteGray(grayInteract, free, 'icon') //显示点击状态 ccUtils.setBtnInteract(!grayInteract, button) if (ads.isZero) { this.redActiveControl() this.initUI() } else if (ads.inTime) { //格式化数字 ccUtils.setLabel(ads.min + ':' + ads.sec, node, 'time') } }) } @render //处理剩余时间 handleGetAwardRemainTime() { let time = Data.main.serverTime, endOfDay = this.selModType == MOD.weekGift ? Date.getWeekTime(time, 0) : Date.getDayTime(time), remain = Math.floor(endOfDay - time) < 60 ? 60 : Math.floor(endOfDay - time) if (remain == 0) { Mgr.net.send(msgCmd.cmd_shop_data) } else { ccUtils.setLabel(`${Mgr.i18n.getTimeLabel(remain)}`, this.refreshBox, 'time_info') } } // 点击事件======================================= //左侧总类页签点击 onToggleClick(event, data: string) { Mgr.audio.playSFX(SOUND.toggleClick) this.selStoreType = parseInt(data) this.checkStore() let allShopType = [MOD.dailyGift, MOD.dailyStore, MOD.resourceStore, MOD.relicStore] this.selModType = allShopType[this.selStoreType - 1] //对底部页签初始化 ccUtils.setTogglesChecked(0, this.tipToggleBox) Mgr.ui.show( UI.CurrencyUI, this.selStoreType == SHOP_TYPE.relic ? [GOODS.relicCoin, GOODS.diamond] : [GOODS.coin, GOODS.diamond], ) this.initUI() } //底部页签点击 onTipToggleClick(event) { Mgr.audio.playSFX(SOUND.toggleClick) this.selModType = event.target['mod'] this.initUI() } //商品购买 onGoodsBuy(event) { if (event.currentTarget == event.target) { let index = this.selStoreType == SHOP_TYPE.gift || this.selStoreType == SHOP_TYPE.resource ? event.currentTarget.parent['index'] : event.currentTarget['index'], item = this.checkModData(index) let data: shopBuy = {type: this.selStoreType, id: item.cfg.ID, num: 1} switch (item.spend) { //广告(免费)商品 case SPEND_TYPE.adFree: let value = Data.main.serverTime + DataConfig[DIS_ID.adFreeTime].data3 Mgr.global.storageAdInfo(this.getAdID(item.cfg.ID), value, item.remain - 1) Mgr.platform.playVideoAD(this.getAdID(item.cfg.ID), () => { Mgr.net.send(msgCmd.cmd_shop_buy, data) }) break //礼金商品 case SPEND_TYPE.recharge: Mgr.net.send(msgCmd.cmd_shop_buy, data) break } } } }