{
  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' }
          ],
        },
      }
    },
  mounted: function() {

  },
  created: function() {
    console.log(this.pfooterinfo);
    if (this.pfooterinfo && this.pfooterinfo.loginUrl) {
      this.loginUrl = this.pfooterinfo.loginUrl;
    } else {
      this.loginUrl = "https://gsb-zc.oss-cn-beijing.aliyuncs.com//zc_41110157500594182420192913391824zhuce_background.png";
    }
  },
  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) {
          console.log("返回信息", d);
        } else {
          console.log(d.msg);
        }
      });
      /*
      this.fetchVcode(this.form1.mobile)
      
      */
    },
    obtaincode2(){
      var that = this;
      if (/^1[23456789]\d{9}$/.test(that.form3.mobile) == false) {
        that.$alert('请输入正确格式的手机号码', '提示', {
          confirmButtonText: '确定',
          callback: action => {
          }
        });
        return;
      };
      that.$root.postReq("/web/userCtl/getUserByMobile", { mobile: that.form3.mobile }).then(function (d) {
        if (d.code == 0) {
          var timer = setInterval(function () {
            console.log("----------getNumber-----------");
            $("#resetCode").attr("disabled", "disabled");
            $("#resetCode").css("cursor", "not-allowed");
            $("#resetCode").text(that.Num2 + "秒后重新获取");
            console.log(that.Num2);
            if (that.Num2 > 0) {
              console.log(that.Num2);
              that.Num2--;
            } else {
              $("#resetCode").attr("disabled", false);
              $("#resetCode").text("获取验证码");
              that.Num2 = 60;
              clearInterval(timer);
            }
          }, 1000);
          that.$root.postReq("/web/userCtl/fetchVcode", { mobile: that.form3.mobile }).then(function (d) {
            console.log(d);
            if (d.status == 0) {
              that.rcode = d.data.vcodestr;
            }
          })
        } else {
          that.$message({
            type: 'error',
            message: '用户尚未注册'
          });
        }
      })
    },
    obtaincode3(){
      var that = this;
      if (/^1[23456789]\d{9}$/.test(that.form4.mobile) == false) {
        that.$alert('请输入正确格式的手机号码', '提示', {
          confirmButtonText: '确定',
          callback: action => {
          }
        });
        return;
      };
      that.$root.postReq("/web/userCtl/getUserByMobile", { mobile: that.form4.mobile }).then(function (d) {
        if (d.code == -1) {
          var timer = setInterval(function () {
            console.log("----------getNumber-----------");
            $("#registerCode").attr("disabled", "disabled");
            $("#registerCode").css("cursor", "not-allowed");
            $("#registerCode").text(that.Num3 + "秒后重新获取");
            console.log(that.Num3);
            if (that.Num3 > 0) {
              console.log(that.Num3);
              that.Num3--;
            } else {
              $("#registerCode").attr("disabled", false);
              $("#registerCode").text("获取验证码");
              that.Num3 = 60;
              clearInterval(timer);
            }
          }, 1000);
          that.$root.postReq("/web/userCtl/fetchVcode", { mobile: that.form4.mobile }).then(function (d) {
            if (d.status == 0) {
              console.log(d);
              that.rcode = d.data.vcodestr;
            }
          })
        } else {
          that.$message({
            type: 'error',
            message: '用户已存在, 请修改并重试'
          });
        }
      })

    },
    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) => {
            if (d.status == 0) {
              this.$root.channelUserId = d.data.channelUserId;
              console.log("返回信息", d)
            } else if (d.status == 2030) {
              console.log(d.msg);
            } else if (d.status == 2060) {
              console.log(d.msg);
            } else {
              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) {
            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"
}
