{
  template: '${tmpl}',
    data: function() {
      return {
        dialogTableVisible: false,
        step: "1",
        steps: [
          { title: "填写基本信息" },
          { title: "填写申请人信息" },
          { title: "确认订单信息" },
        ],
        form: {
          publishedCountryName: "中国",
          fileUrl: "",
          publishedCityName: "北京"
        },
        apply: {
          countryName: "北京"
        },
        showtypenum: false,
        order: {},
        qrcode: "",
        qrCodeJumpUrl: "",
        pay: {
          offlinePayDocument: "",
          paymentPlatformType: "wx"
        },
        payconfirm: false,
        d: {},
        cr_type: [
          {
            value: '自然人',
            label: '自然人'
          }, {
            value: '企业法人',
            label: '企业法人'
          }, {
            value: '机关法人',
            label: '机关法人'
          }, {
            value: '事业单位法人',
            label: '事业单位法人'
          }, {
            value: '社会团体法人',
            label: '社会团体法人'
          }, {
            value: '其他组织',
            label: '其他组织'
          }, {
            value: '其他',
            label: '其他'
          },
        ],
        cr_province: [
          {
            value: '北京',
            label: '北京'
          }, {
            value: '上海',
            label: '上海'
          }, {
            value: '天津',
            label: '天津'
          }, {
            value: '内蒙古',
            label: '内蒙古'
          }, {
            value: '山西',
            label: '山西'
          }, {
            value: '河北',
            label: '河北'
          }
        ],
        cr_certificateType: [
          {
            value: '居民身份证',
            label: '居民身份证'
          }, {
            value: '军官证',
            label: '军官证'
          }, {
            value: '营业执照',
            label: '营业执照'
          }, {
            value: '护照',
            label: '护照'
          }, {
            value: '企业法人营业执照',
            label: '企业法人营业执照'
          }, {
            value: '组织机构代码证书',
            label: '组织机构代码证书'
          }, {
            value: '事业单位法人证书',
            label: '事业单位法人证书'
          }, {
            value: '社团法人证书',
            label: '社团法人证书'
          }, {
            value: '其他有效证件',
            label: '其他有效证件'
          }
        ],
        cr_garden: [
          {
            value: '清华软件园',
            label: '清华软件园'
          }, {
            value: '上海浦东软件园',
            label: '上海浦东软件园'
          }, {
            value: '杭州软件园',
            label: '杭州软件园'
          }, {
            value: '江苏软件园',
            label: '江苏软件园'
          }, {
            value: '东大软件园',
            label: '东大软件园'
          }, {
            value: '齐鲁软件园',
            label: '齐鲁软件园'
          }, {
            value: '西部软件园',
            label: '西部软件园'
          }, {
            value: '长沙软件园',
            label: '长沙软件园'
          }, {
            value: '北京软件产业基地',
            label: '北京软件产业基地'
          }, {
            value: '天津华苑软件园',
            label: '天津华苑软件园'
          }, {
            value: '湖北软件产业基地',
            label: '湖北软件产业基地'
          }, {
            value: '杭州高新软件园',
            label: '杭州高新软件园'
          }, {
            value: '福州软件园',
            label: '福州软件园'
          }, {
            value: '江西金庐软件园',
            label: '江西金庐软件园'
          }, {
            value: '西安软件园',
            label: '西安软件园'
          }, {
            value: '大连软件园',
            label: '大连软件园'
          }, {
            value: '广州软件园',
            label: '广州软件园'
          }, {
            value: '上海软件园',
            label: '上海软件园'
          }, {
            value: '南京软件园',
            label: '南京软件园'
          }, {
            value: '长春软件园',
            label: '长春软件园'
          }, {
            value: '厦门软件园',
            label: '厦门软件园'
          }, {
            value: '合肥软件园',
            label: '合肥软件园'
          }, {
            value: '云南软件园',
            label: '云南软件园'
          }, {
            value: '深圳软件园',
            label: '深圳软件园'
          }, {
            value: '兰州软件园',
            label: '兰州软件园'
          }, {
            value: '青岛软件园',
            label: '青岛软件园'
          }, {
            value: '吉林软件园',
            label: '吉林软件园'
          }, {
            value: '中部软件产业园',
            label: '中部软件产业园'
          }, {
            value: '无锡软件园',
            label: '无锡软件园'
          }, {
            value: '苏州软件园',
            label: '苏州软件园'
          }, {
            value: '常州软件园',
            label: '常州软件园'
          }, {
            value: '宁波国际软件园',
            label: '宁波国际软件园'
          }, {
            value: '河北省软件产业基地（石家庄）',
            label: '河北省软件产业基地（石家庄）'
          }, {
            value: '其他园区',
            label: '其他园区'
          }
        ],
        cr_entType: [{
          value: '国有企业',
          label: '国有企业'
        }, {
          value: '集体企业',
          label: '集体企业'
        }, {
          value: '私营企业',
          label: '私营企业'
        }, {
          value: '港澳台商投资企业',
          label: '港澳台商投资企业'
        }, {
          value: '外商投资企业',
          label: '外商投资企业'
        }, {
          value: '股份有限公司',
          label: '股份有限公司'
        }
        ],
        tradeKey: "",
        interval: null,
        action: "",
        typenum1: "10000",
        typenum2: "0000",
        descTypeName: "原创",
        isPublish: "已发表",
        devWay: "1",
        getWay: "1",
        rangeType: "1",
        rules: {
          softwareName: [
            { required: true, message: '请输入软件名称' }
          ],
          softwareShortName: [
            { required: true, message: '请输入软件简称' }
          ],
          typeNum: [
            { required: true, message: '请选择分类号' }
          ],
          softwareVersion: [
            { required: true, message: '请输入版本号' }
          ],
          devDate: [
            { required: true, message: '请选择开发日期' }
          ],
          publishedDate: [
            { required: true, message: '请选择首次发表日期' }
          ],
          publishedCountryName: [
            { required: true, message: '请选择首次发表国家' }
          ],
          publishedCityName: [
            { required: true, message: '请选择首次发表城市' }
          ],
        },
        rules2: {
          type: [
            { required: true, message: '请输入类别' }
          ],
          name: [
            { required: true, message: '请输入名称' }
          ],
          countryName: [
            { required: true, message: '请输入国籍' }
          ],
          applyProvince: [
            { required: true, message: '请输入省份' }
          ],
          applyCity: [
            { required: true, message: '请输入城市' }
          ],
          certificateType: [
            { required: true, message: '请输入证件类型' }
          ],
          certificateCode: [
            { required: true, message: '请输入证件号码' }
          ],
          garden: [
            { required: true, message: '请输入园区' }
          ],
          entType: [
            { required: true, message: '请输入企业类别' }
          ],
        },
        tradeKey: "",
        interval: null,
      }
    },
  created: function() {

  },
  mounted: function() {
    var that = this;
    var orderNum = this.$store.state.queryParam;
    console.log("orderNumorderNumorderNumorderNum");
    console.log(orderNum);
    this.orderNum = orderNum;
    if (!orderNum) {
      this.$message.warning(`订单参数错误`);
      this.$router.push("/autosubmitorder");
      return;
    }
    var channelCode = this.$store.state.channelCode;
    var itemCode = this.$store.state.itemCode;
    if (!channelCode || !itemCode) {
      this.$message.warning(`参数错误`);
      this.$router.push("/");
      return;
    }
    this.$root.postReq("/web/uploadCtl/getOssConfig", "").then(function (d) {
      that.d["key"] = "key";
      that.d["Bucket"] = d.Bucket;
      that.d["OSSAccessKeyId"] = d.OSSAccessKeyId;
      that.d["Signature"] = d.Signature;
      that.d["policy"] = d.policy;
      that.d["success_action_status"] = d.success_action_status;
      that.action = d.url;
    });
    this.$root.getReq("/web/pconfigCtl/getConfigValue", { configType: "invoiceTaxRate" }).then(function (d) {
      console.log(d);
      if (d != null && d.configValue != null && d.configValue != "") {
        that.invoiceTaxRate = Number(d.configValue);
      }
    });
    this.getOrderDetail();

  },
  methods: {
    getOrderDetail: function() {
      var orderNum = this.orderNum;
      var that = this;
      this.$root.getReq("/web/orderCtl/getSoftwareOrderDetailByOrderNum", { orderNum: orderNum }).then(function (d) {
        console.log("/web/orderCtl/getSoftwareOrderDetailByOrderNum.............>s");
        console.log(d);
        if (d && d.code == "1") {
          that.form = d.data.copyright;
          that.apply = d.data.apply;
          that.order = d.data.order;
          that.form.remark = d.data.order.remark;
        }
      });
    },
    chooseTypeNum: function() {
      this.showtypenum = true;
    },
    closetn: function() {
      this.showtypenum = false;
    },
    submittn: function() {
      this.showtypenum = false;
      this.form.typeNum = this.typenum1 + "-" + this.typenum2;
    },
    tobefore(){
      this.step = Number(this.step) - 1;
      this.step = this.step.toString();
    },
    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;
    },
    uploadsuccess(obj){
      console.log("this.form.fileUrl");
      console.log(obj.result);
      this.form.fileUrl = obj.result;
      console.log(this.form.fileUrl);
    },
    error(err){
      this.$message.warning(`上传失败，请重新上传`);
      console.log(err);
    },
    submitForm(formName) {
      var that = this;
      if (formName == "form" || formName == "apply") {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            var date1 = new Date(that.form.devDate);
            var date2 = new Date(that.form.publishedDate);
            that.form.devDate= date1.toLocaleString().split(" ")[0];
            that.form.publishedDate= date2.toLocaleString().split(" ")[0];
            that.step = Number(that.step) + 1;
          } else {
            console.log('error submit!!');
            return false;
          }
        });
      }
      if (formName == "save") {
        this.$root.showMask();
        if (this.order.orderStatus == "2") {
          this.$message.warning("该订单已取消，无法修改");
          this.getOrderDetail();
          that.$root.hideMask();
          return
        }
        console.log(this.form);
        var tm = { orderNum: this.order.orderNum, reqtype: "1" };
        var tmpApply = this.apply;
        tmpApply.orderNum = this.order.orderNum;
        tmpApply.remark = this.form.remark;
        var customer = {
          orderNum: this.order.orderNum, customerContact: this.apply.customerContact, mobile: this.apply.mobile
        };
        var obj = { tm: tm, apply: tmpApply, customer: customer, copyright: this.form };
        console.log(obj);
        that.$root.postReq("/web/orderCtl/updateOrderDetailByOrderNum", obj).then(function (d) {
          if (d.code == "1") {
            that.$message.success(`修改成功`);
            that.getOrderDetail();
          } else if (d.code = "-100" && d.msg) {
            console.log(d.msg);
            that.$message.warning(d.msg);
            that.getOrderDetail();
          } else {
            that.$message.warning("操作失败");
          }
          that.$root.hideMask();
        }).catch(function (e) {
          that.$root.hideMask();
        });
      }
    },
    wxPay: function() {
      if (this.pay.paymentPlatformType == "offline") {
        this.payconfirm = true;
        return;
      }
      var amount = Number(this.order.totalSum);
      if (this.order.totalSum) {
        this.payconfirm = true;
        if (!this.order.orderNum) {
          return;
        }
        this.$root.postReq("/web/tradeCtl/createUnifiedOrder2", { amount: 0.01, desc: "订单支付", orderNum: this.order.orderNum }).then(d => {
          console.log("createUnifiedOrder");
          console.log(d);
          if (d.data) {
            var o = { id: this.order.id, payQr: d.data.qrurl, payQrCreateTime: new Date().getTime(), payOrderNum: d.data.tradekey };
            this.$root.getReq("/web/orderCtl/orderUpdate", o).then(dd => {
              console.log("dd");
              console.log(dd);
              if (dd.code == '1') {
                this.qrcode = d.data.qrurl;
                this.tradekey = d.data.tradekey + "_" + new Date().getTime();
                this.checkPayState();
              }
            });

          } else {
            this.$message.warning(`获取微信支付码失败`);
          }
        });
      }

    },
    closePayConfirm(){
      this.payconfirm = false;
      this.showtypenum = false;
      var self = this;
      if (this.tradekey) {
        var ts = this.tradekey.split("_");
        var tradeKey = ts[0];
        self.tradeKey = "";
        window.clearInterval(self.interval);
      }
    },
    checkPayState(){
      console.log("==================================================");
      var self = this;
      var userinfo = this.$store.state.currentUser;
      if (this.tradekey != "") {
        var ts = this.tradekey.split("_");
        var tradeKey = ts[0];
        var startTime = Number(ts[1]);
        setTimeout(function () {
          var inth = setInterval(function () {

            if (self.tradekey == "") {
              console.log("结束");
              window.clearInterval(inth);
              return;
            }
            console.log(self.order.orderNum);
            self.$root.getReq("/web/orderCtl/findOneByOrderNum", { orderNum: self.order.orderNum }).then(d => {
              console.log("findOneByOrderNum");
              console.log(d);
              if (d && d.orderStatus == "4") {
                self.order = d;
                self.payOrderNum = "";
                self.tradekey = "";
                window.clearInterval(inth);
                self.$router.push("/autosubmitorder");
                return;
              } else {
                var passTime = (new Date().getTime() - startTime) / 1000;
                var p = Math.round((passTime / 300) * 100);
                console.log("passed seconds " + passTime);
                if (passTime > 300) {
                  self.payOrderNum = "";
                  clearInterval(inth);
                  self.$root.postReq("/web/tradeCtl/closeOrder", { idkey: tradeKey }).then(d => {
                    self.wxPay();
                  });
                }
              }
            });
          }, 10000);
          self.interval = inth;
        }, 5000)
      }
    },
    orderUpdate(){
      if (!this.order.id) {
        return
      }
      var self = this;
      var obj = this.pay;
      console.log("this.order");
      console.log(this.order.id);
      obj["id"] = this.order.id;
      obj["orderStatus"] = "64";
      console.log(obj);
      this.$root.getReq("/web/orderCtl/orderUpdate", obj).then(d => {
        console.log("d");
        console.log(d);
        self.$router.push("/autosubmitorder");
      });
    }
  },
  computed: {
    headStyle: function() {
      return { "background-color": "white" };
    }
  },
  vname: "gsb-softwarecrsubmit"
}
