import GameModel from "../ts/core/GameModel"; import ItemUtil from "../ts/core/ItemUtil"; import AudioUtil from "../ts/core/AudioUtil"; import SKUIUtil from "../ts/gear_2.3.4/util/SKUIUtil"; import MsgAlert from "../ts/game/msg/MsgAlert"; import FGHUD from "../ts/gear_2.3.4/fgui/FGHUD"; import RechargeReward from "../ts/rechargeReward/RechargeReward"; let CPubFunction = require('./PubFunction'); let CItemMgr = require('./ItemMgr').g_ctCItemMgr; let EItemType = require('./ItemMgr').EItemType; let CItemType = require('./ItemMgr').CItemType; let CMainPlayerInfo = require('./MainPlayerInfo'); cc.Class({ extends: cc.Component, properties: { WXcontent: cc.Node, OneWxAccount: cc.Prefab, //多寶閣 malltip: cc.Node, mallmessge: cc.Node, mallname: cc.Label, mallmessgeuse: cc.Label, mallnum: cc.Label, mallsprices: cc.Label, shop_charge_item: cc.Prefab, btnGoodsInfo: cc.Prefab, btnShangJia: cc.Prefab, btnItemType: cc.Prefab, btnEquipGoodsInfo: cc.Prefab, btnMallInfo: cc.Prefab, BuyUI: cc.Prefab, NumPad: cc.Prefab, ShangJiaUI: cc.Prefab, btnItemName: cc.Prefab, selectedIndex: cc.Integer = 0, current: cc.Integer = 0 }, onLoad() { this.m_nMaxGoodsCnt = 8; this.vecItemName = []; this.vecTmpGoods = []; this.vecItemType = []; this.type = 0; this.freshList = {}; this.mallList = {}; this.dayList = {}; var cz1 = cc.find("tabChongZhi/RewardButton", this.node) var cz2 = cc.find("tabChongZhi/RewardButton2", this.node) cz1.active = false; cz2.active = false; return; if (GameModel.player.hideIconList.hasOwnProperty("au")) { if (GameModel.player.hideIconList["au"] == 1) { cz1.x = -240 cz1.active = true cz2.active = false } if (GameModel.player.hideIconList["au"] == 2) { cz2.x = -240 cz2.active = true cz1.active = false } if (GameModel.player.hideIconList["au"] == 0) { cz2.x = -160 cz1.x = -320 cz2.active = true cz1.active = true } } else { cz2.x = -160 cz1.x = -320 cz2.active = true cz1.active = true } }, start() { this.vecTagTeamBtn = [cc.find('btnBaiTan', this.node), cc.find('btnDuoBaoGe', this.node), cc.find('btnChongZhi', this.node)]; this.vecShopTeamBtn = [cc.find('tabBaiTan/btnBuy', this.node), cc.find('tabBaiTan/btnSell', this.node), cc.find('tabBaiTan/btnGongShiQi', this.node)]; this.vecDuoBaoGeTeamBtn = [cc.find('tabDuoBaoGe/btnFhesh', this.node), cc.find('tabDuoBaoGe/btnMerial', this.node), cc.find('tabDuoBaoGe/btnWeekLimit', this.node), cc.find('tabDuoBaoGe/btnFashion', this.node)]; this.vecTabNode = [cc.find('tabBaiTan', this.node), cc.find('tabDuoBaoGe', this.node), cc.find('tabChongZhi', this.node)]; GameModel.send('c2s_ask_roles_goods', { nRoleID: GameModel.player.roleid }); GameModel.send('c2s_get_bagitem', { roleid: GameModel.player.roleid }); cc.find('tabDuoBaoGe/nodSell/picFrame/MallMessage/MallNum/btnPad', this.node).getComponent(cc.Button).clickEvents.push(CPubFunction.CreateEventHandler(this.node, "ShopUI", "OpenNumPad", 0)); this.ShopUI_Init(); this.SetMoneyInfo(); if (this.selectedIndex == 0) { this.OnTabBaiTan(); } else if (this.selectedIndex == 1) { this.OnTabDuoBaoGe(); } else if (this.selectedIndex == 2) { this.OnTabChongZhi(); } }, Close() { AudioUtil.playCloseAudio(); this.node.destroy(); }, SetMoneyInfo() { // cc.find('layMoney/yinliang/ui_common_icon_yinliang/yinliangLabel', this.node).getComponent(cc.Label).string = GameModel.player.gameData.money; // cc.find('layMoney/xianyu/ui_common_icon_xianyu/xianyuLabel', this.node).getComponent(cc.Label).string = GameModel.player.gameData.jade; let topnode = cc.find('topInfo', this.node); let toplogic = topnode.getComponent('TopInfo'); toplogic.updateGameMoney(); }, ShopUI_Init() { cc.find('btnClose', this.node).getComponent(cc.Button).clickEvents.push(CPubFunction.CreateEventHandler(this.node, "ShopUI", "Close", 0)); cc.find('btnBaiTan', this.node).getComponent(cc.Button).clickEvents.push(CPubFunction.CreateEventHandler(this.node, "ShopUI", "OnTabBaiTan", 0)); cc.find('btnDuoBaoGe', this.node).getComponent(cc.Button).clickEvents.push(CPubFunction.CreateEventHandler(this.node, "ShopUI", "OnTabDuoBaoGe", 0)); cc.find('btnChongZhi', this.node).getComponent(cc.Button).clickEvents.push(CPubFunction.CreateEventHandler(this.node, "ShopUI", "OnTabChongZhi", 0)); cc.find('tabBaiTan/btnBuy', this.node).getComponent(cc.Button).clickEvents.push(CPubFunction.CreateEventHandler(this.node, "ShopUI", "InitBuyUI", 0)); cc.find('tabBaiTan/btnSell', this.node).getComponent(cc.Button).clickEvents.push(CPubFunction.CreateEventHandler(this.node, "ShopUI", "InitSellUI", 0)); cc.find('tabBaiTan/btnGongShiQi', this.node).getComponent(cc.Button).clickEvents.push(CPubFunction.CreateEventHandler(this.node, "ShopUI", "InitBuyUI", 2)); cc.find('tabDuoBaoGe/btnFhesh', this.node).getComponent(cc.Button).clickEvents.push(CPubFunction.CreateEventHandler(this.node, "ShopUI", "DbgSelect", 0)); cc.find('tabDuoBaoGe/btnMerial', this.node).getComponent(cc.Button).clickEvents.push(CPubFunction.CreateEventHandler(this.node, "ShopUI", "DbgSelect", 1)); cc.find('tabDuoBaoGe/btnWeekLimit', this.node).getComponent(cc.Button).clickEvents.push(CPubFunction.CreateEventHandler(this.node, "ShopUI", "DbgSelect", 2)); cc.find('tabDuoBaoGe/btnFashion', this.node).getComponent(cc.Button).clickEvents.push(CPubFunction.CreateEventHandler(this.node, "ShopUI", "DbgSelect", 3)); this.InitBuyUI(0, 0); }, SetUITitle(strName) { cc.find('picBg/Name/Lable', this.node).getComponent(cc.Label).string = strName; }, OnTabBaiTan() { AudioUtil.playFenyeAudio(); CPubFunction.ChangeTeamNodeState(this.vecTabNode, 0); CPubFunction.ChangeTeamButtonState(this.vecTagTeamBtn, 'Common/ui_common', 'ui_common_btn_tab1', 'ui_common_btn_tab2', 0); this.SetUITitle('擺 攤'); }, // 點擊多寶閣 OnTabDuoBaoGe() { cc.find("tabDuoBaoGe", this.node).active = true; for (let button of this.vecDuoBaoGeTeamBtn) { button.active = true; } AudioUtil.playFenyeAudio(); CPubFunction.ChangeTeamNodeState(this.vecTabNode, 1); CPubFunction.ChangeTeamButtonState(this.vecTagTeamBtn, 'Common/ui_common', 'ui_common_btn_tab1', 'ui_common_btn_tab2', 1); GameModel.send('c2s_get_mall', { roleid: GameModel.player.roleid }); this.malltip.active = true; this.mallmessge.active = false; this.SetUITitle('多寶閣'); CPubFunction.ChangeTeamButtonState(this.vecDuoBaoGeTeamBtn, 'Common/ui_common', 'ui_common_btn_tab_subheading0', 'ui_common_btn_tab_subheading1', this.type); this.refreshMall(); }, OnTabChongZhi() { AudioUtil.playFenyeAudio(); this._record_num = 0; this.xnum = 0; this.ynum = 0; this.WXcontent.destroyAllChildren(); CPubFunction.ChangeTeamNodeState(this.vecTabNode, 2); CPubFunction.ChangeTeamButtonState(this.vecTagTeamBtn, 'Common/ui_common', 'ui_common_btn_tab1', 'ui_common_btn_tab2', 2); let charge_list = GameModel.conf_charge; for (let i = 1; charge_list[i]; ++i) { this.addChargeGoodsItem(charge_list[i]); } this.SetUITitle('充 值'); }, /* * 添加充值購買物品 */ addChargeGoodsItem(data) { let node = cc.instantiate(this.shop_charge_item); node.parent = this.WXcontent; if (data) { node.getComponent('ShopChargeItem').init(data); } else { node.getComponent('ShopChargeItem').showEditbox(); } }, //添加每個客服的微信號信息 addWXInfo(element) { let infonode = cc.instantiate(this.OneWxAccount); let infologic = infonode.getComponent('WXInfo'); infologic.setInfo(element.account); infonode.parent = this.WXcontent; //infonode.setScale(cc.v2(0.8, 0.8)); infonode.x = 0; infonode.y = 0; let tx = 620 - this.ynum * (infonode.width + 50); let ty = -100 - this.xnum * (infonode.height + 30); let t = 0.1 * (1 + this._record_num); let act1 = cc.moveTo(t, cc.v2(tx, ty)); this._record_num++; var act2 = cc.fadeIn(t); infonode.runAction(act1); infonode.runAction(act2); }, SetGoodsInfo(goGoods, stGoodsInfo) { let stConfigInfo = ItemUtil.getItemData(stGoodsInfo.nConfigID); cc.find('nodItemInfo/Icon', goGoods).getComponent(cc.Sprite).spriteFrame = ItemUtil.getItemIcon(stConfigInfo.icon); cc.find('nodItemInfo/txLap', goGoods).getComponent(cc.Label).string = stGoodsInfo.nCnt; cc.find('labName', goGoods).getComponent(cc.Label).string = stConfigInfo.name; //zzzErr time(null)-nTime cc.find('picText/Label', goGoods).getComponent(cc.Label).string = stGoodsInfo.nPrice; cc.find('labTime', goGoods).getComponent(cc.Label).string = Math.max(Math.floor((stGoodsInfo.nTime + 86400 - CPubFunction.GetTime()) / 3600), 0) + 'H'; }, // 設置物品單元格顯示 SetMallInfo(goGoods, stGoodsInfo) { console.log("stConfigInfo = ", stConfigInfo) let stConfigInfo = ItemUtil.getItemData(stGoodsInfo.itemid); cc.find('nodItemInfo/Icon', goGoods).getComponent(cc.Sprite).spriteFrame = ItemUtil.getItemIcon(stConfigInfo.icon); // cc.find('nodItemInfo/txLap', goGoods).getComponent(cc.Label).string = stGoodsInfo.nCnt; cc.find('labName', goGoods).getComponent(cc.Label).string = stConfigInfo.name; //zzzErr time(null)-nTime cc.find('picText/Label', goGoods).getComponent(cc.Label).string = stGoodsInfo.price; let limitNode = cc.find("limitTip", goGoods); if (limitNode) { let limitTip = limitNode.getComponent(cc.Label); if (this.type == 2) { limitTip.string = `${stGoodsInfo.count}/${stGoodsInfo.time}`; limitNode.active = true; } else { limitNode.active = false; } } // cc.find('itemid', goGoods).getComponent(cc.Label).string = stConfigInfo.itemid; // cc.find('labTime', goGoods).getComponent(cc.Label).string = Math.max(Math.floor((stGoodsInfo.nTime + 86400 - CPubFunction.GetTime()) / 3600), 0) + 'H'; }, HideAll() { cc.find('tabBaiTan/nodBuy', this.node).active = false; cc.find('tabBaiTan/nodSell', this.node).active = false; SKUIUtil.destroyList(this.vecTmpGoods); SKUIUtil.destroyList(this.vecItemType); }, OnReceiveMyGoods() { if (cc.find('tabBaiTan/nodSell', this.node).active == false) return; this.InitSellUI(); }, InitSellUI() { CPubFunction.ChangeTeamButtonState(this.vecShopTeamBtn, 'Common/ui_common', 'ui_common_btn_tab_subheading0', 'ui_common_btn_tab_subheading1', 1); this.HideAll(); cc.find('tabBaiTan/nodSell', this.node).active = true; cc.find('tabBaiTan/nodSell/picText/Label', this.node).getComponent(cc.Label).string = `我的攤位(${CMainPlayerInfo.vecMyGoods.length}/${this.m_nMaxGoodsCnt})`; let contentGoods = cc.find('tabBaiTan/nodSell/scvGoods/view/content', this.node); let stStart = { nX: 127, nY: -48 }; let i = 0; for (; i < this.m_nMaxGoodsCnt; i++) { let stPos = { nX: stStart.nX + (i % 2) * 245, nY: stStart.nY - Math.floor(i / 2) * 82 }; if (i < CMainPlayerInfo.vecMyGoods.length) { let goGoods = CPubFunction.CreateSubNode(contentGoods, stPos, this.btnGoodsInfo, ''); this.SetGoodsInfo(goGoods, CMainPlayerInfo.vecMyGoods[i]); if (CMainPlayerInfo.vecMyGoods[i].nCnt > 0) { goGoods.getComponent(cc.Button).clickEvents.push(CPubFunction.CreateEventHandler(this.node, "ShopUI", 'OpenShangJiaUI', { nIndex: i, nFlag: 1 })); } else { cc.find('nodItemInfo/picTiXian', goGoods).active = true; goGoods.getComponent(cc.Button).clickEvents.push(CPubFunction.CreateEventHandler(this.node, "ShopUI", 'OnTakeMoney', CMainPlayerInfo.vecMyGoods[i].nID)); } this.vecTmpGoods.push(goGoods); } if (i >= CMainPlayerInfo.vecMyGoods.length && i < this.m_nMaxGoodsCnt) { let goShangJia = CPubFunction.CreateSubNode(contentGoods, stPos, this.btnShangJia, ''); goShangJia.getComponent(cc.Button).clickEvents.push(CPubFunction.CreateEventHandler(this.node, "ShopUI", 'OpenShangJiaUI', { nIndex: i, nFlag: 0 })); cc.find('Label', goShangJia).getComponent(cc.Label).string = '點擊上架物品'; this.vecTmpGoods.push(goShangJia); } } let stPos = { nX: stStart.nX + (i % 2) * 245, nY: stStart.nY - Math.floor(i / 2) * 82 }; let goLock = CPubFunction.CreateSubNode(contentGoods, stPos, this.btnShangJia, ''); goLock.getComponent(cc.Button).clickEvents.push(CPubFunction.CreateEventHandler(this.node, "ShopUI", 'OpenShangJiaUI', { nIndex: i, nFlag: 0 })); SKUIUtil.setSpriteFrame(cc.find('nodBtnAdd/Icon', goLock), 'Common/ui_common', 'ui_common_package_lock'); cc.find('Label', goLock).getComponent(cc.Label).string = '增加攤位'; this.vecTmpGoods.push(goLock); contentGoods.height = Math.max(contentGoods.height, Math.ceil((this.m_nMaxGoodsCnt + 1) / 2) * 80 + 0); }, InitBuyUI(event, param) { cc.find("tabDuoBaoGe", this.node).active = false; CPubFunction.ChangeTeamButtonState(this.vecShopTeamBtn, 'Common/ui_common', 'ui_common_btn_tab_subheading0', 'ui_common_btn_tab_subheading1', param); this.HideAll(); cc.find('tabBaiTan/nodBuy', this.node).active = true; let preButton = this.btnItemType; let contentItemType = cc.find('tabBaiTan/nodBuy/scrItemType/view/content', this.node); let nBtnHight = preButton.data.height; let nDis = 0; let nIndex = -1; let stStart = { nX: 117, nY: -36 }; for (const it in CItemMgr.mapItemKind) { nIndex++; let goItemType = CPubFunction.CreateSubNode(contentItemType, { nX: stStart.nX, nY: stStart.nY - nIndex * (nBtnHight + nDis) }, preButton, it); goItemType.getComponent(cc.Button).clickEvents.push(CPubFunction.CreateEventHandler(this.node, "ShopUI", 'OnClickMainKind', it)); cc.find('Label', goItemType).getComponent(cc.Label).string = CItemMgr.mapItemKind[it]; this.vecItemType.push(goItemType); } contentItemType.height = Math.max(contentItemType.height, nIndex * (nBtnHight + nDis) + 80); this.OnClickMainKind(0, EItemType.Equip); this.malltip.active = false; }, InitEquipGoodsList(vecEquips) { vecEquips = [{ Shape: 100105, EName: '武器(一級神兵)', EIndex: 1, EquipType: 2 }, { Shape: 102605, EName: '項鍊(一級神兵)', EIndex: 2, EquipType: 2 }, { Shape: 102305, EName: '衣服(一級神兵)', EIndex: 3, EquipType: 2 }, { Shape: 102105, EName: '頭盔(一級神兵)', EIndex: 4, EquipType: 2 }, { Shape: 102505, EName: '鞋子(一級神兵)', EIndex: 5, EquipType: 2 }, { Shape: 100604, EName: '武器(一階仙器)', EIndex: 1, EquipType: 3 }, { Shape: 102604, EName: '項鍊(一階仙器)', EIndex: 2, EquipType: 3 }, { Shape: 102304, EName: '衣服(一階仙器)', EIndex: 3, EquipType: 3 }, { Shape: 102204, EName: '頭盔(一階仙器)', EIndex: 4, EquipType: 3 }, { Shape: 102504, EName: '鞋子(一階仙器)', EIndex: 5, EquipType: 3 }, ]; cc.find('tabBaiTan/nodBuy', this.node).active = true; let contentGoods = cc.find('tabBaiTan/nodBuy/scvGoods/view/content', this.node); SKUIUtil.destroyList(this.vecTmpGoods); let stStart = { nX: 125, nY: -48 }; for (let i = 0; i < vecEquips.length; i++) { let stPos = { nX: stStart.nX + (i % 2) * 245, nY: stStart.nY - Math.floor(i / 2) * 82 }; let goGoods = CPubFunction.CreateSubNode(contentGoods, stPos, this.btnEquipGoodsInfo, ''); goGoods.getComponent(cc.Button).clickEvents.push(CPubFunction.CreateEventHandler(this.node, "ShopUI", 'BuyEquip', vecEquips[i])); cc.find('nodItemInfo/Icon', goGoods).getComponent(cc.Sprite).spriteFrame = ItemUtil.getItemIcon(vecEquips[i].icon); cc.find('labName', goGoods).getComponent(cc.Label).string = vecEquips[i].EName; //zzzErr time(null)-nTime this.vecTmpGoods.push(goGoods); } contentGoods.height = Math.max(contentGoods.height, Math.ceil((vecEquips.length + 1) / 2) * 80 + 0); }, BuyEquip(e, equipInfo) { GameModel.send('c2s_creat_equip', { type: equipInfo.EquipType, roleid: GameModel.player.roleid, index: equipInfo.EIndex, is: 1 }); }, InitGoodList(vecGoods) { CPubFunction.ChangeTeamButtonState(this.vecShopTeamBtn, 'Common/ui_common', 'ui_common_btn_tab_subheading0', 'ui_common_btn_tab_subheading1', 0); cc.find('tabBaiTan/nodBuy', this.node).active = true; let contentGoods = cc.find('tabBaiTan/nodBuy/scvGoods/view/content', this.node); SKUIUtil.destroyList(this.vecTmpGoods); let stStart = { nX: 125, nY: -48 }; for (let i = 0; i < vecGoods.length; i++) { let stPos = { nX: stStart.nX + (i % 2) * 245, nY: stStart.nY - Math.floor(i / 2) * 82 }; let goGoods = CPubFunction.CreateSubNode(contentGoods, stPos, this.btnGoodsInfo, ''); goGoods.getComponent(cc.Button).clickEvents.push(CPubFunction.CreateEventHandler(this.node, "ShopUI", 'OpenBuyUI', vecGoods[i])); this.SetGoodsInfo(goGoods, vecGoods[i]); this.vecTmpGoods.push(goGoods); } contentGoods.height = Math.max(contentGoods.height, Math.ceil((vecGoods.length + 1) / 2) * 84 + 0); }, //加載出售商品展示 InitMallList(data) { let list = JSON.parse(data.info); this.freshList = list[0]; this.mallList = list[1]; this.dayList = list[2]; this.refreshMall(); }, refreshMall() { SKUIUtil.destroyList(this.vecTmpGoods); let contentGoods = cc.find('tabDuoBaoGe/nodSell/scvGoods/view/content', this.node); contentGoods.destroyAllChildren(); let stStart = { nX: 125, nY: -48 }; let list = null; if (this.type == 0) { list = this.freshList; } else if (this.type == 1) { list = this.mallList; } else if (this.type == 2) { list = this.dayList; } if (!list) { return; } let length = CPubFunction.GetMapLen(list); for (let i = 1; i <= length; i++) { let stPos = { nX: stStart.nX + ((i - 1) % 2) * 245, nY: stStart.nY - Math.floor((i - 1) / 2) * 82 }; let goMall = CPubFunction.CreateSubNode(contentGoods, stPos, this.btnMallInfo, ''); goMall.getComponent(cc.Button).clickEvents.push(CPubFunction.CreateEventHandler(this.node, "ShopUI", 'OpenBuyMall', i - 1)); this.SetMallInfo(goMall, list[i]); this.vecTmpGoods.push(goMall); } let height = Math.max(contentGoods.height, Math.ceil((length + 1) / 2) * 80 + 60); contentGoods.height = height; this.refreshCurrent(); }, OpenBuyUI(stEvent, stGoodsInfo) { CPubFunction.FindAndDeleteNode(cc.find('Canvas/MainUI'), 'BuyUI'); let goBuyUI = CPubFunction.CreateSubNode(cc.find('Canvas/MainUI'), { nX: 0, nY: 0 }, this.BuyUI, 'BuyUI'); let comBuyUI = goBuyUI.getComponent('BuyUI'); comBuyUI.nID = stGoodsInfo.nID; comBuyUI.nConfigID = stGoodsInfo.nConfigID; comBuyUI.nPrice = stGoodsInfo.nPrice; comBuyUI.nMax = stGoodsInfo.nCnt; comBuyUI.nBuyCnt = 1; }, // 點擊道具 OpenBuyMall(event, nIndex) { console.log("點擊道具") CPubFunction.ChangeTeamButtonState(this.vecTmpGoods, 'Common/ui_common', 'ui_common_public_list0', 'ui_common_public_list2', nIndex); this.current = nIndex + 1; this.refreshCurrent(); }, refreshCurrent() { let list; if (this.type == 0) { list = this.freshList; } else if (this.type == 1) { list = this.mallList; } else if (this.type == 2) { list = this.dayList; } if (!list) { return; } if (this.current == 0) { this.malltip.active = true; this.mallmessge.active = false; return; } let data = list[this.current]; let mall = ItemUtil.getItemData(data.itemid); this.malltip.active = false; this.mallmessge.active = true; this.mallname.string = mall.name; let desc = mall.description; if (this.type == 2) { desc += `\n還可以購買: ${Math.max(0, data.time - data.count)}個`; } this.mallmessgeuse.string = desc; this.mallnum.string = 1; this.price = Number(data.price); this.mallsprices.string = this.price; this.price = Number(data.price); this.itemid = data.itemid; this.mallId = data.id; this.mallCount = data.count ? data.count : 0; this.mallLimit = data.time ? data.time : 0; }, Onaddmall() { if (parseInt(this.mallnum.string) >= 10000) { return; } this.mallnum.string = parseInt(this.mallnum.string) + 1; this.mallsprices.string = parseInt(this.mallsprices.string) + Number(this.price); }, onminmall() { if (parseInt(this.mallnum.string) <= 1) { return; } this.mallnum.string = parseInt(this.mallnum.string) - 1; this.mallsprices.string = parseInt(this.mallsprices.string) - Number(this.price); }, OpenNumPad(e, d) { this.mallnum.string = 0; let goNumPad = CPubFunction.CreateSubNode(cc.find('Canvas/MainUI'), { nX: 60, nY: 195 }, this.NumPad, 'NumPad'); goNumPad.getComponent('NumPad').NumPad_Init((nNum) => { this.mallnum.string = CPubFunction.ChangeNumToRange(nNum, 1, 10000); this.mallsprices.string = Number(this.price) * Number(this.mallnum.string); }); }, // 點擊購買 OnBuyMall() { let price = parseInt(this.mallsprices.string); let jade = GameModel.player.gameData.jade; if (jade < price) { FGHUD.hideLoading(); MsgAlert.addMsg(`您的仙玉不足!`); return; } if (this.type == 2) { if (this.mallCount >= this.mallLimit) { return; } this.dayList[this.mallId].count++; } console.log(`請求購買${this.type},${this.mallId},${this.mallnum},${this.mallsprices}`); GameModel.send('c2s_buymall_items', { type: this.type, mallid: this.mallId, mallnum: this.mallnum.string, mallprices: this.mallsprices.string, }); }, BuyPreview(nItemID, nPrice) { this.stCurItem = ItemUtil.getItemData(nItemID); let goIcon = cc.find('svItemDetail/view/content/ItemIcon/icon', this.node); goIcon.getComponent(cc.Sprite).spriteFrame = ItemUtil.getItemIcon(this.stCurItem.icon); cc.find('svItemDetail/view/content/txTitle', this.node).getComponent(cc.Label).string = this.stCurItem.name; let strText = this.stCurItem.description; strText += '\n\n' + '【用途】' + this.stCurItem.usedetail; cc.find('svItemDetail/view/content/txDetal', this.node).getComponent(cc.Label).string = strText; }, OpenShangJiaUI(stEvent, stParam) { CPubFunction.FindAndDeleteNode(cc.find('Canvas/MainUI'), 'ShangJiaUI'); let goShangJiaUI = CPubFunction.CreateSubNode(cc.find('Canvas/MainUI'), { nX: 0, nY: 0 }, this.ShangJiaUI, 'ShangJiaUI'); let comShangJiaUI = goShangJiaUI.getComponent('ShangJiaUI'); if (stParam.nFlag == 0) { comShangJiaUI.ShowBagItem(); } if (stParam.nFlag == 1) { comShangJiaUI.ShowSellingItem(); } }, // 切換多寶閣 DbgSelect(event, param) { CPubFunction.ChangeTeamButtonState(this.vecDuoBaoGeTeamBtn, 'Common/ui_common', 'ui_common_btn_tab_subheading0', 'ui_common_btn_tab_subheading1', param); this.type = param; this.current = 0; this.refreshMall(); }, // 點擊多寶閣 OnClickMainKind(event, nKind) { cc.find('tabBaiTan/nodBuy/scvGoods', this.node).active = false; cc.find('tabBaiTan/nodBuy/scrItemName', this.node).active = true; if (nKind == EItemType.Equip) { this.ShowEquipNameList(CItemMgr.mapEquipType); } else { let mapTmp = {}; mapTmp[0] = new CItemType(nKind, 0, '全部', 0); for (let it in GameModel.game_conf.item) { let stConfig = GameModel.game_conf.item[it]; if (stConfig.type == nKind) { mapTmp[stConfig.id] = new CItemType(nKind, stConfig.id, stConfig.name, stConfig.icon); } } this.ShowEquipNameList(mapTmp); } }, ShowEquipNameList(mapEquipType) //顯示物品 { SKUIUtil.destroyList(this.vecItemName); //按鈕框 let preButton = this.btnItemName; let contItemName = cc.find('tabBaiTan/nodBuy/scrItemName/view/content', this.node); let nBtnHight = preButton.data.height; let nBtnWidth = preButton.data.width; let nDis = 4; let nIndex = -1; let stStart = { nX: 117, nY: -60 }; for (const it in mapEquipType) { nIndex++; let goBtn = CPubFunction.CreateSubNode(contItemName, { nX: stStart.nX + (nIndex % 2) * nBtnWidth, nY: stStart.nY - Math.floor(nIndex / 2) * (nBtnHight + nDis) }, preButton, it); goBtn.getComponent(cc.Button).clickEvents.push(CPubFunction.CreateEventHandler(this.node, "ShopUI", 'OnClickEquipName', mapEquipType[it])); cc.find('Label', goBtn).getComponent(cc.Label).string = mapEquipType[it].strTypeName; cc.find('nodIcon/Icon', goBtn).getComponent(cc.Sprite).spriteFrame = ItemUtil.getItemIcon(mapEquipType[it].icon); this.vecItemName.push(goBtn); } contItemName.height = Math.max(contItemName.height, Math.ceil(nIndex / 2) * (nBtnHight + nDis) + 80); }, OnClickEquipName(stEvent, stItemType) { if (stItemType.nItemKind == 1) return; cc.find('tabBaiTan/nodBuy/scrItemName', this.node).active = false; cc.find('tabBaiTan/nodBuy/scvGoods', this.node).active = true; if (stItemType.nItemKind == 1) { this.InitEquipGoodsList([]); } else { GameModel.send('c2s_get_shop_items', { nKind: stItemType.nItemKind, nItem: stItemType.nParam }); } }, OnTakeMoney(e, nID) { GameModel.send('c2s_take_back_goods', { nID: nID, }); // this.Close(); }, /* * 打開充值獎勵界面 */ onOpenChargeReward() { RechargeReward.Instance.openRewardPanel3(); }, onOpenChargeReward2() { RechargeReward.Instance.openRewardPanel2(); }, });