<template>
|
<view class="change-password-page">
|
<view class="change-password-page__form">
|
<view class="change-password-page__item">
|
<text class="change-password-page__label"><text style="color: red;">*</text>原始密码</text>
|
<input v-model="form.oldPassword" class="change-password-page__input" password placeholder="请输入原始密码" placeholder-style="color: #c2c7d0;" />
|
</view>
|
<view class="change-password-page__item">
|
<text class="change-password-page__label"><text style="color: red;">*</text>新密码</text>
|
<input v-model="form.password" class="change-password-page__input" password placeholder="请输入新密码" placeholder-style="color: #c2c7d0;" />
|
</view>
|
<view class="change-password-page__item">
|
<text class="change-password-page__label"><text style="color: red;">*</text>确认密码</text>
|
<input v-model="form.confirmPassword" class="change-password-page__input" password placeholder="请再次输入新密码" placeholder-style="color: #c2c7d0;" />
|
</view>
|
|
<text class="change-password-page__rule">密码规则:字母、数字组合,不少于8个字符</text>
|
</view>
|
|
<button class="change-password-page__submit" hover-class="change-password-page__submit--hover" @click="handleSubmit">确认修改</button>
|
</view>
|
</template>
|
<script>
|
export default {
|
data() {
|
return {
|
form: {
|
oldPassword:'',
|
password: '',
|
confirmPassword: ''
|
}
|
}
|
},
|
methods: {
|
handleSubmit() {
|
if (!this.form.oldPassword) {
|
uni.showToast({ title: '请输入原始密码', icon: 'none' })
|
return
|
}
|
if (!this.form.password) {
|
uni.showToast({ title: '请输入新密码', icon: 'none' })
|
return
|
}
|
if (!this.form.confirmPassword) {
|
uni.showToast({ title: '请再次输入新密码', icon: 'none' })
|
return
|
}
|
if (this.form.password !== this.form.confirmPassword) {
|
uni.showToast({ title: '两次密码输入不一致', icon: 'none' })
|
return
|
}
|
const passwordRegex = /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$/
|
if (!passwordRegex.test(this.form.password)) {
|
uni.showToast({ title: '密码需字母、数字组合,不少于8个字符', icon: 'none' })
|
return
|
}
|
uni.showLoading({ title: '修改中...' })
|
this.$u.api.changePassword({ newPassword: this.form.password,oldPassword:this.form.oldPassword }).then(res => {
|
uni.hideLoading()
|
if (res.code === 200) {
|
uni.showToast({ title: '修改成功,下次登录请使用新密码登录', icon: 'success' })
|
}
|
}).catch(err => {
|
uni.hideLoading()
|
})
|
}
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
.change-password-page {
|
min-height: 100vh;
|
background: #ffffff;
|
padding-top: 2rpx;
|
|
&__form {
|
background: #ffffff;
|
}
|
|
&__item {
|
display: flex;
|
align-items: center;
|
height: 100rpx;
|
padding: 0 30rpx;
|
border-bottom: 1rpx solid #eceff4;
|
}
|
|
&__label {
|
width: 150rpx;
|
font-size: 32rpx;
|
font-weight: 500;
|
color: #333333;
|
flex-shrink: 0;
|
}
|
|
&__input {
|
flex: 1;
|
height: 100rpx;
|
text-align: right;
|
font-size: 30rpx;
|
color: #333333;
|
background: transparent;
|
}
|
|
&__rule {
|
display: block;
|
padding: 20rpx 30rpx 0;
|
font-size: 24rpx;
|
line-height: 1.6;
|
color: #b3b8c1;
|
}
|
|
&__submit {
|
width: calc(100% - 60rpx);
|
height: 78rpx;
|
line-height: 78rpx;
|
margin: 110rpx auto 0;
|
border-radius: 999rpx;
|
background: #2476f6;
|
font-size: 30rpx;
|
font-weight: 500;
|
color: #ffffff;
|
border: 0;
|
padding: 0;
|
|
&::after {
|
border: 0;
|
}
|
|
&--hover {
|
opacity: 0.92;
|
}
|
}
|
}
|
</style>
|