position.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. <template>
  2. <view>
  3. <Navbar></Navbar>
  4. <view class="box defaultBgc">
  5. <scroll-view class="scrollBox" :scroll-y="true" :scroll-top="scrollTop" @scrolltolower="loadingMore" @scroll="onScroll" style="position:relative;">
  6. <view>
  7. <SwiperAd v-if="swiperAdList.length" :list="swiperAdList" imgUrlKey="img" :strType="false" @click="handleToDetails"></SwiperAd>
  8. <!-- 五宫格菜单 -->
  9. <view class="white-bgc ss-p-t-10">
  10. <uni-grid :column="5" @change="handleGrid" :showBorder="false">
  11. <uni-grid-item v-for="(val, index) in gridList" :index="index" :key="index">
  12. <view class="d-flex align-center flex-column justify-center" style="width: 100%; height: 100%; border: none;">
  13. <image :src="val.icon" style="width: 35px; height: 35px;"></image>
  14. <text class="text color-666 font-size-14 ss-m-t-15">{{ val.label }}</text>
  15. </view>
  16. </uni-grid-item>
  17. </uni-grid>
  18. </view>
  19. <!-- 搜索条 -->
  20. <view class="white-bgc stick ss-p-t-10">
  21. <view style="position: relative;">
  22. <uni-search-bar
  23. v-model="query.content"
  24. placeholder="输入职位/公司关键字"
  25. cancelButton="none"
  26. :focus="false"
  27. bgColor="#fff"
  28. @confirm="onSearch($event.value)"
  29. @clear="query.content = ''; onSearch()"
  30. >
  31. </uni-search-bar>
  32. <button class="search-btn" @tap.stop="onSearch">搜索</button>
  33. </view>
  34. </view>
  35. <view class="white-bgc px-10 stickFilter">
  36. <FilterList :list="filterList" idValue="label" @change="handleSearch"></FilterList>
  37. </view>
  38. <PositionList :list="positionListData" :noMore="false"></PositionList>
  39. <uni-load-more :status="more" />
  40. </view>
  41. </scroll-view>
  42. <AdvertisePop v-if="showAdvertisePop" />
  43. </view>
  44. </view>
  45. </template>
  46. <script setup>
  47. import { ref, reactive, nextTick } from 'vue'
  48. import SwiperAd from '@/components/SwiperAd'
  49. import FilterList from '@/components/FilterList'
  50. import PositionList from '@/components/PositionList'
  51. import AdvertisePop from '@/components/Advertisement'
  52. import { dealDictObjData } from '@/utils/position'
  53. import { getJobAdvertisedSearch, getPromotedPosition } from '@/api/position'
  54. import { onShow, onLoad, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
  55. import Navbar from '@/components/Navbar'
  56. import { getRewardEventList } from '@/utils/eventList'
  57. import { getMorningNewsArticle } from '@/api/content'
  58. import { getWebContent } from '@/api/common'
  59. onLoad(() => {
  60. wx.showShareMenu({
  61. withShareTicket: true,
  62. menus: ['shareAppMessage', 'shareTimeline']
  63. })
  64. onShareAppMessage(() => {
  65. return {
  66. title: '门墩儿 专注顶尖招聘',
  67. path: '/pages/index/position',
  68. imageUrl: '../../static/img/share-poster.jpg'
  69. }
  70. })
  71. onShareTimeline(() => {
  72. return {
  73. title: '门墩儿 专注顶尖招聘',
  74. path: '/pages/index/position',
  75. imageUrl: '../../static/img/share-poster.jpg'
  76. }
  77. })
  78. if (!uni.getStorageSync('token')) getRewardEventList()
  79. })
  80. const more = ref('more')
  81. // 轮播图-优选集团信息
  82. const preferredGroup = ref({})
  83. // 获取轮播图
  84. const showAdvertisePop = ref(false)
  85. const swiperAdList = ref([])
  86. const getSystemWebContent = async () => {
  87. const { data } = await getWebContent()
  88. swiperAdList.value = data?.appHomeCarousel || []
  89. // 是否展示弹窗广告
  90. showAdvertisePop.value = data && data.appAdvertisement && data.appAdvertisement.length ? true : false
  91. }
  92. const filterList = ref([
  93. { label: '城市', multiple: true, dictType: 'areaTreeData', key: 'areaIds', map: { text: 'name', value: 'id' } },
  94. // { label: '行业', dictType: 'industryTreeData',key: 'industryIds', map: { text: 'nameCn', value: 'id' } },
  95. { label: '职位', dictType: 'positionTreeData',key: 'positionId', map: { text: 'nameCn', value: 'id' } },
  96. { label: '求职类型', dictType: 'menduner_job_type', key: 'jobType' },
  97. { label: '薪资待遇', dictType: 'menduner_pay_scope', key: 'payScope' },
  98. // { label: '工作经验', dictType: 'menduner_exp_type', key: 'expType' },
  99. ])
  100. const gridList = [
  101. { label: '门墩儿猎头', icon: '/static/img/headhunting.png', path: '/pagesB/headhunting/index' },
  102. { label: '精选企业', icon: '/static/img/enterprise.png', path: '/pagesB/recommendEnterprise/index' },
  103. { label: '酒店英语', icon: '/static/img/group.png', path: '' },
  104. { label: '早报资讯', icon: '/static/img/information.png', id: 'morningNews' },
  105. { label: '了解门墩儿', icon: '/static/img/contact.png', path: '/pagesB/about/index' }
  106. ]
  107. // 轮播图链接跳转
  108. const handleToDetails = ({ link, title }) => {
  109. if (!link) return
  110. // 企业详情
  111. if (link.includes('/pagesB/companyDetail/index')) {
  112. uni.navigateTo({ url: link })
  113. }
  114. // 优选集团
  115. else if (link.includes('/pagesB/preferredGroup/index')) {
  116. console.log(link, 'link')
  117. const id = link.split('?id=')[1]
  118. if (preferredGroup.value && Object.keys(preferredGroup.value).length > 0 && preferredGroup.value[id]) uni.navigateTo({ url: link })
  119. }
  120. // 公众号链接
  121. else uni.navigateTo({ url: `/pages/addWebView/index?url=${link}&title=${title || '风尚榜奖投票'}` })
  122. }
  123. const handleGrid = async (e) => {
  124. const index = e.detail.index
  125. const obj = gridList[index]
  126. // 早报资讯
  127. if (obj?.id === 'morningNews') {
  128. try {
  129. const { data } = await getMorningNewsArticle()
  130. if (data && Object.keys(data).length && data.url) {
  131. uni.navigateTo({
  132. url: `/pages/addWebView/index?url=${data.url}&title=门墩儿早报`
  133. })
  134. } else uni.showToast({ icon: 'none', title: '暂无早报资讯内容' })
  135. } catch (err) {
  136. uni.showToast({ icon: 'none', title: err.msg })
  137. }
  138. }
  139. if (obj?.path) {
  140. uni.navigateTo({
  141. url: obj.path
  142. })
  143. }
  144. if (obj?.weiXinPublicUrl) {
  145. uni.navigateTo({ url: `/pages/addWebView/index?url=${obj?.weiXinPublicUrl}&title=${obj?.title || '风尚榜奖投票'}` })
  146. }
  147. }
  148. const checkValue = (obj) => {
  149. return Object.values(obj).some(value => {
  150. return value !== null && value !== undefined && value !== '' && (Array.isArray(value) ? value.length > 0 : true)
  151. })
  152. }
  153. const type = ref('recommend')
  154. const positionListData = ref([])
  155. const query = reactive({
  156. pageSize: 20,
  157. pageNo: 1,
  158. hire: false,
  159. content: '',
  160. positionId: '',
  161. areaIds: [],
  162. industryIds: [],
  163. jobType: [],
  164. payScope: ''
  165. })
  166. const getData = async () => {
  167. // 效验是否有带搜索条件
  168. const { content, areaIds, industryIds, jobType, payScope, positionId } = query
  169. const hasValue = checkValue({ content, areaIds, industryIds, jobType, payScope, positionId })
  170. // 当前接口为推荐列表时,带查询条件需返回到列表顶部
  171. if (hasValue && type.value === 'recommend') {
  172. scrollTop.value = old.value.scrollTop
  173. nextTick(() => {
  174. type.value = 'position'
  175. scrollTop.value = 0
  176. })
  177. }
  178. // 当前接口为只为列表时,清除查询条件需返回到列表顶部
  179. if (!hasValue && type.value === 'position') {
  180. scrollTop.value = old.value.scrollTop
  181. nextTick(() => {
  182. type.value = 'recommend'
  183. scrollTop.value = 0
  184. })
  185. }
  186. // 带搜索条件(除分页外)用职位搜索接口,无条件则用推荐接口
  187. const api = hasValue ? getJobAdvertisedSearch : getPromotedPosition
  188. const _query = Object.keys(query).reduce((acc, cur) => {
  189. if (!query[cur]) {
  190. return acc
  191. }
  192. acc[cur] = query[cur]
  193. return acc
  194. }, {})
  195. const params = hasValue ? _query : { pageSize: query.pageSize, pageNo: query.pageNo, hire: 0 }
  196. type.value = hasValue ? 'position' : 'recommend'
  197. try {
  198. const res = await api(params)
  199. const arr = res?.data?.list || []
  200. // 推荐接口返回数据需要拼接
  201. const list = !hasValue ? arr.map(e => {
  202. const { anotherName, logoUrl, scale, industryId, enterpriseId, enterpriseName, ...job } = e
  203. return { job, enterprise: { anotherName, logoUrl, scale, industryId, enterpriseId, name: enterpriseName } }
  204. }) : arr
  205. positionListData.value.push(...list.map(e => {
  206. if (!e) {
  207. return e
  208. }
  209. e.job = { ...e.job, ...dealDictObjData({}, e.job) }
  210. e.enterprise = { ...e.enterprise, ...dealDictObjData({}, e.enterprise)}
  211. return e
  212. }))
  213. if (positionListData.value.length === +res.data.total) {
  214. more.value = 'noMore'
  215. return
  216. }
  217. } catch (error) {
  218. query.pageNo--
  219. more.value = 'more'
  220. }
  221. }
  222. // 设置自定义tabbar选中值
  223. onShow(() => {
  224. const currentPage = getCurrentPages()[0]; // 获取当前页面实例
  225. const currentTabBar = currentPage?.getTabBar?.();
  226. // 设置当前tab页的下标index
  227. currentTabBar?.setData({ selected: 0 });
  228. getSystemWebContent()
  229. getData()
  230. // 优选集团数据
  231. uni.request({
  232. url: 'https://minio.menduner.com/dev/4bf5186e6a19347acfc858eaf835a7dec5200465a911d940b06688543eb95fd3.json',
  233. method: 'GET',
  234. success: (res) => {
  235. // console.log(res.data, 'success-优选集团')
  236. preferredGroup.value = res.data
  237. },
  238. fail: res => {
  239. log(res, 'fail')
  240. }
  241. })
  242. })
  243. const scrollTop = ref(0)
  244. const old = ref({
  245. scrollTop: 0
  246. })
  247. const onScroll = (e) =>{
  248. old.value.scrollTop = e.detail.scrollTop
  249. }
  250. const handleSearch = (key, value) => {
  251. query[key] = value
  252. // if (key === 'positionId' || key === 'payScope') {
  253. // query[key] = value || null
  254. // } else {
  255. // query[key] = value ? [value] : []
  256. // }
  257. onSearch()
  258. }
  259. const onSearch = () => {
  260. query.pageNo = 1
  261. positionListData.value = []
  262. getData()
  263. }
  264. // 加载更多
  265. const loadingMore = () => {
  266. more.value = 'loading'
  267. query.pageNo++
  268. getData()
  269. }
  270. </script>
  271. <style scoped lang="scss">
  272. .stick {
  273. z-index: 1;
  274. position: sticky;
  275. top: 0;
  276. }
  277. .stickFilter {
  278. z-index: 1;
  279. position: sticky;
  280. box-shadow: 0px 10rpx 12rpx 0px rgba(195, 195, 195, .25);
  281. top: 120rpx;
  282. }
  283. .px-0 { padding-left: 0 !important; padding-right: 0 !important; }
  284. .pb-10 {
  285. padding-bottom: 10px;
  286. }
  287. .pb-20 { padding-bottom: 20px; }
  288. .px-5 { padding-left: 5px; padding-right: 5px; }
  289. .px-10 { padding-left: 10px; padding-right: 10px; }
  290. .mx-10 { margin-left: 10px; margin-right: 10px }
  291. .mx-20 { margin-left: 20px; margin-right: 20px; }
  292. .mb-10 { margin-bottom: 10px; }
  293. .box {
  294. height: 100vh;
  295. overflow: hidden;
  296. padding-bottom: 120rpx;
  297. box-sizing: border-box;
  298. display: flex;
  299. flex-direction: column;
  300. }
  301. .scrollBox{
  302. flex: 1;
  303. height: 0 !important;
  304. padding-bottom: 24rpx;
  305. box-sizing: border-box;
  306. }
  307. :deep(.uni-searchbar__box) {
  308. width: calc(100% - 105px);
  309. height: 40px !important;
  310. border: 1px solid #00897B;
  311. padding-right: 20px;
  312. flex: none;
  313. }
  314. .search-btn {
  315. position: absolute;
  316. right: 11px;
  317. top: 10px;
  318. width: 110px;
  319. height: 40px;
  320. font-size: 16px;
  321. background-color: #00897B;
  322. color: #fff;
  323. border-radius: 0 5px 5px 0;
  324. z-index: 9;
  325. }
  326. :deep(.picker-view) {
  327. padding-bottom: 80px !important;
  328. }
  329. </style>