{
  template: '${tmpl}',
    data: function() {
      var that = this;
      var validateMethod = function (rule, value, callback) {
        console.log(rule);
        if (rule.field == "mobile") {
          if (/^1[23456789]\d{9}$/.test(value) == false) {
            return callback(new Error("请输入正确格式的手机号"));
          } else {
            return callback();
          }
        }
        if (rule.field == "code") {
          if (that.form1.code.length != 6) {
            return callback(new Error("输入验证码有误，请重新输入"));
          }
        }
        return callback();
      };
      return {
        ldms: [],
        activeIndex: "1",
        loginUrl: "",
        form1: {
          mobile: "",
          password: "",
          code: "",
        },
        form2: {
          username: "",
          password: "",
        },
        form3: {
          mobile: "",
          code: "",
          password: "",
        },
        form4: {
          mobile: "",
          code: "",
          password: "",
        },
        a: true,
        b: false,
        c: false,
        Num: 60,
        Num2: 60,
        Num3: 60,
        rcode: "",
        rules1: {
          username: [
            { required: true, message: '请输入账号', trigger: 'blur' },
          ],
          password: [
            { required: true, message: '请输入密码', trigger: 'blur' },
          ],
          mobile: [
            { required: true, message: '请输入手机号', trigger: 'blur' },
            { validator: validateMethod, trigger: 'blur' },
          ],
          code: [
            { required: true, message: '请输入手机接收到的验证码', trigger: 'blur' },
            { validator: validateMethod, trigger: 'blur' },
          ],
        },
        rules2: {
          username: [
            { required: true, message: '请输入账号', trigger: 'blur' },
          ],
          password: [
            { required: true, message: '请输入密码', trigger: 'blur' },
          ],
        },
        rules3: {
          mobile: [
            { required: true, message: '请输入手机号', trigger: 'blur' },
            { validator: validateMethod, trigger: 'blur' },
          ],
          code: [
            { required: true, message: '请输入手机接收到的验证码', trigger: 'blur' },
            { validator: validateMethod, trigger: 'blur' },
          ],
          password: [
            { required: true, message: '请输入密码', trigger: 'blur' },
            { min: 6, max: 18, message: '长度在 6 到 18 个字符', trigger: 'blur' }
          ],
        },
        rules4: {
          mobile: [
            { required: true, message: '请输入手机号', trigger: 'blur' },
            { validator: validateMethod, trigger: 'blur' },
          ],
          code: [
            { required: true, message: '请输入手机接收到的验证码', trigger: 'blur' },
            { validator: validateMethod, trigger: 'blur' }
          ],
          password: [
            { required: true, message: '请输入密码', trigger: 'blur' },
            { min: 6, max: 18, message: '长度在 6 到 18 个字符', trigger: 'blur' }
          ],
        },
        vCodeLoding: false,
      }
    },
  mounted: function() {
    this.$root.isLogin = false;
  },
  created: function() {
    console.log(this.pfooterinfo);
    if (this.$root.channelName == "bw") {
      this.loginUrl = "/imgs/loginbg.png";
    }
  },
  destroyed() {
    this.$root.isLogin = false;
  },
  methods: {
    handleSelect(key, keyPath) {
      console.log(key, keyPath);
      this.activeIndex = key;
    },
    resetall(){
      this.form1.mobile = "";
      this.form1.code = "";
      this.form2.username = "";
      this.form2.password = "";
      this.form3.mobile = "";
      this.form3.code = "";
      this.form3.password = "";
      this.form4.mobile = "";
      this.form4.code = "";
      this.form4.password = "";
    },
    rsetpassword(){
      this.a = false;
      this.b = true;
      this.c = false;
      this.rcode = "";
      this.resetall();
    },
    login(){
      switch (this.$root.channelName) {
        case "bw":
          this.$router.push({ path: `/bw/login` });
          break;

        default:
          break;
      }

      this.a = true;
      this.b = false;
      this.c = false;
      this.rcode = "";
      this.resetall();
    },
    register(){
      this.a = false;
      this.b = false;
      this.c = true;
      this.rcode = "";
      this.resetall();
    },
    obtaincode1(){

      let obj = this.$root.copyParams({ mobile: this.form1.mobile }, "getVerifyCode", "/auth/accessAuth/springBoard");
      this.$root.postReq("/web/trademark/tmqueryCtl/doPost", obj).then((d) => {
        if (d.status == 0) {
          this.vCodeLoding = true;
          let date = 60;
          let timer = setInterval(() => {
            $('#registerVcode').text(date--);
            if (date < 1) {
              clearInterval(timer);
              this.vCodeLoding = false;
              $('#registerVcode').text('获取验证码');
            }
          }, 1000);

          console.log("返回信息", d);
        } else {
          this.$message(d.msg);
          console.log(d.msg);
        }
      });
      /*
      this.fetchVcode(this.form1.mobile)
      
      */
    },

    checklogin1(){
      var that = this;
      var obj = {
        mobile: that.form1.mobile,
        password: that.form1.password,
        vcode: that.form1.code,
      };
      that.$refs.form1.validate(valid => {
        if (valid) {
          var userInfo = that.$root.copyParams(obj, "userPinByRegister", "/auth/accessAuth/springBoard");
          console.log(userInfo, 'mmmmmmmmmmmmmmmmmmmmmm');
          this.$root.postReq("/web/trademark/tmqueryCtl/doPost", userInfo).then((d) => {
            console.log("返回信息", d.msg);
            if (d.status == 0) {
              this.$message({
                message: '注册成功!',
                type: 'success'
              });
              this.$router.push(`/${this.$root.channelName}/login`);
              console.log("返回信息", d)
            } else if (d.status == 2030) {
              console.log(d.msg);
              this.$message(d.msg);
            } else if (d.status == 2060) {
              console.log(d.msg);
              this.$message(d.msg);
            } else {
              this.$message(d.msg);
              console.log(d.msg);
            }
          });
        } else {
          console.log('输入有误')
        }
      })
    },
    checklogin2(){
      var that = this;
      var obj = {
        userName: that.form2.username,
        password: that.form2.password
      };
      that.$refs.form2.validate(valid => {
        if (valid) {
          that.$root.postReq("/web/userCtl/login", { u: obj }).then(function (d) {
            console.log(d.msg);
            if (d.status == 0) {
              that.$root.refreshLoginState(() => {
                console.log("....................................................................................innner");
                var afto = localStorage.getItem("afterLogin");
                if (afto) {
                  that.$root.pushx(JSON.parse(afto));
                  localStorage.removeItem("afterLogin");
                  that.$root.removetab("/login");
                } else {
                  location.reload();
                }
              });
            } else {
              that.$message({
                type: 'error',
                message: '用户名或密码错误，请重试.'
              });
            }
          })
        }
      });
    },
    sumbitreset(){
      var that = this;
      var obj = {
        mobile: this.form3.mobile,
        password: this.form3.password
      };
      that.$refs.form3.validate(valid => {
        if (valid) {
          that.$root.postReq("/web/userCtl/resetPassword", obj).then(function (d) {
            if (d.status == 0) {
              that.$message({
                type: 'success',
                message: '密码重置成功'
              });
            }
          })
        }
      })
    },
    submitregister(){
      var that = this;
      var obj = {
        mobile: this.form4.mobile,
        password: this.form4.password
      };
      that.$refs.form4.validate(valid => {
        if (valid) {
          that.$root.postReq("/web/userCtl/submitregister", obj).then(function (d) {
            if (d.status == 0) {
              that.$message({
                type: 'success',
                message: '注册成功,请登录'
              });
              that.login();
            } else if (d.status == 1) {
              that.$message({
                type: 'error',
                message: '该手机号码已注册'
              });
            }
          })
        }
      })
    },
    fetchVcode(mobilenum){
      var that = this;
      if (/^1[23456789]\d{9}$/.test(mobilenum) == false) {
        this.$alert('请输入正确格式的手机号码', '提示', {
          confirmButtonText: '确定',
          callback: action => {
          }
        });
        return;
      };
      var timer = setInterval(function () {
        console.log("----------getNumber-----------");
        $("#loginCode").attr("disabled", "disabled");
        $("#loginCode").css("cursor", "not-allowed");
        $("#loginCode").text(that.Num + "秒后重新获取");
        console.log(that.Num);
        if (that.Num > 0) {
          console.log(that.Num);
          that.Num--;
        } else {
          $("#loginCode").attr("disabled", false);
          $("#loginCode").text("获取验证码");
          that.Num = 60;
          clearInterval(timer);
        }
      }, 1000);
      this.$root.postReq("/web/userCtl/fetchVcode", { mobile: mobilenum }).then(function (d) {
        if (d.status == 0) {
          that.rcode = d.data.vcodestr;
        }
      })

    },
    validmethod: function (rule, value, callback) {
      console.log("code validdate");
      var self = this;
      var fm = this.currentFrm.getFormModel();
      return callback();
    },
    sbhandler: function () {
      var self = this;
      var fm = this.$refs.loginFrm.getFormModel();
      this.$refs.loginFrm.validate(function (v) {
        if (v) {
          self.$root.postReq("/web/userCtl/login", { u: fm }).then(function (d) {
            if (d.status == 0) {
              console.log("....................................................................................");
              self.$root.refreshLoginState(() => {
                console.log("....................................................................................innner");
                var afto = localStorage.getItem("afterLogin");
                if (afto) {
                  self.$root.pushx(JSON.parse(afto));
                  localStorage.removeItem("afterLogin");
                  self.$root.removetab("/login");
                } else {
                  location.reload();
                }
              });
            } else {
              self.$message({
                type: 'error',
                message: '用户名或密码错误，请重试.'
              });
            }
          });
        }
      });
    },

  },
  vname: "gsb-login"
}
