emis-app/pages/user/updatePassword.vue
2024-06-11 01:07:56 +08:00

122 lines
2.9 KiB
Vue

<template>
<tpx-page>
<tpx-layout>
<template v-slot:body>
<view class="com-jianju pos-rlt pb-30" style="padding-top: 2rpx;">
<view class="blcok-white radius-20">
<view class="">
<view class="">
<tpx-input type="password" v-model:value="submitParam.oldPassword" placeholder="原密码"></tpx-input>
</view>
<view class="mt-30">
<tpx-input type="password" v-model:value="submitParam.newPassword" placeholder="新密码"></tpx-input>
</view>
<view class="mt-30">
<tpx-input type="password" v-model:value="submitParam._confirmNewPassword" placeholder="新确认密码"></tpx-input>
</view>
</view>
</view>
</view>
</template>
<template v-slot:footer>
<view class="blcok-white-noradius">
<u-button @click="handleSubmit()" type="primary" size="large" shape="circle"
custom-style="height:80rpx;font-size: 30rpx;"
>确定</u-button>
</view>
</template>
</tpx-layout>
</tpx-page>
</template>
<script>
import { USERKEY } from "@/store/actionKey"
import { encrypt } from "@/common/libs/jsencrypt_utils"
import * as apiService from "@/common/api"
import { checkParams } from "@/common/validate"
import { getSessionLoginInfo, setSessionLoginInfo } from "@/session"
export default {
props: {
},
computed: {
},
data() {
return {
queryOption: {
},
submitParam: {
oldPassword: '',
newPassword: '',
_confirmNewPassword: '',
},
submitValidConfig: {
oldPassword: { required: true, requiredMsg: '原密码不能为空' },
newPassword: { required: true, requiredMsg: '新密码不能为空' },
_confirmNewPassword: {
required: true, requiredMsg: '新确认密码不能为空',
validMsgFun: ({ val })=> {
let msg = ''
if(val.newPassword != val._confirmNewPassword) {
msg = '新确认密码和新密码必须一样'
}
return msg
}
},
},
}
},
onShareAppMessage() {
return {
// title: '',
// path: 'TODO'
}
},
onLoad(queryOption) {
this.queryOption = queryOption
this.initData();
},
onUnload() {
},
methods: {
async initData() {
},
async handleSubmit() {
let params = {
...this.submitParam,
// oldPassword: encrypt(this.submitParam.oldPassword),
// newPassword: encrypt(this.submitParam.newPassword),
}
await checkParams(this.submitParam, this.submitValidConfig)
await apiService.updatePwdByApp(params)
this.showToast("修改成功,请重新登录")
let info = getSessionLoginInfo()
delete info.password
setSessionLoginInfo(info)
await this.$store.dispatch(USERKEY.LOGOUT)
this.goto(`login/login`, 2)
},
}
}
</script>
<style lang="scss">
@import '@/common/uni-nvue.scss';
page {
background-color: #F6F6F6;
height: 100% !important;
}
</style>
<style scoped lang="scss">
</style>