index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559
  1. <template>
  2. <div :class="{ isMobile: mobile }">
  3. <!-- web -->
  4. <div v-if="!mobile">
  5. <div class="jobList">
  6. <div class="topArea" v-if="!isSeoList">
  7. <!--{{JSON.stringify(typeList)}}-->
  8. </div>
  9. <div class="contentArea">
  10. <div class="selectArea" v-if="!isSeoList">
  11. <!--职业角色、国内地区筛选-->
  12. <div class="selectContent" v-for="(key, i) in Object.keys(typeList)" :key="i + 'selectContent'">
  13. <div class="content">
  14. <div class="left">
  15. <p>{{ typeList[key].title }}</p>
  16. </div>
  17. <div class="right">
  18. <div class="cell" v-for="(item, ii) in typeList[key].list"
  19. :class="{selected: item.id === selected[key], noneClick: !canSelectCity && key === 'city'}"
  20. @click="changeIndexSeo(key, item)" v-if="ii < 8 || expansion[key]" :key="ii + key + item.id">
  21. <p>{{ item.name }}</p>
  22. </div>
  23. </div>
  24. <div class="more" @click="changeExpansion(key)" v-if="typeList[key].list.length > 8">{{ expansion[key] ? "收起" : "更多" }}</div>
  25. </div>
  26. <div class="smallContent" v-if="key === 'direction' && typeList[key].smallList.length > 0">
  27. <div class="cell" v-for="(item, ii) in typeList[key].smallList" :class="{ selected: item.id === selected.directionSmall }"
  28. @click="changeIndexSeo('directionSmall', item)" :key="ii + key + item.id">
  29. <p>{{ item.name }}</p>
  30. </div>
  31. </div>
  32. </div>
  33. </div>
  34. <!--不包含搜索关键字-->
  35. <div class="breadcrumb" v-if="!page.keyword">
  36. <a v-for="(item, index) in breadcrumbList" :key="'breadcrumb' + index" :href="item.url" :title="item.name">
  37. <p v-if="index !== breadcrumbList.length - 1">
  38. {{ item.name }}<span>&nbsp;>&nbsp;</span>
  39. </p>
  40. <h1 v-else>{{ item.name }}</h1>
  41. </a>
  42. </div>
  43. <!--包含搜索关键字-->
  44. <div class="breadcrumb" v-else>
  45. <h1>搜索包含"{{ page.keyword }}"的兼职招聘</h1>
  46. </div>
  47. <!--搜索结果-->
  48. <div class="listArea">
  49. <div class="list" v-loading="loading">
  50. <nuxt-link class="cell" v-for="item in dataList" :key="item.id" :to="`/d/${item.hashId}`" target="_blank" :title="item.name">
  51. <div class="topArea">
  52. <div class="left">{{ item.title }}</div>
  53. <div class="right">{{ item.salaryName }}</div>
  54. </div>
  55. <div class="workDesc">{{ item.description }}</div>
  56. <div class="labelList">
  57. <div class="label" v-for="skill in item.skills || []">
  58. <p>{{ skill.name }}</p>
  59. </div>
  60. <div class="label">
  61. <p>{{ item.experienceName }}</p>
  62. </div>
  63. </div>
  64. <div class="bottomArea">
  65. <div class="companyInfo">
  66. <div class="logo">
  67. <img :src="item.companyInfo.logo" alt/>
  68. </div>
  69. <div class="companyName">
  70. {{ item.companyInfo.shortName || item.companyInfo.name }}
  71. </div>
  72. </div>
  73. <div class="publishTime">{{ item.createdAtFormat }}</div>
  74. </div>
  75. </nuxt-link>
  76. <div v-if="dataList.length === 0" class="noneData">
  77. <p>没有数据</p>
  78. </div>
  79. </div>
  80. </div>
  81. <div class="pagination">
  82. <el-pagination v-if="!isSeoList" background layout="prev, pager, next" :total="page.total" :page-size="page.pageSize" @current-change="pageChange"
  83. :current-page="Number(page.current)"></el-pagination>
  84. <div v-else>
  85. <div class="list">
  86. <nuxt-link v-for="(item, index) in new Array(Math.ceil(page.total / page.size))" :to="`/?page=${index + 1}`" :key="page + index">{{ index + 1
  87. }}
  88. </nuxt-link>
  89. </div>
  90. </div>
  91. </div>
  92. <BottomBanner></BottomBanner>
  93. </div>
  94. </div>
  95. <SeoFooter style :data="footer"/>
  96. </div>
  97. <!-- mobile -->
  98. <div v-else class="jobListMobile">
  99. <div class="topSelect">
  100. <van-dropdown-menu>
  101. <!--方式-->
  102. <van-dropdown-item
  103. v-model="selected['workType']"
  104. :options="typeList['workType'].list"
  105. key="workType"
  106. @change="changeIndex('workType')"
  107. />
  108. <!--地区-->
  109. <van-dropdown-item
  110. v-model="selected['city']"
  111. :options="typeList['city'].list"
  112. key="city"
  113. @change="changeIndex('city')"
  114. :disabled="selected.workType === 1"
  115. />
  116. <!--职业-->
  117. <van-dropdown-item
  118. :title="calcName.text"
  119. key="direction"
  120. ref="directionSelect"
  121. >
  122. <van-tree-select
  123. :items="typeList['direction'].list"
  124. active-id="1123321100"
  125. :main-active-index.sync="selected['directionIndex']"
  126. @click-item="
  127. data => {
  128. changeIndex('directionSmall', data);
  129. }
  130. "
  131. />
  132. </van-dropdown-item>
  133. </van-dropdown-menu>
  134. </div>
  135. <h1>{{ calcH1() }}</h1>
  136. <van-pull-refresh
  137. v-model="refreshing"
  138. @refresh="onRefresh"
  139. class="listArea"
  140. :class="{ noneInWx: !$deviceType.app }"
  141. >
  142. <div style="text-align: center" v-if="firstLoading">
  143. <van-loading size="24px">加载中...</van-loading>
  144. </div>
  145. <van-list
  146. v-else
  147. v-model="loading"
  148. :finished="finished"
  149. finished-text="没有更多了"
  150. @load="onLoad"
  151. :immediate-check="false"
  152. class="list"
  153. >
  154. <nuxt-link
  155. class="cell"
  156. v-for="item in dataList"
  157. :key="item.id"
  158. :to="`/d/${item.hashId}`"
  159. target="_blank"
  160. :title="item.name"
  161. >
  162. <div class="topArea">
  163. <div class="left">{{ item.title }}</div>
  164. <div class="right">{{ item.salaryName }}</div>
  165. </div>
  166. <div class="workDesc">{{ item.description }}</div>
  167. <div class="labelList">
  168. <div class="label" v-for="skill in item.skills || []">
  169. <p>{{ skill.name }}</p>
  170. </div>
  171. </div>
  172. <div class="companyInfo" @click.stop="jumpToCompanyInfo(item)">
  173. <div class="logo">
  174. <img :src="item.companyInfo.logo" alt/>
  175. </div>
  176. <div class="companyName">
  177. {{ item.companyInfo.shortName || item.companyInfo.name }}
  178. </div>
  179. </div>
  180. </nuxt-link>
  181. </van-list>
  182. </van-pull-refresh>
  183. <a v-if="!deviceType.app && mobile" class="downapp" :href="downloadhref"
  184. >下载APP</a
  185. >
  186. </div>
  187. </div>
  188. </template>
  189. <script>
  190. import ConnectUs from "@/components/common/connectUs";
  191. import BindMobile from "@/components/common/bindMobile";
  192. import DealSeoData from "@/components/job/dealSeoIndex";
  193. import DealSeoFooter from "@/components/job/dealSeoFooter";
  194. import BottomBanner from "@/components/job/bottomBanner";
  195. import SeoFooter from "@/components/SeoFooter";
  196. import {mapState, mapMutations} from "vuex";
  197. import deviceType from "../../plugins/deviceType";
  198. export default {
  199. name: "JobListSeoIndex",
  200. // layout: "opacity_header",
  201. showCommonFooter: false,
  202. components: {ConnectUs, BindMobile, SeoFooter, BottomBanner},
  203. data() {
  204. return {
  205. expansion: {direction: 0, city: 0},
  206. isShowToast: false,
  207. name: "",
  208. phone: "",
  209. loading: false,
  210. refreshing: false,
  211. firstLoading: false, //移动端加载loading
  212. isLoading: false,
  213. selected: {},
  214. downloadhref: "",
  215. type: ""
  216. };
  217. },
  218. head() {
  219. const {
  220. title = "",
  221. keyword = "",
  222. descrption = "",
  223. h1 = "",
  224. canonical = "",
  225. metaLocation
  226. } = this.head || {};
  227. let obj = {
  228. title: title,
  229. meta: [
  230. {
  231. name: "keywords",
  232. content: keyword
  233. },
  234. {
  235. name: "descrption",
  236. content: descrption
  237. },
  238. {
  239. name: "h1",
  240. content: h1
  241. }
  242. ],
  243. link: [{rel: "canonical", href: canonical}]
  244. };
  245. if (metaLocation) {
  246. obj.meta.push({name: "location", content: metaLocation});
  247. }
  248. return obj;
  249. },
  250. async asyncData({...params}) {
  251. console.log("*********params:", params);
  252. try {
  253. params.store.commit("updateNoneCommonFooter", true);
  254. } catch (e) {
  255. console.log("updateNoneCommonFooter", e);
  256. }
  257. console.log("asyncdata..............");
  258. let dealDataObj = new DealSeoData(params);
  259. let ans = await dealDataObj.dealData();
  260. let dealSeoFooterObj = new DealSeoFooter(params);
  261. let {footer, selected} = await dealSeoFooterObj.dealData();
  262. if (this) {
  263. this.selected = selected;
  264. }
  265. return {
  266. selected: selected,
  267. ...ans,
  268. footer
  269. };
  270. },
  271. watch: {},
  272. computed: {
  273. ...mapState(["isPC", "isWeixin", "deviceType", "noneCommonFooter"]),
  274. canSelectCity() {
  275. //远程无法选中地区
  276. return this.selected.workType !== 1;
  277. },
  278. calcName() {
  279. const {
  280. direction,
  281. directionSmall,
  282. directionName = "",
  283. directionSmallName = ""
  284. } = this.selected;
  285. let job = directionSmall || direction;
  286. let jobName =
  287. directionSmallName === "全部"
  288. ? directionName
  289. : directionSmallName || directionName;
  290. return {
  291. text: jobName || "全部职业",
  292. value: job
  293. };
  294. }
  295. },
  296. created() {
  297. console.log("created................", this.selected, this.typeList);
  298. // this.firstLoading = true
  299. },
  300. mounted() {
  301. console.log("mounted................", this.selected, this.typeList);
  302. // this.getList()
  303. if (this.mobile) {
  304. document.body.style = "overflow:hidden;";
  305. }
  306. let UA = navigator.userAgent;
  307. console.log("-------------", UA);
  308. var isWeixin = UA.match(/MicroMessenger/i) == "micromessenger";
  309. console.error(isWeixin ? "是微信" : "不是微信");
  310. var isAndroid = UA.indexOf("Android") > -1 || UA.indexOf("Adr") > -1; //android终端
  311. console.error(isAndroid ? "是安卓" : "不是安卓");
  312. var isiOS = !!UA.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
  313. console.error(isiOS ? "是IOS" : "不是IOS");
  314. if (isWeixin) {
  315. this.downloadhref =
  316. "http://a.app.qq.com/o/simple.jsp?pkgname=com.proginn";
  317. } else if (isAndroid) {
  318. this.downloadhref =
  319. "http://inncms.storage.proginn.com/android/proginn-v4.10.0.apk";
  320. } else if (isiOS) {
  321. this.downloadhref =
  322. "https://itunes.apple.com/cn/app/cheng-xu-yuan-ke-zhan/id979914687";
  323. }
  324. console.log("this.downloadhref =", this.downloadhref);
  325. this.type = deviceType.app ? "APP" : "浏览器";
  326. },
  327. methods: {
  328. //移动端选择器
  329. changeIndex(key, item) {
  330. //级联选择 特殊处理一下
  331. console.log(this.selected, this.typeList);
  332. if (key === "directionSmall") {
  333. //当右侧选择的不是"全部"选项的时候,将大选项初始化
  334. if (item.id) {
  335. this.selected["direction"] = 0;
  336. this.selected["directionName"] = "";
  337. this.selected["directionSlug"] = "";
  338. this.selected[key] = item.id;
  339. this.selected[key + "Name"] = item.name;
  340. this.selected[key + "Slug"] = item.slug;
  341. } else {
  342. //当右侧选择的是"全部"选项的时候, 将右侧数据初始化,只保留左侧数据
  343. //左侧更改时 直接更改的是索引index,故这里要转换一下
  344. let myItem = this.typeList.direction.list[
  345. this.selected.directionIndex
  346. ];
  347. this.selected["direction"] = myItem.id;
  348. this.selected["directionName"] = myItem.name;
  349. this.selected["directionSlug"] = myItem.slug;
  350. this.selected[key] = 0;
  351. this.selected[key + "Name"] = "";
  352. this.selected[key + "Slug"] = "";
  353. }
  354. }
  355. //如果选中的工作方式是远程,则初始化 城市选择
  356. if (key === "workType" && this.selected.workType === 1) {
  357. this.selected.city = 0;
  358. this.selected.cityName = "";
  359. }
  360. this.page.page = 1;
  361. this.page.total = 0;
  362. this.firstLoading = true;
  363. this.getList();
  364. this.$refs.directionSelect.toggle(false);
  365. },
  366. //web的选择器
  367. changeIndexSeo(key, item) {
  368. console.log("hhhahahahahhhhhhhhhhhhhhhhh");
  369. console.log("key:", key, "item:", item, "selected:", this.selected);
  370. //远程无法选中地区
  371. if (!this.canSelectCity && key === "city") {
  372. return;
  373. }
  374. // 如果选中了远程工作,重置城市选择
  375. if (key === "workType" && item.id === 1) {
  376. this.selected.city = 0;
  377. this.selected.cityName = "";
  378. this.selected.citySlug = "";
  379. }
  380. this.selected[key] = item.id;
  381. this.selected[key + "Slug"] = item.slug;
  382. //大工作分类时,先显示子分类
  383. if (key === "direction") {
  384. if (item.id === 0) {
  385. this.selected["directionSmall"] = item.id;
  386. this.selected["directionSmallSlug"] = item.slug;
  387. } else {
  388. let list = this.typeList.direction.list.filter(
  389. item => item.id === this.selected.direction
  390. )[0];
  391. if (list.children && list.children.length > 1) {
  392. this.selected["directionSmall"] = -1;
  393. this.typeList[key].smallList = [...((list && list.children) || [])];
  394. return;
  395. }
  396. }
  397. }
  398. let {
  399. citySlug,
  400. directionSlug,
  401. directionSmallSlug,
  402. workTypeSlug
  403. } = this.selected;
  404. let url = "/";
  405. if (citySlug) {
  406. url += citySlug + "/";
  407. }
  408. if (directionSmallSlug || directionSlug) {
  409. url += (directionSmallSlug || directionSlug) + "/";
  410. }
  411. //驻场方式 不放到url里面
  412. if (key === "workType") {
  413. this.page.page = 1;
  414. this.page.total = 0;
  415. this.getList();
  416. return;
  417. }
  418. location.href = url;
  419. },
  420. changeExpansion(key) {
  421. this.expansion[key] = !this.expansion[key];
  422. },
  423. getList() {
  424. const {
  425. page,
  426. selected: {city, direction, directionSmall, workType}
  427. } = this;
  428. let p = {
  429. cityId: city,
  430. ...page
  431. };
  432. direction && (p.occupationId = direction); //一级
  433. workType && (p.workType = workType);
  434. directionSmall > 0 && (p.directionId = directionSmall); //耳二级
  435. if (this.isLoading) {
  436. return;
  437. }
  438. this.loading = true;
  439. this.isLoading = true;
  440. this.$axios
  441. .post("/api/recruit/search", p)
  442. .then(res => {
  443. if (Number(res.data.status) === 1) {
  444. let data = res.data.data;
  445. this.page.total = data.total;
  446. if (this.page.page === 1 || !this.mobile) {
  447. this.dataList = [...data.list];
  448. } else {
  449. this.dataList = [...this.dataList, ...data.list];
  450. }
  451. this.page.page += 1;
  452. this.page.current = Number(data.page);
  453. if (this.page.total <= this.dataList.length) {
  454. this.finished = true;
  455. }
  456. }
  457. })
  458. .finally(() => {
  459. this.firstLoading = false;
  460. this.refreshing = false;
  461. this.isLoading = false;
  462. this.$nextTick(() => {
  463. this.loading = false;
  464. });
  465. console.log(
  466. "this.finished................................",
  467. this.finished
  468. );
  469. });
  470. },
  471. pageChange(i) {
  472. this.page.page = i;
  473. this.getList();
  474. },
  475. jumpToCompanyInfo(item) {
  476. const {
  477. companyInfo: {uid}
  478. } = item;
  479. window.open(
  480. this.$store.state.domainConfig.baseUrl + `/wo/${uid}`,
  481. `targetCompany${uid}`
  482. );
  483. },
  484. /** 移动端下拉刷新 **/
  485. onRefresh() {
  486. // 清空列表数据
  487. this.finished = false;
  488. console.log("onRefresh");
  489. this.onLoad();
  490. },
  491. onLoad() {
  492. console.log("onLoad");
  493. this.getList();
  494. },
  495. calcH1() {
  496. const {
  497. city,
  498. cityName = "",
  499. direction,
  500. directionName = "",
  501. directionSmall,
  502. directionSmallName = ""
  503. } = this.selected;
  504. let job = directionSmall || direction;
  505. let jobName =
  506. directionSmallName === "全部"
  507. ? directionName
  508. : directionSmallName || directionName;
  509. let title = "兼职招聘";
  510. if (city && job) {
  511. title = `${cityName}${jobName}兼职招聘`;
  512. } else if (city && !job) {
  513. //兼职城市
  514. title = `${cityName}兼职招聘`;
  515. } else if (!city && job) {
  516. //岗位页
  517. title = `${jobName}兼职招聘`;
  518. }
  519. return title;
  520. },
  521. is_weixin() {
  522. }
  523. }
  524. };
  525. </script>
  526. <style scope lang="scss">
  527. @import "../../assets/css/job/index.scss";
  528. </style>
  529. <style lang="scss">
  530. .van-dropdown-menu__title {
  531. color: #666;
  532. }
  533. .downapp {
  534. position: absolute;
  535. bottom: 0;
  536. z-index: 1000;
  537. width: 100vw;
  538. height: 50px;
  539. background: cornflowerblue;
  540. color: white;
  541. font-size: 15px;
  542. text-align: center;
  543. line-height: 50px;
  544. }
  545. </style>