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

1

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