{
  template:'${tmpl}',
  data:function(){
      return {
          ldms:[],
          vcode:123
      }
  },
  mounted:function(){
      this.ldms=[
          {
              "title":"用户注册",
              "colnum":2,
               ctls:[
                 {"type":"input","label":"账号","prop":"userName","placeHolder":"请输入登录账号","style":"width:150px",rules:[ { "validator":"validatex","trigger": 'blur' }, { "required": true, "message": '  ', "trigger": 'blur' },,]},
                 {"type":"input","label":"昵称","prop":"nickName","placeHolder":"请输入昵称","style":"width:150px",rules:[ { "required": true, "message": '  ', "trigger": 'blur' },]},
                 {"type":"input","label":"密码","prop":"password","placeHolder":"请输入登录密码","style":"width:150px",rules:[ { "required": true, "message": '  ', "trigger": 'blur' },]},
                 {"type":"input","label":"密码确认","prop":"pwdconfirm","placeHolder":"请输入登录密码确认","style":"width:150px",rules:[   { "validator":"validatex","trigger": 'blur' }, { "required": true, "message": '  ', "trigger": 'blur' },]},            
                 {"type":"input","label":"电话","prop":"mobile","placeHolder":"请输入电话","style":"width:150px",rules:[ { "validator":"validatex","trigger": 'blur' },{ "required": true, "message": '  ', "trigger": 'blur' },]},
                 {"type":"btn","label":"获取验证码","prop":"fetchvcode","placeHolder":"","style":{"width":"150px","margin-left":"0px","margin-top":"40px"},"face":"primary"},
              ]
            },
            {
                "title":null,
                "colnum":2,
                 ctls:[
                    {"type":"input","label":"验证码","prop":"vcode","placeHolder":"请输入验证码","style":{"width":"150px"},rules:[ { "validator":"validatex","trigger": 'blur' },{ "required": true, "message": '  ', "trigger": 'blur' },]},
                   {"type":"btn","label":"开始提交","prop":"btnLogin","placeHolder":"请输入手机号","style":{"width":"150px","margin-left":"0px","margin-top":"40px"},"face":"warning"},
                ]
              },
      ];

  },
  created:function(){

  },
  methods:{
      validmethod:async function (rule,value,callback) { 
          console.log("code validdate");
          var self=this;
          var fm=this.$refs.regFrm.getFormModel();
        
          if(rule.field=="userName"){
              console.log(rule);
            var scallbak=callback;
            var d=  await this.$root.postReq("/web/auth/userCtl/checkSameName",{uname:value});
            if(d && d.status==0){
                if(d.data.isExist){
                    return callback("已存在账号名称!");
                }
            }else{
                return callback("服务异常，请稍后再试!");
            }
          }
          if(rule.field=="pwdconfirm"){
              var pwv=fm.password;
              if(value!=pwv){
                  return callback("两次输入的密码不相同!");
              }
          }
          if(rule.field=="mobile"){
            if(/^1[23456789]\d{9}$/.test(value) == false){
                return callback("请检查号码格式!");
            }
          }
          if(rule.field=="vcode"){
            if(value != this.vcode){
                return callback("验证码有误，可重新获取!");
            }
          }
          console.log(rule);
          return callback();
      },
      registerclick:function (fm,prop){
          var self=this;
          var fm=this.$refs.regFrm.getFormModel();
          if(prop=="fetchvcode"){
            if(/^1[23456789]\d{9}$/.test(fm.mobile) == false){

                this.$refs.regFrm.overBtnLoading(prop);
                 return;
              }else{
                self.$root.postReq("/web/auth/userCtl/fetchVcode",{u:fm.mobile}).then(function(d){
                    if(d.status==0){
                        self.vcode=d.data.vcodestr;
                        setTimeout(()=>{
                            self.$refs.regFrm.overBtnLoading(prop);
                        },3000);
                     
                    }           
                  });
              }
              return;
          }
          if(this.vcode!=fm.vcode){
            this.$refs.regFrm.overBtnLoading(prop);
            return;
          }
          this.$refs.regFrm.validate(function(v){
              if(v){
                  console.log(v);
                  self.$refs.regFrm.overBtnLoading(prop);
                  self.$root.postReq("/web/auth/userCtl/register",{u:fm}).then(function(d){
                      if(d.status==0){
                          console.log(d.data);
                          location.href=d.data.jumpUrl;
                      }
                    });
              }else{
                self.$refs.regFrm.overBtnLoading(prop);
              }
          });
       },
   
  },
  vname:"gsb-register"
}
