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 (data.type === 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' + data.type; if (data.type === 4) { /// 加载背景 shopid 16 17 18 19 DWTool.loadResSpriteFrame(path + index + 1).then((spriteFrame) => { this.itemBgSprite.spriteFrame = spriteFrame; }).catch((msg) => { console.log(msg); }); ////加载黄色背景 } else { let bgPath = './textures/store/800401'; DWTool.loadResSpriteFrame(bgPath).then((spriteFrame) => { this.itemBgSprite.spriteFrame = spriteFrame; }).catch((msg) => { console.log(msg); }); } if (data.type === 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.useTitleLabel.fontSize = 20; this.useTitleLabel.string = '订阅\n查看详细内容'; this.subTitleRichText.string = `${itemDatas[0].desc}`; let path = './textures/store/800000'; let bgPath = './textures/store/800401'; let titlePath = './textures/store/store_subcript'; DWTool.loadResSpriteFrame(path).then((spriteFrame) => { this.iconSprite.spriteFrame = spriteFrame; }).catch((msg) => { console.log(msg); }); DWTool.loadResSpriteFrame(bgPath).then((spriteFrame) => { this.itemBgSprite.spriteFrame = spriteFrame; }).catch((msg) => { console.log(msg); }); DWTool.loadResSpriteFrame(titlePath).then((spriteFrame) => { this.titleSprite.spriteFrame = spriteFrame; }).catch((msg) => { console.log(msg); }); }, useButtonAction() { GameModule.audioMng.playClickButton(); /// 推荐合辑 if (this._isAlbum) { AlertManager.showStoreAlbumAlert(this._itemDatas); /// 如果是礼包 } else if (this._shopData.type == 4) { AlertManager.showStoreGiftAlert(this._index, this._shopData); } else { WeChat.jumpCustomerServices(); } }, // update (dt) {}, });