var app = new Vue({
  el: "#app",
  data: function () {
    return {
      companyId: 0,
      nameA: "",
      name: "",
    }
  },
  created: function () {
  },
  mounted: function () {
    var self = this;
    self.companyId = this.getUrlParam("comid") || 0;
    console.log(self.companyId, "-------------------------");
    self.getCompany();
  },
  methods: {
    postReq(path, data) {
      return axios.post(path, data).then(function (r) {
        return r.data ? r.data : null;
      })
    },
    getCompany() {
      var self = this;
      this.$root.postReq("/web/ecompanyCtl/wxsignCompany", {
        id: this.companyId
      }).then(rd => {
        if (rd.status == 0) {
          self.name = rd.data.name;
          self.nameA = rd.data.nameA;
        } else {
          self.$message.error(`公司不存在`);
        }
      });
    },
    getOpenId() {
      var self = this;
      if(self.openId) {
        return;
      }
      //调用接口,根据用户名判断是否协议
      this.$root.postReq("/web/wxCtl/wxuseropenid", {
        code: self.code
      }).then(rd => {
        if (rd.status == 0) {
          self.openId = rd.data;
          self.btnloading = false;
        } else {
          self.$message.error(`获取openId失败，请退出重试`);
        }
      });
    },
    getUrlParam(name) {
      var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
      var r = window.location.search.substr(1).match(reg);
      return r ? unescape(r[2]) : null;
    },
    btnclick: function (pfm, code) {
    },
    goback() {
      console.log(111111111111);
      window.history.go(-1);
    },
  },
});