369 lines
7.7 KiB
Vue
Executable File
369 lines
7.7 KiB
Vue
Executable File
<template>
|
|
<view class="page">
|
|
<view class="content">
|
|
|
|
<view class="base-person">
|
|
<view class="thick-divider"></view>
|
|
<view class="item-box">
|
|
<view class="item-title">原密码</view>
|
|
<input @input="inputOrgPwd" :value="name" placeholder="请输入原密码" class="item-content"
|
|
placeholder-class="item-input" />
|
|
</view>
|
|
<view style="width: 90%;background: #f2f2f2;height: 1rpx;align-self: center;"></view>
|
|
<view class="item-box">
|
|
<view class="item-title">新密码</view>
|
|
<input @input="inputNewPwd" :value="npassword" placeholder="请输入新密码" class="item-content"
|
|
placeholder-class="item-input" />
|
|
</view>
|
|
<view style="width: 90%;background: #f2f2f2;height: 1rpx;align-self: center;"></view>
|
|
<view class="item-box">
|
|
<view class="item-title">确认密码</view>
|
|
<input @input="inputConfirmPwd" :value="rnpassword" placeholder="请确认新密码" class="item-content"
|
|
placeholder-class="item-input" />
|
|
</view>
|
|
</view>
|
|
<!-- <view class="base-person">
|
|
<view class="item">
|
|
<view class="item-title">原密码</view>
|
|
<input @input="inputOrgPwd" :value="ypassword" placeholder="请输入原密码" />
|
|
</view>
|
|
<view class="item">
|
|
<view class="item-title">新密码</view>
|
|
<input @input="inputNewPwd" :value="npassword" placeholder="请输入新密码" />
|
|
</view>
|
|
<view class="item">
|
|
<view class="item-title">确认密码</view>
|
|
<input @input="inputConfirmPwd" :value="rnpassword" placeholder="请确认新密码" />
|
|
</view>
|
|
</view> -->
|
|
<view class="btn-box">
|
|
<view class="save-btn" @click="changePassword">确认提交</view>
|
|
</view>
|
|
</view>
|
|
<pageLoading v-if="showPageLoading"></pageLoading>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import pageLoading from '@/components/loading/pageLoading.vue';
|
|
import md5 from "@/common/md5";
|
|
export default {
|
|
components: {
|
|
pageLoading
|
|
},
|
|
data() {
|
|
return {
|
|
token: '',
|
|
ypassword: '',
|
|
npassword: '',
|
|
rnpassword: '',
|
|
showPageLoading: true,
|
|
};
|
|
},
|
|
methods: {
|
|
inputOrgPwd(event) {
|
|
this.ypassword = event.target.value
|
|
},
|
|
inputNewPwd(event) {
|
|
this.npassword = event.target.value
|
|
},
|
|
inputConfirmPwd(event) {
|
|
this.rnpassword = event.target.value
|
|
},
|
|
changePassword() {
|
|
var _self = this
|
|
if (_self.checkParams()) {
|
|
uni.showLoading({
|
|
title: '修改中...',
|
|
})
|
|
_self.$app.request({
|
|
url: _self.$api.user.doChangePwd,
|
|
method: 'PUT',
|
|
data: {
|
|
'newPassword': md5(md5(md5(_self.npassword))),
|
|
'oldPassword': md5(md5(md5(_self.ypassword)))
|
|
},
|
|
success: (res) => {
|
|
uni.hideLoading()
|
|
uni.showToast({
|
|
icon: "success",
|
|
title: '修改成功',
|
|
success() {
|
|
setTimeout(function() {
|
|
let pages = getCurrentPages(); // 当前页面
|
|
let beforePage = pages[pages.length - 2]; // 前一个页面
|
|
beforePage.$vm.loginOut = true;
|
|
uni.navigateBack()
|
|
}, 1000);
|
|
}
|
|
})
|
|
|
|
},
|
|
fail(error) {
|
|
uni.hideLoading()
|
|
uni.showToast({
|
|
title: '修改失败',
|
|
duration: 1000
|
|
})
|
|
}
|
|
})
|
|
}
|
|
},
|
|
checkParams() {
|
|
var _self = this;
|
|
if (_self.ypassword == '') {
|
|
uni.showToast({
|
|
title: '请输入原密码',
|
|
duration: 1000
|
|
})
|
|
return false;
|
|
}
|
|
if (_self.npassword == '') {
|
|
uni.showToast({
|
|
title: '请输入新密码',
|
|
duration: 1000
|
|
})
|
|
return false;
|
|
}
|
|
if (_self.rnpassword == '') {
|
|
uni.showToast({
|
|
title: '请输入新密码',
|
|
duration: 1000
|
|
})
|
|
return false;
|
|
}
|
|
if (_self.npassword != _self.rnpassword) {
|
|
uni.showToast({
|
|
title: '新密码不相同',
|
|
duration: 1000
|
|
})
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
},
|
|
onLoad() {
|
|
var _self = this;
|
|
_self.token = getApp().globalData.token
|
|
|
|
},
|
|
onUnload() {},
|
|
onShow() {
|
|
var _self = this;
|
|
uni.getStorage({
|
|
key: 'token',
|
|
success: res => {
|
|
_self.token = res.data;
|
|
}
|
|
});
|
|
_self.showPageLoading = false
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
page {
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
.page {
|
|
display: flex;
|
|
flex: 1;
|
|
flex-direction: column;
|
|
overflow: auto;
|
|
height: 100%;
|
|
}
|
|
|
|
.content {
|
|
flex: 1;
|
|
width: 100%;
|
|
height: 100rpx;
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
|
|
.base-person {
|
|
display: flex;
|
|
flex-direction: column;
|
|
justify-content: center;
|
|
align-items: flex-start;
|
|
font-size: 20rpx;
|
|
margin-bottom: 20rpx;
|
|
width: 100%;
|
|
|
|
.thick-divider {
|
|
height: 5rpx;
|
|
background: #f2f2f2;
|
|
width: 100%;
|
|
}
|
|
|
|
.hint-txt {
|
|
padding: 10rpx 40rpx;
|
|
color: darkred;
|
|
font-size: 20rpx;
|
|
background: #f2f2f2;
|
|
}
|
|
|
|
.item-box-v {
|
|
display: flex;
|
|
flex-direction: column;
|
|
justify-content: space-between;
|
|
margin-top: 10rpx;
|
|
background: white;
|
|
align-items: flex-start;
|
|
width: 100%;
|
|
padding-bottom: 50rpx;
|
|
|
|
.item-title {
|
|
font-size: 28rpx;
|
|
padding: 10rpx 30rpx;
|
|
}
|
|
|
|
.item-content {
|
|
display: flex;
|
|
flex-direction: row;
|
|
justify-content: flex-end;
|
|
align-items: center;
|
|
padding: 10rpx 30rpx;
|
|
font-size: 28rpx;
|
|
|
|
input {
|
|
font-size: 28rpx;
|
|
}
|
|
}
|
|
|
|
.item-content-bg {
|
|
display: flex;
|
|
flex-direction: column;
|
|
justify-content: flex-start;
|
|
align-items: center;
|
|
padding: 20rpx;
|
|
width: 85%;
|
|
background: #f3f3f3;
|
|
border-radius: 10rpx;
|
|
align-self: center;
|
|
height: 220rpx;
|
|
|
|
textarea {
|
|
font-size: 28rpx;
|
|
text-align: left;
|
|
width: 100%;
|
|
}
|
|
|
|
.hint-num {
|
|
align-self: flex-end;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
.item-box {
|
|
display: flex;
|
|
flex-direction: row;
|
|
justify-content: space-between;
|
|
margin-top: 10rpx;
|
|
background: white;
|
|
align-items: center;
|
|
width: 100%;
|
|
|
|
.item-input {
|
|
font-size: 28rpx;
|
|
}
|
|
|
|
.item-title {
|
|
font-size: 28rpx;
|
|
flex: 0.5;
|
|
padding: 15rpx 30rpx;
|
|
}
|
|
|
|
.item-content {
|
|
display: flex;
|
|
flex-direction: row;
|
|
justify-content: flex-end;
|
|
align-items: center;
|
|
flex: 1.5;
|
|
padding: 15rpx 30rpx;
|
|
}
|
|
}
|
|
|
|
.item {
|
|
display: flex;
|
|
flex-direction: row;
|
|
margin: 20rpx;
|
|
justify-content: flex-start;
|
|
align-items: center;
|
|
width: 95%;
|
|
|
|
.item-title {
|
|
font-size: 25rpx;
|
|
width: 100%;
|
|
background: #e4f3f2;
|
|
padding: 10rpx;
|
|
}
|
|
|
|
.item-title-box {
|
|
display: flex;
|
|
flex-direction: row;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
background: #f2f2f2;
|
|
padding: 10rpx;
|
|
width: 100%;
|
|
|
|
.item-title-name {
|
|
font-size: 20rpx;
|
|
}
|
|
|
|
.item-title-del {
|
|
color: darkgreen;
|
|
}
|
|
|
|
}
|
|
|
|
input {
|
|
margin-top: 20rpx;
|
|
padding: 10rpx;
|
|
width: 95%;
|
|
font-size: 25rpx;
|
|
border: 1rpx #d3d3d3 solid;
|
|
}
|
|
}
|
|
}
|
|
|
|
.add-person {
|
|
color: green;
|
|
border: 1rpx #c28127 solid;
|
|
border-radius: 10rpx;
|
|
text-align: center;
|
|
align-self: flex-start;
|
|
margin-top: 10rpx;
|
|
border-radius: 10rpx;
|
|
width: 25%;
|
|
padding: 10rpx;
|
|
}
|
|
|
|
.btn-box {
|
|
width: 100%;
|
|
align-items: center;
|
|
display: flex;
|
|
flex-direction: row;
|
|
justify-content: center;
|
|
background: white;
|
|
bottom: 0;
|
|
position: fixed;
|
|
|
|
.save-btn {
|
|
color: white;
|
|
background-color: #8cc7b5;
|
|
width: 95%;
|
|
border-radius: 10rpx;
|
|
text-align: center;
|
|
align-self: center;
|
|
margin-top: 5rpx;
|
|
border-radius: 10rpx;
|
|
padding: 10rpx;
|
|
}
|
|
}
|
|
</style>
|