| | |
| | | <text class="change-password-page__rule">密码规则:字母、数字组合,不少于8个字符</text> |
| | | </view> |
| | | |
| | | <button class="change-password-page__submit" hover-class="change-password-page__submit--hover">确认修改</button> |
| | | <button class="change-password-page__submit" hover-class="change-password-page__submit--hover" @click="handleSubmit">确认修改</button> |
| | | </view> |
| | | </template> |
| | | |
| | |
| | | confirmPassword: '' |
| | | } |
| | | } |
| | | }, |
| | | methods: { |
| | | handleSubmit() { |
| | | if (!this.form.password) { |
| | | uni.showToast({ title: '请输入新密码', icon: 'none' }) |
| | | return |
| | | } |
| | | if (!this.form.confirmPassword) { |
| | | uni.showToast({ title: '请再次输入新密码', icon: 'none' }) |
| | | return |
| | | } |
| | | if (this.form.password !== this.form.confirmPassword) { |
| | | uni.showToast({ title: '两次密码输入不一致', icon: 'none' }) |
| | | return |
| | | } |
| | | const passwordRegex = /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$/ |
| | | if (!passwordRegex.test(this.form.password)) { |
| | | uni.showToast({ title: '密码需字母、数字组合,不少于8个字符', icon: 'none' }) |
| | | return |
| | | } |
| | | uni.showLoading({ title: '修改中...' }) |
| | | this.$u.api.changePassword({ newPassword: this.form.password }).then(res => { |
| | | uni.hideLoading() |
| | | if (res.code === 200) { |
| | | uni.showToast({ title: '修改成功', icon: 'success' }) |
| | | setTimeout(() => { |
| | | this.$store.commit('clearAll') |
| | | uni.reLaunch({ |
| | | url: '/pages/login/login' |
| | | }) |
| | | }, 1500) |
| | | } |
| | | }).catch(err => { |
| | | uni.hideLoading() |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | </script> |