FriendHelpItem.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. const {QuestMainMissionType} = require("../utils/GameEnum");
  2. const DWTool = require('../utils/DWTool');
  3. const InviteApi = require('../net/InviteApi');
  4. const GameModule = require("../utils/GameModule");
  5. cc.Class({
  6. extends: cc.Component,
  7. properties: {
  8. friendCountRichText: cc.RichText,
  9. timeRichText: cc.RichText,
  10. noButton: cc.Button,
  11. gainButton: cc.Button,
  12. finishButton: cc.Button,
  13. },
  14. // LIFE-CYCLE CALLBACKS:
  15. // onLoad () {},
  16. start () {
  17. },
  18. configData(model) {
  19. this.model = model;
  20. this.hideAllButton();
  21. switch (model.status) {
  22. case QuestMainMissionType.NoFinished:
  23. this.noButton.node.active = true;
  24. break;
  25. case QuestMainMissionType.Finished:
  26. this.finishButton.node.active = true;
  27. break;
  28. case QuestMainMissionType.Gain:
  29. this.gainButton.node.active = true;
  30. break;
  31. }
  32. this.friendCountRichText.string = `<b>${model.count}位好友已成功点击</b>`;
  33. var timeString = model.time / 60;
  34. if (DWTool.isDot(timeString)) {
  35. timeString = timeString.toFixed(2);
  36. }
  37. this.timeRichText.string = `<b><color=#61250e>${timeString}分钟</color></b>`;
  38. },
  39. hideAllButton() {
  40. this.noButton.node.active = false;
  41. this.gainButton.node.active = false;
  42. this.finishButton.node.active = false;
  43. },
  44. gainAward() {
  45. InviteApi.postFriendGainAward(this.model.rewardId, (responseData) => {
  46. // if (responseData.isCancel) {
  47. // TapTapTool.removeRedDot(GameRedDot.inviteFriend);
  48. // }
  49. this.refreshButtonState();
  50. }, (error) => {
  51. Global.commonAlert.showCommonErrorAlert("领取失败");
  52. });
  53. },
  54. refreshButtonState() {
  55. GameModule.audioMng.playGetAward();
  56. this.model.state = QuestMainMissionType.Finished;
  57. this.hideAllButton();
  58. this.finishButton.node.active = true;
  59. // GameEvent.fire(GameNotificationKey.InviteGainAward, this.model);
  60. },
  61. // update (dt) {},
  62. });