Commit bb146b4b authored by 邱旭's avatar 邱旭

1

parent 903d03ef
......@@ -2,7 +2,7 @@
* 简单的倒计时
* 2019.10.24
*/
export default class CutTime {
export default class CutTimer {
private _timer: egret.Timer = null;
private _label: eui.Label = null;
......
......@@ -65,7 +65,7 @@ export default class MapScene extends Scene {
}
// 邀请有礼角标倒计时
private timer: egret.Timer;
private inviteTimer: egret.Timer;
private cutTime: number;
async start(data?) {
......@@ -294,6 +294,10 @@ export default class MapScene extends Scene {
if(this['pic'])
egret.Tween.removeTweens(this['pic']);
if(this.inviteTimer){
this.inviteTimer.stop();
this.inviteTimer.removeEventListener(egret.TimerEvent.TIMER, this.inviteCutTimer, this);
}
}
getScrollV(lastOrder, stageHeight) {
......@@ -542,8 +546,8 @@ export default class MapScene extends Scene {
return;
}
let flag = res.data.completeFlag;
if(this.timer) {
this.timer.stop();
if(this.inviteTimer) {
this.inviteTimer.stop();
}
switch(true) {
case (flag == 0): // 未完成 显示倒计时
......@@ -551,10 +555,10 @@ export default class MapScene extends Scene {
this["inviteTipsBg"].visible = true;
this["inviteTips"].visible = true;
this.cutTime = res.data.endTime - res.data.sysTime + 5000;
this.timer = new egret.Timer(1000, 0);
this.timer.addEventListener(egret.TimerEvent.TIMER, this.cutTimer, this);
this.timer.start();
this.cutTimer();
this.inviteTimer = new egret.Timer(1000, 0);
this.inviteTimer.addEventListener(egret.TimerEvent.TIMER, this.inviteCutTimer, this);
this.inviteTimer.start();
this.inviteCutTimer();
break;
case (flag == 1): // 完成未开奖 待领奖 显示待领奖
this["inviteGroup"].visible = true;
......@@ -590,12 +594,12 @@ export default class MapScene extends Scene {
// 倒计时
private cutTimer() {
private inviteCutTimer() {
let timer = this.convertTime(this.cutTime -= 1000);
if(timer.hour === "00"
&& timer.min === "00"
&& timer.sec === "00") {
this.timer.stop();
this.inviteTimer.stop();
GDispatcher.dispatchEvent("getInviteInfo");
}
this["inviteTips"].text = `${timer.hour}:${timer.min}:${timer.sec}`;
......
......@@ -184,6 +184,14 @@ export default class InvitePanel extends Panel {
return 'Invite'
}
destroy() {
super.destroy();
if(this.timer){
this.timer.stop();
this.timer.removeEventListener(egret.TimerEvent.TIMER, this.cutTimer, this);
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////
......
......@@ -5,11 +5,11 @@ import { NetManager } from "../../libs/tw/manager/NetManager";
import { iswx } from "../iswx";
import Utils from "../Utils";
import ScratchRulePanel from "./ScratchRulePanel";
import CutTime from "../CutTime";
import CutTimer from "../CutTimer";
export default class ScratchPanel extends Panel {
private invite_img: egret.Texture;
private cutTimer: CutTime;
private cutTimer: CutTimer;
constructor(data) {
super();
......@@ -122,11 +122,11 @@ export default class ScratchPanel extends Panel {
this["list"].dataProvider = new eui.ArrayCollection(this.data.invitationUser);
// 倒计时
this.cutTimer = new CutTime(this["cutTimeLabel"], "将在hh:mm:ss后消失", () => {
this.cutTimer = new CutTimer(this["cutTimeLabel"], "将在hh:mm:ss后消失", () => {
this.hidePanel();
}
);
let cutTime = this.data.endTime - this.data.sysTime + 5000;
let cutTime = this.data.endTime - this.data.sysTime + 3000;
if(!this.cutTimer.start(cutTime)) {
this.cutTimer.stop();
this.cutTimer.start(cutTime);
......@@ -167,6 +167,11 @@ export default class ScratchPanel extends Panel {
});
}
destroy() {
super.destroy();
this.cutTimer.stop();
}
protected get closeBtns(): eui.Button[] {
return [this['closeBtn']]
}
......
......@@ -7,7 +7,7 @@
"invitationId": "活动id",
"invitationCount": 5,
"img": "http://yun.duiba.com.cn/db_games/xiaoxiaole.jpg",
"sysTime": 1570673805000,
"sysTime": 1570673808000,
"endTime": 1570673810000,
"invitationUser": [
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment