(function() { Vue.component('register-form', { template: '
\ \
\
\
\
\
注册
\
\
\ \
\
\ \
\
\ \ \
\
\ \ \
\

密码格式为6-16位,不允许有空格

\ \ \
\
\
\
\
', //
\ // \ //
\ //
\ // \ // 获取验证码\ //
\ props: [], data: function() { return { IDCard: "", phone: "", password: "", rePassword: "", captcha: "", toggle: true, idCardType:1, idCardTypes:[ {value:1,name:'身份证'}, // {value:2,name:'军官证'}, ], pwdType:false, codeMsg:"获取验证码", } }, methods: { register: function() { var vm = this if(!vm.toggle){ alert("协议未勾选!"); return ; } if(!isCardNo(vm.IDCard)) { return ; } if(!vm.Password) { alert("登录密码不能为空!"); return false; } if(!vm.captcha) { alert("验证码不能为空!"); return false; } if(!vm.toggle) { alert("未确认是否阅读并接受条款"); return false; } // location.href = "../login/login.html" //连接注册后台接口 var data = { idCardNo: vm.IDCard, password: vm.password, } var params = { userJsonData: JSON.stringify(data), appId: httpRequest.client_id } loginAPI.registe(params).then(function(res) { if(res.successFlg) { alert("注册成功"); sessionStorage.setItem("userAgent", JSON.stringify(res)); var data1 = { grant_type: httpRequest.grant_type, client_id: httpRequest.client_id, idCardNo: vm.IDCard, password: vm.password, } loginAPI.accessToken(data1).then(function(oauthInfo) { sessionStorage.setItem("oauthInfo", JSON.stringify(oauthInfo)); }).catch(function(e) { console.log("获取accessToken失败") }) vm.getJueSeData(res); } else { alert(res.errorMsg); } }).catch(function(err) { alert(err.errorMsg); }) }, gologin: function() { location.href = "../../login/html/login.html" }, getCode: function(num){ var vm=this; if(num<0){ vm.codeMsg="获取验证码"; }else{ setTimeout(function(){ num--; vm.codeMsg="("+num+"s)重新获取"; vm.getCode(num); },1000) } }, changePwdType:function(ev){ var obj=$(ev.target); if(obj.hasClass('type-change-icon-active')){ obj.removeClass('type-change-icon-active'); obj.parent().find('.form-password').attr('type','password') }else{ obj.addClass('type-change-icon-active'); obj.parent().find('.form-password').attr('type','text') } }, getJueSeData: function(userAgent) { var vm = this; //获取居民权限接口 loginAPI.findByUserId({ userId: userAgent.id }).then(function(data) { sessionStorage.setItem("roleList", JSON.stringify(data.detailModelList)); //缓存角色列表 // location.href = "../../../home/html/home.html"//跳转到主页面 location.href = "../../../page/mine/html/personal-info.html" }) }, }, watch: { Password: function(newVal, oldVal) { var val = newVal.toString(); var reg = /\s+/g; //去除空格 if(reg.test(val)) { this.Password = oldVal; } }, idCardType:function(val){ for(var i in this.idCardTypes){ if(this.idCardTypes[i].value==val){ $('.idCardType').attr('placeholder','请输入'+this.idCardTypes[i].name+'号码'); break; } } } } }); function isCardNo(card, phone) { // 身份证号码为15位或者18位,15位时全为数字,18位前17位为数字,最后一位是校验位,可能为数字或字符X var iscard = false; var reg1 = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/; if(reg1.test(card) === false) { alert("身份证号输入不合法"); } else { iscard = true } return iscard; } })()