auto_go.js
950 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
Component({
/*** 页面的初始数据***/
data: {
msgStatus:false,
countDownNum:3, //默认3秒后跳转
stop:0 //强行停止的开关
},
methods: {
show:function (){
this.data.stop=0;
this.setData({msgStatus:true,countDownNum:3})
this.cut_down();
},
hide:function (){
this.setData({msgStatus:false})
},
//-- 定时器跳转 --
cut_down(){
if(this.data.stop) return false;
if(this.data.countDownNum>0){
var a=this.data.countDownNum-1;
this.setData({countDownNum:a})
setTimeout(()=>{
this.cut_down();
},1000);
}else{
if(this.data.stop) return false;
this.hide();
this.triggerEvent('childFun');
}
},
//-- 3秒跳转的自动关闭 --
stop(){
this.data.stop=1;
this.hide();
}
}
})