const DWTool = require("../utils/DWTool"); const {GameNotificationKey, GameRedDot, InviteMissionItemType} = require('../utils/GameEnum'); const InviteApi = require('../net/InviteApi'); const TapTapTool = require("../utils/TapTapTool"); const GameModule = require("../utils/GameModule"); cc.Class({ extends: cc.Component, properties: { awardNode1: cc.Node, awardItemNode1: cc.Node, countLabel1: cc.Label, awardRichText: cc.RichText, noButton: cc.Button, gainButton: cc.Button, finishButton: cc.Button, }, // LIFE-CYCLE CALLBACKS: // onLoad () {}, start () { }, hideAllButton() { this.noButton.node.active = false; this.gainButton.node.active = false; this.finishButton.node.active = false; }, onDisable() { }, configData(model, invitedCount) { this.model = model; this.hideAllButton(); switch (model.state) { case InviteMissionItemType.NoFinished: this.noButton.node.active = true; break; case InviteMissionItemType.Finished: this.finishButton.node.active = true; break; case InviteMissionItemType.Gain: this.gainButton.node.active = true; break; } let diamond = model.diamond; if (diamond > 0) { this.awardNode1.active = true; cc.loader.loadRes("/textures/invite/talent_invite_diamond", cc.SpriteFrame, (err, spriteFrame) => { if (err) { } else { this.awardItemNode1.getComponent('cc.Sprite').spriteFrame = spriteFrame; } }); this.countLabel1.string = DWTool.coinParse(diamond); } if (invitedCount >= model.count) { this.awardRichText.string = `邀请奖励\n(好友:${model.count}/${model.count}名)`; } else { this.awardRichText.string = `邀请奖励\n(好友:${invitedCount}/${model.count}名)`; } }, gainAward() { InviteApi.postGainAward(this.model.id, (responseData) => { if (responseData.isCancel) { TapTapTool.removeRedDot(GameRedDot.inviteFriend); } this.refreshButtonState(); }, (error) => { Global.commonAlert.showCommonErrorAlert("领取失败"); }); }, refreshButtonState() { GameModule.audioMng.playGetAward(); this.model.state = InviteMissionItemType.Finished; this.hideAllButton(); this.finishButton.node.active = true; GameEvent.fire(GameNotificationKey.InviteGainAward, this.model); }, // update (dt) {}, });