设置密码
This commit is contained in:
@@ -17,6 +17,19 @@
|
||||
<view class="input-titile">姓名</view>
|
||||
<input class="input-con" v-model="fromValue.name" placeholder="请输入您的姓名" />
|
||||
</view>
|
||||
<view class="content-input" :class="{ 'input-error': passwordError }">
|
||||
<view class="input-titile">设置密码</view>
|
||||
<input
|
||||
class="input-con"
|
||||
v-model="fromValue.ytjPassword"
|
||||
placeholder="请输入密码"
|
||||
type="password"
|
||||
maxlength="8"
|
||||
@input="validatePassword"
|
||||
/>
|
||||
<view v-if="passwordError" class="error-message">{{ passwordError }}</view>
|
||||
<view v-if="fromValue.ytjPassword && !passwordError" class="success-message">✓ 密码格式正确</view>
|
||||
</view>
|
||||
<view class="content-sex">
|
||||
<view class="sex-titile">性别</view>
|
||||
<view class="sext-ri">
|
||||
@@ -160,6 +173,7 @@ const state = reactive({
|
||||
});
|
||||
const fromValue = reactive({
|
||||
name: '',
|
||||
ytjPassword: '', // 新增密码字段
|
||||
sex: 0,
|
||||
birthDate: '',
|
||||
education: '',
|
||||
@@ -167,6 +181,9 @@ const fromValue = reactive({
|
||||
idCard: '',
|
||||
phone: ''
|
||||
});
|
||||
|
||||
// 输入校验相关
|
||||
const passwordError = ref('');
|
||||
// 移除重复的onLoad定义,已在上方实现
|
||||
|
||||
// 在onLoad中初始化数据,确保页面加载时就能获取技能信息
|
||||
@@ -240,6 +257,7 @@ function initLoad() {
|
||||
const currentUserInfo = userInfo.value && Object.keys(userInfo.value).length > 0 ? userInfo.value : cachedUserInfo;
|
||||
|
||||
fromValue.name = currentUserInfo.name || '';
|
||||
fromValue.ytjPassword = ''; // 密码输入框默认为空,不加载已有密码
|
||||
fromValue.sex = currentUserInfo.sex !== undefined ? Number(currentUserInfo.sex) : 0;
|
||||
fromValue.phone = currentUserInfo.phone || '';
|
||||
fromValue.birthDate = currentUserInfo.birthDate || '';
|
||||
@@ -356,6 +374,12 @@ const confirm = () => {
|
||||
return $api.msg('请输入正确手机号');
|
||||
}
|
||||
|
||||
// 密码校验
|
||||
validatePassword();
|
||||
if (fromValue.ytjPassword && passwordError.value) {
|
||||
return $api.msg(passwordError.value);
|
||||
}
|
||||
|
||||
// 构建appSkillsList数据结构 - 使用新的技能数据结构,包含id字段
|
||||
const appSkillsList = state.skills
|
||||
.filter(skill => skill.name && skill.name.trim() !== '')
|
||||
@@ -613,6 +637,54 @@ const changeSex = (sex) => {
|
||||
fromValue.sex = sex;
|
||||
};
|
||||
|
||||
// 密码实时校验
|
||||
const validatePassword = () => {
|
||||
const password = (fromValue.ytjPassword || '').trim();
|
||||
|
||||
// 如果为空,清除错误信息
|
||||
if (!password) {
|
||||
passwordError.value = '';
|
||||
return;
|
||||
}
|
||||
|
||||
// 校验规则:长度8位,包含大小写字母和数字,至少各有一个
|
||||
if (password.length !== 8) {
|
||||
passwordError.value = '密码长度必须为8位';
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查是否包含大写字母
|
||||
const hasUpperCase = /[A-Z]/.test(password);
|
||||
// 检查是否包含小写字母
|
||||
const hasLowerCase = /[a-z]/.test(password);
|
||||
// 检查是否包含数字
|
||||
const hasNumber = /[0-9]/.test(password);
|
||||
|
||||
if (!hasUpperCase) {
|
||||
passwordError.value = '密码必须包含至少一个大写字母';
|
||||
return;
|
||||
}
|
||||
|
||||
if (!hasLowerCase) {
|
||||
passwordError.value = '密码必须包含至少一个小写字母';
|
||||
return;
|
||||
}
|
||||
|
||||
if (!hasNumber) {
|
||||
passwordError.value = '密码必须包含至少一个数字';
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查是否只包含字母和数字
|
||||
if (!/^[A-Za-z0-9]+$/.test(password)) {
|
||||
passwordError.value = '密码只能包含大小写字母和数字';
|
||||
return;
|
||||
}
|
||||
|
||||
// 校验通过
|
||||
passwordError.value = '';
|
||||
};
|
||||
|
||||
const changePoliticalAffiliation = () => {
|
||||
openSelectPopup({
|
||||
title: '政治面貌',
|
||||
@@ -770,6 +842,19 @@ function getDatePickerIndexes(dateStr) {
|
||||
height: 80rpx;
|
||||
border-bottom: 2rpx solid #EBEBEB
|
||||
position: relative;
|
||||
.error-message
|
||||
color: #ff4757;
|
||||
font-size: 24rpx;
|
||||
margin-top: 10rpx;
|
||||
line-height: 1.4;
|
||||
.success-message
|
||||
color: #2ed573;
|
||||
font-size: 24rpx;
|
||||
margin-top: 10rpx;
|
||||
line-height: 1.4;
|
||||
.input-error
|
||||
.input-con
|
||||
border-bottom-color: #ff4757;
|
||||
.triangle::before
|
||||
position: absolute;
|
||||
right: 20rpx;
|
||||
|
||||
Reference in New Issue
Block a user