123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- const {QuestMainMissionType} = require("../utils/GameEnum");
- const DWTool = require('../utils/DWTool');
- const InviteApi = require('../net/InviteApi');
- const GameModule = require("../utils/GameModule");
- cc.Class({
- extends: cc.Component,
- properties: {
- friendCountRichText: cc.RichText,
- timeRichText: cc.RichText,
- noButton: cc.Button,
- gainButton: cc.Button,
- finishButton: cc.Button,
- },
- // LIFE-CYCLE CALLBACKS:
- // onLoad () {},
- start () {
- },
- configData(model) {
- this.model = model;
- this.hideAllButton();
- switch (model.status) {
- case QuestMainMissionType.NoFinished:
- this.noButton.node.active = true;
- break;
- case QuestMainMissionType.Finished:
- this.finishButton.node.active = true;
- break;
- case QuestMainMissionType.Gain:
- this.gainButton.node.active = true;
- break;
- }
- this.friendCountRichText.string = `<b>${model.count}位好友已成功点击</b>`;
- var timeString = model.time / 60;
- if (DWTool.isDot(timeString)) {
- timeString = timeString.toFixed(2);
- }
- this.timeRichText.string = `<b><color=#61250e>${timeString}分钟</color></b>`;
- },
- hideAllButton() {
- this.noButton.node.active = false;
- this.gainButton.node.active = false;
- this.finishButton.node.active = false;
- },
- gainAward() {
- InviteApi.postFriendGainAward(this.model.rewardId, (responseData) => {
- // if (responseData.isCancel) {
- // TapTapTool.removeRedDot(GameRedDot.inviteFriend);
- // }
- this.refreshButtonState();
- }, (error) => {
- Global.commonAlert.showCommonErrorAlert("领取失败");
- });
- },
- refreshButtonState() {
- GameModule.audioMng.playGetAward();
- this.model.state = QuestMainMissionType.Finished;
- this.hideAllButton();
- this.finishButton.node.active = true;
- // GameEvent.fire(GameNotificationKey.InviteGainAward, this.model);
- },
- // update (dt) {},
- });
|