Files
qingdao-employment-service/pages/nearby/components/four.vue

455 lines
15 KiB
Vue
Raw Normal View History

2024-11-18 16:33:37 +08:00
<template>
2025-03-28 15:19:42 +08:00
<scroll-view :scroll-y="true" class="nearby-scroll" @scrolltolower="scrollBottom">
2024-11-18 16:33:37 +08:00
<view class="two-head">
2025-11-07 11:30:07 +08:00
<view class="head-all">
<text>热门商圈</text>
<text class="color_333333 button-click" @click="handleOpenBusinessDistrict">
更多
<uni-icons type="forward" color="#333333" size="14"></uni-icons>
</text>
2025-03-28 15:19:42 +08:00
</view>
2025-11-07 11:30:07 +08:00
<scroll-view class="scroll-head" :scroll-x="true" :scroll-into-view="activeTab" :show-scrollbar="false">
<view class="head-item-content">
<view
class="head-item"
:class="{ active: state.comId === item.commercialAreaId }"
v-for="(item, index) in comlistPuted"
:key="item.commercialAreaName"
@click="clickCommercialArea(item)"
>
{{ item.commercialAreaName }}
</view>
</view>
</scroll-view>
2024-11-18 16:33:37 +08:00
</view>
<view class="nearby-list">
2025-05-13 11:10:38 +08:00
<view class="nav-filter" @touchmove.stop.prevent>
<view class="filter-top">
<scroll-view :scroll-x="true" :show-scrollbar="false" class="tab-scroll">
<view class="jobs-left">
2025-03-28 15:19:42 +08:00
<view
2025-05-13 11:10:38 +08:00
class="job button-click"
:class="{ active: state.tabIndex === 'all' }"
2025-03-28 15:19:42 +08:00
@click="choosePosition('all')"
>
全部
</view>
<view
2025-05-13 11:10:38 +08:00
class="job button-click"
:class="{ active: state.tabIndex === index }"
2025-03-28 15:19:42 +08:00
v-for="(item, index) in userInfo.jobTitle"
:key="index"
2025-05-13 11:10:38 +08:00
@click="choosePosition(index)"
2025-03-28 15:19:42 +08:00
>
{{ item }}
</view>
2024-11-18 16:33:37 +08:00
</view>
</scroll-view>
2025-05-13 11:10:38 +08:00
<view class="jobs-add button-click" @click="navTo('/packageA/pages/addPosition/addPosition')">
<uni-icons class="iconsearch" color="#666D7F" type="plusempty" size="18"></uni-icons>
<text>添加</text>
2024-11-18 16:33:37 +08:00
</view>
</view>
2025-05-13 11:10:38 +08:00
<view class="filter-bottom">
<view class="btm-left">
<view
class="button-click filterbtm"
:class="{ active: pageState.search.order === item.value }"
v-for="item in rangeOptions"
@click="handelHostestSearch(item)"
:key="item.value"
>
{{ item.text }}
2025-03-28 15:19:42 +08:00
</view>
2024-11-18 16:33:37 +08:00
</view>
2025-05-13 11:10:38 +08:00
<view class="btm-right button-click" @click="openFilter">
筛选
<image class="right-sx" :class="{ active: showFilter }" src="@/static/icon/shaixun.png"></image>
2024-11-18 16:33:37 +08:00
</view>
</view>
</view>
2025-05-13 11:10:38 +08:00
<view class="one-cards">
<renderJobs :list="list" :longitude="longitudeVal" :latitude="latitudeVal"></renderJobs>
<empty v-if="!list.length"></empty>
<loadmore v-show="list.length > pageState.pageSize" ref="loadmoreRef"></loadmore>
2025-05-13 11:10:38 +08:00
</view>
2024-11-18 16:33:37 +08:00
</view>
2025-05-13 11:10:38 +08:00
<!-- 筛选 -->
<select-filter ref="selectFilterModel"></select-filter>
2025-11-07 11:30:07 +08:00
<select-filter2-col ref="selectFilter2ColModel"></select-filter2-col>
2024-11-18 16:33:37 +08:00
</scroll-view>
</template>
<script setup>
2025-11-07 11:30:07 +08:00
import { reactive, inject, watch, ref, onMounted, onBeforeUnmount, computed } from 'vue';
2025-03-28 15:19:42 +08:00
import { onLoad, onShow } from '@dcloudio/uni-app';
2025-05-13 11:10:38 +08:00
const { $api, navTo, debounce, customSystem } = inject('globalFunction');
import { storeToRefs } from 'pinia';
2025-03-28 15:19:42 +08:00
import useLocationStore from '@/stores/useLocationStore';
2025-05-13 11:10:38 +08:00
import useUserStore from '@/stores/useUserStore';
import useDictStore from '@/stores/useDictStore';
const { oneDictData } = useDictStore();
const { userInfo } = storeToRefs(useUserStore());
const { longitudeVal, latitudeVal } = storeToRefs(useLocationStore());
import point2 from '@/static/icon/point2.png';
import LocationPng from '@/static/icon/Location.png';
import selectFilter from '@/components/selectFilter/selectFilter.vue';
2025-11-07 11:30:07 +08:00
import selectFilter2Col from '@/components/selectFilter/selectFilter2Col.vue';
2025-05-13 11:10:38 +08:00
2025-03-28 15:19:42 +08:00
const emit = defineEmits(['onFilter']);
const state = reactive({
tabIndex: 'all',
2025-05-13 11:10:38 +08:00
tabBxText: 'buxianquyu',
2025-03-28 15:19:42 +08:00
comlist: [],
comId: 0,
2025-05-13 11:10:38 +08:00
areaInfo: {},
2025-03-28 15:19:42 +08:00
});
2025-11-07 11:30:07 +08:00
const commercialAreaList = ref([]);
2025-05-13 11:10:38 +08:00
const isLoaded = ref(false);
const showFilter = ref(false);
const selectFilterModel = ref();
2025-11-07 11:30:07 +08:00
const selectFilter2ColModel = ref();
2025-03-28 15:19:42 +08:00
const fromValue = reactive({
area: 0,
});
2025-11-07 11:30:07 +08:00
const activeTab = ref('');
2025-03-28 15:19:42 +08:00
const loadmoreRef = ref(null);
const pageState = reactive({
page: 0,
total: 0,
maxPage: 2,
pageSize: 10,
search: {
order: 0,
},
});
const list = ref([]);
2025-11-07 11:30:07 +08:00
const comlistPuted = computed(() => {
// const commercialArea = state.comlist.find((item) => item.commercialAreaId === state.comId);
// if (commercialArea) {
// const otherItems = state.comlist.filter((item) => item.commercialAreaId !== state.comId);
// return [commercialArea, ...otherItems];
// } else {
// return [state.areaInfo, ...state.comlist];
// }
// activeTab.value = state.areaInfo.commercialAreaId;
return state.comlist;
});
2025-05-13 11:10:38 +08:00
const rangeOptions = ref([
{ value: 0, text: '推荐' },
{ value: 1, text: '最热' },
{ value: 2, text: '最新发布' },
]);
function choosePosition(index) {
state.tabIndex = index;
list.value = [];
if (index === 'all') {
pageState.search = {
...pageState.search,
jobTitle: '',
};
getJobList('refresh');
} else {
// const id = useUserStore().userInfo.jobTitleId.split(',')[index];
pageState.search.jobTitle = userInfo.value.jobTitle[index];
getJobList('refresh');
}
}
function openFilter() {
showFilter.value = true;
selectFilterModel.value?.open({
title: '筛选',
maskClick: true,
success: (values) => {
pageState.search = {
...pageState.search,
};
for (const [key, value] of Object.entries(values)) {
pageState.search[key] = value.join(',');
}
showFilter.value = false;
getJobList('refresh');
},
cancel: () => {
showFilter.value = false;
},
});
}
2025-03-28 15:19:42 +08:00
onLoad(() => {
getBusinessDistrict();
});
async function loadData() {
try {
if (isLoaded.value) return;
2025-05-13 11:10:38 +08:00
const area = oneDictData('area')[0];
fromValue.area = area.value;
2025-03-28 15:19:42 +08:00
getJobList('refresh');
isLoaded.value = true;
} catch (err) {
isLoaded.value = false; // 重置状态允许重试
throw err;
}
}
2025-05-13 11:10:38 +08:00
function clickCommercialArea(area) {
state.areaInfo = area;
state.comId = area.commercialAreaId;
getJobList('refresh');
}
2025-03-28 15:19:42 +08:00
function scrollBottom() {
getJobList();
loadmoreRef.value.change('loading');
}
2025-05-13 11:10:38 +08:00
// function choosePosition(index) {
// state.tabIndex = index;
// if (index === 'all') {
// pageState.search.jobTitle = '';
// } else {
// pageState.search.jobTitle = userInfo.jobTitle[index];
// }
// getJobList('refresh');
// }
function changeArea(area, item) {
fromValue.area = area;
2025-03-28 15:19:42 +08:00
getJobList('refresh');
}
function getBusinessDistrict() {
2025-11-07 11:30:07 +08:00
$api.createRequest(`/app/common/commercialArea/getAllData`).then((resData) => {
2025-03-28 15:19:42 +08:00
if (resData.data.length) {
state.comlist = resData.data;
state.areaInfo = resData.data[0];
state.comId = resData.data[0].commercialAreaId;
}
});
}
2025-05-13 11:10:38 +08:00
2025-03-28 15:19:42 +08:00
function getJobList(type = 'add') {
if (type === 'add' && pageState.page < pageState.maxPage) {
pageState.page += 1;
}
if (type === 'refresh') {
pageState.page = 1;
pageState.maxPage = 2;
}
let params = {
longitude: state.areaInfo.longitude,
latitude: state.areaInfo.latitude,
current: pageState.page,
pageSize: pageState.pageSize,
radius: 2,
...pageState.search,
};
2025-05-13 11:10:38 +08:00
if (fromValue.area === state.tabBxText) {
params.countyIds = [];
}
$api.createRequest('/app/job/countyJob', params, 'POST').then((resData) => {
2025-03-28 15:19:42 +08:00
const { rows, total } = resData;
if (type === 'add') {
const str = pageState.pageSize * (pageState.page - 1);
const end = list.value.length;
const reslist = rows;
list.value.splice(str, end, ...reslist);
} else {
list.value = rows;
}
pageState.total = resData.total;
pageState.maxPage = Math.ceil(pageState.total / pageState.pageSize);
2025-07-21 14:49:45 +08:00
if (loadmoreRef.value && typeof loadmoreRef.value.change === 'function') {
if (rows.length < pageState.pageSize) {
loadmoreRef.value.change('noMore');
} else {
loadmoreRef.value.change('more');
}
2025-03-28 15:19:42 +08:00
}
});
}
function handelHostestSearch(val) {
pageState.search.order = val.value;
getJobList('refresh');
}
function handleFilterConfirm(val) {
pageState.search = {
order: pageState.search.order,
};
for (const [key, value] of Object.entries(val)) {
pageState.search[key] = value.join(',');
}
getJobList('refresh');
}
2025-11-07 11:30:07 +08:00
function handleOpenBusinessDistrict() {
if (commercialAreaList.value.length) {
openFilter2Col();
} else {
getBusinessDistrictList();
}
}
function getBusinessDistrictList() {
$api.createRequest(`/app/common/commercialArea`).then((resData) => {
if (resData.data.length) {
commercialAreaList.value = resData.data;
openFilter2Col();
}
});
}
function openFilter2Col() {
selectFilter2ColModel.value?.open({
data: commercialAreaList.value,
title: '商圈',
currentValue: state.comId,
maskClick: true,
success: (values) => {
pageState.search = {
...pageState.search,
latitude: values.latitude,
longitude: values.longitude,
};
state.areaInfo = values;
state.comId = values.value;
getJobList('refresh');
},
});
}
2025-03-28 15:19:42 +08:00
defineExpose({ loadData, handleFilterConfirm });
2024-11-18 16:33:37 +08:00
</script>
<style lang="stylus" scoped>
2025-11-07 11:30:07 +08:00
.scroll-head
width: 100%;
overflow: hidden;
2025-03-28 15:19:42 +08:00
.tabchecked
color: #4778EC !important
2024-11-18 16:33:37 +08:00
.nearby-scroll
overflow: hidden;
height: 100%;
background: #f4f4f4;
2024-11-18 16:33:37 +08:00
.two-head
padding: 22rpx;
2025-05-13 11:10:38 +08:00
display: flex;
2025-11-07 11:30:07 +08:00
flex-direction: column
flex-wrap: no-wrap
2025-05-13 11:10:38 +08:00
// grid-template-columns: repeat(4, 1fr);
// grid-column-gap: 10rpx;
// grid-row-gap: 24rpx;
background: #FFFFFF
// border-radius: 17rpx 17rpx 17rpx 17rpx;
2025-11-07 11:30:07 +08:00
.head-all{
display: flex;
justify-content: space-between;
align-items: center
margin-bottom: 16rpx
}
.head-item-content{
display: flex
flex-wrap: nowrap
}
2024-11-18 16:33:37 +08:00
.head-item
2025-11-07 11:30:07 +08:00
padding: 0 10rpx
2025-05-13 11:10:38 +08:00
margin: 10rpx
white-space: nowrap
2025-11-07 11:30:07 +08:00
// min-width: 156rpx
2025-05-13 11:10:38 +08:00
line-height: 64rpx
2024-11-18 16:33:37 +08:00
text-align: center;
2025-11-07 11:30:07 +08:00
// width: fit-content;
2024-11-18 16:33:37 +08:00
font-size: 21rpx;
2025-05-13 11:10:38 +08:00
font-weight: 400;
font-size: 28rpx;
color: #6C7282;
background: #F6F6F6;
border-radius: 12rpx 12rpx 12rpx 12rpx;
2024-11-18 16:33:37 +08:00
.active
2025-07-09 15:15:37 +08:00
font-family: 'PingFangSC-Medium', 'PingFang SC', 'Helvetica Neue', Helvetica, Arial, 'Microsoft YaHei', sans-serif;
2025-05-13 11:10:38 +08:00
color: #256BFA;
background: #E9F0FF;
border-radius: 12rpx 12rpx 12rpx 12rpx;
.nearby-list
border-top: 2rpx solid #EBEBEB;
2025-11-30 16:47:06 +08:00
min-height: calc(100% - 140rpx)
background: #f4f4f4
2025-11-30 16:47:06 +08:00
display: flex;
flex-direction: column;
2025-05-13 11:10:38 +08:00
.one-cards{
height: 100%
2024-11-18 16:33:37 +08:00
display: flex;
flex-direction: column;
2025-05-13 11:10:38 +08:00
padding: 0 20rpx 20rpx 20rpx;
background: #f4f4f4
2025-11-30 16:47:06 +08:00
flex: 1
2025-05-13 11:10:38 +08:00
}
.nav-filter
padding: 16rpx 28rpx 0 28rpx
background: #ffffff
2025-05-13 11:10:38 +08:00
.filter-top
display: flex
justify-content: space-between;
.tab-scroll
flex: 1;
overflow: hidden;
margin-right: 20rpx
white-space: nowrap;
overflow: hidden;
text-overflow: clip;
-webkit-mask-image: linear-gradient(to right, black 60%, transparent);
mask-image: linear-gradient(to right, black 60%, transparent);
.jobs-left
display: flex
flex-wrap: nowrap
.job
font-weight: 400;
font-size: 36rpx;
color: #666D7F;
margin-right: 32rpx;
white-space: nowrap
.active
2025-07-09 15:15:37 +08:00
font-family: 'PingFangSC-Medium', 'PingFang SC', 'Helvetica Neue', Helvetica, Arial, 'Microsoft YaHei', sans-serif;
2025-05-13 11:10:38 +08:00
font-weight: 500;
font-size: 36rpx;
color: #000000;
.jobs-add
display: flex
2024-11-18 16:33:37 +08:00
align-items: center;
2025-05-13 11:10:38 +08:00
justify-content: center;
font-weight: 400;
font-size: 32rpx;
color: #666D7F;
line-height: 38rpx;
.filter-bottom
display: flex
justify-content: space-between
padding: 24rpx 0
.btm-left
display: flex
.filterbtm
2024-11-18 16:33:37 +08:00
font-weight: 400;
2025-05-13 11:10:38 +08:00
font-size: 32rpx;
color: #666D7F;
margin-right: 40rpx
.active
font-weight: 500;
font-size: 32rpx;
color: #256BFA;
.btm-right
font-weight: 400;
font-size: 32rpx;
color: #6C7282;
.right-sx
width: 26rpx;
height: 26rpx;
.active
transform: rotate(180deg)
</style>