<template>
  <div class="container">
    <pay-wait-layer :value="isPayWait" />
  </div>
</template>

<script>
import detailPayMixin from "@/views/Goods/Detail/modules/detailPay.mixin";
// import qs from "qs";
import localStorage from "@/service/localStorage";
import { isXyqb } from "@/service/validation";
export default {
  name: "PayWaiting",
  mixins: [detailPayMixin],
  data() {
    return {
      orderInfo: {}
    };
  },
  mounted() {
    // if (document.referrer.length > 0) {
    //   window.location.href =
    //     window.location.origin +
    //     "/payWaiting" +
    //     qs.stringify(this.$route.query, { encode: true, addQueryPrefix: true });
    // }
    this.isPayWait = true;
    this.orderInfo = this.$route.query;
    // 如果存在isXyqb，同时当前不是在信用钱包环境
    if (this.orderInfo.isConsultant) {
      this.$router.replace({ path: "/consultant", query: { from: "wxh5" } });
      return;
    } else if (
      (this.orderInfo.isXyqb == 1 ||
        (this.orderInfo.third && this.orderInfo.third.indexOf("1") === 0)) &&
      !isXyqb
    ) {
      window.location.href = "xyqb://my";
      setTimeout(() => {
        if (localStorage.get("mongoToken")) {
          this.$router.replace("/policy");
        } else {
          this.$router.replace("/home");
        }
      }, 1000);
      return;
    } else if (!this.orderInfo.payOrderNo) {
      // 没有订单信息的情况
      this.$notify({ type: "warning", message: "正在跳转..." });
      setTimeout(() => {
        window.location.href = "/policy";
      }, 1000);
      return;
    }
    this.getPayResult();
  }
};
</script>
<style lang="less" src="./index.less" scoped></style>
