1919 <!-- 登录表单 -->
2020 <div v-if =" isLogin" class =" login-form flex-column-all-center" >
2121 <div class =" input-field flex-column-justify-center" >
22- <fluent-text-field label =" FM号 " placeholder =" 请输入FM号 " class =" form-input"
23- @input = " handleLoginUserNameInput " ></ fluent-text-field >
24- <fluent-text-field label =" 密码" type =" password" placeholder =" 请输入密码" class =" form-input"
25- @input = " handleLoginPasswordInput " / >
22+ <FluentInput label =" 用户名 " placeholder =" 请输入用户名 " class =" form-input" v-model = " loginData.number " >
23+ </ FluentInput >
24+ <FluentInput label =" 密码" type =" password" placeholder =" 请输入密码" class =" form-input"
25+ v-model = " loginData.password " ></ FluentInput >
2626 </div >
2727 <div class =" tip" v-if =" messageLoginTipShow" >
2828 <el-text style =" color : red ;" >{{ messageLogin }}</el-text >
2929 </div >
3030 <div class =" tool" >
31- <fluent-checkbox class =" remember-me" @input =" handleLoginRememberMeInput" >记住我</fluent-checkbox >
31+ <!-- 有问题,无法实现双向绑定-->
32+ <FluentCheckBox class =" remember-me" v-model =" loginData.isRemeberMe" >记住我</FluentCheckBox >
33+ <!-- <fluent-checkbox class="remember-me" @input="handleLoginRememberMeInput">记住我</fluent-checkbox> -->
3234 <el-link class =" register" @click =" isLogin = !isLogin" >注册</el-link >
3335 </div >
3436 <fluent-button class =" login form-input" @click =" login" appearance =" accent" >登录</fluent-button >
3537 </div >
3638 <!-- 注册表单 -->
3739 <div v-else class =" register-form" >
3840 <div class =" input-field flex-column-justify-center" >
39- <fluent-text-field label =" 邮箱" placeholder =" 请输入邮箱地址" class =" form-input"
40- @input = " handleRegisterEmailInput " ></fluent-text-field >
41- <fluent-text-field label =" 密码" type =" password" placeholder =" 请输入密码" class =" form-input"
42- @input = " handleRegisterPasswordInput " / >
43- <fluent-text-field label =" 再次输入密码" type =" password" placeholder =" 请再次输入密码" class =" form-input"
44- @input = " handleRegisterConfirmPasswordInput " / >
41+ <FluentInput label =" 邮箱" placeholder =" 请输入邮箱地址" class =" form-input"
42+ v-model = " registerData.email " ></FluentInput >
43+ <FluentInput label =" 密码" type =" password" placeholder =" 请输入密码" class =" form-input"
44+ v-model = " registerData.password " ></ FluentInput >
45+ <FluentInput label =" 再次输入密码" type =" password" placeholder =" 请再次输入密码" class =" form-input"
46+ v-model = " registerData.confirmPassword " ></ FluentInput >
4547 <div class =" flex-row-space-between validate-code" >
46- <fluent-text-field label =" 验证码" placeholder =" 请输入验证码" class =" form-input"
47- @input = " handleRegisterValidateCodeInput " ></fluent-text-field >
48+ <FluentInput label =" 验证码" placeholder =" 请输入验证码" class =" form-input"
49+ v-model = " registerData.validateCode " ></FluentInput >
4850 <fluent-button class =" validate-code-btn" appearance =" accent" @click =" getVerificationCode"
4951 :disabled =" verificating" >{{ verificating ? `${timeLeft} 秒后重试` : '获取验证码' }}</fluent-button >
5052 </div >
6365import { watch } from ' vue' ;
6466import { onMounted , ref } from ' vue' ;
6567import { toggleDark , isDark } from ' ../util/theme' ;
68+
69+ import FluentInput from ' ../components/fluent-ui/FluentInput.vue' ;
70+ import FluentCheckBox from ' ../components/fluent-ui/FluentCheckBox.vue' ;
6671// 状态
6772
6873interface LoginData {
69- number: number ;
74+ number: string ;
7075 password: string ;
7176 isRemeberMe: boolean ;
7277}
@@ -90,7 +95,7 @@ const timeLeft = ref(5);
9095const timer = ref <NodeJS .Timeout | null >(null );
9196
9297const loginData = ref <LoginData >({
93- number: 0 ,
98+ number: ' ' ,
9499 password: ' ' ,
95100 isRemeberMe: false
96101})
@@ -147,7 +152,7 @@ const setMessage = (msg: string) => {
147152const validateForm = () => {
148153 if (isLogin .value ) {
149154 if (! loginData .value .number ) {
150- setMessage (' 用户名不能为空 ' );
155+ setMessage (' FM号不能为空 ' );
151156 return false ;
152157 }
153158
@@ -197,7 +202,7 @@ const validateForm = () => {
197202 setMessage (' 密码只能包含字母、数字和下划线' );
198203 return false ;
199204 }
200-
205+
201206 if (registerData .value .password .length > 20 ) {
202207 setMessage (' 密码长度不能大于20位' );
203208 return false ;
@@ -218,49 +223,11 @@ const validateForm = () => {
218223 return true ;
219224}
220225
221-
222- const handleLoginUserNameInput = (event : Event ) => {
223- const target = event .target as HTMLInputElement ;
224- loginData .value .number = Number (target .value );
225- }
226-
227-
228-
229- const handleRegisterEmailInput = (event : Event ) => {
230- const target = event .target as HTMLInputElement ;
231- registerData .value .email = target .value ;
232- }
233-
234- const handleRegisterPasswordInput = (event : Event ) => {
235- const target = event .target as HTMLInputElement ;
236- registerData .value .password = target .value ;
237- }
238-
239- const handleRegisterConfirmPasswordInput = (event : Event ) => {
240- const target = event .target as HTMLInputElement ;
241- registerData .value .confirmPassword = target .value ;
242- }
243-
244- const handleRegisterValidateCodeInput = (event : Event ) => {
245- const target = event .target as HTMLInputElement ;
246- registerData .value .validateCode = target .value ;
247- }
248-
249-
250- const handleLoginPasswordInput = (event : Event ) => {
251- const target = event .target as HTMLInputElement ;
252- loginData .value .password = target .value ;
253- }
254-
255- const handleLoginRememberMeInput = (event : Event ) => {
256- const target = event .target as HTMLInputElement ;
257- loginData .value .isRemeberMe = target .checked ;
258- }
259-
260226const login = () => {
261227 if (! validateForm ()) {
262228 return ;
263229 }
230+ console .log (' loginData' , loginData .value );
264231
265232}
266233
@@ -306,8 +273,8 @@ onMounted(() => {
306273
307274<style lang="scss" scoped>
308275.login-view {
309- width : 300px ; // 可以根据需要设置具体的宽度
310- height : 400px ; // 可以根据需要设置具体的高度
276+ width : 300px ;
277+ height : 400px ;
311278 display : flex ;
312279 justify-content : center ;
313280 align-items : center ;
0 commit comments