实现个人信息的显示、隐藏小眼睛功能

This commit is contained in:
Qi 2025-04-27 20:27:52 +08:00
parent 229b607cc7
commit 8280137f43
1 changed files with 77 additions and 7 deletions

View File

@ -45,7 +45,12 @@
v-model="userInfo.identityId" v-model="userInfo.identityId"
name="userCardId" name="userCardId"
label="身份证号" label="身份证号"
/> :type="showIdentityId ? 'text' : 'text'"
>
<template #right-icon>
<van-icon class="icon" :name="showIdentityId ? 'eye-o' : 'closed-eye'" @click="toggleIdentityId"/>
</template>
</van-field>
<!-- <van-field--> <!-- <van-field-->
<!-- style="height: 35px; line-height: 100%"--> <!-- style="height: 35px; line-height: 100%"-->
<!-- v-model="user.sex"--> <!-- v-model="user.sex"-->
@ -70,8 +75,12 @@
v-model="userInfo.phone" v-model="userInfo.phone"
name="phone" name="phone"
label="手机号" label="手机号"
type="number" type="text"
/> >
<template #right-icon>
<van-icon class="icon" :name="showphone ? 'eye-o' : 'closed-eye'" @click="togglephone"/>
</template>
</van-field>
<van-field <van-field
style="height: 35px; line-height: 100%" style="height: 35px; line-height: 100%"
v-if="userInfo.jobTitle" v-if="userInfo.jobTitle"
@ -114,8 +123,12 @@
v-model="userInfo.pyCard" v-model="userInfo.pyCard"
name="pyCard" name="pyCard"
label="银行卡号" label="银行卡号"
type="number" type="text"
/> >
<template #right-icon>
<van-icon class="icon" :name="showpyCard ? 'eye-o' : 'closed-eye'" @click="togglepyCard"/>
</template>
</van-field>
<van-field <van-field
style="height: 35px; line-height: 100%" style="height: 35px; line-height: 100%"
@ -199,7 +212,7 @@
</van-form> </van-form>
</div> </div>
<span class="dialog-close-content" @click="show0 = false">×</span> <span class="dialog-close-content" @click="show0 = false, showIdentityId = false, showphone = false , showpyCard =false ">×</span>
</van-dialog> </van-dialog>
<p>我的信息</p> <p>我的信息</p>
</van-col> </van-col>
@ -347,6 +360,9 @@
const showDitu = ref(false); const showDitu = ref(false);
const handoff = ref(false); const handoff = ref(false);
const handoffValue = ref('xysh-img1'); const handoffValue = ref('xysh-img1');
const showIdentityId = ref(false);
const showphone = ref(false);
const showpyCard = ref(false);
function toggleShow() { function toggleShow() {
if (handoff.value) { if (handoff.value) {
@ -400,6 +416,13 @@
dormitoryStatus: 0, // 宿10 dormitoryStatus: 0, // 宿10
mealCard: '', // mealCard: '', //
dormitoryId: '', dormitoryId: '',
identityIdFull:'',
phoneFull:'',
pyCardFull:'',
identityIdMasked:'',
phoneMasked:'',
pyCardMasked:'',
}); });
const showGroup = () => { const showGroup = () => {
@ -441,7 +464,22 @@
(res) => { (res) => {
console.log('获取到的用户信息', res); console.log('获取到的用户信息', res);
Object.assign(userInfo, res.result.user); // 使 Object.assign Object.assign(userInfo, res.result.user); // 使 Object.assign
// console.log( store.LoginUser.majorId)
//
userInfo.identityIdFull = userInfo.identityId; //
userInfo.phoneFull = userInfo.phone; //
userInfo.pyCardFull = userInfo.pyCard; //
//
userInfo.identityIdMasked = userInfo.identityId.substring(0, 5) + '****' + userInfo.identityId.substring(13, 18);
userInfo.phoneMasked = userInfo.phone.substring(0, 3) + '****' + userInfo.phone.substring(7, 11);
userInfo.pyCardMasked = userInfo.pyCard.substring(0, 4) + '***********' + userInfo.pyCard.substring(15, 19);
//
userInfo.identityId = userInfo.identityIdMasked;
userInfo.phone = userInfo.phoneMasked;
userInfo.pyCard = userInfo.pyCardMasked;
console.log("userInfo.phone",userInfo.phone);
store.setMajorId(store.LoginUser.majorId); store.setMajorId(store.LoginUser.majorId);
Object.assign(showIcon, res.result); Object.assign(showIcon, res.result);
}, },
@ -460,6 +498,33 @@
}); });
return majorName; return majorName;
} }
//
const toggleIdentityId = () => {
showIdentityId.value = !showIdentityId.value;
if(showIdentityId.value){
userInfo.identityId = userInfo.identityIdFull; //
}else{
userInfo.identityId = userInfo.identityIdMasked; //
}
};
//
const togglephone = () => {
showphone.value = !showphone.value;
if(showphone.value){
userInfo.phone = userInfo.phoneFull; //
}else{
userInfo.phone = userInfo.phoneMasked; //
}
};
//
const togglepyCard = () => {
showpyCard.value = !showpyCard.value;
if(showpyCard.value){
userInfo.pyCard = userInfo.pyCardFull; //
}else{
userInfo.pyCard = userInfo.pyCardMasked; //
}
};
const majors = [ const majors = [
{ {
@ -680,4 +745,9 @@
background: url('@/assets/orangeUi/xysh2.jpg') no-repeat center center; background: url('@/assets/orangeUi/xysh2.jpg') no-repeat center center;
background-size: cover; background-size: cover;
} }
.icon {
font-size: 24px;
color: #666;
margin-right: -20px;
}
</style> </style>