</view>
<view class="card-item">
<view class="left">
<text>确认密码</text>
</view>
<view class="center">
<input type="text" maxlength="16" :password="CPWD" class="s-input"
placeholder="请输入确认密码" v-model="passwordVo.confirm_password"
/>
</view>
<view class="right">
<uni-icons class="right-icon" color="#999999" :size="24" type="CPWD?'eye-slash':'eye'" @click="changePassword('CPWD')" /> </view>
</view>
</view>
</view>
<view class="submit-box">
<view @click="confirm" class="submit-btn" :class="{'active':canLogin}">提交
</view>
</view>
</view>
</template>
<script>
import service from '@/service';
import {
regexPassword
} from '@/utils/formRegex.js';
export default {
components: {},
computed: {
// 登录按钮是否高亮
canLogin() {
if (this.passwordVo.new_password && this.passwordVo.confirm_password) {
return true;
} else {
return false;
}
}
},
data() {
return {
pageTitle: '修改密码',
passwordVo: {
new_password: '',
confirm_password: '',
},
NPWD: true,
CPWD: true,
};
},
methods: {
// 密码框切换
changePassword(val) {
this[val] = !this[val];
},
newpasswordInput({
detail: {
value
}
}) {
// if (regexPassword(value)) {
// console.log('密码验证成功');
// } else {
// uni.showToast({
// icon: 'none',
// title: '密码至少8个字符,且包含大小写英文字母及数字',
// });
// }
},
confirm() {
if (this.passwordVo.new_password === '') {
uni.showToast({
icon: 'none',
title: '新密码不能为空',
});
return;
}
if (this.passwordVo.confirm_password === '') {
uni.showToast({
icon: 'none',
title: '确认密码不能为空',
});
return;
}
if (this.passwordVo.new_password != this.passwordVo.confirm_password) {
uni.showToast({
icon: 'none',
title: '两次输入的密码不一致',
});
return;
} else if (!regexPassword(this.passwordVo.new_password)) {
uni.showToast({
icon: 'none',
title: '密码至少8个字符,且包含大小写英文字母及数字',
});
return;
} else if (!regexPassword(this.passwordVo.confirm_password)) {
uni.showToast({
icon: 'none',
title: '密码至少8个字符,且包含大小写英文字母及数字',
});
return;
} else {
this.senNet();
}
},
senNet() {
let obj = {
password: this.passwordVo.new_password
};
this.$http.setPassword(obj).then((res) => {
if (res.code === '000000') {
uni.showToast({
icon: 'none',
title: '密码设置成功',
mask: true,
duration: 2000
});
setTimeout(() => {
uni.reLaunch({
url: '/pages/my/index'
})
}, 2000);
}
}).finally(() => {
uni.hideLoading({
noConflict: true
});
});
},
},
};
</script>
<style lang="scss" scoped>
.page-container {
background: #F7F7F7;
}
.content {
.operation-card {
background: #fff;
margin: 20rpx 20rpx 0;
border-radius: 16rpx;
overflow: hidden;
.card-title {
font-weight: 500;
font-size: 32rpx;
color: #000000;
line-height: 28rpx;
margin: 40rpx 30rpx 34rpx;
}
.card-item {
height: 112rpx;
display: flex;
align-items: center;
border-bottom: 2rpx solid #F7F7F7;
margin: 0 32rpx;
padding: 32rpx 0;
box-sizing: border-box;
border-radius: 16rpx;
overflow: hidden;
.left {
width: 160rpx;
}
.center {
flex: 1;
display: flex;
align-items: center;
.s-input {
flex: 1;
height: 112rpx;
}
}
.right {
width: 48rpx;
padding: 20rpx;
margin-left: 20rpx;
.right-icon {
height: 100%;
display: flex;
align-items: center;
// padding: 0 10rpx;
}
}
}
.card-item:last-child {
border-bottom: none;
}
}
}
.submit-box {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
background: #fff;
padding: 28rpx 32rpx 68rpx;
border-radius: 32rpx 32rpx 0px 0px;
overflow: hidden;
box-sizing: border-box;
.submit-btn {
width: 100%;
height: 100rpx;
background: #C4D6FF;
border-radius: 16rpx;
font-weight: 600;
overflow: hidden;
font-size: 36rpx;
color: #ffffff;
display: flex;
justify-content: center;
align-items: center;
}
.submit-btn.active {
background: #3974FE;
}
}
</style>
1***@qq.com (作者)
日了,原生也有
2025-08-07 16:05
1***@qq.com (作者)
tm,把锅甩给腾讯,老板今天就要
2025-08-07 16:06
DCloud_UNI_yuhe
回复 1***@qq.com: 这样得去微信社区反馈一下了
2025-08-12 15:51