123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- 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 = `<color=#2E2E2E>${data.desc}</c>`
- 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 = `<color=#2E2E2E>${itemDatas[0].desc}</c>`;
- },
- 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) {},
- });
|