|
@@ -2,7 +2,7 @@
|
|
|
<view>
|
|
|
<Navbar></Navbar>
|
|
|
<view class="box defaultBgc">
|
|
|
- <scroll-view class="scrollBox" scroll-y="true" @scrolltolower="loadingMore" style="position:relative;">
|
|
|
+ <scroll-view class="scrollBox" :scroll-y="true" :scroll-top="scrollTop" @scrolltolower="loadingMore" @scroll="onScroll" style="position:relative;">
|
|
|
<view>
|
|
|
<SwiperAd :list="swiperAdList" :strType="false" @click="handleToDetails"></SwiperAd>
|
|
|
<!-- 五宫格菜单 -->
|
|
@@ -51,13 +51,13 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { ref, reactive } from 'vue'
|
|
|
+import { ref, reactive, nextTick } from 'vue'
|
|
|
import SwiperAd from '@/components/SwiperAd'
|
|
|
import FilterList from '@/components/FilterList'
|
|
|
import PositionList from '@/components/PositionList'
|
|
|
import AdvertisePop from '@/components/Advertisement'
|
|
|
import { dealDictObjData } from '@/utils/position'
|
|
|
-import { getJobAdvertisedSearch } from '@/api/position'
|
|
|
+import { getJobAdvertisedSearch, getPromotedPosition } from '@/api/position'
|
|
|
import { onShow, onLoad, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
|
|
|
import Navbar from '@/components/Navbar'
|
|
|
import { getRewardEventList } from '@/utils/eventList'
|
|
@@ -164,22 +164,48 @@ const handleGrid = async (e) => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+const checkValue = (obj) => {
|
|
|
+ return Object.values(obj).some(value => {
|
|
|
+ return value !== null && value !== undefined && value !== '' && (Array.isArray(value) ? value.length > 0 : true)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
const positionListData = ref([])
|
|
|
const query = reactive({
|
|
|
pageSize: 20,
|
|
|
pageNo: 1,
|
|
|
hire: false,
|
|
|
content: '',
|
|
|
+ positionId: '',
|
|
|
areaIds: [],
|
|
|
industryIds: [],
|
|
|
jobType: [],
|
|
|
- payScope: [],
|
|
|
- expType: []
|
|
|
+ payScope: ''
|
|
|
})
|
|
|
const getData = async () => {
|
|
|
+ // 效验是否有带搜索条件
|
|
|
+ const { content, areaIds, industryIds, jobType, payScope, positionId } = query
|
|
|
+ const hasValue = checkValue({ content, areaIds, industryIds, jobType, payScope, positionId })
|
|
|
+
|
|
|
+ // 带查询条件时返回到顶部
|
|
|
+ if (hasValue) {
|
|
|
+ scrollTop.value = old.value.scrollTop
|
|
|
+ nextTick(() => {
|
|
|
+ scrollTop.value = 0
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ // 带搜索条件(除分页外)用职位搜索接口,无条件则用推荐接口
|
|
|
+ const api = hasValue ? getJobAdvertisedSearch : getPromotedPosition
|
|
|
+ const params = hasValue ? query : { pageSize: query.pageSize, pageNo: query.pageNo, hire: 0 }
|
|
|
try {
|
|
|
- const res = await getJobAdvertisedSearch(query)
|
|
|
- const list = res?.data?.list || []
|
|
|
+ const res = await api(params)
|
|
|
+ const arr = res?.data?.list || []
|
|
|
+ // 推荐接口返回数据需要拼接
|
|
|
+ const list = !hasValue ? arr.map(e => {
|
|
|
+ const { anotherName, logoUrl, scale, industryId, enterpriseId, enterpriseName, ...job } = e
|
|
|
+ return { job, enterprise: { anotherName, logoUrl, scale, industryId, enterpriseId, name: enterpriseName } }
|
|
|
+ }) : arr
|
|
|
positionListData.value.push(...list.map(e => {
|
|
|
if (!e) {
|
|
|
return e
|
|
@@ -196,11 +222,17 @@ const getData = async () => {
|
|
|
query.pageNo--
|
|
|
more.value = 'more'
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
getData()
|
|
|
|
|
|
+const scrollTop = ref(0)
|
|
|
+const old = ref({
|
|
|
+ scrollTop: 0
|
|
|
+})
|
|
|
+const onScroll = (e) =>{
|
|
|
+ old.value.scrollTop = e.detail.scrollTop
|
|
|
+}
|
|
|
+
|
|
|
const handleSearch = (key, value) => {
|
|
|
if (key === 'positionId' || key === 'payScope') {
|
|
|
query[key] = value || null
|