@@ -15,7 +15,7 @@ const postData = reactive({
1515})
1616
1717const rules = reactive ({
18- eamil : [
18+ email : [
1919 { required: true , message: t (' forgot-password.pleaseEnterEmail' ) },
2020 ],
2121 code: [
@@ -46,6 +46,27 @@ async function reset(values: any) {
4646 }
4747}
4848
49+ const isGettingCode = ref (false )
50+
51+ const buttonText = computed (() => {
52+ return isGettingCode .value ? t (' forgot-password.gettingCode' ) : t (' forgot-password.getCode' )
53+ })
54+
55+ async function getCode() {
56+ if (! postData .email ) {
57+ showNotify ({ type: ' warning' , message: t (' forgot-password.pleaseEnterEmail' ) })
58+ return
59+ }
60+
61+ isGettingCode .value = true
62+ const res = await userStore .getCode ()
63+ if (res .code === 0 ) {
64+ showNotify ({ type: ' success' , message: ` ${t (' forgot-password.sendCodeSuccess' )}: ${res .result } ` })
65+ }
66+
67+ isGettingCode .value = false
68+ }
69+
4970function handleBackLogin() {
5071 router .replace ({ name: ' login' })
5172}
@@ -56,31 +77,31 @@ function handleBackLogin() {
5677 <van-form :model =" postData" :rules =" rules" @submit =" reset" >
5778 <div class =" overflow-hidden rounded-3xl" >
5879 <van-field
59- v-model =" postData.email"
60- :rules =" rules.eamil "
80+ v-model.trim =" postData.email"
81+ :rules =" rules.email "
6182 name =" email"
6283 :placeholder =" t('forgot-password.email')"
6384 />
6485 </div >
6586
6687 <div class =" mt-16 overflow-hidden rounded-3xl" >
6788 <van-field
68- v-model =" postData.code"
89+ v-model.trim =" postData.code"
6990 :rules =" rules.code"
7091 name =" code"
7192 :placeholder =" t('forgot-password.code')"
7293 >
7394 <template #button >
74- <van-button size =" small" type =" primary" plain >
75- {{ $t('forgot-password.getCode') }}
95+ <van-button size =" small" type =" primary" plain @click = " getCode " >
96+ {{ buttonText }}
7697 </van-button >
7798 </template >
7899 </van-field >
79100 </div >
80101
81102 <div class =" mt-16 overflow-hidden rounded-3xl" >
82103 <van-field
83- v-model =" postData.password"
104+ v-model.trim =" postData.password"
84105 type =" password"
85106 :rules =" rules.password"
86107 name =" password"
@@ -90,7 +111,7 @@ function handleBackLogin() {
90111
91112 <div class =" mt-16 overflow-hidden rounded-3xl" >
92113 <van-field
93- v-model =" postData.confirmPassword"
114+ v-model.trim =" postData.confirmPassword"
94115 type =" password"
95116 :rules =" rules.confirmPassword"
96117 name =" confirmPassword"
0 commit comments