{
  template: '${tmpl}',
    data: function () {
      return {
        imgHeight: null,
        orderNum: "",
        orderInfo: {},
        payType: "wx",
        d: {},
        action: "",
        zfpzUrl: "",
        accounts: [],
        account_id: "",
        account_index: "",
        accountinfo: {},
        qrcode: "",
        tradekey: "",
        time: "",
        interval: null,
        roleList: null,
        isBizemp: false,
        loading: false,
        payOrderType: false,
        email: "",
        poliyLevel: "",
        address: "",
        Deparment: "",
        industry: "",
        period: "3个月",
        currentPay: true,
        currentPay1: false,
        currentPay2: false,
        currentPay3: false,
        d: {}
      }
    },
  mounted: function () {
    this.imgHeight = 'min-height:' + (document.documentElement.clientHeight - 221) + "px;";
    var that = this;
    var obj = this.$root.copyParams("", "getOssConfig", "/action/tmTools/springBoard");
    this.$root.postReq("/web/trademark/tmqueryCtl/doPost", obj).then(function (d) {
      that.d["key"] = "key";
      that.d["Bucket"] = d.data.Bucket;
      that.d["OSSAccessKeyId"] = d.data.OSSAccessKeyId;
      that.d["Signature"] = d.data.Signature;
      that.d["policy"] = d.data.policy;
      that.d["success_action_status"] = d.data.success_action_status;
      that.action = d.data.url;
    });
    this.getPayQrCode();
  },
  created: function () {

  },
  methods: {
    afterpayjump() {
      this.$router.push({
        path: `/${that.$root.channelName}/paysuccess`,
        query: {
          totalSum: this.orderInfo.totalSum,
          orderNo: this.orderInfo.orderNo
        }
      });
    },
    bankchange(d) {
      var account = this.accounts[d];
      console.log(account);
      if (account) {
        this.accountinfo = account;
        this.account_id = account.id;
      }
    },
    copyLink() {
      var oInput = document.createElement('input');
      oInput.value = "https://igirl.gongsibao.com/orderpay/orderpay?state=" + this.orderNum;
      document.body.appendChild(oInput);
      oInput.select();
      document.execCommand("Copy");
      oInput.className = 'oInput';
      oInput.style.display = 'none';
      this.$message({
        type: 'success',
        message: '复制成功'
      });
    },
    error(err) {
      this.$message.warning(`上传失败，请重新上传`);
      console.log(err);
    },
    setKey(name, flag) {
      console.log(name);
      console.log(flag);
      name = name.substring(name.length - 5);
      var myDate = new Date();
      var key = "zc_" + Math.round(Math.random() * 500) + myDate.getMonth() + myDate.getTime() + myDate.getFullYear() + myDate.getDate() + myDate.getHours() + myDate.getMinutes() + myDate.getSeconds() + myDate.getMilliseconds() + name.replace(" ", "");
      console.log(this.$refs[flag]);
      this.$refs[flag].d.key = key;
    },
    uploadsuccess2(result, obj) {
      this.zfpzUrl = result;
      this.payOrderType = true;
    },
    toOfflinePay() {
      this.payType = "offline";
      this.closePayConfirm();
      this.currentPay3 = false;
      this.currentPay2 = true;
      this.currentPay1 = false;
      this.currentPay = false;
    },
    toOtherPeoplePay() {
      this.payType = "otherPeople";
      this.closePayConfirm();
      this.currentPay3 = true;
      this.currentPay2 = false;
      this.currentPay1 = false;
      this.currentPay = false;
    },
    offlinePaySubmit() {
      var that = this;
      var fileUrl = this.zfpzUrl;
      var orderNum = this.orderNum;
      var account_id = this.account_id;
      if (!fileUrl) {
        that.$message.warning("请上传支付凭证");
        return;
      }
      if (!account_id) {
        that.$message.warning("请选择付款账户");
        return;
      }
      if (orderNum) {
        var obj = {
          fileUrl: fileUrl,
          orderNum: orderNum,
          account_id: account_id,
        };
        this.$root.showMask();
        this.$root.getReq("/web/orderCtl/offlinePay", obj).then(function (d) {
          if (d && d.code == 1) {
            that.$message.success("支付成功");
            that.afterpayjump();
            /** if (that.isBizemp) {
              that.$root.pushx({
                title: "我的订单",
                name: "/myordermag"
              });
            } else {
              that.$root.pushx({
                title: "我的订单",
                name: "/myorder"
              });
            }*/
          } else {
            that.$message.warning(d.msg);
          }
          that.$root.hideMask();
        }).catch(function (e) {
          that.$message.warning("操作失败");
          that.$root.hideMask();
        })
      } else {
        that.$message.warning("参数错误");
      }
    },
    toWxPay() {
      this.currentPay3 = false;
      this.currentPay2 = false;
      this.currentPay1 = false;
      this.currentPay = true;
      this.payType = "wx";
      this.closePayConfirm();
      this.getPayQrCode();
    },
    toAliPay() {
      this.currentPay3 = false;
      this.currentPay2 = false;
      this.currentPay1 = true;
      this.currentPay = false;
      this.payType = "alipay";
      this.closePayConfirm();
      this.getPayQrCode();
    },
    getPayQrCode: function () {
      var self = this;
      /*
      if (!this.orderInfo || !this.orderInfo.code) {
        this.$message.warning(`获取支付码失败，订单信息有误`);
        return;
      }
      */
      self.$root.loading = true;
      let obj = self.$root.copyParams({ "opType": this.payType, "orderNo": this.$route.query.orderNo }, "getTlPayQrCode", '/action/tmOrder/springBoard');
      self.$root.postReq("/web/trademark/tmqueryCtl/doPost", obj).then(d => {
        self.$root.loading = false;
        console.log(d, "getQrCode........................", d.data);
        if (d && d.status == 0) {
          var data = d.data;
          this.orderInfo = d.data.order;
          if (data.trxstatus == "0000") {
            self.qrcode = "http://bigdata.gongsibao.com/api/qc?detailLink=" + encodeURIComponent(data.payinfo);
            self.orderInfo.wxPayOrderCode = data.trxid;
            self.orderInfo.aliPayOrderCode = data.trxid;
            self.time = new Date().getTime();
            self.checkOrderStatus();
          } else {
            self.$message.warning("请刷新重试");
          }
        } else {
          console.log(d, "bbbbbbbbbbbbbbbbbbbbbbbbbbbb", d.msg);
          self.$message.warning(d.msg);
        }
      }).catch(e => {
        console.log(e);
        self.$message.warning(`获取支付码失败`);
        self.$root.loading = false;
      });
    },
    closePayConfirm() {
      if (this.interval) {
        window.clearInterval(this.interval);
      }
    },
    checkOrderStatus() {
      var self = this;
      var startTime = Number(this.time);
      setTimeout(function () {
        var inth = setInterval(function () {
          console.log(self.orderInfo, ".............................");
          var obj = self.$root.copyParams({
            orderCode: self.orderInfo.orderNo,
            orderNo: self.orderInfo.orderNo,
            wxPayOrderCode: self.orderInfo.wxPayOrderCode,
            aliPayOrderCode: self.orderInfo.aliPayOrderCode,
            op_type: self.payType
          }, "checkPayStatusTl", "/action/tmOrder/springBoard");
          self.$root.postReq("/web/trademark/tmqueryCtl/doPost", obj).then(d => {
            console.log(d);
            if (d && d.status == 0 && d.data && d.data.orderPayStatus == "yfk") {
              self.orderInfo = d.data;
              window.clearInterval(inth);
              self.$message.success("付款成功");
              self.$message.success("支付成功");
              self.$router.push({
                path: `/${self.$root.channelName}/paysuccess`,
                query: {
                  totalSum: d.data.totalSum,
                  orderNo: d.data.code
                }
              });
              return;
            } else {
              var passTime = (new Date().getTime() - startTime) / 1000;
              var p = Math.round((passTime / 300) * 100);
              if (passTime > 300) {
                clearInterval(inth);
              }
            }
          });
        }, 5000);
        self.interval = inth;
      }, 5000);
    },
    Subscribe() {
      console.log("oooooooooooo");
      axios.post('http://106.13.228.212:8010/gsb/Subscribe', {
        "userId": this.userId,
        "poliyLevel": this.poliyLevel,
        "city": this.address,
        "Departments": this.Department,
        "industry": this.industry,
        "BeginTime": this.Date_new(new Date()),
        "Email": this.email,
        "comanyname": this.currentCompany,
        "username": this.userName,
        "period": this.period,
        "money": this.money,
        "pid": this.orderInfo.orderNo
      }).then(d => {
        console.log(this.cities, "this.cities----------------------");
        console.log(this.currentCompany, "this.currentCompany----------------------");
        console.log(String(this.cities), "string----------------------");
        console.log(JSON.stringify(this.cities), "cities----------------------");
      })
    },
    Date_new(str) {
      let date = str || new Date(),
        year = date.getFullYear(),
        month = date.getMonth() + 1,
        day = date.getDate(),
        hours = date.getHours(),
        minutes = date.getMinutes(),
        second = date.getSeconds();
      let a = `${year}-${month}-${day} ${hours}:${minutes}:${second}`;
      return a;
    },
  },
  vname: "gsb_orderpay"
}