1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- 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) {},
- });
|