const HomeApi = require('../net/HomeApi'); const AlertManager = require('../utils/AlertManager'); const GameModule = require("../utils/GameModule"); cc.Class({ extends: cc.Component, properties: { btnSpriteFrame: [cc.SpriteFrame], gainButton: cc.Button }, // LIFE-CYCLE CALLBACKS: onLoad () { if (Global.isMineEnter) { this.gainButton.interactable = true; this.gainButton.getComponent(cc.Sprite).spriteFrame = this.btnSpriteFrame[1]; } else { this.gainButton.interactable = false; this.gainButton.getComponent(cc.Sprite).spriteFrame = this.btnSpriteFrame[0]; } }, start () { }, gainAward() { GameModule.audioMng.playClickButton(); this.gainButton.interactable = false; HomeApi.getAppletAward((respondData) => { GameModule.audioMng.playGetAward(); if (respondData.diamond) { let showText = `钻石 x ${respondData.diamond}`; AlertManager.showActGiftAlert('diamond', showText); GameModule.userInfo.updateUserRes({ diamond: parseInt(respondData.diamond) }); } else { Global.commonAlert.showCommonErrorAlert("领取奖励成功"); } GameGlobal.appletAward = true; this.node.destroy(); GameEvent.fire('Gain_My_Applet'); }, (code, msg) => { this.gainButton.interactable = true; Global.commonAlert.showCommonErrorAlert("领取失败"); }); }, closeView() { GameModule.audioMng.playClickButton(); this.node.destroy(); } // update (dt) {}, });