1
- <template >
1
+ <template >
2
2
<div class =" sign-in-container" >
3
3
<el-card class =" box-card" >
4
4
<div class =" sign-in-body" >
53
53
</div >
54
54
</div >
55
55
56
- <!-- Verification Code Dialog -->
57
- <el-dialog title =" Verify Email" :visible.sync =" showVerifyDialog" width =" 30%" >
58
- <span >Enter the 6-digit code sent to your email:</span >
59
- <el-input v-model =" activeCode" placeholder =" 6-digit code" maxlength =" 6" class =" sign-in-input" />
60
- <div slot =" footer" class =" dialog-footer" >
61
- <el-button @click =" verifyCode" >Verify</el-button >
62
- </div >
63
- </el-dialog >
56
+ <!-- Verification Code Dialog -->
57
+ <el-dialog title =" Verify Email" :visible.sync =" showVerifyDialog" width =" 30%" >
58
+ <span >Enter the 6-digit code sent to your email:</span >
59
+ <el-input v-model =" activeCode" placeholder =" 6-digit code" maxlength =" 6" class =" sign-in-input" />
60
+ <div slot =" footer" class =" dialog-footer" >
61
+ <el-button @click =" verifyCode" >Verify</el-button >
62
+ </div >
63
+ </el-dialog >
64
64
</el-card >
65
65
</div >
66
66
</template >
67
67
68
68
<script >
69
- import axios from " axios" ;
69
+ import axios from ' axios' ;
70
70
71
71
export default {
72
72
name: ' sign-in' ,
@@ -78,8 +78,8 @@ export default {
78
78
userPassword: ' ' ,
79
79
nickname: ' '
80
80
},
81
- showVerifyDialog: false ,
82
- activeCode: ' ' ,
81
+ showVerifyDialog: false ,
82
+ activeCode: ' '
83
83
};
84
84
},
85
85
methods: {
@@ -107,21 +107,21 @@ export default {
107
107
.signIn (this .userInfo )
108
108
.then ((res ) => {
109
109
if (res .status_code === 1 ) {
110
- this .$confirm (
111
- ` A verification email has been sent to ${ this .userInfo .email } . Please check your inbox for the 6-digit verification code to activate your email.` ,
112
- ' Email Sent' ,
113
- {
114
- confirmButtonText: ' OK' ,
115
- type: ' info' ,
116
- // callback: () => {
117
- // // Redirect to login page after confirmation
118
- // this.$router.replace({ path: '/login' });
119
- // }
120
- }
121
- );
110
+ this .$confirm (
111
+ ` A verification email has been sent to ${ this .userInfo .email } . Please check your inbox for the 6-digit verification code to activate your email.` ,
112
+ ' Email Sent' ,
113
+ {
114
+ confirmButtonText: ' OK' ,
115
+ type: ' info'
116
+ // callback: () => {
117
+ // // Redirect to login page after confirmation
118
+ // this.$router.replace({ path: '/login' });
119
+ // }
120
+ }
121
+ );
122
122
123
- // 显示输入验证码框
124
- this .showVerifyDialog = true ;
123
+ // Show verification dialog
124
+ this .showVerifyDialog = true ;
125
125
} else {
126
126
this .$message .error (' Registration failed, user already exists!' );
127
127
}
@@ -136,23 +136,28 @@ export default {
136
136
}
137
137
},
138
138
139
- // 然后请求后端验证
140
- verifyCode () {
141
- axios .post (' http://47.252.36.46:8080/user/verifyCode' , {
142
- email: this .userInfo .email ,
143
- activeCode: this .activeCode
144
- }).then (res => {
145
- if (res .data .status_code === 1 ) { // 验证成功
146
- this .$message .success (" Registration successful! Account activated." );
147
- this .$router .push (' /login' );
148
- } else { // 验证失败
149
- this .$message .error (" Invalid verification code. Please try again." );
150
- this .showVerifyDialog = true ; // 保持弹窗显示状态
151
- }
152
- }).catch (error => {
153
- this .$message .error (" An error occurred. Please try again later." );
154
- });
155
- }
139
+ // Verify email with 6-digit code
140
+ verifyCode () {
141
+ axios
142
+ .post (' http://47.252.36.46:8080/user/verifyCode' , {
143
+ email: this .userInfo .email ,
144
+ activeCode: this .activeCode
145
+ })
146
+ .then ((res ) => {
147
+ if (res .data .status_code === 1 ) {
148
+ // Success
149
+ this .$message .success (' Registration successful! Account activated.' );
150
+ this .$router .push (' /login' );
151
+ } else {
152
+ // Error
153
+ this .$message .error (' Invalid verification code. Please try again.' );
154
+ this .showVerifyDialog = true ;
155
+ }
156
+ })
157
+ .catch ((error ) => {
158
+ this .$message .error (' An error occurred. Please try again later.' );
159
+ });
160
+ }
156
161
}
157
162
};
158
163
</script >
0 commit comments