|
@@ -7,58 +7,54 @@
|
|
|
left-arrow
|
|
left-arrow
|
|
|
safeAreaInsetTop
|
|
safeAreaInsetTop
|
|
|
customClass="navbar"
|
|
customClass="navbar"
|
|
|
|
|
+ @click-left="handleClickLeft"
|
|
|
/>
|
|
/>
|
|
|
- <!-- 背景层 -->
|
|
|
|
|
- <view class="auth-bg"></view>
|
|
|
|
|
- <!-- 内容层 -->
|
|
|
|
|
|
|
+ <view class="auth-bg" />
|
|
|
<view class="auth-body">
|
|
<view class="auth-body">
|
|
|
- <!-- 表单-->
|
|
|
|
|
<view class="auth-form">
|
|
<view class="auth-form">
|
|
|
- <form>
|
|
|
|
|
- <view class="form-item">
|
|
|
|
|
- <view class="form-label">账号</view>
|
|
|
|
|
- <view class="form-input">
|
|
|
|
|
- <input
|
|
|
|
|
- class="form-input-inner"
|
|
|
|
|
- type="number"
|
|
|
|
|
- maxlength="11"
|
|
|
|
|
- placeholder="请输入账号"
|
|
|
|
|
- v-model="form.username"
|
|
|
|
|
- />
|
|
|
|
|
- </view>
|
|
|
|
|
- <text class="error" v-if="errors.username">{{ errors.username }}</text>
|
|
|
|
|
- </view>
|
|
|
|
|
-
|
|
|
|
|
- <view class="form-item">
|
|
|
|
|
- <view class="form-label">验证码</view>
|
|
|
|
|
- <view class="form-input">
|
|
|
|
|
- <input class="form-input-inner" v-model="form.code" placeholder="请输入验证码" />
|
|
|
|
|
- <button class="get-code" :disabled="codeDisabled" @click="sendCode">
|
|
|
|
|
- {{ countdown > 0 ? `${countdown}s 后重试` : '发送验证码' }}
|
|
|
|
|
- </button>
|
|
|
|
|
- </view>
|
|
|
|
|
- <text class="error" v-if="errors.code">{{ errors.code }}</text>
|
|
|
|
|
- </view>
|
|
|
|
|
-
|
|
|
|
|
- <view class="form-item">
|
|
|
|
|
- <view class="form-label">密码</view>
|
|
|
|
|
- <view class="form-input">
|
|
|
|
|
- <input
|
|
|
|
|
- class="form-input-inner"
|
|
|
|
|
- v-model="form.password"
|
|
|
|
|
- password
|
|
|
|
|
- placeholder="请输入密码"
|
|
|
|
|
- />
|
|
|
|
|
- </view>
|
|
|
|
|
- <text class="error" v-if="errors.password">{{ errors.password }}</text>
|
|
|
|
|
- </view>
|
|
|
|
|
- <view class="tips">
|
|
|
|
|
- 密码为8~16位包含大小写字母、数字、!#$%^&*@特殊符号,且不能三位连续数字!
|
|
|
|
|
- </view>
|
|
|
|
|
- </form>
|
|
|
|
|
-
|
|
|
|
|
|
|
+ <!-- 账号 -->
|
|
|
|
|
+ <AuthInputItem
|
|
|
|
|
+ label="账号"
|
|
|
|
|
+ v-model="form.username"
|
|
|
|
|
+ type="number"
|
|
|
|
|
+ :maxlength="11"
|
|
|
|
|
+ placeholder="请输入账号"
|
|
|
|
|
+ :error="errors.username"
|
|
|
|
|
+ @clear="clearFieldError('username')"
|
|
|
|
|
+ @validate="validateField('username')"
|
|
|
|
|
+ />
|
|
|
|
|
+ <AuthInputItem
|
|
|
|
|
+ label="验证码"
|
|
|
|
|
+ v-model="form.code"
|
|
|
|
|
+ type="number"
|
|
|
|
|
+ :maxlength="11"
|
|
|
|
|
+ placeholder="请输入验证码"
|
|
|
|
|
+ :error="errors.code"
|
|
|
|
|
+ @clear="clearFieldError('code')"
|
|
|
|
|
+ @validate="validateField('code')"
|
|
|
|
|
+ >
|
|
|
|
|
+ <template #suffix>
|
|
|
|
|
+ <button class="get-code" :disabled="codeDisabled" @click.stop.prevent="sendCode">
|
|
|
|
|
+ {{ countdown > 0 ? `${countdown}s 后重试` : '发送验证码' }}
|
|
|
|
|
+ </button>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </AuthInputItem>
|
|
|
|
|
+ <AuthInputItem
|
|
|
|
|
+ label="密码"
|
|
|
|
|
+ v-model="form.password"
|
|
|
|
|
+ type="number"
|
|
|
|
|
+ :maxlength="11"
|
|
|
|
|
+ placeholder="请输入密码"
|
|
|
|
|
+ passwordToggle
|
|
|
|
|
+ :error="errors.password"
|
|
|
|
|
+ @validate="validateField('password')"
|
|
|
|
|
+ @clear="clearFieldError('password')"
|
|
|
|
|
+ />
|
|
|
|
|
+ <view class="tips">
|
|
|
|
|
+ 密码为8~16位包含大小写字母、数字、!#$%^&*@特殊符号,且不能三位连续数字!
|
|
|
|
|
+ </view>
|
|
|
<view class="submit">
|
|
<view class="submit">
|
|
|
- <button class="submit-btn" @click="submit">确定</button>
|
|
|
|
|
|
|
+ <button class="submit-btn" @click.prevent="submit">确定</button>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
@@ -67,6 +63,7 @@
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
import { reactive } from 'vue'
|
|
import { reactive } from 'vue'
|
|
|
|
|
+import AuthInputItem from '@/components/auth/AuthInputItem.vue'
|
|
|
import { useFormValidator } from '@/composables/useFormValidator'
|
|
import { useFormValidator } from '@/composables/useFormValidator'
|
|
|
import { resetPasswordRules } from '@/validators/resetPassword'
|
|
import { resetPasswordRules } from '@/validators/resetPassword'
|
|
|
import { debounce } from '@/plugins/debounce'
|
|
import { debounce } from '@/plugins/debounce'
|
|
@@ -79,38 +76,48 @@ const form = reactive({
|
|
|
password: '',
|
|
password: '',
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
-const { errors, validate, validateField } = useFormValidator(resetPasswordRules, form)
|
|
|
|
|
|
|
+const { errors, validate, validateField, clearFieldError } = useFormValidator(
|
|
|
|
|
+ resetPasswordRules,
|
|
|
|
|
+ form
|
|
|
|
|
+)
|
|
|
|
|
+
|
|
|
|
|
+const handleClickLeft = () => {
|
|
|
|
|
+ uni.navigateBack()
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
-/** 倒计时 */
|
|
|
|
|
const { countdown, disabled: codeDisabled, start: startCountdown } = useCodeCountdown()
|
|
const { countdown, disabled: codeDisabled, start: startCountdown } = useCodeCountdown()
|
|
|
|
|
|
|
|
const toast = (title: string, duration = 800) => uni.showToast({ title, icon: 'none', duration })
|
|
const toast = (title: string, duration = 800) => uni.showToast({ title, icon: 'none', duration })
|
|
|
|
|
|
|
|
-const goLoginLater = (delay = 1000) => {
|
|
|
|
|
- setTimeout(() => {
|
|
|
|
|
- uni.reLaunch({ url: '/pages/login/index' })
|
|
|
|
|
- }, delay)
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
const sendCodeImpl = async () => {
|
|
const sendCodeImpl = async () => {
|
|
|
if (codeDisabled.value) return
|
|
if (codeDisabled.value) return
|
|
|
if (!(await validateField('username'))) return
|
|
if (!(await validateField('username'))) return
|
|
|
|
|
|
|
|
const { code, data, msg } = await getPwdCodeForNoAuthApi(form.username)
|
|
const { code, data, msg } = await getPwdCodeForNoAuthApi(form.username)
|
|
|
- if (code !== 0 || !data) return toast(msg || '发送验证码失败')
|
|
|
|
|
|
|
+ if (code !== 0 || !data) {
|
|
|
|
|
+ toast(msg || '发送验证码失败')
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
toast('验证码已发送,请注意查收')
|
|
toast('验证码已发送,请注意查收')
|
|
|
startCountdown(60)
|
|
startCountdown(60)
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
const sendCode = debounce(sendCodeImpl)
|
|
const sendCode = debounce(sendCodeImpl)
|
|
|
|
|
+
|
|
|
const submitImpl = async () => {
|
|
const submitImpl = async () => {
|
|
|
if (!(await validate())) return
|
|
if (!(await validate())) return
|
|
|
|
|
+
|
|
|
const { code, data, msg } = await updUserPwdApi(form)
|
|
const { code, data, msg } = await updUserPwdApi(form)
|
|
|
- if (code !== 0 || !data) return toast(msg || '修改密码失败')
|
|
|
|
|
|
|
+ if (code !== 0 || !data) {
|
|
|
|
|
+ toast(msg || '修改密码失败')
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
toast('密码重置成功,请使用新密码登录')
|
|
toast('密码重置成功,请使用新密码登录')
|
|
|
- goLoginLater()
|
|
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ uni.reLaunch({ url: '/pages/login/index' })
|
|
|
|
|
+ }, 1000)
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
const submit = debounce(submitImpl)
|
|
const submit = debounce(submitImpl)
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|