Files
ks-app-employment-service/pages/nearby/nearby.vue

125 lines
3.7 KiB
Vue
Raw Normal View History

2024-11-18 16:33:37 +08:00
<template>
2025-05-13 11:10:38 +08:00
<AppLayout title="附近" :use-scroll-view="false">
<template #headerleft>
<view class="btn">
<image src="@/static/icon/back.png" @click="navBack"></image>
</view>
</template>
<view class="app-container">
<view class="nearby-head">
<view class="head-item" :class="{ actived: state.current === 0 }" @click="changeType(0)">附近工作</view>
<view class="head-item" :class="{ actived: state.current === 1 }" @click="changeType(1)">区县工作</view>
<view class="head-item" :class="{ actived: state.current === 2 }" @click="changeType(2)">地铁周边</view>
<view class="head-item" :class="{ actived: state.current === 3 }" @click="changeType(3)">商圈附近</view>
</view>
<view class="nearby-content">
<swiper class="swiper" :current="state.current" @change="changeSwiperType">
<swiper-item class="swiper-item" v-for="(_, index) in 4" :key="index">
<component :is="components[index]" :ref="(el) => handelComponentsRef(el, index)" />
</swiper-item>
</swiper>
</view>
2024-11-18 16:33:37 +08:00
</view>
2025-05-13 11:10:38 +08:00
</AppLayout>
2024-11-18 16:33:37 +08:00
</template>
<script setup>
import oneComponent from './components/one.vue';
import twoComponent from './components/two.vue';
import threeComponent from './components/three.vue';
import fourComponent from './components/four.vue';
import { reactive, inject, watch, ref, onMounted } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app';
2025-05-13 11:10:38 +08:00
const { $api, debounce, throttle, navBack } = inject('globalFunction');
2025-03-28 15:19:42 +08:00
const loadedMap = reactive([false, false, false, false]);
const swiperRefs = [ref(null), ref(null), ref(null), ref(null)];
const components = [oneComponent, twoComponent, threeComponent, fourComponent];
const filterId = ref(0);
const showFilter = ref(false);
const showFilter1 = ref(false);
const showFilter2 = ref(false);
const showFilter3 = ref(false);
2024-11-18 16:33:37 +08:00
const state = reactive({
2025-03-28 15:19:42 +08:00
current: 0,
2024-11-18 16:33:37 +08:00
all: [{}],
});
2025-03-28 15:19:42 +08:00
onMounted(() => {
handleTabChange(state.current);
});
const handelComponentsRef = (el, index) => {
if (el) {
2025-05-13 11:10:38 +08:00
console.log(el);
2025-03-28 15:19:42 +08:00
swiperRefs[index].value = el;
}
};
2024-11-18 16:33:37 +08:00
// 查看消息类型
function changeSwiperType(e) {
2025-03-28 15:19:42 +08:00
const index = e.detail.current;
state.current = index;
handleTabChange(index);
2024-11-18 16:33:37 +08:00
}
function changeType(index) {
state.current = index;
2025-03-28 15:19:42 +08:00
handleTabChange(index);
}
function handleTabChange(index) {
if (!loadedMap[index]) {
swiperRefs[index].value?.loadData();
loadedMap[index] = true;
}
2024-11-18 16:33:37 +08:00
}
</script>
<style lang="stylus" scoped>
2025-05-13 11:10:38 +08:00
.btn {
display: flex;
justify-content: space-between;
align-items: center;
width: 60rpx;
height: 60rpx;
}
image {
height: 100%;
width: 100%;
}
2024-11-18 16:33:37 +08:00
.app-container
width: 100%;
2025-05-13 11:10:38 +08:00
height: 100%;
2024-11-18 16:33:37 +08:00
display: flex;
flex-direction: column;
.nearby-head
height: 63rpx;
line-height: 63rpx;
text-align: center;
display: flex;
align-items: center;
2025-05-13 11:10:38 +08:00
font-weight: 400;
font-size: 32rpx;
color: #666D7F;
2024-11-18 16:33:37 +08:00
.head-item
width: calc(100% / 4);
z-index: 9
.actived
2025-03-28 15:19:42 +08:00
// width: 169rpx;
2025-05-13 11:10:38 +08:00
// height: 63rpx;
// background: #13C57C;
// box-shadow: 0rpx 7rpx 7rpx 0rpx rgba(0,0,0,0.25);
// border-radius: 0rpx 0rpx 0rpx 0rpx;
font-weight: 500;
font-size: 32rpx;
color: #000000;
2024-11-18 16:33:37 +08:00
.nearby-content
flex: 1;
overflow: hidden;
.swiper
height: 100%;
.swiper-item
display: flex;
flex-direction: column;
</style>