Browse Source

feat(student): 学员忘记密码功能

- 新增忘记密码页面,包含验证手机号码和设置新密码两个步骤
- 添加用户类型选择功能,支持学员和员工两种类型
- 实现短信验证码发送和验证功能
- 增加表单验证逻辑,确保用户输入的密码一致且符合要求- 添加重置密码接口调用,完成密码重置流程
master
liutong 10 months ago
parent
commit
bd22acebd4
  1. 7
      api/apiRoute.js
  2. 232
      pages/student/login/forgot.vue

7
api/apiRoute.js

@ -88,6 +88,13 @@ export default {
return res;
})
},
//公共端-忘记密码-通过短信验证码进行密码重置(学生/员工通用)
common_forgetPassword(data = {}) {
let url = '/common/forgetPassword'
return http.post(url, data).then(res => {
return res;
})
},

232
pages/student/login/forgot.vue

@ -1,55 +1,99 @@
<template>
<view>
<view class="title">
<view :class="{'green-text': tset_style === 1}">1.验证手机号码</view>
<view :class="{'green-text': tset_style === 2}">2.设置新密码</view>
<view :class="{'green-text': titleIndex === 1}" @click="changeTitle(1)">1.验证手机号码</view>
<view :class="{'green-text': titleIndex === 2}" @click="changeTitle(2)">2.设置新密码</view>
</view>
<view :style="{'background-color':'#fff','width':'100%','height':'100vh' }">
<view style="width: 95%;height: 30rpx;"></view>
<view v-if="tset_style == 1">
<view style="width: 95%;margin:30rpx auto;">
<fui-input borderTop placeholder="请输入手机号" v-model="user" @input="input"
backgroundColor="#f2f2f2"></fui-input>
</view>
<view style="width: 95%;margin: auto;">
<fui-input borderTop :padding="['20rpx','32rpx']" v-model="code" placeholder="请输入短信验证码" @input="input"
backgroundColor="#f2f2f2">
<fui-countdown-verify ref="fui_cdv" @send="sendCode"></fui-countdown-verify>
</fui-input>
</view>
</view>
<view v-if="tset_style == 2">
<view style="width: 95%;margin:30rpx auto;">
<fui-input borderTop placeholder="请设置6-20位新的登录密码" v-model="user" @input="input"
backgroundColor="#f2f2f2"></fui-input>
</view>
<view style="width: 95%;margin: auto;">
<fui-input borderTop :padding="['20rpx','32rpx']" v-model="code" placeholder="请再次输入新的登录密码" @input="input"
backgroundColor="#f2f2f2">
</fui-input>
</view>
</view>
<view style="width: 95%;margin:60rpx auto;">
<fui-button background="#00be8c" radius="5rpx" @click="nextStep" v-if="tset_style == 1">下一步</fui-button>
<fui-button background="#00be8c" radius="5rpx" @click="submit" v-if="tset_style == 2">提交</fui-button>
</view>
<view style="width: 95%;height: 30rpx;"></view>
<view v-if="titleIndex == 1">
<view style="width: 95%;margin:30rpx auto;">
<fui-input borderTop placeholder="请输入手机号" v-model="formData.phone" @input="input"
backgroundColor="#f2f2f2"></fui-input>
</view>
<view style="width: 95%;margin: auto;">
<fui-input borderTop :padding="['20rpx','32rpx']" v-model="formData.code" placeholder="请输入短信验证码" @input="input"
backgroundColor="#f2f2f2">
<fui-countdown-verify ref="fui_cdv" @send="sendCode"></fui-countdown-verify>
</fui-input>
</view>
<view style="width: 95%;margin: auto; margin-top: 30rpx;" @click="openPicker()">
<fui-form-item label="" arrow highlight background="#f2f2f2">
<input class="fui-page__input" v-model="formData.user_type_name" placeholder="请选择用户类型" placeholder-style="color:#ccc;" disabled/>
</fui-form-item>
</view>
</view>
<view v-if="titleIndex == 2">
<view style="width: 95%;margin:30rpx auto;">
<fui-input borderTop placeholder="请设置6-20位新的登录密码" v-model="formData.password" @input="input"
backgroundColor="#f2f2f2"></fui-input>
</view>
<view style="width: 95%;margin: auto;">
<fui-input borderTop :padding="['20rpx','32rpx']" v-model="formData.password_2" placeholder="请再次输入新的登录密码" @input="input"
backgroundColor="#f2f2f2">
</fui-input>
</view>
</view>
<view style="width: 95%;margin:60rpx auto;">
<fui-button background="#00be8c" radius="5rpx" @click="nextStep" v-if="titleIndex == 1">下一步</fui-button>
<fui-button background="#00be8c" radius="5rpx" @click="submit" v-if="titleIndex == 2">提交</fui-button>
</view>
</view>
<!-- 选择器 -->
<fui-picker
:linkage="true"
:options="picker_options"
:layer="1"
:show="picker_show"
@change="changeCicker"
@cancel="cancelCicker">
</fui-picker>
</view>
</template>
<script>
import apiRoute from '@/api/apiRoute.js';
export default {
data() {
return {
code: '',
user: '',
tset_style: 1,
}
},
onLoad() {
//
picker_show:false,//
picker_options:[
{
text:'学员',
value:'customer',
},
{
text:'员工',
value:'personnel',
}
],//
//-
formData: {
phone: '',//
code: '',//
code_type: 'editPassword',//(/ )|=editPassword
password: '',//
password_2: '',//
user_type: '',//|customer=|personnel=(/)
user_type_name: '',//|customer=|personnel=(/)
},
titleIndex:1,//|1=|2=
}
},
onLoad() {},
methods: {
//
sendCode() {
//
setTimeout(() => {
@ -59,9 +103,119 @@
this.$refs.fui_cdv && this.$refs.fui_cdv.success()
}, 800)
},
nextStep(){
this.tset_style = 2
}
//--
changeCicker(e){
this.formData.user_type = e.value
this.formData.user_type_name = e.text
this.cancelCicker()
},
//
openPicker(){
this.picker_show = true
},
//
cancelCicker(){
this.picker_show = false
},
//
async nextStep(){
//
if(!this.formData.code){
uni.showToast({
title: '请输入短信验证码',
icon: 'none'
})
return
}
if(!this.formData.phone){
uni.showToast({
title: '请输入手机号',
icon: 'none'
})
return
}
if(!this.formData.user_type){
uni.showToast({
title: '请选择用户类型',
icon: 'none'
})
return
}
this.titleIndex = 2
},
//
async validateForm(formData) {
//
if(!formData.phone){
uni.showToast({
title: `请填写手机号`,
icon: 'none'
});
this.changeTitle(1)
return false
}
if(!formData.user_type){
uni.showToast({
title: `请选择用户类型`,
icon: 'none'
});
this.changeTitle(1)
return false
}
if(!formData.code){
uni.showToast({
title: `请填写短信验证码`,
icon: 'none'
});
this.changeTitle(1)
return false
}
if(!formData.password || formData.password != formData.password_2){
uni.showToast({
title: `两次密码不一致`,
icon: 'none'
});
this.changeTitle(2)
return false
}
return true;
},
//
async submit(){
let params = {...this.formData}
let res_validateForm = await this.validateForm(params);//
if(!res_validateForm){
return
}
let res = await apiRoute.common_forgetPassword(params);//
if(res.code != 1){
uni.showToast({
title: res.msg,
icon: 'none'
})
return
}
uni.showToast({
title: res.msg,
icon: 'success'
})
//1s
setTimeout(() => {
//-
uni.navigateTo({
url: `/pages/student/login/login`
})
}, 1000)
},
//
changeTitle(index){
this.titleIndex = index
},
}
}
</script>

Loading…
Cancel
Save