96 lines
2.9 KiB
Vue
96 lines
2.9 KiB
Vue
![]() |
<template>
|
||
|
<view class="reset-password">
|
||
|
<u--form ref="formRef" :rules="rules" :model="formData">
|
||
|
<u-form-item label="原密码" labelWidth="140rpx" borderBottom prop="old_password">
|
||
|
<u--input v-model="formData.old_password" type="password" placeholder="请输入原密码" maxlength="18"></u--input>
|
||
|
</u-form-item>
|
||
|
<u-form-item label="新密码" labelWidth="140rpx" borderBottom prop="password">
|
||
|
<u--input v-model="formData.password" type="password" placeholder="请输入新密码" maxlength="18"></u--input>
|
||
|
</u-form-item>
|
||
|
<u-form-item label="确认密码" labelWidth="140rpx" borderBottom prop="password_confirm">
|
||
|
<u--input v-model="formData.password_confirm" type="password" placeholder="请确认新密码" maxlength="18"></u--input>
|
||
|
</u-form-item>
|
||
|
<u-button style="margin-top: 28rpx;background-color: #3175f9;color: #fff;" @click="submit">提交</u-button>
|
||
|
</u--form>
|
||
|
</view>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
|
import { Toast } from '../../libs/uniApi';
|
||
|
import { changePassword } from "@/api/oaUser.js"
|
||
|
export default {
|
||
|
data() {
|
||
|
return {
|
||
|
formData:{
|
||
|
old_password: '', // 原密码
|
||
|
password: '', // 新密码
|
||
|
password_confirm: '', // 确认密码
|
||
|
},
|
||
|
rules:{
|
||
|
old_password: {
|
||
|
type: 'string',
|
||
|
required: true,
|
||
|
min: 6,
|
||
|
max: 18,
|
||
|
message: '请输入6-18位密码',
|
||
|
trigger: ['change', 'blur']
|
||
|
},
|
||
|
password: {
|
||
|
type: 'string',
|
||
|
required: true,
|
||
|
min: 6,
|
||
|
max: 18,
|
||
|
message: '请输入6-18位密码',
|
||
|
trigger: ['change', 'blur']
|
||
|
},
|
||
|
password_confirm: {
|
||
|
type: 'string',
|
||
|
required: true,
|
||
|
min: 6,
|
||
|
max: 18,
|
||
|
message: '请输入6-18位密码',
|
||
|
trigger: ['change', 'blur']
|
||
|
},
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
methods: {
|
||
|
submit() {
|
||
|
this.$refs.formRef.validate().then(async (e)=>{
|
||
|
if(e){
|
||
|
if(this.formData.password == this.formData.old_password) return Toast('新密码不能与原密码一致');
|
||
|
if(this.formData.password !== this.formData.password_confirm) return Toast('两次新密码不一致');
|
||
|
try{
|
||
|
await changePassword({...this.formData});
|
||
|
Toast('修改成功');
|
||
|
this.$u.sleep(500).then(()=>{
|
||
|
uni.showLoading({
|
||
|
mask:true,
|
||
|
title:'加载中'
|
||
|
})
|
||
|
uni.switchTab({
|
||
|
url:'/pages/oaHome/oaHome',
|
||
|
success: () => {
|
||
|
uni.hideLoading()
|
||
|
}
|
||
|
})
|
||
|
})
|
||
|
}catch(e){
|
||
|
// console.log(e);
|
||
|
Toast(e.msg||'修改失败')
|
||
|
}
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
</script>
|
||
|
|
||
|
<style>
|
||
|
.reset-password {
|
||
|
margin: 28rpx;
|
||
|
padding: 28rpx;
|
||
|
background-color: #fff;
|
||
|
border-radius: 14rpx;
|
||
|
}
|
||
|
</style>
|