NewRewardWindow_2.ts 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. import { _decorator, Component, Node, Label, ProgressBar, instantiate, Prefab, UITransform, v3, Sprite, Button } from 'cc';
  2. import { Http } from '../../core/net/Http';
  3. import { WindowManager } from '../../core/ui/window/WindowManager';
  4. import { WindowOpenMode } from '../../core/ui/window/WindowOpenMode';
  5. import { Utils } from '../../core/utils/Utils';
  6. import { g } from '../../Data/g';
  7. import { platform } from '../../Data/platform';
  8. import { ScrollItem } from './ScrollItem';
  9. const { ccclass, property } = _decorator;
  10. @ccclass('NewRewardWindow2')
  11. export class NewRewardWindow2 extends Component {
  12. @property({ type: Label, tooltip: "倒计时文本" }) countLabel: Label;
  13. @property({ type: Label, tooltip: "差值文本" }) lerpLabel: Label;
  14. @property({ type: Label, tooltip: "还需要多少人文本" }) needLabel: Label;
  15. @property({ type: Node, tooltip: "差值节点" }) needNode: Node;
  16. @property({ type: ProgressBar, tooltip: "当前进度" }) progress: ProgressBar;
  17. @property({ type: Node, tooltip: "邀请按钮" }) inviteButton: Node;
  18. @property({ type: Node, tooltip: "开启按钮" }) openButton: Node;
  19. @property({ type: Node, tooltip: "滚动视图" }) scroll: Node;
  20. @property({ type: Prefab, tooltip: "滚动视图Item" }) scrollItem: Prefab;
  21. @property({ type: Http, tooltip: "Http组件" }) http: Http;
  22. private scrollY = 0;
  23. private time: number = 0;
  24. private scrollInited = false;
  25. async start() {
  26. this.time = g.userData.createTime * 1000 + 3 * 60 * 60 * 1000;
  27. if (Date.now() > this.time) {
  28. this.countLabel.string = "已失效";
  29. this.inviteButton.getComponent(Sprite).grayscale = this.openButton.getComponent(Sprite).grayscale = true;
  30. this.inviteButton.getComponent(Button).interactable = this.openButton.getComponent(Button).interactable = false;
  31. }
  32. let result = await this.http.send("/api/threedayTask/threeDayUserCount");
  33. if (result.code == 0) {
  34. this.lerpLabel.string = `仅差${0.05 * result.data}元`;
  35. this.needLabel.string = `(仅需再邀请${result.data}人)`;
  36. this.progress.progress = (5 - (0.05 * result.data)) / 5;
  37. this.needNode.active = this.needLabel.node.active = this.inviteButton.active = !(this.openButton.active = (result.data == 0));
  38. g.gameData.needChildCount = result.data;
  39. }
  40. for (let i = 0; i < this.scrollData.length; i++) {
  41. let node = instantiate(this.scrollItem);
  42. node.setParent(this.scroll);
  43. node.getComponent(ScrollItem).setData(this.scrollData[i]);
  44. }
  45. this.scrollInited = true;
  46. }
  47. update() {
  48. if (Date.now() < this.time) {
  49. if (this.countLabel.string != Utils.formatCountDown(this.time - Date.now())) {
  50. this.countLabel.string = Utils.formatCountDown(this.time - Date.now());
  51. }
  52. }
  53. if (this.scrollInited) {
  54. if (this.scroll.position.y >= this.scroll.getComponent(UITransform).height - 190) {
  55. this.scrollY = 0;
  56. }
  57. this.scrollY += 0.1;
  58. this.scroll.setPosition(v3(0, this.scrollY, 0));
  59. }
  60. }
  61. public async oninviteButton() {
  62. platform.reportThinking("login", JSON.stringify({ guide: "first_invite" }));
  63. let result = await this.http.send("/api/app/share", {});
  64. if (result.code == 0) {
  65. platform.wxShare(result.data.url, result.data.title, result.data.descroption);
  66. } else {
  67. WindowManager.showTips("分享信息获取失败,请稍后再试");
  68. }
  69. }
  70. public async onOpenButton() {
  71. let result = await this.http.send("/api/threeDayTask/threedayTaskOpen");
  72. if (result.code == 0) {
  73. platform.umUp("activateFriends");//新人奖励里面成功激活邀请好友埋点
  74. WindowManager.open("Prefabs/NewRewardWindow/NewRewardWindow_3", WindowOpenMode.CloseAndAdd);
  75. g.gameData.threedayTaskTime = result.data;
  76. }
  77. }
  78. private scrollData = [
  79. {
  80. head: "https://thirdwx.qlogo.cn/mmopen/vi_32/KOWicx0LUP4gZdLdQxVHViakubv0ibqctoSmE4eceibfccfiaFJXlSxBS5WkibyFvROmH9ibkNLBDICXS6UwDYj4M7oZg/132",
  81. name: "氢*晓"
  82. },
  83. {
  84. head: "https://thirdwx.qlogo.cn/mmopen/vi_32/DYAIOgq83eoO58CpmkcLM7ibD5GuDfGibEkHjgPxO0iaRksiaHtaiciatrafc0ZCAGziaoPeJwh7NYGW3byJP1fcpFEpg/132",
  85. name: "开*天"
  86. },
  87. {
  88. head: " https://thirdwx.qlogo.cn/mmopen/vi_32/DYAIOgq83eq4gibiad6kNsfGvIsEHPhOXnpXYZPibONNW80J36ibHJAd5zyhSrWU3shrH2FFZbzltxUXFL0RQLgu8g/132",
  89. name: "开*果"
  90. },
  91. {
  92. head: "https://thirdwx.qlogo.cn/mmopen/vi_32/5BkayaLlSGXtu7j9VS7WVSwZibRF4UaIBHExc75LNmKmd1M2BKLSicZD1gJicxAawmP89JKwJcIFfSwaGf9GMVWwg/132",
  93. name: "李*林"
  94. },
  95. {
  96. head: "https://thirdwx.qlogo.cn/mmopen/vi_32/875iboibEbc6FIgtwc53plW2ibqSMjA4mWMsdBJibWbXtcVjqBKUib5icCkcb3az4rmGjdanpDPdQMw97WZh6ossLlpw/132",
  97. name: "海*涯"
  98. },
  99. {
  100. head: "https://thirdwx.qlogo.cn/mmopen/vi_32/oZFicmq8Y8YtibRnWjAwUeQATCNFVj8iazWSfccQRZOiaia7yicM9FtqliblicickqyNZ96xiaKiaqIIS6V2ThA3nWI8Uq0DA/132",
  101. name: "一*顺"
  102. },
  103. {
  104. head: "https://thirdwx.qlogo.cn/mmopen/vi_32/FIvl6uib6D884L6gWqCNUrCMMDPrL1X129icEHVa4jDLPTokcAUS0L94ewfUDebaZNjgotHyUI5FFkVt2RRa4rdA/132",
  105. name: "故*妳"
  106. },
  107. {
  108. head: "https://thirdwx.qlogo.cn/mmopen/vi_32/oiaOyMkj2UPVWBBzpl1JX4ibxHUTlf6jKUSaIgcGeYPqKXKTmaQCgEUv501Cib3YycaZw5IUfvIJ7DqEZ71rNqfiag/132",
  109. name: "我*作"
  110. },
  111. {
  112. head: "https://thirdwx.qlogo.cn/mmopen/vi_32/lOyf89Ultxpzht91wFNPkLafqwKK5LzibcHlRWb15fiaLMfS7zvSrVyrobAAHGZNIPqKv5racoScbmFpV54zUEYQ/132",
  113. name: "野*?"
  114. },
  115. {
  116. head: "https://thirdwx.qlogo.cn/mmopen/vi_32/kibLRaMZ9icCbR0dDI8Z46X5whDW117SFFdkS1G0jCOR9VrUf2aeXkmLbKwh7kia9yQWibL4LytqvuN7qoXMnmxA2A/132",
  117. name: "我*在"
  118. },
  119. {
  120. head: "https://thirdwx.qlogo.cn/mmopen/vi_32/wUuxa1EfTRELZtGX4TvoiafGIV8picaFommGrCakuS2CE7FxPuRsQic1zftZvibK5mu5YXGdYyauBnkZkxHeHo0f3g/132",
  121. name: "翟*利"
  122. },
  123. {
  124. head: "https://thirdwx.qlogo.cn/mmopen/vi_32/zcUUdYnKGymFiagUQGRDvh9h6bJBQ9Sn9wNkBw1BWqpKfeniaApO2ia48EicWWRjAS9eZq06WjrpjdbCvacHsVz1UA/132",
  125. name: "汤*粉"
  126. },
  127. {
  128. head: "https://thirdwx.qlogo.cn/mmopen/vi_32/joXcgmQODQ5LicjjNtaFDeeQ7ib9tfw59fgt03cQ73Yl0w5J81vdiaYiah9M40L4c5pwOdRhsIicicxUWsQvaSPkMSIg/132",
  129. name: "幸*乐"
  130. },
  131. {
  132. head: "https://thirdwx.qlogo.cn/mmopen/vi_32/1b820GreUob15yeicXA8al6VKd39D14h2mKMqFKUqgAevialqZrXgppE0AcGibk8GGbjYuO9KnVFI2c4J84oAmHCg/132",
  133. name: "迷*茫"
  134. },
  135. {
  136. head: "https://thirdwx.qlogo.cn/mmopen/vi_32/3oibKMCQxIEPAOib95dNm8KI3uAyb1eEibzSD8UIZT9zv0ukQJ2XAh3UibdbDIWkG98YicVRZGudGiaawgOibicNBmEAZA/132",
  137. name: "哈*哈"
  138. },
  139. {
  140. head: "https://thirdwx.qlogo.cn/mmopen/vi_32/dgLzFyDFZ1D2ibMuNDzKY5prHtPPn9BQGPWiaiaEo3NUaeHdz4YDc3ETib284ImkkVNLurtTHxiaD1zIOjHc2Tk7euw/132",
  141. name: ",A*B"
  142. }
  143. ]
  144. }