123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- const {QuestMainMissionType, GameNotificationKey} = require("../utils/GameEnum");
- const DWTool = require('../utils/DWTool');
- const InviteApi = require('../net/InviteApi');
- const GameModule = require("../utils/GameModule");
- const TapTapTool = require("../utils/TapTapTool");
- const GameRedDot = require('../utils/GameEnum').GameRedDot;
- 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.AlreadyGet:
- this.finishButton.node.active = true;
- break;
- case QuestMainMissionType.CanGain:
- 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.friendAward);
- }
- this.refreshButtonState();
- let isNew = true;
- for (let i = 0; i < Global._timeInformations.length; ++ i) {
- let information = Global._timeInformations[i];
- if (information.type == 3) {
- /// 如果是已经使用过的直接刷新时间就可以啦
- information.cdTime = Global.friendRewardCdTime;
- isNew = false;
- break;
- }
- }
- if (isNew) {
- let messageItem = {'cdTime': Global.friendRewardCdTime, 'type': 3};
- Global._timeInformations.push(messageItem);
- GameEvent.fire(GameNotificationKey.GameUpdateMessageList, 1, true);
- }
- }, (error) => {
- Global.commonAlert.showCommonErrorAlert("领取失败");
- });
- },
- refreshButtonState() {
- GameModule.audioMng.playGetAward();
- this.model.status = QuestMainMissionType.AlreadyGet;
- this.hideAllButton();
- this.finishButton.node.active = true;
- Global.friendRewardCdTime += this.model.time * 1000;
- GameEvent.fire(GameNotificationKey.GainFriendHelpClick);
- }
- // update (dt) {},
- });
|