<template>
  <div />
</template>
<script>
import { payByALIH5 } from '@/service/pay.service';

export default {
  data() {
    return {
      aliOrderString: '',
      toastN: ''
    };
  },

  created() {
    this.toastN = this.$toast.loading({
      loadingType: 'circular',
      duration: 8000,
      cover: true,
      onClose: () => {
        this.$router.replace({
          name: 'payWaiting',
          query: { orderNo: this.$route.query.orderNo }
        });
      }
    });
    this.aliOrderString = window.sessionStorage.getItem('aliOrderString');
    if (this.aliOrderString) {
      window.sessionStorage.removeItem('aliOrderString');
      payByALIH5({ url: this.aliOrderString });
    } else {
      this.toastN = null;
      this.$router.replace({
        name: 'payWaiting',
        query: { orderNo: this.$route.query.orderNo }
      });
    }
  },
  beforeDestroy() {
    clearInterval(this.timer);
  }
};
</script>
