auto_go.js 950 Bytes
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();
     }
  }


})