const DWTool = require("../utils/DWTool"); const WeChat = require('../net/WeChat'); const GameModule = require("../utils/GameModule"); cc.Class({ extends: cc.Component, properties: { btnArr: [cc.Button], moneyLabels: [cc.Label], titleLabels: [cc.Label], recommendSprite: cc.Node, }, // LIFE-CYCLE CALLBACKS: // onLoad () {}, start () { }, init(shopDatas) { this._shopDatas = shopDatas; /// 如果只有一个 那么说明买过了 if (this._shopDatas.length == 1) { this.recommendSprite.active = false; this.btnArr[0].node.active = false; this.btnArr[2].node.active = false; let titileArr = ['周使用权', '月使用权', '年使用权']; this.titleLabels[1].string = titileArr[shopDatas[0].shopId - 1]; /// 转换为天数 let cdTime = shopDatas[0].cdTime; let dayTime = 1000 * 60 * 60 * 24; let days = parseInt(cdTime / dayTime); let hours = parseInt((parseInt(cdTime) % dayTime ) / (1000 * 60 * 60)); if (days === 0) { if (hours == 0) { this.moneyLabels[1].string = DWTool.calculateTime(shopDatas[0].cdTime / 1000); } else { this.moneyLabels[1].string = '剩余' + hours + '小时'; } } else { this.moneyLabels[1].string = '剩余' + days + '天' + hours + '小时'; } /// 不能点击 this.btnArr[1].interactable = false; /// 更新价格信息 } else { this.moneyLabels[0].string = '¥' + this._shopDatas[1].price; this.moneyLabels[1].string = '¥' + this._shopDatas[0].price; this.moneyLabels[2].string = '¥' + this._shopDatas[2].price; } }, closeButtonAction() { GameModule.audioMng.playClickButton(); this.node.destroy(); }, //// eventData 1 2 3 月 周 年 buyAction() { GameModule.audioMng.playClickButton(); WeChat.jumpCustomerServices() } // update (dt) {}, });