<template>
  <view>
    <a ref="payUrlRef" :href="jumpUrl"></a>
  </view>
</template>

<script>
export default {
  data() {
    return {
      jumpUrl: ''
    };
  },
  onload() {
    let url = localStorage.getItem('jumpUrl');
    // let url = this.cookie.get("jumpUrl");
    if (url) {
      this.jumpUrl = url;
    } else {
      this.jumpUrl = 'https://h5.pdzhtc.com';
    }
    this.getOrderId();
  },
  mounted() {
    this.$refs.payUrlRef.click();
  },
  methods: {
    getOrderId(id) {
      const localToken = JSON.parse(localStorage.getItem('lifeData') ?? '{}');
      const token = localToken?.data?.vuex_token;
      $.ajax({
        //请求方式
        type: 'get',
        //请求地址
        url: baseUrl + '/client/orderinfo/orderListByPoly/' + id,
        // token
        beforeSend: function (request) {
          request.setRequestHeader('Authorization', 'Bearer ' + token);
        },
        //请求成功
        success: function (result) {
          if (result.code === 200) {
            this.jumpUrl = result?.data?.jumpUrl ?? 'https://h5.pdzhtc.com';
          } else {
            alert(result.msg);
          }
        },
        //请求失败,包含具体的错误信息
        error: function (e) {
          alert('程序错误!');
        }
      });
    }
  }
};
</script>

<style></style>