import { _decorator, Component, Node, Label, ProgressBar, instantiate, Prefab, UITransform, v3, Sprite, Button } from 'cc'; import { Http } from '../../core/net/Http'; import { WindowManager } from '../../core/ui/window/WindowManager'; import { WindowOpenMode } from '../../core/ui/window/WindowOpenMode'; import { Utils } from '../../core/utils/Utils'; import { g } from '../../Data/g'; import { platform } from '../../Data/platform'; import { ScrollItem } from './ScrollItem'; const { ccclass, property } = _decorator; @ccclass('NewRewardWindow2') export class NewRewardWindow2 extends Component { @property({ type: Label, tooltip: "倒计时文本" }) countLabel: Label; @property({ type: Label, tooltip: "差值文本" }) lerpLabel: Label; @property({ type: Label, tooltip: "还需要多少人文本" }) needLabel: Label; @property({ type: Node, tooltip: "差值节点" }) needNode: Node; @property({ type: ProgressBar, tooltip: "当前进度" }) progress: ProgressBar; @property({ type: Node, tooltip: "邀请按钮" }) inviteButton: Node; @property({ type: Node, tooltip: "开启按钮" }) openButton: Node; @property({ type: Node, tooltip: "滚动视图" }) scroll: Node; @property({ type: Prefab, tooltip: "滚动视图Item" }) scrollItem: Prefab; @property({ type: Http, tooltip: "Http组件" }) http: Http; private scrollY = 0; private time: number = 0; private scrollInited = false; async start() { this.time = g.userData.createTime * 1000 + 3 * 60 * 60 * 1000; if (Date.now() > this.time) { this.countLabel.string = "已失效"; this.inviteButton.getComponent(Sprite).grayscale = this.openButton.getComponent(Sprite).grayscale = true; this.inviteButton.getComponent(Button).interactable = this.openButton.getComponent(Button).interactable = false; } let result = await this.http.send("/api/threedayTask/threeDayUserCount"); if (result.code == 0) { this.lerpLabel.string = `仅差${0.05 * result.data}元`; this.needLabel.string = `(仅需再邀请${result.data}人)`; this.progress.progress = (5 - (0.05 * result.data)) / 5; this.needNode.active = this.needLabel.node.active = this.inviteButton.active = !(this.openButton.active = (result.data == 0)); g.gameData.needChildCount = result.data; } for (let i = 0; i < this.scrollData.length; i++) { let node = instantiate(this.scrollItem); node.setParent(this.scroll); node.getComponent(ScrollItem).setData(this.scrollData[i]); } this.scrollInited = true; } update() { if (Date.now() < this.time) { if (this.countLabel.string != Utils.formatCountDown(this.time - Date.now())) { this.countLabel.string = Utils.formatCountDown(this.time - Date.now()); } } if (this.scrollInited) { if (this.scroll.position.y >= this.scroll.getComponent(UITransform).height - 190) { this.scrollY = 0; } this.scrollY += 0.1; this.scroll.setPosition(v3(0, this.scrollY, 0)); } } public async oninviteButton() { platform.reportThinking("login", JSON.stringify({ guide: "first_invite" })); let result = await this.http.send("/api/app/share", {}); if (result.code == 0) { platform.wxShare(result.data.url, result.data.title, result.data.descroption); } else { WindowManager.showTips("分享信息获取失败,请稍后再试"); } } public async onOpenButton() { let result = await this.http.send("/api/threeDayTask/threedayTaskOpen"); if (result.code == 0) { platform.umUp("activateFriends");//新人奖励里面成功激活邀请好友埋点 WindowManager.open("Prefabs/NewRewardWindow/NewRewardWindow_3", WindowOpenMode.CloseAndAdd); g.gameData.threedayTaskTime = result.data; } } private scrollData = [ { head: "https://thirdwx.qlogo.cn/mmopen/vi_32/KOWicx0LUP4gZdLdQxVHViakubv0ibqctoSmE4eceibfccfiaFJXlSxBS5WkibyFvROmH9ibkNLBDICXS6UwDYj4M7oZg/132", name: "氢*晓" }, { head: "https://thirdwx.qlogo.cn/mmopen/vi_32/DYAIOgq83eoO58CpmkcLM7ibD5GuDfGibEkHjgPxO0iaRksiaHtaiciatrafc0ZCAGziaoPeJwh7NYGW3byJP1fcpFEpg/132", name: "开*天" }, { head: " https://thirdwx.qlogo.cn/mmopen/vi_32/DYAIOgq83eq4gibiad6kNsfGvIsEHPhOXnpXYZPibONNW80J36ibHJAd5zyhSrWU3shrH2FFZbzltxUXFL0RQLgu8g/132", name: "开*果" }, { head: "https://thirdwx.qlogo.cn/mmopen/vi_32/5BkayaLlSGXtu7j9VS7WVSwZibRF4UaIBHExc75LNmKmd1M2BKLSicZD1gJicxAawmP89JKwJcIFfSwaGf9GMVWwg/132", name: "李*林" }, { head: "https://thirdwx.qlogo.cn/mmopen/vi_32/875iboibEbc6FIgtwc53plW2ibqSMjA4mWMsdBJibWbXtcVjqBKUib5icCkcb3az4rmGjdanpDPdQMw97WZh6ossLlpw/132", name: "海*涯" }, { head: "https://thirdwx.qlogo.cn/mmopen/vi_32/oZFicmq8Y8YtibRnWjAwUeQATCNFVj8iazWSfccQRZOiaia7yicM9FtqliblicickqyNZ96xiaKiaqIIS6V2ThA3nWI8Uq0DA/132", name: "一*顺" }, { head: "https://thirdwx.qlogo.cn/mmopen/vi_32/FIvl6uib6D884L6gWqCNUrCMMDPrL1X129icEHVa4jDLPTokcAUS0L94ewfUDebaZNjgotHyUI5FFkVt2RRa4rdA/132", name: "故*妳" }, { head: "https://thirdwx.qlogo.cn/mmopen/vi_32/oiaOyMkj2UPVWBBzpl1JX4ibxHUTlf6jKUSaIgcGeYPqKXKTmaQCgEUv501Cib3YycaZw5IUfvIJ7DqEZ71rNqfiag/132", name: "我*作" }, { head: "https://thirdwx.qlogo.cn/mmopen/vi_32/lOyf89Ultxpzht91wFNPkLafqwKK5LzibcHlRWb15fiaLMfS7zvSrVyrobAAHGZNIPqKv5racoScbmFpV54zUEYQ/132", name: "野*?" }, { head: "https://thirdwx.qlogo.cn/mmopen/vi_32/kibLRaMZ9icCbR0dDI8Z46X5whDW117SFFdkS1G0jCOR9VrUf2aeXkmLbKwh7kia9yQWibL4LytqvuN7qoXMnmxA2A/132", name: "我*在" }, { head: "https://thirdwx.qlogo.cn/mmopen/vi_32/wUuxa1EfTRELZtGX4TvoiafGIV8picaFommGrCakuS2CE7FxPuRsQic1zftZvibK5mu5YXGdYyauBnkZkxHeHo0f3g/132", name: "翟*利" }, { head: "https://thirdwx.qlogo.cn/mmopen/vi_32/zcUUdYnKGymFiagUQGRDvh9h6bJBQ9Sn9wNkBw1BWqpKfeniaApO2ia48EicWWRjAS9eZq06WjrpjdbCvacHsVz1UA/132", name: "汤*粉" }, { head: "https://thirdwx.qlogo.cn/mmopen/vi_32/joXcgmQODQ5LicjjNtaFDeeQ7ib9tfw59fgt03cQ73Yl0w5J81vdiaYiah9M40L4c5pwOdRhsIicicxUWsQvaSPkMSIg/132", name: "幸*乐" }, { head: "https://thirdwx.qlogo.cn/mmopen/vi_32/1b820GreUob15yeicXA8al6VKd39D14h2mKMqFKUqgAevialqZrXgppE0AcGibk8GGbjYuO9KnVFI2c4J84oAmHCg/132", name: "迷*茫" }, { head: "https://thirdwx.qlogo.cn/mmopen/vi_32/3oibKMCQxIEPAOib95dNm8KI3uAyb1eEibzSD8UIZT9zv0ukQJ2XAh3UibdbDIWkG98YicVRZGudGiaawgOibicNBmEAZA/132", name: "哈*哈" }, { head: "https://thirdwx.qlogo.cn/mmopen/vi_32/dgLzFyDFZ1D2ibMuNDzKY5prHtPPn9BQGPWiaiaEo3NUaeHdz4YDc3ETib284ImkkVNLurtTHxiaD1zIOjHc2Tk7euw/132", name: ",A*B" } ] }