fix: 修复模态框显示时页面滚动问题

为多个组件添加watch监听,当模态框显示时隐藏页面滚动条,关闭时恢复
修复学校筛选条件中sid改为id的字段匹配问题
清理viewMap组件中多余的注释代码
This commit is contained in:
DESKTOP-RQ919RC\Pc
2025-09-02 19:00:51 +08:00
parent a60338cf3e
commit 0d443eb2e2
7 changed files with 42 additions and 12 deletions

View File

@@ -95,6 +95,7 @@ let watchSet = (num) => {
const handleEscKey = e => (e.key == "Escape" && close())
onMounted(() => {
document.body.style.overflow = "hidden";
watchEffect(() => {
show = props.show;
list.value = props.list;
@@ -106,6 +107,7 @@ onMounted(() => {
});
onBeforeUnmount(() => {
document.body.style.overflow = "unset";
window.removeEventListener("keydown", handleEscKey);
});

View File

@@ -48,9 +48,9 @@
<script setup>
import { ElLoading } from "element-plus";
import { ref, reactive, onMounted, getCurrentInstance, defineEmits, inject } from "vue";
import { ref, reactive, onMounted, getCurrentInstance, defineEmits, inject, watch } from "vue";
import { useRouter, useRoute } from "vue-router";
import store from "../../store/index"
import store from "../../store/index";
const { proxy } = getCurrentInstance();
const router = useRouter();
@@ -61,6 +61,11 @@ let identityList = ref([]);
let popType = ref(""); // choice agent: 确认是否是中介(有个人房源) affirmAgent: 确认是否是中介(有中介房源)
watch(popType, (newValue) => {
if (newValue) document.body.style.overflow = "hidden";
else document.body.style.overflow = "unset";
});
let agent = ref([`中介账号发布的房源信息,均展示在“<span style="color: #000; font-weight:650;">中介房源</span>”频道中,即不能发布“<span style="color: #000; font-weight:650;">个人房源</span>”、“<span style="color: #000; font-weight:650;">求房源</span>”;如您已上架个人房源或求房源信息,在你确认中介身份后,将会自动下架`]);
let affirmAgent = ref([`个人账号只能发布“<span style="color: #000; font-weight:650;">个人房源</span>”、“<span style="color: #000; font-weight:650;">求房源</span>”,在您确认不是中介身份后,将会自动下架您的中介房源;`, `中介账号只能发布“<span style="color: #000; font-weight:650;">中介房源</span>”,如您已上架个人房源或求房源信息,在你确认中介身份后,将会自动下架;`]);
@@ -78,7 +83,7 @@ let loading = ref(null); // 加载
// 点击按钮
const ClickBtn = () => {
if (store.state.realname == 0 && store.state.userInfoWin?.uin > 0) {
store.commit('openAttest')
store.commit("openAttest");
return;
}
if (identityList.value.length == 0) init();

View File

@@ -1,9 +1,7 @@
<template>
<div class="flexcenter" :class="{ 'pop-mask': show }">
<div class="" :class="{ 'pop': show }">
<!-- <div class="close flexcenter" > -->
<img class=" close icon" @click="showPop" src="@/assets/img/publicImage/white-cross.svg">
<!-- </div> -->
<div id="container">
<div class="location-bj flexcenter" @click="showPop" v-if="!show">
<div class="location-site flexacenter" v-if="props['name']">
@@ -18,7 +16,7 @@
</template>
<script setup>
import { ref, defineProps, defineExpose } from 'vue';
import { ref, defineProps, defineExpose, watch } from 'vue';
const props = defineProps({
latlng: Object,
@@ -60,6 +58,11 @@ loadScript(`https://map.qq.com/api/gljs?v=1.exp&key=${key.value}&callback=initMa
let show = ref(false) // 弹窗状态
watch(show, (newValue) => {
if (newValue) document.body.style.overflow = "hidden";
else document.body.style.overflow = "unset";
});
const showPop = () => {
show.value = !show.value
// if (!show.value) return

View File

@@ -1520,6 +1520,11 @@ const getLikeList = () => {
let isSelectSchool = ref(false); // 选择学校状态
watch(isSelectSchool, (newValue) => {
if (newValue) document.body.style.overflow = "hidden";
else document.body.style.overflow = "unset";
});
let distancePitch = ref({});
let distanceList = ref([]);
@@ -1633,6 +1638,11 @@ let returnSum = ref(0);
let remarkList = ref([]);
let remarkTypeid = ref(0); // 0 全部 1 考察 2 回访
watch(isInspectPop, (newValue) => {
if (newValue) document.body.style.overflow = "hidden";
else document.body.style.overflow = "unset";
});
const getComment = () => {
proxy
.$post("https://api.gter.net/v1/apartment/comment", { token })

View File

@@ -897,6 +897,11 @@ let clone = (text) => {
//显示联系方式
let showConcat = ref(false);
watch(showConcat, (newValue) => {
if (newValue) document.body.style.overflow = "hidden";
else document.body.style.overflow = "unset";
});
//数据包
let indexData = reactive({});
//房源详情

View File

@@ -814,6 +814,12 @@ export default {
pageTopBar,
userBox,
},
watch: {
targetAreaState(newVal) {
if (newVal) document.body.style.overflow = "hidden";
else document.body.style.overflow = "unset";
},
},
methods: {
require(url) {
return require(url);
@@ -955,7 +961,6 @@ export default {
}
});
this.info = info;
this.verified = data.verified;
// this.verified = 1

View File

@@ -92,7 +92,7 @@ onMounted(() => {
// 判断 学校id是否在筛选
if (value["school"]) {
const schoolList = store.state.schoolList || [];
const isExist = schoolList.some((item) => item.sid == value["school"]);
const isExist = schoolList.some((item) => item.id == value["school"]);
if (!isExist) value["school"] = 0;
}
pitchValue.value = value;