<template>
|
<view class="">
|
<page-nav title="密码设置"></page-nav>
|
|
|
<view class="flex_column head titleFont" style="min-height: 1400rpx;">
|
<view class="flex_center marginTop20 marginLeft20">
|
<view style="margin-left: 36rpx;">原密码:</view>
|
<view class='inputClass'>
|
<u--input placeholder="请输入" border="surround" v-model="oldPassword"></u--input>
|
</view>
|
</view>
|
<view class="flex_center marginTop20 marginLeft20">
|
<view style="margin-left: 36rpx;">新密码:</view>
|
<view class='inputClass'>
|
<u--input placeholder="请输入" border="surround" v-model="newPassword"></u--input>
|
</view>
|
</view>
|
<view class="flex_center marginTop20 marginLeft20">
|
<view>确认密码:</view>
|
<view class='inputClass'>
|
<u--input placeholder="请输入" border="surround" v-model="newPasswordConfirm"></u--input>
|
</view>
|
</view>
|
</view>
|
|
|
<view class="footer">
|
<u-button :loading="isDisabledSubmitButtonReset" loadingText="重置中..."
|
style='width: 50%;border-radius: 10rpx 0 0 10rpx;' type="success" @click="resetPassword" text="重置密码"
|
size="large">
|
</u-button>
|
<u-button :loading="isDisabledSubmitButtonEdit" loadingText="修改中..."
|
style='width: 50%;border-radius:0 10rpx 10rpx 0' @click="editPassword" type="primary" text="修改密码"
|
size="large"></u-button>
|
</view>
|
|
</view>
|
</template>
|
|
|
<script>
|
import {
|
UpdateUserPassword,
|
ResettUserPassword
|
} from '../../config/api.js';
|
|
export default {
|
onLoad(option) {
|
|
},
|
|
onPullDownRefresh() {
|
setTimeout(() => {
|
this.init(() => {
|
uni.stopPullDownRefresh();
|
})
|
}, 1000);
|
},
|
|
data() {
|
return {
|
topRightMessageCount: '',
|
|
isDisabledSubmitButtonReset: false,
|
|
isDisabledSubmitButtonEdit: false,
|
|
oldPassword: '', //原密码
|
newPassword: '', //新密码
|
newPasswordConfirm: '', //确认密码
|
|
|
}
|
},
|
created() {
|
|
},
|
mounted() {
|
this.init()
|
|
},
|
methods: {
|
init() {
|
uni.stopPullDownRefresh();
|
},
|
|
// 重置密码
|
async resetPassword() {
|
const data = {
|
usercode: uni.getStorageSync("usercode"),
|
username: uni.getStorageSync("username"),
|
usertype: 'APP'
|
}
|
this.isDisabledSubmitButtonReset = true
|
const res = await ResettUserPassword(this.global.formatData(data))
|
|
if (res.code === '200') {
|
this.isDisabledSubmitButtonReset = false
|
this.$u.toast('密码重置成功!')
|
|
uni.setStorageSync("Token", '')
|
uni.setStorageSync("usercode", '')
|
uni.setStorageSync("username", '')
|
uni.setStorageSync("storg_code", '')
|
uni.setStorageSync("storg_name", '')
|
|
setTimeout(() => {
|
uni.redirectTo({
|
url: '../login/index'
|
});
|
}, 2000)
|
|
} else {
|
this.isDisabledSubmitButtonReset = false
|
this.$u.toast('密码重置失败!')
|
}
|
|
},
|
// 修改密码
|
async editPassword() {
|
if (!this.oldPassword) {
|
return this.$u.toast('请输入原密码!')
|
}
|
if (!this.newPassword) {
|
return this.$u.toast('请输入新密码!')
|
}
|
if (!this.newPasswordConfirm) {
|
return this.$u.toast('请输入确认密码!')
|
}
|
|
if (this.newPassword.trim() !== this.newPasswordConfirm.trim()) {
|
return this.$u.toast('新密码与确认密码不一致!')
|
}
|
|
const data = {
|
// usercode: uni.getStorageSync("usercode"),
|
// username: uni.getStorageSync("username"),
|
password: this.oldPassword.trim(),
|
newpassword: this.newPassword.trim()
|
}
|
|
this.isDisabledSubmitButtonEdit = true
|
const res = await UpdateUserPassword(this.global.formatData(data))
|
|
if (res.code === '200') {
|
this.isDisabledSubmitButtonEdit = false
|
this.$u.toast('密码修改成功!')
|
uni.setStorageSync("Token", '')
|
uni.setStorageSync("usercode", '')
|
uni.setStorageSync("username", '')
|
uni.setStorageSync("storg_code", '')
|
uni.setStorageSync("storg_name", '')
|
|
setTimeout(() => {
|
uni.redirectTo({
|
url: '../login/index'
|
});
|
}, 2000)
|
|
} else {
|
this.isDisabledSubmitButtonEdit = false
|
this.$u.toast('密码修改失败!')
|
}
|
|
}
|
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
@import url('@/style/global.css');
|
|
::v-deep .uicon-arrow-left>span {
|
display: block;
|
}
|
</style>
|