<template>
|
<view class="change">
|
<view class="change_list">
|
<view class="change_list_item">
|
<view class="label">新密码</view>
|
<view class="input">
|
<input type="password" v-if="!isOpen" v-model="password" placeholder="请输入新密码" placeholder-class="placeholder" />
|
<input type="text" v-else v-model="password" placeholder="请输入新密码" placeholder-class="placeholder" />
|
<u-icon name="eye-fill" color="#999999" size="20" v-if="!isOpen" @click="isOpen = true"></u-icon>
|
<u-icon name="eye-off" color="#999999" size="20" v-else @click="isOpen = false"></u-icon>
|
</view>
|
</view>
|
<view class="change_list_item">
|
<view class="label">确认密码</view>
|
<view class="input">
|
<input type="password" v-if="!isOpen1" v-model="confirmPassword" placeholder="请再次输入新密码" placeholder-class="placeholder" />
|
<input type="text" v-else v-model="confirmPassword" placeholder="请再次输入新密码" placeholder-class="placeholder" />
|
<u-icon name="eye-fill" color="#999999" size="20" v-if="!isOpen1" @click="isOpen1 = true"></u-icon>
|
<u-icon name="eye-off" color="#999999" size="20" v-else @click="isOpen1 = false"></u-icon>
|
</view>
|
</view>
|
</view>
|
<view class="change_info">密码规则:字母、数字组合,不少于8个字符</view>
|
<view class="change_submit" @click="submit">确认</view>
|
<u-toast ref="uToast"></u-toast>
|
</view>
|
</template>
|
|
<script>
|
import { CheckPassWord } from '@/utils/utils.js'
|
import { mapState } from 'vuex'
|
export default {
|
data() {
|
return {
|
password: '',
|
confirmPassword: '',
|
isOpen: false,
|
isOpen1: false
|
};
|
},
|
computed: {
|
...mapState(['userInfo'])
|
},
|
methods: {
|
submit() {
|
if (!this.password) {
|
uni.showToast({
|
title: '新密码不能为空',
|
icon: 'none',
|
duration: 2000
|
});
|
return
|
}
|
if (!CheckPassWord(this.password)) {
|
uni.showToast({
|
title: '密码必须为字母、数字组合,不少于8个字符',
|
icon: 'none',
|
duration: 2000
|
});
|
return
|
}
|
if (!this.confirmPassword) {
|
uni.showToast({
|
title: '确认密码不能为空',
|
icon: 'none',
|
duration: 2000
|
});
|
return
|
}
|
if (this.password !== this.confirmPassword) {
|
uni.showToast({
|
title: '密码不一致',
|
icon: 'none',
|
duration: 2000
|
});
|
return
|
}
|
this.$u.api.resetPwd({ id: this.userInfo.id, password: this.password })
|
.then(res => {
|
uni.showToast({
|
title: '修改成功',
|
mask: true,
|
icon: 'success',
|
duration: 2000,
|
complete() {
|
setTimeout(() => {
|
uni.navigateBack({
|
delta: 1
|
});
|
}, 2000)
|
}
|
});
|
})
|
}
|
}
|
}
|
</script>
|
|
<style lang="scss">
|
.change {
|
width: 100%;
|
padding-top: 20rpx;
|
box-sizing: border-box;
|
.change_list {
|
width: 100%;
|
padding: 0 30rpx;
|
background-color: #fff;
|
box-sizing: border-box;
|
.change_list_item {
|
width: 100%;
|
height: 100%;
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
border-bottom: 1rpx solid #E5E5E5;
|
&:last-child {
|
border: none !important;
|
}
|
.label {
|
font-size: 30rpx;
|
font-family: PingFangSC-Regular, PingFang SC;
|
font-weight: 400;
|
color: #222222;
|
flex-shrink: 0;
|
margin-right: 30rpx;
|
}
|
.input {
|
flex: 1;
|
height: 100rpx;
|
line-height: 100rpx;
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
.placeholder {
|
font-size: 28rpx;
|
font-family: PingFangSC-Regular, PingFang SC;
|
font-weight: 400;
|
color: #999999;
|
}
|
input {
|
width: 100%;
|
height: 100%;
|
font-size: 28rpx;
|
font-family: PingFangSC-Regular, PingFang SC;
|
font-weight: 400;
|
color: #000000;
|
text-align: right;
|
margin-right: 20rpx;
|
}
|
}
|
}
|
}
|
.change_info {
|
font-size: 26rpx;
|
font-family: PingFangSC-Regular, PingFang SC;
|
font-weight: 400;
|
color: #999999;
|
margin-top: 24rpx;
|
margin-left: 32rpx;
|
}
|
.change_submit {
|
width: calc(100% - 60rpx);
|
margin-left: 30rpx;
|
box-sizing: border-box;
|
height: 88rpx;
|
line-height: 88rpx;
|
text-align: center;
|
background: #0055FF;
|
border-radius: 4rpx;
|
font-size: 30rpx;
|
font-family: PingFangSC-Regular, PingFang SC;
|
font-weight: 400;
|
color: #FFFFFF;
|
margin-top: 100rpx;
|
}
|
}
|
</style>
|