integrated_traffic_uniapp/pages/login/forget/forget-reset.vue

217 lines
5.3 KiB
Vue
Raw Normal View History

2024-01-16 17:24:49 +08:00
<template>
<view>
<cu-custom bgColor="bg-gradual-blueness" :isBack="true">
<block slot="backText">返回</block>
<block slot="content">设置密码</block>
</cu-custom>
<view class="register">
<view class="user_main">
<view >账号{{USERNAME}}</view>
</view>
2024-01-16 17:24:49 +08:00
<view class="reg-form">
<view class="reg-input">
<input password @input="oldInpPwd" placeholder="旧密码" name="input"></input>
</view>
</view>
<view class="reg-form">
<view class="reg-input">
<input password @input="nowInpPwd" placeholder="新密码" name="input"></input>
</view>
</view>
<view class="reg-form">
<view class="reg-input">
<input password @input="ConfirmInpPwd" placeholder="确认新密码" name="input"></input>
</view>
</view>
<view class="reg-title">
<text class="text-gray">需8-20位字母大小写数字字符混合</text>
2024-01-16 17:24:49 +08:00
</view>
<view class="flex flex-direction mt50">
<button :loading="buttonloading" class="cu-btn bg-blue lg round" @click="updateUserPwd()"></button>
</view>
</view>
</view>
</template>
<script>
import {
basePath,loginUser,
} from '@/common/tool.js';
export default {
data() {
return {
oldPwd :'',
nowPwd :'',
buttonloading: false,
confirmPwd :'',
USERNAME: loginUser.USERNAME
2024-01-16 17:24:49 +08:00
}
},
methods: {
oldInpPwd(e){
this.oldPwd = e.detail.value
},
nowInpPwd(e){
this.nowPwd = e.detail.value
},
ConfirmInpPwd(e){
this.confirmPwd = e.detail.value
},
//跳转事件
goToEdit(e) {
uni.navigateTo({
url: '/pages/application/basic-info-manage/basic-information/basic-information-edit'
});
},
updateUserPwd(){
var _this = this;
if (_this.oldPwd == '') {
uni.showToast({
icon: 'none',
title: '请输入旧密码',
duration: 2000
});
return;
}
if (_this.nowPwd == '') {
uni.showToast({
icon: 'none',
title: '请输入新密码',
duration: 2000
});
return;
}
if (_this.confirmPwd == '') {
uni.showToast({
icon: 'none',
title: '请输入确认密码',
duration: 2000
});
return;
}
if(_this.nowPwd != _this.confirmPwd){
uni.showToast({
icon: 'none',
title: '两次输入的密码不一致',
duration: 2000
});
return;
}
if(_this.nowPwd.length < 8){
uni.showToast({
icon: 'none',
title: '密码需要大于8位',
duration: 2000
});
return
}
if(_this.nowPwd.length > 20){
uni.showToast({
icon: 'none',
title: '密码需要小于20位',
duration: 2000
});
return
}
var reg1 = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[~!@#$%^&*.])[\da-zA-Z~!@#$%^&*.]{8,}$/
if (!reg1.test(_this.nowPwd)) {
uni.showToast({
icon: 'none',
title: '密码必须包含大小写字母、数字、特殊符号',
duration: 2000
});
return
}
2024-01-16 17:24:49 +08:00
this.buttonloading = true
uni.request({
url: basePath +'/app/user/editUserPwd' ,
method: 'POST',
dataType: 'json',
header: {
'Content-type':'application/x-www-form-urlencoded'
},
data: {
USERNAME:loginUser.USERNAME,
PASSWORD:_this.oldPwd,
NOWPASSWORD : _this.confirmPwd,
CORPINFO_ID:loginUser.CORPINFO_ID,
USER_ID:loginUser.USER_ID,
},
success: (res) => {
uni.hideLoading();//结束加载中动画
this.buttonloading = false
if (res.data != null) {
var result = res.data.result;
var Code = res.data.code;
console.log(res.data.code)
if ("success" === result) {
if("9999" === Code){
uni.showToast({
icon: 'none',
title: "旧密码错误",
duration: 2000
});
}else{
uni.showToast({
title: "密码修改成功",
duration: 1500, // 适当延长显示时间
success: function() {
// 使用 setTimeout 确保提示框完全显示后再跳转
setTimeout(function() {
uni.navigateTo({
url: '/pages/login/home',
});
}, 1500); // 延迟时间与 duration 一致或略长
}
});
}
2024-01-16 17:24:49 +08:00
} else if ("usererror" === result) {
2024-01-16 17:24:49 +08:00
uni.showToast({
icon: 'none',
title: "密码有误",
duration: 2000
});
}else if ("exception" == result) {
uni.showToast({
icon: 'none',
title: res.data.exception,
duration: 2000
});
}else{
uni.showToast({
icon: 'none',
title: "登录错误!请联系管理员",
duration: 2000
});
}
}
}
})
},
}
}
</script>
<style>
.mt50{
margin-top: 50upx;
}
.mb40{
margin-bottom: 40upx;
}
page{
background-color: #FFFFFF;
}
.user_main{
width: 100%;
padding:30upx 20upx ;
background: #d8e9ff;
border-radius: 10upx;
box-sizing: border-box;
margin-bottom: 40upx;
font-size: 30upx;
}
2024-01-16 17:24:49 +08:00
</style>