//index js
export default{
  data(){
    return {
      timer:null
    };
  },
  mounted(){
    //onez.data(this,['items']);
  },
  watch:{
    pagedata(){
      if(this.timer){
        clearInterval(this.timer);
      }
      if(this.pagedata.waiting){
        this.timer=setInterval(this.check,2000);
        if(onez.is_weixin()){
          if(!this.pagedata.openid){
            var url=location.href.split('#')[0];
            if(url.indexOf('?')==-1){
              url+='?';
            }else{
              url+='&';
            }
            url+='getOpenId=1';
            location.href=url;
          }
        }
      }
    }
  },
  methods:{
    check(){
      this.post({ac:'check'},(res)=>{
        if(res.status=='end'){
          clearInterval(this.timer);
          onez.data(this,['pagedata']);
        }
      });
    }
  }
}
