1818 <el-form-item prop =" email" >
1919 <el-input type =" email" v-model =" ldata.email" ></el-input >
2020 </el-form-item >
21+ <div class =" icon-lable form-required" ><i class =" el-icon-check" /> Captcha</div >
22+ <captcha ref =" captchaElement" class =" margin-bottom" />
2123 <el-form-item >
2224 <el-button type =" primary" v-on:click =" onSubmit();" :loading =" buttonLoading" >Register</el-button >
2325 <el-button v-on:click =" $store.state.user.showregister = false;" >Cancel</el-button >
3032
3133<script >
3234import apiurl from ' ./../../apiurl' ;
35+ import captcha from ' ./../lib/captcha.vue' ;
3336
3437export default {
3538 name: ' UserRegister' ,
@@ -93,13 +96,18 @@ export default {
9396 };
9497 },
9598 methods: {
99+ refresh_captcha () {
100+ this .$refs .captchaElement .refresh_captcha ();
101+ },
96102 submit () {
97103 this .buttonLoading = true ;
98104 this .$axios
99105 .post (apiurl (' /account' ), {
100106 username: this .ldata .username ,
101107 password: this .ldata .password ,
102- email: this .ldata .email
108+ email: this .ldata .email ,
109+ captcha_key: this .$store .state .captcha .captchaKey ,
110+ captcha_answer: this .$store .state .captcha .captchaAnswer
103111 })
104112 .then (() => {
105113 this .$store .state .user .showregister = false ;
@@ -112,6 +120,9 @@ export default {
112120 if (err .request .status === 400 ) {
113121 // HTTP 400 Bad Request
114122 this .$SegmentMessage .error (this , JSON .parse (err .request .response ).detail );
123+ } else if (err .request .status === 406 ){
124+ // HTTP 406 Not Acceptable
125+ this .$SegmentMessage .error (this , JSON .parse (err .request .response ).detail );
115126 } else if (err .request .status === 409 ) {
116127 // HTTP 409 Conflict
117128 this .$SegmentMessage .error (this , ' Username has been taken' );
@@ -122,6 +133,7 @@ export default {
122133 // Unknown error
123134 this .$SegmentMessage .error (this , ' Unknown error' );
124135 }
136+ this .refresh_captcha ();
125137 this .buttonLoading = false ;
126138 });
127139 },
@@ -137,13 +149,19 @@ export default {
137149 reset () {
138150 this .$refs [' register' ].resetFields ();
139151 }
152+ },
153+ components: {
154+ captcha
140155 }
141156};
142157 </script >
143158
144159<style scoped>
145- .form-required ::before {
146- content : " *" ;
147- color : #f56c6c ;
160+ .form-required {
161+ margin-bottom : 5px ;
162+ }
163+
164+ .margin-bottom {
165+ margin-bottom : 20px ;
148166}
149167 </style >
0 commit comments