<template>
|
<view class="container items-center">
|
<view class="reset-content">
|
<form @submit="submitForm" class="reset-form">
|
<view class="reset-form-item password-clz">
|
<view class="input">
|
<text class="reset-form-title">旧密码:</text>
|
<input class="reset-input" :focus="formData.passwordFocus" name="password" comfirm-type="done"
|
type="password" v-model="form.password" placeholder="请输入旧密码" />
|
</view>
|
</view>
|
<view class="reset-form-item password-clz">
|
<view class="input">
|
<text class="reset-form-title">新密码:</text>
|
<input class="reset-input" :focus="formData.newpasswordFocus" name="newpassword"
|
comfirm-type="done" type="password" v-model="form.newpassword" placeholder="请输入新密码" />
|
</view>
|
</view>
|
<view class="reset-form-item password-clz">
|
<view class="input">
|
<text class="reset-form-title">确认密码:</text>
|
<input class="reset-input" :focus="formData.confirmpasswordFocus" name="confirmpassword"
|
comfirm-type="done" type="password" v-model="form.confirmpassword" placeholder="请输入确认密码" />
|
</view>
|
</view>
|
<view class="button-clz">
|
<button form-type="submit" class="blue-button button-button-clz">确认修改</button>
|
</view>
|
</form>
|
</view>
|
</view>
|
</template>
|
|
<script>
|
import Session from "@/common/utils.js"
|
import {
|
showModal,
|
showToast
|
} from "@/common/Page.js"
|
import {
|
resetPassword
|
} from "@/api/org.js"
|
import Validate from '@/common/Validate.js'
|
|
export default {
|
data() {
|
return {
|
form: {
|
password: '',
|
newpassword: '',
|
confirmpassword: ''
|
},
|
formData: {
|
passwordFocus: true,
|
newpasswordFocus: false,
|
confirmpasswordFocus: false,
|
}
|
}
|
},
|
methods: {
|
|
submitForm(e) {
|
var _this = this
|
_this.validateForm = new Validate({
|
password: {
|
required: {
|
message: '旧密码不能为空'
|
}
|
},
|
newpassword: {
|
required: {
|
message: '新密码不能为空'
|
}
|
},
|
confirmpassword: {
|
required: {
|
message: '确认密码不能为空'
|
}
|
}
|
});
|
if (!_this.validateForm.checkForm(e)) {
|
|
let data = _this.validateForm.errorList[0];
|
console.log("submitForm failed ", data);
|
showToast(data.msg, "none");
|
return false;
|
} else {
|
//保存数据
|
let param = e.detail.value;
|
let loginInfo = Session.getValue('logininfo')
|
if (param.password != loginInfo.password) {
|
showToast("原密码输入错误!", "none");
|
_this.form.confirmpassword = ""
|
_this.form.password = ""
|
_this.form.newpassword = ""
|
return false;
|
}
|
if (param.newpassword != param.confirmpassword) {
|
showToast("两次输入的密码不相同!", "none");
|
_this.form.confirmpassword = ""
|
_this.form.password = ""
|
_this.form.newpassword = ""
|
return false;
|
}
|
var _this = this
|
resetPassword(param.userlogin, param.password, param.newpassword).then((res) => {
|
const app = getApp()
|
console.log("resetPassword", ret[0].code)
|
loginInfo.password = ""
|
Session.setValue('logininfo', loginInfo)
|
showToast('密码已修改,请重新登录', 'none')
|
app.globalData.userdata = {};
|
Session.clearValue('userdata');
|
uni.reLaunch({
|
url: '/pages/loading/loading'
|
})
|
|
}).catch((rej) => {
|
console.log("密码修改异常", rej);
|
this.showError(rej);
|
|
})
|
}
|
},
|
showError(ex) {
|
let tip = typeof ex == 'string' ? ex : typeof ex.err_msg == 'string' ? ex.err_msg : typeof ex.errMsg ==
|
'string' ? ex.errMsg : ""
|
showModal(tip, "提示", false)
|
},
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
@import "../../common/css/button.scss";
|
|
.justify-center {
|
justify-content: center;
|
}
|
|
.items-center {
|
align-items: center
|
}
|
|
.reset-form {
|
display: flex;
|
width: 750rpx;
|
padding: 20px !important;
|
flex-direction: column;
|
}
|
|
.reset-form-item {
|
width: 750rpx;
|
padding: 0.3125rem 0.3125rem !important;
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
|
}
|
|
.reset-form-item .input {
|
display: flex;
|
width: 100%;
|
padding: 8px 0px;
|
background-color: transparent;
|
flex-direction: row;
|
}
|
|
.reset-form-title {
|
padding-top: 2px;
|
width: 80px;
|
text-align: right;
|
}
|
|
.reset-input {
|
display: flex;
|
margin-left: 5px;
|
}
|
|
.password-clz {
|
margin-left: 10px;
|
width: calc(100% - 80px) !important;
|
font-size: 14px !important;
|
margin-top: 8px;
|
margin-bottom: 0px;
|
border-bottom: 1px solid #f2e7e7;
|
margin-right: 10px;
|
}
|
|
.blue-button {
|
background-color: #00aaff !important;
|
color: white !important;
|
}
|
|
.button-clz {
|
display: flex;
|
justify-content: center;
|
width: calc(100% - 40px) !important;
|
font-size: 17px !important;
|
margin-top: 20px;
|
margin-bottom: 10px;
|
border-radius: 0px;
|
}
|
|
.button-button-clz {
|
font-size: 17px !important;
|
margin: 0px !important;
|
width: 240px !important;
|
height: 48px;
|
}
|
|
.container {
|
display: flex;
|
font-size: 12px;
|
width: 750rpx;
|
height: 100%;
|
}
|
|
.reset-content {
|
width: 750rpx;
|
height: 360px;
|
}
|
</style>
|