index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. <template>
  2. <div :class="{isMobile: mobile}">
  3. <div v-if="!mobile">
  4. <div class="jobList">
  5. <div class="topArea" v-if="!isSeoList">
  6. <!--{{JSON.stringify(typeList)}}-->
  7. </div>
  8. <div class="contentArea">
  9. <div class="selectArea" v-if="!isSeoList">
  10. <div class="selectContent" v-for="(key, i) in Object.keys(typeList)" :key="i + 'selectContent'">
  11. <div class="content">
  12. <div class="left"><p>{{typeList[key].title}}</p></div>
  13. <div class="right">
  14. <div class="cell"
  15. v-for="(item, ii) in typeList[key].list"
  16. :class="{selected: item.id === selected[key], noneClick: !canSelectCity && key === 'city'}"
  17. @click="changeIndexSeo(key, item)"
  18. v-if="ii < 8 || expansion[key]"
  19. :key="ii+key+item.id"
  20. >
  21. <p>{{item.name}}</p>
  22. </div>
  23. </div>
  24. <div class="more" @click="changeExpansion(key)" v-if="typeList[key].list.length > 8">
  25. {{expansion[key] ? "收起" : "更多"}}
  26. </div>
  27. </div>
  28. <div class="smallContent"
  29. v-if="key === 'direction' && typeList[key].smallList.length > 0"
  30. >
  31. <div class="cell"
  32. v-for="(item) in typeList[key].smallList"
  33. :class="{selected: item.id === selected.directionSmall}"
  34. @click="changeIndexSeo('directionSmall', item)"
  35. >
  36. <p>{{item.name}}</p>
  37. </div>
  38. </div>
  39. </div>
  40. </div>
  41. <div class="breadcrumb">
  42. <a
  43. v-for="(item, index) in breadcrumbList"
  44. :key="'breadcrumb'+index"
  45. :href="item.url"
  46. :title="item.name"
  47. >
  48. <p v-if="index!==breadcrumbList.length-1">{{item.name}} <span>&nbsp;>&nbsp;</span></p>
  49. <h1 v-else>{{item.name}}</h1>
  50. </a>
  51. </div>
  52. <div class="listArea">
  53. <!--<h1 class="sTitle">{{head.h1 || '解决方案'}}</h1>-->
  54. <div class="list" v-loading="loading">
  55. <nuxt-link class="cell"
  56. v-for="item in dataList"
  57. :key="item.id"
  58. :to="`/job/detail/${item.id}.html`"
  59. target="_blank"
  60. :title="item.name"
  61. >
  62. <div class="topArea">
  63. <div class="left">{{item.title}}</div>
  64. <div class="right">{{item.salaryName}}</div>
  65. </div>
  66. <div class="workDesc">{{item.description}}</div>
  67. <div class="labelList">
  68. <div class="label" v-for="skill in (item.skills || [])"><p>{{skill.name}}</p></div>
  69. </div>
  70. <div class="companyInfo" @click.stop="jumpToCompanyInfo(item)">
  71. <div class="logo">
  72. <img :src="item.companyInfo.logo" alt=""/>
  73. </div>
  74. <div class="companyName">{{item.companyInfo.name || item.companyInfo.shortName}}</div>
  75. </div>
  76. </nuxt-link>
  77. <div v-if="dataList.length === 0" class="noneData">
  78. <p>没有数据</p>
  79. </div>
  80. </div>
  81. </div>
  82. <div class="pagination">
  83. <el-pagination v-if="!isSeoList" background layout="prev, pager, next" :total="page.total"
  84. :page-size="page.pageSize" @current-change="pageChange" :current-page="Number(page.current
  85. )"></el-pagination>
  86. <div v-else>
  87. <div class="list">
  88. <nuxt-link v-for="(item,index) in new Array(Math.ceil(page.total / page.size))"
  89. :to="`/job/?page=${index+1}`"
  90. :key="(page)+index"
  91. >
  92. {{index+1}}
  93. </nuxt-link>
  94. </div>
  95. </div>
  96. </div>
  97. <BottomBanner></BottomBanner>
  98. </div>
  99. </div>
  100. <SeoFooter style="" :data="footer"/>
  101. </div>
  102. <div v-else class="jobListMobile">
  103. <div class="topSelect">
  104. <van-dropdown-menu>
  105. <!--方式-->
  106. <van-dropdown-item v-model="selected['workType']" :options="typeList['workType'].list" key="workType" @change="changeIndex('workType')"/>
  107. <!--地区-->
  108. <van-dropdown-item v-model="selected['city']" :options="typeList['city'].list" key="city" @change="changeIndex('city')" :disabled="selected.workType===1"/>
  109. <!--职业-->
  110. <van-dropdown-item :title="calcName.text" key="direction" ref="directionSelect">
  111. <van-tree-select
  112. :items="typeList['direction'].list"
  113. active-id="1123321100"
  114. :main-active-index.sync="selected['directionIndex']"
  115. @click-item="(data)=>{changeIndex('directionSmall', data)}"
  116. />
  117. </van-dropdown-item>
  118. </van-dropdown-menu>
  119. </div>
  120. <h1>{{calcH1()}}</h1>
  121. <van-pull-refresh v-model="refreshing" @refresh="onRefresh" class="listArea">
  122. <div style="text-align: center" v-if="firstLoading">
  123. <van-loading size="24px">加载中...</van-loading>
  124. </div>
  125. <van-list
  126. v-else
  127. v-model="loading"
  128. :finished="finished"
  129. finished-text="没有更多了"
  130. @load="onLoad"
  131. :immediate-check="false"
  132. class="list"
  133. >
  134. <nuxt-link class="cell"
  135. v-for="item in dataList"
  136. :key="item.id"
  137. :to="`/job/detail/${item.id}.html`"
  138. target="_blank"
  139. :title="item.name"
  140. >
  141. <div class="topArea">
  142. <div class="left">{{item.title}}</div>
  143. <div class="right">{{item.salaryName}}</div>
  144. </div>
  145. <div class="workDesc">{{item.description}}</div>
  146. <div class="labelList">
  147. <div class="label" v-for="skill in (item.skills || [])"><p>{{skill.name}}</p></div>
  148. </div>
  149. <div class="companyInfo" @click.stop="jumpToCompanyInfo(item)">
  150. <div class="logo">
  151. <img :src="item.companyInfo.logo" alt=""/>
  152. </div>
  153. <div class="companyName">{{item.companyInfo.name || item.companyInfo.shortName}}</div>
  154. </div>
  155. </nuxt-link>
  156. </van-list>
  157. </van-pull-refresh>
  158. </div>
  159. </div>
  160. </template>
  161. <script>
  162. import ConnectUs from "@/components/common/connectUs"
  163. import BindMobile from "@/components/common/bindMobile"
  164. import DealSeoData from "@/components/job/dealSeoIndex"
  165. import DealSeoFooter from "@/components/job/dealSeoFooter"
  166. import BottomBanner from "@/components/job/bottomBanner"
  167. import SeoFooter from "@/components/SeoFooter"
  168. export default {
  169. name: "JobListSeoIndex",
  170. // layout: "opacity_header",
  171. showCommonFooter: false,
  172. components: { ConnectUs, BindMobile, SeoFooter, BottomBanner },
  173. head() {
  174. const { title = "", keyword = "", descrption = "", h1 = "", canonical = "", metaLocation } = this.head || {}
  175. let obj = {
  176. title: title,
  177. meta: [
  178. {
  179. 'name': 'keywords',
  180. 'content': keyword
  181. }, {
  182. 'name': 'descrption',
  183. 'content': descrption
  184. }, {
  185. 'name': 'h1',
  186. 'content': h1
  187. }
  188. ],
  189. link: [
  190. { rel: 'canonical', href: canonical },
  191. ]
  192. }
  193. if (metaLocation) {
  194. obj.meta.push({ 'name': 'location', 'content': metaLocation })
  195. }
  196. return obj
  197. },
  198. async asyncData({ ...params }) {
  199. try {
  200. params.store.commit("updateNoneCommonFooter", true)
  201. } catch ( e ) {
  202. console.log("updateNoneCommonFooter", e)
  203. }
  204. let dealDataObj = new DealSeoData(params)
  205. let ans = await dealDataObj.dealData()
  206. let dealSeoFooterObj = new DealSeoFooter(params)
  207. let footer = await dealSeoFooterObj.dealData()
  208. return {
  209. ...ans,
  210. ...footer
  211. }
  212. },
  213. data() {
  214. return {
  215. expansion: {
  216. direction: 0,
  217. city: 0,
  218. },
  219. isShowToast: false,
  220. name: '',
  221. phone: '',
  222. loading: false,
  223. refreshing: false,
  224. firstLoading: false, //移动端加载loading
  225. isLoading: false
  226. }
  227. },
  228. watch: {
  229. },
  230. computed: {
  231. canSelectCity() {
  232. //远程无法选中地区
  233. return this.selected.workType !== 1
  234. },
  235. calcName() {
  236. const {direction, directionSmall, directionName = "", directionSmallName = "", } = this.selected
  237. let job = directionSmall || direction
  238. let jobName = directionSmallName === "全部" ? directionName : (directionSmallName || directionName)
  239. return {
  240. text: jobName || '全部职业',
  241. value: job
  242. }
  243. }
  244. },
  245. created() {
  246. // this.firstLoading = true
  247. },
  248. mounted() {
  249. // this.getList()
  250. if (this.mobile) {
  251. document.body.style = "overflow:hidden;"
  252. }
  253. },
  254. methods: {
  255. //移动端选择器
  256. changeIndex(key, item) {
  257. //级联选择 特殊处理一下
  258. console.log(this.selected, this.typeList)
  259. if (key === 'directionSmall') {
  260. //当右侧选择的不是"全部"选项的时候,将大选项初始化
  261. if (item.id) {
  262. this.selected[ 'direction'] = 0
  263. this.selected[ 'directionName'] = ''
  264. this.selected[ 'directionSlug'] = ''
  265. this.selected[ key] = item.id
  266. this.selected[ key + 'Name' ] = item.name
  267. this.selected[ key + 'Slug' ] = item.slug
  268. } else {
  269. //当右侧选择的是"全部"选项的时候, 将右侧数据初始化,只保留左侧数据
  270. //左侧更改时 直接更改的是索引index,故这里要转换一下
  271. let myItem = this.typeList.direction.list[this.selected.directionIndex]
  272. this.selected[ 'direction'] = myItem.id
  273. this.selected[ 'directionName'] = myItem.name
  274. this.selected[ 'directionSlug'] = myItem.slug
  275. this.selected[ key] = 0
  276. this.selected[ key + 'Name' ] = ''
  277. this.selected[ key + 'Slug' ] = ''
  278. }
  279. }
  280. //如果选中的工作方式是远程,则初始化 城市选择
  281. if (key === 'workType' && this.selected.workType === 1) {
  282. this.selected.city = 0
  283. this.selected.cityName = ''
  284. }
  285. this.page.page = 1
  286. this.page.total = 0
  287. this.firstLoading = true
  288. this.getList()
  289. this.$refs.directionSelect.toggle(false);
  290. },
  291. //web的选择器
  292. changeIndexSeo(key, item) {
  293. console.log("key:", key, "item:", item, "selected:", this.selected)
  294. //远程无法选中地区
  295. if (!this.canSelectCity && key === 'city') {
  296. return
  297. }
  298. // 如果选中了远程工作,重置城市选择
  299. if (key === "workType" && item.id === 1) {
  300. this.selected.city = 0
  301. this.selected.cityName = ""
  302. this.selected.citySlug= ""
  303. }
  304. this.selected[ key ] = item.id
  305. this.selected[ key + 'Slug' ] = item.slug
  306. //大工作分类时,先显示子分类
  307. if (key === 'direction') {
  308. if (item.id === 0) {
  309. this.selected[ 'directionSmall' ] = item.id
  310. this.selected[ 'directionSmallSlug' ] = item.slug
  311. } else {
  312. let list = this.typeList.direction.list.filter(item => item.id === this.selected.direction)[0]
  313. if (list.children && list.children.length > 1) {
  314. this.selected[ 'directionSmall' ] = -1
  315. this.typeList[key].smallList = [...(list && list.children || [])]
  316. return
  317. }
  318. }
  319. }
  320. let { citySlug, directionSlug, directionSmallSlug, workTypeSlug} = this.selected
  321. let url = "/job/"
  322. if (citySlug) {
  323. url += citySlug + '/'
  324. }
  325. if (directionSmallSlug || directionSlug) {
  326. url += (directionSmallSlug || directionSlug) + '/'
  327. }
  328. //驻场方式 不放到url里面
  329. if (key === "workType" ) {
  330. this.page.page = 1
  331. this.page.total = 0
  332. this.getList()
  333. return
  334. }
  335. location.href = url
  336. },
  337. changeExpansion(key) {
  338. this.expansion[ key ] = !this.expansion[ key ]
  339. },
  340. getList() {
  341. const { page, selected: {city, direction, directionSmall, workType} } = this
  342. let p = {
  343. cityId: city,
  344. ...page
  345. }
  346. direction && (p.occupationId = direction) //一级
  347. workType && (p.workType = workType)
  348. directionSmall > 0 && (p.directionId = directionSmall) //耳二级
  349. if (this.isLoading) {
  350. return
  351. }
  352. this.loading = true
  353. this.isLoading = true
  354. this.$axios.post('/api/recruit/search', p).then(res => {
  355. if (Number(res.data.status) === 1) {
  356. let data = res.data.data
  357. this.page.total = data.total
  358. if (this.page.page === 1 || !this.mobile) {
  359. this.dataList = [...data.list]
  360. } else {
  361. this.dataList = [ ...this.dataList, ...data.list]
  362. }
  363. this.page.page += 1
  364. this.page.current = Number(data.page)
  365. if (this.page.total <= this.dataList.length) {
  366. this.finished = true
  367. }
  368. }
  369. }).finally(() => {
  370. this.firstLoading = false
  371. this.refreshing = false
  372. this.isLoading = false
  373. this.$nextTick(()=>{
  374. this.loading = false
  375. })
  376. console.log("this.finished", this.finished)
  377. })
  378. },
  379. pageChange(i) {
  380. this.page.page = i
  381. this.getList()
  382. },
  383. jumpToCompanyInfo(item) {
  384. const {companyInfo:{uid}} = item
  385. window.open(`/wo/${uid}`, `targetCompany${uid}`)
  386. },
  387. /** 移动端下拉刷新 **/
  388. onRefresh() {
  389. // 清空列表数据
  390. this.finished = false;
  391. console.log('onRefresh')
  392. this.onLoad();
  393. },
  394. onLoad() {
  395. console.log('onLoad')
  396. this.getList()
  397. },
  398. calcH1() {
  399. const { city, cityName = "", direction, directionName = "", directionSmall, directionSmallName = "" } = this.selected
  400. let job = directionSmall || direction
  401. let jobName = directionSmallName === "全部" ? directionName : (directionSmallName || directionName)
  402. let title = "兼职招聘"
  403. if (city && job) {
  404. title = `${cityName}${jobName}兼职招聘`
  405. } else if (city && !job) {
  406. //兼职城市
  407. title = `${cityName}兼职招聘`
  408. } else if (!city && job) {
  409. //岗位页
  410. title = `${jobName}兼职招聘`
  411. }
  412. return title
  413. },
  414. }
  415. }
  416. </script>
  417. <style scope lang="scss">
  418. @import "../../assets/css/job/index.scss";
  419. </style>
  420. <style lang="scss">
  421. .van-dropdown-menu__title {
  422. color: #666;
  423. }
  424. </style>