| | |
| | | </view> |
| | | <view class="btngroup"> |
| | | <u-button color="#AEAEAE" class="custom-style" shape="circle" @click="reset">重置</u-button> |
| | | <u-button color="#1D6FE9" class="custom-style" shape="circle" @click="submit">提交</u-button> |
| | | <u-button |
| | | :color="submitLoading ? '#AEAEAE' : '#1D6FE9'" |
| | | class="custom-style" |
| | | shape="circle" |
| | | text="提交" |
| | | :loading="submitLoading" |
| | | loading-text="提交中" |
| | | loading-mode="circle" |
| | | :loading-size="13" |
| | | @click="submit" |
| | | /> |
| | | </view> |
| | | </view> |
| | | </template> |
| | |
| | | newPassword: '', |
| | | newPassword1: '', |
| | | }); |
| | | const submitLoading = ref(false); |
| | | // 校验密码不能包含中文 |
| | | const validatePasswordNoChinese = (password) => { |
| | | const chineseRegex = /[\u4e00-\u9fa5]/; |
| | |
| | | }); |
| | | return false; |
| | | } |
| | | // const hasLetter = /[a-zA-Z]/.test(password); |
| | | // const hasNumber = /\d/.test(password); |
| | | // if (!hasLetter || !hasNumber) { |
| | | // ElMessage.error('密码需同时包含字母和数字'); |
| | | // return false; |
| | | // } |
| | | return true; |
| | | }; |
| | | const clearForm = () => { |
| | |
| | | clearForm(); |
| | | }; |
| | | const submit = () => { |
| | | if (submitLoading.value) return; |
| | | // 原始密码校验 |
| | | if (!passwordForm.value.oldPassword) { |
| | | |
| | |
| | | |
| | | // 复杂度校验 |
| | | if (!validatePasswordStrength(passwordForm.value.newPassword)) return; |
| | | submitLoading.value = true; |
| | | updatePassword(md5(passwordForm.value.oldPassword), |
| | | md5(passwordForm.value.newPassword), |
| | | md5(passwordForm.value.newPassword1)).then(res => { |
| | |
| | | uni.showToast({ |
| | | title: '修改信息成功', |
| | | icon: 'none', |
| | | duration: 2000 |
| | | duration: 1500 |
| | | }); |
| | | clearForm(); |
| | | userStore.setUserInfo(null) |
| | | uni.removeStorageSync('rememberedUser'); |
| | | uni.reLaunch({ |
| | | url: '/pages/login/index' |
| | | }) |
| | | setTimeout(() => { |
| | | uni.reLaunch({ |
| | | url: '/pages/login/index' |
| | | }) |
| | | }, 1500); |
| | | return |
| | | |
| | | } else { |
| | | uni.showToast({ |
| | |
| | | duration: 2000 |
| | | }); |
| | | } |
| | | submitLoading.value = false; |
| | | |
| | | }).catch(() => { |
| | | submitLoading.value = false; |
| | | }); |
| | | |
| | | }; |