chunk-f0a70954.30799d8b.js 7.8 KB

1
  1. (window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-f0a70954"],{1348:function(e,t,r){"use strict";r.r(t);var s=function(){var e=this,t=this,r=t._self._c;return r("div",{staticClass:"main user-layout-register"},[t._m(0),r("a-form",{ref:"formRegister",attrs:{autoFormCreate:function(t){e.form=t},id:"formRegister"}},[r("a-form-item",{attrs:{fieldDecoratorId:"username",fieldDecoratorOptions:{rules:[{required:!0,message:"用户名不能为空"},{validator:this.checkUsername}],validateTrigger:["change","blur"],validateFirst:!0}}},[r("a-input",{attrs:{size:"large",type:"text",autocomplete:"false",placeholder:"请输入用户名"}})],1),r("a-popover",{attrs:{placement:"rightTop",trigger:"click",visible:t.state.passwordLevelChecked}},[r("template",{slot:"content"},[r("div",{style:{width:"240px"}},[r("div",{class:["user-register",t.passwordLevelClass]},[t._v("强度:"),r("span",[t._v(t._s(t.passwordLevelName))])]),r("a-progress",{attrs:{percent:t.state.percent,showInfo:!1,strokeColor:t.passwordLevelColor}}),r("div",{staticStyle:{"margin-top":"10px"}},[r("span",[t._v("请至少输入 8 个字符。请不要使用容易被猜到的密码。")])])],1)]),r("a-form-item",{attrs:{fieldDecoratorId:"password",fieldDecoratorOptions:{rules:[{required:!1},{validator:this.handlePasswordLevel}],validateTrigger:["change","blur"],validateFirst:!0}}},[r("a-input",{attrs:{size:"large",type:"password",autocomplete:"false",placeholder:"至少8位密码,区分大小写"},on:{click:t.handlePasswordInputClick}})],1)],2),r("a-form-item",{attrs:{fieldDecoratorId:"password2",fieldDecoratorOptions:{rules:[{required:!0,message:"至少8位密码,区分大小写"},{validator:this.handlePasswordCheck}],validateTrigger:["change","blur"],validateFirst:!0}}},[r("a-input",{attrs:{size:"large",type:"password",autocomplete:"false",placeholder:"确认密码"}})],1),r("a-form-item",{attrs:{fieldDecoratorId:"email",fieldDecoratorOptions:{rules:[{required:!0,type:"email",message:"请输入正确的邮箱地址"},{validator:this.handleEmailCheck}],validateTrigger:["change","blur"],validateFirst:!0}}},[r("a-input",{attrs:{size:"large",type:"text",placeholder:"邮箱"}})],1),r("a-form-item",{attrs:{fieldDecoratorId:"mobile",fieldDecoratorOptions:{rules:[{required:!0,pattern:/^1[3456789]\d{9}$/,message:"请输入正确的手机号"},{validator:this.handlePhoneCheck}],validateTrigger:["change","blur"],validateFirst:!0}}},[r("a-input",{attrs:{size:"large",placeholder:"11 位手机号"}},[r("a-select",{attrs:{slot:"addonBefore",size:"large",defaultValue:"+86"},slot:"addonBefore"},[r("a-select-option",{attrs:{value:"+86"}},[t._v("+86")]),r("a-select-option",{attrs:{value:"+87"}},[t._v("+87")])],1)],1)],1),r("a-row",{attrs:{gutter:16}},[r("a-col",{staticClass:"gutter-row",attrs:{span:16}},[r("a-form-item",{attrs:{fieldDecoratorId:"captcha",fieldDecoratorOptions:{rules:[{required:!0,message:"请输入验证码"}],validateTrigger:"blur",validateFirst:!0}}},[r("a-input",{attrs:{size:"large",type:"text",placeholder:"验证码"}},[r("a-icon",{style:{color:"rgba(0,0,0,.25)"},attrs:{slot:"prefix",type:"mail"},slot:"prefix"})],1)],1)],1),r("a-col",{staticClass:"gutter-row",attrs:{span:8}},[r("a-button",{staticClass:"getCaptcha",attrs:{size:"large",disabled:t.state.smsSendBtn},domProps:{textContent:t._s(t.state.smsSendBtn?t.state.time+" s":"获取验证码")},on:{click:function(e){return e.stopPropagation(),e.preventDefault(),t.getCaptcha.apply(null,arguments)}}})],1)],1),r("a-form-item",[r("a-button",{staticClass:"register-button",attrs:{size:"large",type:"primary",htmlType:"submit",loading:t.registerBtn,disabled:t.registerBtn},on:{click:function(e){return e.stopPropagation(),e.preventDefault(),t.handleSubmit.apply(null,arguments)}}},[t._v("注册\n ")]),r("router-link",{staticClass:"login",attrs:{to:{name:"login"}}},[t._v("使用已有账户登录")])],1)],1)],1)},a=[function(){var e=this,t=e._self._c;return t("h3",[t("span",[e._v("注册")])])}],i=r("ac0d"),o=(r("7ded"),r("0fea")),n=r("4ec3");function l(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,s)}return r}function c(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?l(Object(r),!0).forEach((function(t){d(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):l(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function d(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var u={0:"低",1:"低",2:"中",3:"强"},p={0:"error",1:"error",2:"warning",3:"success"},f={0:"#ff0000",1:"#ff0000",2:"#ff7e05",3:"#52c41a"},m={name:"Register",components:{},mixins:[i["b"]],data:function(){return{form:null,state:{time:60,smsSendBtn:!1,passwordLevel:0,passwordLevelChecked:!1,percent:10,progressColor:"#FF0000"},registerBtn:!1}},computed:{passwordLevelClass:function(){return p[this.state.passwordLevel]},passwordLevelName:function(){return u[this.state.passwordLevel]},passwordLevelColor:function(){return f[this.state.passwordLevel]}},methods:{checkUsername:function(e,t,r){var s={username:t};Object(n["h"])(s).then((function(e){e.success?r():r("用户名已存在!")}))},handleEmailCheck:function(e,t,r){var s={email:t};Object(n["h"])(s).then((function(e){e.success?r():r("邮箱已存在!")}))},handlePasswordLevel:function(e,t,r){var s=0,a=/^(?=.*[a-zA-Z])(?=.*\d)(?=.*[~!@#$%^&*()_+`\-={}:";'<>?,./]).{8,}$/;a.test(t)||r(new Error("密码由8位数字、大小写字母和特殊符号组成!")),/[0-9]/.test(t)&&s++,/[a-zA-Z]/.test(t)&&s++,/[^0-9a-zA-Z_]/.test(t)&&s++,this.state.passwordLevel=s,this.state.percent=30*s,s>=2?(s>=3&&(this.state.percent=100),r()):(0===s&&(this.state.percent=10),r(new Error("密码强度不够")))},handlePasswordCheck:function(e,t,r){var s=this.form.getFieldValue("password");void 0===t&&r(new Error("请输入密码")),t&&s&&t.trim()!==s.trim()&&r(new Error("两次密码不一致")),r()},handlePhoneCheck:function(e,t,r){var s={phone:t};Object(n["h"])(s).then((function(e){e.success?r():r("手机号已存在!")}))},handlePasswordInputClick:function(){this.isMobile()?this.state.passwordLevelChecked=!1:this.state.passwordLevelChecked=!0},handleSubmit:function(){var e=this;this.form.validateFields((function(t,r){if(!t){var s={username:r.username,password:r.password,email:r.email,phone:r.mobile,smscode:r.captcha};Object(o["j"])("/sys/user/register",s).then((function(t){t.success?e.$router.push({name:"registerResult",params:c({},r)}):e.registerFailed(t.message)}))}}))},getCaptcha:function(e){var t=this;e.preventDefault();var r=this;this.form.validateFields(["mobile"],{force:!0},(function(e,s){if(!e){t.state.smsSendBtn=!0;var a=window.setInterval((function(){r.state.time--<=0&&(r.state.time=60,r.state.smsSendBtn=!1,window.clearInterval(a))}),1e3),i=t.$message.loading("验证码发送中..",0),n={mobile:s.mobile,smsmode:"1"};Object(o["j"])("/sys/sms",n).then((function(e){e.success||(t.registerFailed(e.message),setTimeout(i,0)),setTimeout(i,500)})).catch((function(e){setTimeout(i,1),clearInterval(a),r.state.time=60,r.state.smsSendBtn=!1,t.requestFailed(e)}))}}))},registerFailed:function(e){this.$notification["error"]({message:"注册失败",description:e,duration:2})},requestFailed:function(e){this.$notification["error"]({message:"错误",description:((e.response||{}).data||{}).message||"请求出现错误,请稍后再试",duration:4}),this.registerBtn=!1}},watch:{"state.passwordLevel":function(e){}}},h=m,g=(r("f444"),r("41d4"),r("2877")),v=Object(g["a"])(h,s,a,!1,null,"fa568c6c",null);t["default"]=v.exports},"41d4":function(e,t,r){"use strict";r("d396")},"58d2":function(e,t,r){},d396:function(e,t,r){},f444:function(e,t,r){"use strict";r("58d2")}}]);