position.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  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. <uni-popup ref="inputDialog" type="dialog">
  44. <view class="shareQrCodePopupContent">
  45. <view class="ss-m-b-10">请前往网页版门墩儿查看</view>
  46. <uni-link href="https://www.menduner.com" text="点击复制网页地址" color="#00897B" fontSize="16" copyTips="已复制,请在电脑端打开"></uni-link>
  47. </view>
  48. </uni-popup>
  49. </view>
  50. </view>
  51. </template>
  52. <script setup>
  53. import { ref, reactive, nextTick } from 'vue'
  54. import SwiperAd from '@/components/SwiperAd'
  55. import FilterList from '@/components/FilterList'
  56. import PositionList from '@/components/PositionList'
  57. import AdvertisePop from '@/components/Advertisement'
  58. import { dealDictObjData } from '@/utils/position'
  59. import { getJobAdvertisedSearch, getPromotedPosition } from '@/api/position'
  60. import { onShow, onLoad, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
  61. import Navbar from '@/components/Navbar'
  62. import { getRewardEventList } from '@/utils/eventList'
  63. import { getMorningNewsArticle } from '@/api/content'
  64. import { getWebContent } from '@/api/common'
  65. // 设置自定义tabbar选中值
  66. onShow(() => {
  67. const currentPage = getCurrentPages()[0]; // 获取当前页面实例
  68. const currentTabBar = currentPage?.getTabBar?.();
  69. // 设置当前tab页的下标index
  70. currentTabBar?.setData({ selected: 0 });
  71. })
  72. onLoad(() => {
  73. wx.showShareMenu({
  74. withShareTicket: true,
  75. menus: ['shareAppMessage', 'shareTimeline']
  76. })
  77. onShareAppMessage(() => {
  78. return {
  79. title: '门墩儿 专注顶尖招聘',
  80. path: '/pages/index/position',
  81. imageUrl: '../../static/img/share-poster.jpg'
  82. }
  83. })
  84. onShareTimeline(() => {
  85. return {
  86. title: '门墩儿 专注顶尖招聘',
  87. path: '/pages/index/position',
  88. imageUrl: '../../static/img/share-poster.jpg'
  89. }
  90. })
  91. if (!uni.getStorageSync('token')) getRewardEventList()
  92. })
  93. const inputDialog = ref()
  94. const more = ref('more')
  95. // 获取轮播图
  96. const showAdvertisePop = ref(false)
  97. const swiperAdList = ref([])
  98. const getSystemWebContent = async () => {
  99. const { data } = await getWebContent()
  100. swiperAdList.value = data.appHomeCarousel || []
  101. // 是否展示弹窗广告
  102. showAdvertisePop.value = data && data.appAdvertisement && data.appAdvertisement.length ? true : false
  103. }
  104. getSystemWebContent()
  105. const filterList = ref([
  106. { label: '城市', dictType: 'areaTreeDataExtend', key: 'areaIds', map: { text: 'name', value: 'id' } },
  107. // { label: '行业', dictType: 'industryTreeData',key: 'industryIds', map: { text: 'nameCn', value: 'id' } },
  108. { label: '职位', dictType: 'positionTreeData',key: 'positionId', map: { text: 'nameCn', value: 'id' } },
  109. { label: '求职类型', dictType: 'menduner_job_type', key: 'jobType' },
  110. { label: '薪资待遇', dictType: 'menduner_pay_scope', key: 'payScope' },
  111. // { label: '工作经验', dictType: 'menduner_exp_type', key: 'expType' },
  112. ])
  113. const gridList = [
  114. { label: '门墩儿猎头', icon: '/static/img/headhunting.png', path: '/pagesB/headhunting/index' },
  115. { label: '精选企业', icon: '/static/img/enterprise.png', path: '/pagesB/recommendEnterprise/index' },
  116. { label: '酒店英语', icon: '/static/img/group.png', path: '' },
  117. { label: '早报资讯', icon: '/static/img/information.png', id: 'morningNews' },
  118. { label: '风尚榜投票', icon: '/static/img/contact.png', weiXinPublicUrl: 'https%3A%2F%2F6b29.yuandianpx.cn%2F18%2F%23%2Fvote%3Fact%3D31', title:'『2024中国酒店YOUNG风尚榜』投票通道' }
  119. ]
  120. // 跳转企业详情
  121. const handleToDetails = ({ link, title }) => {
  122. // if (id) {
  123. // uni.navigateTo({ url: `/pagesB/companyDetail/index?id=${id}` })
  124. // }
  125. if (link) {
  126. uni.navigateTo({ url: `/pages/addWebView/index?url=${link}&title=${title || '风尚榜奖投票'}` })
  127. }
  128. }
  129. const handleGrid = async (e) => {
  130. // uni.showToast({
  131. // icon: 'none',
  132. // title: '请前往网页版门墩儿查看'
  133. // })
  134. // inputDialog.value.open()
  135. const index = e.detail.index
  136. const obj = gridList[index]
  137. // 早报资讯
  138. if (obj?.id === 'morningNews') {
  139. try {
  140. const { data } = await getMorningNewsArticle()
  141. if (data && Object.keys(data).length && data.url) {
  142. uni.navigateTo({
  143. url: `/pages/addWebView/index?url=${data.url}&title=门墩儿早报`
  144. })
  145. } else uni.showToast({ icon: 'none', title: '暂无早报资讯内容' })
  146. } catch (err) {
  147. uni.showToast({ icon: 'none', title: err.msg })
  148. }
  149. }
  150. if (obj?.path) {
  151. uni.navigateTo({
  152. url: obj.path
  153. })
  154. }
  155. if (obj?.weiXinPublicUrl) {
  156. uni.navigateTo({ url: `/pages/addWebView/index?url=${obj?.weiXinPublicUrl}&title=${obj?.title || '风尚榜奖投票'}` })
  157. }
  158. }
  159. const checkValue = (obj) => {
  160. return Object.values(obj).some(value => {
  161. return value !== null && value !== undefined && value !== '' && (Array.isArray(value) ? value.length > 0 : true)
  162. })
  163. }
  164. const positionListData = ref([])
  165. const query = reactive({
  166. pageSize: 20,
  167. pageNo: 1,
  168. hire: false,
  169. content: '',
  170. positionId: '',
  171. areaIds: [],
  172. industryIds: [],
  173. jobType: [],
  174. payScope: ''
  175. })
  176. const getData = async () => {
  177. // 效验是否有带搜索条件
  178. const { content, areaIds, industryIds, jobType, payScope, positionId } = query
  179. const hasValue = checkValue({ content, areaIds, industryIds, jobType, payScope, positionId })
  180. // 带查询条件时返回到顶部
  181. if (hasValue) {
  182. scrollTop.value = old.value.scrollTop
  183. nextTick(() => {
  184. scrollTop.value = 0
  185. })
  186. }
  187. // 带搜索条件(除分页外)用职位搜索接口,无条件则用推荐接口
  188. const api = hasValue ? getJobAdvertisedSearch : getPromotedPosition
  189. const params = hasValue ? query : { pageSize: query.pageSize, pageNo: query.pageNo, hire: 0 }
  190. try {
  191. const res = await api(params)
  192. const arr = res?.data?.list || []
  193. // 推荐接口返回数据需要拼接
  194. const list = !hasValue ? arr.map(e => {
  195. const { anotherName, logoUrl, scale, industryId, enterpriseId, enterpriseName, ...job } = e
  196. return { job, enterprise: { anotherName, logoUrl, scale, industryId, enterpriseId, name: enterpriseName } }
  197. }) : arr
  198. positionListData.value.push(...list.map(e => {
  199. if (!e) {
  200. return e
  201. }
  202. e.job = { ...e.job, ...dealDictObjData({}, e.job) }
  203. e.enterprise = { ...e.enterprise, ...dealDictObjData({}, e.enterprise)}
  204. return e
  205. }))
  206. if (positionListData.value.length === +res.data.total) {
  207. more.value = 'noMore'
  208. return
  209. }
  210. } catch (error) {
  211. query.pageNo--
  212. more.value = 'more'
  213. }
  214. }
  215. getData()
  216. const scrollTop = ref(0)
  217. const old = ref({
  218. scrollTop: 0
  219. })
  220. const onScroll = (e) =>{
  221. old.value.scrollTop = e.detail.scrollTop
  222. }
  223. const handleSearch = (key, value) => {
  224. if (key === 'positionId' || key === 'payScope') {
  225. query[key] = value || null
  226. } else {
  227. query[key] = value ? [value] : []
  228. }
  229. onSearch()
  230. }
  231. const onSearch = () => {
  232. query.pageNo = 1
  233. positionListData.value = []
  234. getData()
  235. }
  236. const loadingMore = () => { // 加载更多
  237. more.value = 'loading'
  238. query.pageNo++
  239. getData()
  240. }
  241. </script>
  242. <style scoped lang="scss">
  243. .stick {
  244. z-index: 1;
  245. position: sticky;
  246. top: 0;
  247. }
  248. .stickFilter {
  249. z-index: 1;
  250. position: sticky;
  251. box-shadow: 0px 10rpx 12rpx 0px rgba(195, 195, 195, .25);
  252. top: 120rpx;
  253. }
  254. .px-0 { padding-left: 0 !important; padding-right: 0 !important; }
  255. .pb-10 {
  256. padding-bottom: 10px;
  257. }
  258. .pb-20 { padding-bottom: 20px; }
  259. .px-5 { padding-left: 5px; padding-right: 5px; }
  260. .px-10 { padding-left: 10px; padding-right: 10px; }
  261. .mx-10 { margin-left: 10px; margin-right: 10px }
  262. .mx-20 { margin-left: 20px; margin-right: 20px; }
  263. .mb-10 { margin-bottom: 10px; }
  264. .box {
  265. height: 100vh;
  266. overflow: hidden;
  267. padding-bottom: 120rpx;
  268. box-sizing: border-box;
  269. display: flex;
  270. flex-direction: column;
  271. }
  272. .scrollBox{
  273. flex: 1;
  274. height: 0 !important;
  275. padding-bottom: 24rpx;
  276. box-sizing: border-box;
  277. }
  278. :deep(.uni-searchbar__box) {
  279. width: calc(100% - 105px);
  280. height: 40px !important;
  281. border: 1px solid #00897B;
  282. padding-right: 20px;
  283. flex: none;
  284. }
  285. .search-btn {
  286. position: absolute;
  287. right: 11px;
  288. top: 10px;
  289. width: 110px;
  290. height: 40px;
  291. font-size: 16px;
  292. background-color: #00897B;
  293. color: #fff;
  294. border-radius: 0 5px 5px 0;
  295. z-index: 9;
  296. }
  297. :deep(.picker-view) {
  298. padding-bottom: 80px !important;
  299. }
  300. .shareQrCodePopupContent {
  301. width: 75vw;
  302. padding: 40rpx;
  303. margin-bottom: 20rpx;
  304. text-align: center;
  305. background-color: #fff;
  306. }
  307. </style>