|
|
@@ -1,13 +1,18 @@
|
|
|
<template>
|
|
|
<view class="auth-content">
|
|
|
- <wd-navbar fixed placeholder :title="title" left-arrow safeAreaInsetTop customClass="navbar" />
|
|
|
+ <wd-navbar
|
|
|
+ fixed
|
|
|
+ placeholder
|
|
|
+ title="重置密码"
|
|
|
+ left-arrow
|
|
|
+ safeAreaInsetTop
|
|
|
+ customClass="navbar"
|
|
|
+ />
|
|
|
<!-- 背景层 -->
|
|
|
<view class="auth-bg"></view>
|
|
|
<!-- 内容层 -->
|
|
|
<view class="auth-body">
|
|
|
- <view class="auth-title"> 欢迎登录 </view>
|
|
|
-
|
|
|
- <!-- 表单(内部类名不动) -->
|
|
|
+ <!-- 表单-->
|
|
|
<view class="auth-form">
|
|
|
<form>
|
|
|
<view class="form-item">
|
|
|
@@ -16,32 +21,42 @@
|
|
|
<input
|
|
|
class="form-input-inner"
|
|
|
type="number"
|
|
|
- focus
|
|
|
maxlength="11"
|
|
|
placeholder="请输入账号"
|
|
|
+ v-model="form.phone"
|
|
|
/>
|
|
|
</view>
|
|
|
+ <text class="error" v-if="errors.phone">{{ errors.phone }}</text>
|
|
|
</view>
|
|
|
|
|
|
<view class="form-item">
|
|
|
- <view class="form-label">密码</view>
|
|
|
+ <view class="form-label">验证码</view>
|
|
|
<view class="form-input">
|
|
|
- <input class="form-input-inner" password placeholder="请输入密码" />
|
|
|
- <view class="forget-password" @click="forgetPassword">忘记密码?</view>
|
|
|
+ <input class="form-input-inner" v-model="form.code" placeholder="请输入验证码" />
|
|
|
+ <button class="get-code" @click="sendCode">发送验证码</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-label">密码</view>
|
|
|
<view class="form-input">
|
|
|
- <input class="form-input-inner" placeholder="请输入验证码" />
|
|
|
- <button class="get-code">发送验证码</button>
|
|
|
+ <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>
|
|
|
|
|
|
<view class="submit">
|
|
|
- <button class="submit-btn">确定</button>
|
|
|
+ <button class="submit-btn" @click="submit">确定</button>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
@@ -49,20 +64,42 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import projectConfig from '@/config/presets/index'
|
|
|
-const { title } = projectConfig
|
|
|
+import { reactive } from 'vue'
|
|
|
+import { useFormValidator } from '@/composables/useFormValidator'
|
|
|
+import { resetPasswordRules } from '@/validators/resetPassword'
|
|
|
|
|
|
+/** 表单模型 */
|
|
|
const form = reactive({
|
|
|
phone: '',
|
|
|
- password: '',
|
|
|
code: '',
|
|
|
+ password: '',
|
|
|
})
|
|
|
|
|
|
-const forgetPassword = () => {
|
|
|
- console.log('cc')
|
|
|
+/** 表单校验 Hook */
|
|
|
+const { errors, validate, validateField } = useFormValidator(resetPasswordRules, form)
|
|
|
+
|
|
|
+/** 提交 */
|
|
|
+const submit = async () => {
|
|
|
+ const ok = await validate()
|
|
|
+ console.log('ok', ok)
|
|
|
+ console.log('form', form)
|
|
|
+
|
|
|
+ if (!ok) return
|
|
|
+
|
|
|
+ console.log('校验通过', form)
|
|
|
+ // TODO: 提交重置密码接口
|
|
|
+}
|
|
|
+
|
|
|
+/** 获取验证码前校验 */
|
|
|
+const sendCode = async () => {
|
|
|
+ const ok = await validateField('phone')
|
|
|
+ if (!ok) return
|
|
|
+
|
|
|
+ console.log('发送验证码', form.phone)
|
|
|
+ // TODO: 调用发送验证码接口
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
-@import '@/styles/modules/auth-page.scss';
|
|
|
+@import '../../styles/modules/auth-page.scss';
|
|
|
</style>
|