<template>
|
<view class="login">
|
<view class="login-main">
|
<text class="login-main-title">修改密码</text>
|
<view class="login-main-subtitle">修改后请保存密码,忘记密码请找管理员修改</view>
|
<view class="login-main-body">
|
<uni-forms ref="form" :modelValue="formData">
|
<uni-forms-item label="原密码:" required name="yuser">
|
<uni-easyinput v-model="formData.yuser" type="password" focus
|
placeholder="请输入原密码"></uni-easyinput>
|
</uni-forms-item>
|
<uni-forms-item label="新密码:" required name="newpass">
|
<uni-easyinput type="password" v-model="formData.newpass" placeholder="请输入新密码"></uni-easyinput>
|
</uni-forms-item>
|
<uni-forms-item label="确认密码:" required name="qnewpass">
|
<uni-easyinput type="password" v-model="formData.qnewpass" placeholder="请确认新密码"></uni-easyinput>
|
</uni-forms-item>
|
<u-button type="success" size="default" shape="circle" :ripple="true" ripple-bg-color="#909399"
|
@click="login">
|
修改
|
</u-button>
|
</uni-forms>
|
</view>
|
</view>
|
</view>
|
</template>
|
|
<script>
|
import smCrypto from '@/common/smCrypto.js'
|
export default {
|
data() {
|
return {
|
formData: {
|
newpass: '',
|
qnewpass: '',
|
yuser: '',
|
},
|
rules: {
|
newpass: {
|
rules: [{
|
required: true,
|
errorMessage: '请输入新密码',
|
}, ]
|
},
|
qnewpass: {
|
rules: [{
|
required: true,
|
errorMessage: '请再次确认新密码',
|
}, {
|
validateFunction: function(rule, value, data, callback) {
|
console.log(data)
|
if (data.qnewpass != data.newpass) {
|
callback('两次密码不一致')
|
}
|
return true
|
}
|
}]
|
},
|
yuser: {
|
rules: [{
|
required: true,
|
errorMessage: '请输入原密码',
|
}]
|
}
|
}
|
}
|
},
|
onReady() {
|
// 需要在onReady中设置规则
|
this.$refs.form.setRules(this.rules)
|
},
|
methods: {
|
login(form) {
|
this.$refs.form.validate().then(res => {
|
console.log('success', res);
|
this.$t.message.loading('正在修改')
|
let parms = {
|
oldPwd: smCrypto.doSm2Encrypt(res.yuser),
|
newPwd: smCrypto.doSm2Encrypt(res.newpass),
|
}
|
let url ="/api/user/modifyPwd?oldPwd=" +this.formData.yuser +"&newPwd=" +this.formData.newpass;
|
this.$u.post(url,{}).then(res => {
|
console.log(res);
|
uni.clearStorage();
|
this.$t.message.toast(res.message)
|
this.$t.message.closeLoading()
|
setTimeout(e => {
|
uni.reLaunch({
|
url: '/pages/login/login'
|
});
|
},1500)
|
}).catch(err => {
|
this.$t.message.toast(res.message)
|
this.$t.message.closeLoading()
|
})
|
}).catch(err => {
|
this.$t.message.toast(err)
|
})
|
}
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
.login {
|
// font-family: PingFangSC-Regular, PingFang SC;
|
// background-color: $color-white;
|
height: calc(100vh - var(--window-top));
|
width: 100vw;
|
box-sizing: border-box;
|
|
&-main {
|
padding: 112rpx 75rpx 0 75rpx;
|
position: relative;
|
|
&-title {
|
display: flex;
|
justify-content: center;
|
align-items: center;
|
height: 64rpx;
|
font-size: 48rpx;
|
font-weight: 600;
|
// color: $color-text-secondary;
|
line-height: 64rpx;
|
letter-spacing: 8rpx;
|
}
|
|
&-subtitle {
|
font-size: 28rpx;
|
// color: $color-text-thirdly;
|
line-height: 40rpx;
|
letter-spacing: 12rpx;
|
text-align: center;
|
margin: 8rpx 0 104rpx;
|
}
|
|
&-body {
|
position: relative;
|
box-sizing: border-box;
|
width: 600rpx;
|
height: 548rpx;
|
|
.login-password {
|
position: relative;
|
padding: 40rpx 0 40rpx;
|
}
|
|
.login-passwordre {
|
position: relative;
|
padding: 0rpx 0 40rpx;
|
}
|
|
.verCode {
|
position: relative;
|
padding: 0rpx 0 140rpx;
|
display: flex;
|
flex-direction: row;
|
align-items: center;
|
justify-content: center;
|
}
|
}
|
}
|
|
&-footer {
|
display: flex;
|
flex-direction: column;
|
width: 100%;
|
height: 300rpx;
|
text-align: center;
|
line-height: 28rpx;
|
font-size: 20rpx;
|
font-weight: 500;
|
}
|
}
|
</style>
|