12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- 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 (GameGlobal.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 {
- GameGlobal.commonAlert.showCommonErrorAlert("领取奖励成功");
- }
- GameGlobal.appletAward = true;
- this.node.destroy();
- GameEvent.fire('Gain_My_Applet');
- }, (code, msg) => {
- this.gainButton.interactable = true;
- GameGlobal.commonAlert.showCommonErrorAlert("领取失败");
- });
- },
- closeView() {
- GameModule.audioMng.playClickButton();
- this.node.destroy();
- }
- // update (dt) {},
- });
|