<template>
   <view ref="form" v-if="orderId">
     <web-view :src="html" ></web-view>
   </view>
</template>

<script>
export default {
  name: "index",
  data(){
    return{
      baseUrl: 'http://pay.huansi.net/#/payorder/',
      orderId: '',
      timer: null,
      loading: false,
      // html: 'http://pay.huansi.net/#/payorder/1483979726701785089'
    }
  },
  computed:{
    html(){
      return `${this.baseUrl}${this.orderId}`
    }
  },
  methods:{
     checkStatus(){
       if(this.loading){
         return;
       }
       this.loading = true;
       this.$http("stylelibraryorder.listingDetailsByCode",this.orderId)
          .then(res =>{
          let {
            code, data,msg
          } = res;
          if(code === 200){
            if(data.status === 2){
              uni.showToast({
                title: msg,
                complete:() =>{
                  this.$Router.back();
                }
              })
            }
          }else{
            uni.showToast({
              title: msg
            })
          }
        }).then(res =>{
         this.loading = false;
       })

    }
  },
  onLoad() {
    this.orderId = this.$Router.currentRoute.query.id;
    if(this.ticker){
      clearInterval(this.ticker);
    }else {
      this.ticker = setInterval(this.checkStatus, 1000);
    }
  },
  onUnload(){
    clearInterval(this.ticker);
  }
}
</script>

<style scoped>

</style>
