const DWTool = require("../utils/DWTool"); const AlertManager = require('../utils/AlertManager'); const WeChat = require('../net/WeChat'); const GameModule = require("../utils/GameModule"); cc.Class({ extends: cc.Component, properties: { itemBgSprite: cc.Sprite, iconSprite: cc.Sprite, titleSprite: cc.Sprite, subTitleRichText: cc.RichText, useTitleLabel: cc.Label, useButton: cc.Button, useSprite: cc.Sprite, }, // LIFE-CYCLE CALLBACKS: onLoad () {}, start () { }, /// tabIndex是第几个tab index 在数组中的index init(data, fontSize, tabIndex, index) { this._isAlbum = false; this._tabIndex = tabIndex; if (tabIndex === 4) { index = data.shopId - 16; } this._index = index; this._shopData = data; this.subTitleRichText.string = `${data.desc}` this.subTitleRichText.fontSize = fontSize; this.useTitleLabel.string = `¥ ${data.price}`; let path = './textures/store/800' + tabIndex; if (tabIndex === 4) { /// 加载背景 shopid 16 17 18 19 DWTool.loadResSpriteFrame(path + index + 1).then((spriteFrame) => { this.itemBgSprite.spriteFrame = spriteFrame; }).catch((msg) => { console.log(msg); }); } if (tabIndex === 1) { this.titleSprite.node.scaleX = 1; this.titleSprite.node.scaleY = 1; } DWTool.loadResSpriteFrame(path + index + 2).then((spriteFrame) => { this.iconSprite.spriteFrame = spriteFrame; }).catch((msg) => { console.log(msg); }); DWTool.loadResSpriteFrame(path + index + 3).then((spriteFrame) => { this.titleSprite.spriteFrame = spriteFrame; }).catch((msg) => { console.log(msg); }); }, /// 初始化商品的第二个 initAlbum(itemDatas) { this._isAlbum = true; this._itemDatas = itemDatas; this.subTitleRichText.string = `${itemDatas[0].desc}`; }, useButtonAction() { GameModule.audioMng.playClickButton(); /// 推荐合辑 if (this._isAlbum) { AlertManager.showStoreAlbumAlert(this._itemDatas); /// 如果是礼包 } else if (this._tabIndex == 4) { AlertManager.showStoreGiftAlert(this._index, this._shopData); } else { WeChat.jumpCustomerServices(); } }, // update (dt) {}, });