{
  template: '${tmpl}',
  data: function () {
    return {
      cs: [],
      eaccount_id: 0,
      signloading: false,
      eaccount: {},
      isInsure: true,
      isShowInsure: false,
      isShowProductInfo: false,
      isShowServiceInfo: false,
    }
  },
  mounted: function () {
    var that = this;

    this.eaccount_id = localStorage.getItem("eaccount_id") || 0;

    var ecid = localStorage.getItem("ecid");
    var ecompany_id = localStorage.getItem("ecompany_id");
    if(this.eaccount_id && this.eaccount_id != "undefined") {
      if(ecid && ecid != "null" && ecid != "undefined") {
        this.$root.postReq("/web/etemplateCtl/info", {
          id: ecid,
        }).then(function (d) {
          if (d.status == 0) {
            var ecompany = d.data;
            ecompany.isInsure = true;
            ecompany.companyid = d.data.ecompany_id;
            ecompany.companyname = d.data.ecompany.name;
            that.cs = [ecompany];
            console.log(that.cs, "aaaaaaaaaaaaaaaaaaaaaaaaaaaa ecid");
          }
        });
      } else if (ecompany_id && ecompany_id != "null" && ecompany_id != "undefined") {
        this.$root.postReq("/web/etemplateCtl/findReadyContracts", {
          ecompany_id: ecompany_id,
          eaccount_id: this.eaccount_id
        }).then(function (d) {
          if (d.status == 0) {
            if(d.data) {
              for(var row of d.data) {
                row.isInsure = true;
              }
            }
            that.cs = d.data;
            console.log(that.cs);
          }
        });
      } else {
        this.$router.push("/ecompany/signinfo");
      }

      setTimeout(() => {
        localStorage.removeItem("h5router");
      }, 5000);
    } else {
      this.$router.push("/ecompany/signinfo");
    }
    /* this.getLoginUser(); */
    this.getAccount();
  },
  created: function () {

  },
  methods: {
    showProductInfo() {
      this.isShowProductInfo  = true;
      window.location.href = "http://192.168.18.125:3000/pdfh5?pdfname=productInfo&pdftitle=产品条款";
    },
    showServiceInfo() {
      this.isShowServiceInfo  = true;
      window.location.href = "http://192.168.18.125:3000/pdfh5?pdfname=serviceInfo&pdftitle=服务协议";
    },
    testisInsure() {
      console.log(this.isInsure);
    },
    docheck(item) {
      item.isInsure = !item.isInsure;
    },
    startsign(item) {
      item.isInsure = false;

      var self = this;
      self.signloading = true;

      var id = item.id;
      var ecompany_id = localStorage.getItem("ecompany_id");
      var apply_id = localStorage.getItem("apply_id") || "";

      this.$root.postReq("/web/econtractCtl/genContract", {
        etemplateid: id,
        eaccount_id: self.eaccount_id,
        apply_id: apply_id,
        isInsure: item.isInsure,
      }).then(function (d) {
        if (d.status == 0) {
          if (d.data.esignUrl) {
            window.location.href = d.data.esignUrl;
          }
        } else {
          self.$alert(d.msg || "系统忙，请稍候重试", '提示', {
            confirmButtonText: '确定',
            callback: action => {}
          });
        }
        setTimeout(() => {
          self.signloading = false;  
        }, 2000);
      });
    },
    getAccount() {
      if (!this.eaccount_id) {
        return;
      }
      var self = this;
      this.$root.postReq("/web/usereaccountCtl/findOne", {
        id: this.eaccount_id
      }).then(function (d) {
        if (d.status == 0) {
          self.eaccount = d.data;
        }
      });
    },
    showInsureInfo() {
      this.isShowInsure = true;

    }

    /*
    getLoginUser : function (){
      var self =this;
      this.$root.postReq("/web/userCtl/loginUser",{}).then(function(d){
        if(d.status==0){
          self.loginUser = d.data;
        }
      });
    }
    */
  },
  vname: "gsb-waitsign"
}