Commit 98fc3690 authored by 邱旭's avatar 邱旭

1

parent 6a6cdeb4
...@@ -31,12 +31,10 @@ export default class CutTimer { ...@@ -31,12 +31,10 @@ export default class CutTimer {
* @param labelText 该字符串将作为倒计时显示的文字,hh、mm、ss将被分别替换成时,分,秒,例:将在hh:mm:ss后消失 -> 将在18:07:21后消失 * @param labelText 该字符串将作为倒计时显示的文字,hh、mm、ss将被分别替换成时,分,秒,例:将在hh:mm:ss后消失 -> 将在18:07:21后消失
* @param callFun 如果希望他在结束时去做一些什么则传入一个回调函数 * @param callFun 如果希望他在结束时去做一些什么则传入一个回调函数
*/ */
constructor(label: IDisplayText, labelText: string, callFun?: Function) { constructor(label?: IDisplayText, labelText?: string, callFun?: Function) {
this._label = label; this._label = label || null;
this._labelText = labelText; this._labelText = labelText || "hh:mm:ss";
if(callFun) { this._callFun = callFun || null;
this._callFun = callFun;
}
} }
/** /**
...@@ -108,11 +106,14 @@ export default class CutTimer { ...@@ -108,11 +106,14 @@ export default class CutTimer {
&& timer.sec === "00") { && timer.sec === "00") {
this.stopAndCallFun(); this.stopAndCallFun();
} }
if(!this._label){
return;
}
let str = this._labelText; let str = this._labelText;
str = str.replace(/hh/g, timer.hour); str = str.replace(/hh/g, timer.hour);
str = str.replace(/mm/g, timer.min); str = str.replace(/mm/g, timer.min);
str = str.replace(/ss/g, timer.sec); str = str.replace(/ss/g, timer.sec);
if(this._label instanceof eui.Label){ if(this._label instanceof eui.Label) {
this._label.textFlow = (new HtmlTextParser).parser(str); this._label.textFlow = (new HtmlTextParser).parser(str);
} else { } else {
this._label.text = str; this._label.text = str;
......
...@@ -3,17 +3,23 @@ import PanelCtrl from "../../../libs/new_wx/ctrls/panelCtrl"; ...@@ -3,17 +3,23 @@ import PanelCtrl from "../../../libs/new_wx/ctrls/panelCtrl";
import { GDispatcher } from "../../../libs/tc/util/GDispatcher"; import { GDispatcher } from "../../../libs/tc/util/GDispatcher";
import { NetManager } from "../../../libs/tw/manager/NetManager"; import { NetManager } from "../../../libs/tw/manager/NetManager";
import { getlogItem } from "../../Main"; import { getlogItem } from "../../Main";
import CutTimer from "../../CutTimer";
export default class HbRainIcon extends IconBase { export default class HbRainIcon extends IconBase {
private cutTimer: CutTimer = null;
constructor(name: string, group: eui.Group, btn: eui.Button, tipsBg?: eui.Image, tipsLabel?: eui.Label) { constructor(name: string, group: eui.Group, btn: eui.Button, tipsBg?: eui.Image, tipsLabel?: eui.Label) {
super(name, group, btn, tipsBg, tipsLabel); super(name, group, btn, tipsBg, tipsLabel);
this.cutTimer = new CutTimer();
this.cutTimer.callFun = () => {
this.updateIcon();
};
this.updateIcon();
} }
protected start() { protected start() {
super.start(); super.start();
this.updateIcon();
} }
public showLog() { public showLog() {
...@@ -27,19 +33,35 @@ export default class HbRainIcon extends IconBase { ...@@ -27,19 +33,35 @@ export default class HbRainIcon extends IconBase {
if(res.code == "600054" || res.code == "600055") { if(res.code == "600054" || res.code == "600055") {
this.visible = false; this.visible = false;
} }
GDispatcher.dispatchEvent('updateActIcon');
return; return;
} }
const data = res.data; const data = res.data;
if(!data.currentSession && !data.nextSession) {
let time: number;
const sysTime = res.timestamp; // 当前系统时间
if(data.currentSession) {
this.visible = true;
time = data.currentSession.endTime - sysTime + 3000;
if(!this.cutTimer.start(time)) {
this.cutTimer.stop();
this.cutTimer.start(time);
}
} else if(data.nextSession) {
this.visible = true;
time = data.nextSession.startTime - sysTime + 3000;
if(!this.cutTimer.start(time)) {
this.cutTimer.stop();
this.cutTimer.start(time);
}
} else {
this.visible = false; this.visible = false;
return;
} }
this.visible = true; GDispatcher.dispatchEvent('updateActIcon');
}); });
} }
/** /**
* 点击icon * 点击icon
* @param e 点击事件 * @param e 点击事件
......
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
"success": true, "success": true,
"code": "0000000000", "code": "0000000000",
"desc": "OK", "desc": "OK",
"timestamp": 1573440905952, "timestamp": 1573210800000,
"data": { "data": {
"currentRemainTimes": 0, "currentRem1ainTimes": 0,
"currentSession": { "currentSession": {
"sessionIndex": 10, "sessionIndex": 10,
"startTime": 1573210800000, "startTime": 1573210800000,
"endTime": 1573440915952, "endTime": 1573210803000,
"limitScore": 10 "limitScore": 10
}, },
"nextSession": { "nextSession": {
......
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