screen.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. <template>
  2. <view>
  3. <navBar title="筛选" color="#000" />
  4. <!-- 列表 -->
  5. <view class="list flex justify-between">
  6. <!-- 左侧分类 -->
  7. <!-- <view class="list-l">
  8. <scroll-view scroll-y="true" style="width: 100%;height: 100%;padding-bottom: 20rpx;">
  9. <block v-if="type">
  10. <view class="list-l-item flex align-center " v-if="index!=3" @click="change_click_index(index)"
  11. :class="current==index?'active':''" v-for="(item,index) in list" :key="index">
  12. {{item.name}}
  13. </view>
  14. </block>
  15. <block v-else>
  16. <view class="list-l-item flex align-center " @click="change_click_index(index)"
  17. :class="current==index?'active':''" v-for="(item,index) in list" :key="index">
  18. {{item.name}}
  19. </view>
  20. </block>
  21. </scroll-view>
  22. </view> -->
  23. <!-- 右侧列表 -->
  24. <view class="list-r">
  25. <scroll-view
  26. scroll-y="true"
  27. @scroll="
  28. (e) => {
  29. scrolls(e);
  30. }
  31. "
  32. scroll-with-animation="true"
  33. :scroll-into-view="'bottomView' + current"
  34. style="width: 100%; height: 100%; padding-bottom: 20rpx"
  35. >
  36. <block v-if="type">
  37. <view
  38. class="list-r-item"
  39. :id="'bottomView' + index"
  40. v-if="list.length > 0 && index != 3"
  41. v-for="(item, index) in list"
  42. :key="index"
  43. >
  44. <view class="list-r-item-title">
  45. {{ item.name }}
  46. </view>
  47. <view class="list-r-item-childs flex justify-around align-center flex-wrap">
  48. <view
  49. class="list-r-item-childs-i flex justify-center align-center"
  50. v-for="(ite, ind) in item.list"
  51. :class="ite.select == true ? 'activeRight' : ''"
  52. @click="selectHyList(index, item.name, ite, ind)"
  53. :key="ind"
  54. >
  55. {{ ite.value }}
  56. </view>
  57. <view
  58. class="list-r-item-childs-i flex justify-center align-center"
  59. style="height: 0; padding: 0"
  60. >
  61. </view>
  62. </view>
  63. </view>
  64. </block>
  65. <block v-else>
  66. <view
  67. class="list-r-item"
  68. :id="'bottomView' + index"
  69. v-if="list.length > 0"
  70. v-for="(item, index) in list"
  71. :key="index"
  72. >
  73. <view class="list-r-item-title">
  74. {{ item.name }}
  75. </view>
  76. <view class="list-r-item-childs flex justify-around align-center flex-wrap">
  77. <view
  78. class="list-r-item-childs-i flex justify-center align-center"
  79. v-for="(ite, ind) in item.list"
  80. :class="ite.select == true ? 'activeRight' : ''"
  81. @click="selectHyList(index, item.name, ite, ind)"
  82. :key="ind"
  83. >
  84. {{ ite.value }}
  85. </view>
  86. <view
  87. class="list-r-item-childs-i flex justify-center align-center"
  88. style="height: 0; padding: 0"
  89. >
  90. </view>
  91. </view>
  92. </view>
  93. </block>
  94. <empty v-if="list.length == 0" />
  95. </scroll-view>
  96. </view>
  97. </view>
  98. <!-- 底部按钮 -->
  99. <view class="bottom flex justify-center">
  100. <view class="bottom-box flex justify-between">
  101. <view @click="cleanSe()" class="bottom-box-left flex justify-center align-center">
  102. 清除
  103. </view>
  104. <view
  105. @click="submitSe()"
  106. class="bottom-box-right flex justify-center align-center"
  107. >
  108. 确定
  109. </view>
  110. </view>
  111. </view>
  112. </view>
  113. </template>
  114. <script>
  115. import empty from "../../components/empty.vue";
  116. import navBar from "@/components/nav-bar/index.vue";
  117. export default {
  118. components: {
  119. empty,
  120. navBar
  121. },
  122. data() {
  123. return {
  124. current: 0,
  125. currents: 0,
  126. list: [],
  127. top_list: [],
  128. selectArr: [],
  129. type: "",
  130. isBrowse: false, //是否是从用户浏览记录里过来的
  131. isCompyBrowse: false, //是否是从企业浏览记录过来的
  132. isCompyHistory: false, //是否是从企业的投递记录过来的
  133. };
  134. },
  135. onLoad(option) {
  136. if (option.type) {
  137. this.type = option.type;
  138. }
  139. if (option.isBrowse) {
  140. this.isBrowse = true;
  141. } else {
  142. this.isBrowse = false;
  143. }
  144. if (option.isCompyBrowse) {
  145. this.isCompyBrowse = true;
  146. } else {
  147. this.isCompyBrowse = false;
  148. }
  149. if (option.isCompyHistory) {
  150. this.isCompyHistory = true;
  151. } else {
  152. this.isCompyHistory = false;
  153. }
  154. this.getSchools();
  155. },
  156. methods: {
  157. /**
  158. * 清空筛选条件并清空缓存
  159. */
  160. cleanSe() {
  161. this.list.map((item) => {
  162. item.list.map((ite) => {
  163. ite.select = false;
  164. });
  165. });
  166. if (this.isBrowse) {
  167. uni.removeStorageSync("browse");
  168. } else if (this.isCompyBrowse) {
  169. uni.removeStorageSync("isCompyBrowse");
  170. } else if (this.isCompyHistory) {
  171. uni.removeStorageSync("isCompyHistory");
  172. } else {
  173. uni.removeStorageSync("filter");
  174. }
  175. },
  176. /**
  177. * 处理选中的条件
  178. */
  179. submitSe() {
  180. let arr = JSON.parse(JSON.stringify(this.list));
  181. arr =
  182. arr &&
  183. arr.map((item) => {
  184. item.list =
  185. item.list &&
  186. item.list.filter((val) => {
  187. if (val.select) return val;
  188. });
  189. if (item.list.length > 0) {
  190. return item;
  191. }
  192. });
  193. arr = arr.filter((val) => {
  194. if (val) return val;
  195. });
  196. if (this.isBrowse) {
  197. //把选中的条件存到本地然后返回首页进行筛选
  198. uni.setStorageSync("browse", arr);
  199. } else if (this.isCompyBrowse) {
  200. uni.setStorageSync("isCompyBrowse", arr);
  201. } else if (this.isCompyHistory) {
  202. uni.setStorageSync("isCompyHistory", arr);
  203. } else {
  204. uni.setStorageSync("filter", arr); //把选中的条件存到本地然后返回首页进行筛选
  205. }
  206. uni.navigateBack();
  207. },
  208. /**
  209. * @param {Object} index 外层下标
  210. * @param {Object} name 外层名称
  211. * @param {Object} info 内层对象
  212. * @param {Object} ind 内层下标
  213. * 选择右侧的筛选
  214. * 薪资单选,其余可以多选
  215. */
  216. selectHyList(index, name, info, ind) {
  217. //选中
  218. if (name == "薪资范围(单选)") {
  219. // 薪资单选
  220. this.list[1].list.map((item, index) => {
  221. item.select = false;
  222. info.select = true;
  223. });
  224. } else {
  225. //其余多选
  226. if (info.value == "不限") {
  227. this.list[index].list.map((item, index) => {
  228. item.select = false;
  229. info.select = true;
  230. });
  231. } else {
  232. this.list[index].list.map((item, ind) => {
  233. if (item.value == "不限") {
  234. item.select = false;
  235. }
  236. });
  237. info.select = !info.select;
  238. }
  239. }
  240. this.$forceUpdate();
  241. },
  242. /**
  243. * @param {Object} index
  244. * 点击切换分类
  245. */
  246. change_click_index(index) {
  247. this.current = index;
  248. //解决最后一个 ***来回*** 问题 (由于点击左侧导航,右侧锚点位置信息变化,此时滚动事件也随之滚动。)
  249. uni.setStorageSync("resolve", "last");
  250. setTimeout(() => {
  251. uni.removeStorageSync("resolve");
  252. }, 400);
  253. },
  254. scrolls(e) {
  255. if (!uni.getStorageSync("resolve")) {
  256. // this.get_node_details(e);
  257. }
  258. },
  259. /**
  260. * @param {Object} options
  261. * 获取节点信息
  262. */
  263. get_node_details(options) {
  264. const query = uni.createSelectorQuery().in(this); //获得实例
  265. //获取多个节点方式
  266. query
  267. .selectAll(".list-r-item")
  268. .boundingClientRect((data) => {
  269. this.top_list = data.map((item) => {
  270. return Math.ceil(item.top);
  271. });
  272. this.async_detail_msg(options);
  273. })
  274. .exec();
  275. },
  276. /**
  277. * @param {Object} options
  278. * 设置滚动的位置
  279. */
  280. async_detail_msg(options) {
  281. //options 为滚动信息。 options.detail.scrollTop 值为相对于scroll-view。
  282. let top_page = options.detail.scrollTop + this.top_list[0];
  283. for (let i = 0; i < this.top_list.length; i++) {
  284. let node1 = this.top_list[i];
  285. let node2 = this.top_list[i + 1];
  286. if (node2 && top_page >= node1 && top_page < node2) {
  287. this.current = i;
  288. break;
  289. } else if (node2 && top_page === node2) {
  290. this.current = i + 1;
  291. break;
  292. }
  293. }
  294. },
  295. /**
  296. * 获取学历列表
  297. */
  298. getSchools() {
  299. this.$Request
  300. .get("/app/dict/list", {
  301. type: "学历",
  302. })
  303. .then((res) => {
  304. if (res.code == 0) {
  305. let list = [
  306. {
  307. value: "不限",
  308. },
  309. ];
  310. let obj = {
  311. name: "学历要求",
  312. list: [...list, ...res.data],
  313. };
  314. console.log(obj, "学历");
  315. this.getMoney(obj);
  316. }
  317. });
  318. },
  319. /**
  320. * 获取薪资 列表
  321. */
  322. getMoney(obj1) {
  323. this.$Request
  324. .get("/app/dict/list", {
  325. type: "薪资 ",
  326. })
  327. .then((res) => {
  328. if (res.code == 0) {
  329. let list = [
  330. {
  331. value: "不限",
  332. },
  333. ];
  334. let obj = {
  335. name: "薪资范围(单选)",
  336. list: [...list, ...res.data],
  337. };
  338. this.getJy(obj1, obj);
  339. }
  340. });
  341. },
  342. /**
  343. * 获取工作经验列表
  344. */
  345. getJy(obj1, obj2) {
  346. this.$Request
  347. .get("/app/dict/list", {
  348. type: "工作经验 ",
  349. })
  350. .then((res) => {
  351. if (res.code == 0) {
  352. let list = [
  353. {
  354. value: "不限",
  355. },
  356. ];
  357. let obj = {
  358. name: "经验要求",
  359. list: [...list, ...res.data],
  360. };
  361. this.getGm(obj1, obj2, obj);
  362. }
  363. });
  364. },
  365. /**
  366. * 获取公司规模列表
  367. */
  368. getGm(obj1, obj2, obj3) {
  369. this.$Request
  370. .get("/app/dict/list", {
  371. type: "公司规模 ",
  372. })
  373. .then((res) => {
  374. if (res.code == 0) {
  375. let list = [
  376. {
  377. value: "不限",
  378. },
  379. ];
  380. let obj = {
  381. name: "公司规模",
  382. list: [...list, ...res.data],
  383. };
  384. this.getIndustryList(obj1, obj2, obj3, obj);
  385. }
  386. });
  387. },
  388. /**
  389. * 获取行业列表
  390. */
  391. getIndustryList(obj1, obj2, obj3, obj4) {
  392. this.$Request.get("/app/industry/getIndustryList").then((res) => {
  393. if (res.code == 0) {
  394. let list = [
  395. {
  396. value: "不限",
  397. },
  398. ];
  399. let arrAy = [];
  400. res.data.map((item) => {
  401. arrAy = [...arrAy, ...item.childrenList];
  402. });
  403. let arrs = JSON.parse(JSON.stringify(arrAy).replace(/industryName/g, "value"));
  404. let obj = {
  405. name: "行业",
  406. list: [...list, ...arrs],
  407. };
  408. let arr = [];
  409. arr[0] = obj1;
  410. arr[1] = obj2;
  411. arr[2] = obj3;
  412. arr[3] = obj4;
  413. arr[4] = obj;
  414. arr.map((item) => {
  415. item.list.map((ite) => {
  416. ite.select = false;
  417. });
  418. });
  419. this.list = arr;
  420. if (uni.getStorageSync("filter")) {
  421. let filter = uni.getStorageSync("filter");
  422. let arrs = [];
  423. filter.map((item) => {
  424. item.list.map((ite) => {
  425. arrs.push(ite.value);
  426. });
  427. });
  428. console.log(this.list, "list");
  429. console.log(arrs, "list");
  430. this.list.map((item, index) => {
  431. item.list.map((ite, ind) => {
  432. arrs.map((it, ins) => {
  433. if (ite.value == it) {
  434. ite.select = true;
  435. }
  436. });
  437. });
  438. });
  439. }
  440. if (uni.getStorageSync("browse")) {
  441. let browse = uni.getStorageSync("browse");
  442. let arrs = [];
  443. browse.map((item) => {
  444. item.list.map((ite) => {
  445. arrs.push(ite.value);
  446. });
  447. });
  448. this.list.map((item, index) => {
  449. item.list.map((ite, ind) => {
  450. arrs.map((it, ins) => {
  451. if (ite.value == it) {
  452. ite.select = true;
  453. }
  454. });
  455. });
  456. });
  457. }
  458. if (uni.getStorageSync("isCompyBrowse")) {
  459. let isCompyBrowse = uni.getStorageSync("isCompyBrowse");
  460. let arrs = [];
  461. isCompyBrowse.map((item) => {
  462. item.list.map((ite) => {
  463. arrs.push(ite.value);
  464. });
  465. });
  466. this.list.map((item, index) => {
  467. item.list.map((ite, ind) => {
  468. arrs.map((it, ins) => {
  469. if (ite.value == it) {
  470. ite.select = true;
  471. }
  472. });
  473. });
  474. });
  475. }
  476. if (uni.getStorageSync("isCompyHistory")) {
  477. let isCompyHistory = uni.getStorageSync("isCompyHistory");
  478. let arrs = [];
  479. isCompyHistory.map((item) => {
  480. item.list.map((ite) => {
  481. arrs.push(ite.value);
  482. });
  483. });
  484. this.list.map((item, index) => {
  485. item.list.map((ite, ind) => {
  486. arrs.map((it, ins) => {
  487. if (ite.value == it) {
  488. ite.select = true;
  489. }
  490. });
  491. });
  492. });
  493. }
  494. }
  495. });
  496. },
  497. },
  498. };
  499. </script>
  500. <style lang="scss">
  501. page {
  502. background-color: #ffffff;
  503. }
  504. .activeRight {
  505. color: rgba(1, 107, 246, 1) !important;
  506. background-color: rgba(153, 196, 250, 0.4) !important;
  507. border-radius: 18rpx !important;
  508. border: 0.5px solid rgba(1, 107, 246, 1);
  509. }
  510. .active {
  511. border-left: 8rpx solid #016bf6 !important;
  512. color: #016bf6 !important;
  513. }
  514. .list {
  515. width: 100%;
  516. /* #ifdef H5 */
  517. height: calc(100vh - 200rpx);
  518. /* #endif */
  519. /* #ifndef H5 */
  520. height: calc(100vh - 120rpx);
  521. /* #endif */
  522. .list-l {
  523. width: 30%;
  524. height: 100%;
  525. .list-l-item {
  526. margin-top: 40rpx;
  527. font-size: 28rpx;
  528. color: #121212;
  529. padding-left: 20rpx;
  530. border-left: 8rpx solid #ffffff;
  531. }
  532. }
  533. .list-r {
  534. width: 100%;
  535. height: 100%;
  536. border-left: 1rpx solid #f2f2f7;
  537. box-sizing: border-box;
  538. .list-r-item {
  539. width: 100%;
  540. margin-top: 40rpx;
  541. .list-r-item-title {
  542. width: 100%;
  543. color: #121212;
  544. font-size: 32rpx;
  545. font-weight: bold;
  546. padding-left: 30rpx;
  547. }
  548. .list-r-item-childs {
  549. width: 100%;
  550. .list-r-item-childs-i {
  551. width: calc((100% - 120rpx) / 2);
  552. margin-top: 20rpx;
  553. padding-top: 16rpx;
  554. padding-bottom: 16rpx;
  555. padding-left: 16rpx;
  556. padding-right: 16rpx;
  557. font-size: 26rpx;
  558. color: #121212;
  559. background: rgba(245, 248, 254, 1);
  560. text-align: center;
  561. border-radius: 18rpx;
  562. }
  563. }
  564. }
  565. }
  566. }
  567. .bottom {
  568. width: 100%;
  569. height: 120rpx;
  570. position: fixed;
  571. bottom: 0;
  572. background-color: #ffffff;
  573. .bottom-box {
  574. width: 686rpx;
  575. height: 70rpx;
  576. margin-top: 20rpx;
  577. .bottom-box-left {
  578. width: 40%;
  579. height: 80rpx;
  580. color: #ffffff;
  581. border-radius: 999rpx;
  582. background: rgba(153, 196, 250, 1);
  583. }
  584. .bottom-box-right {
  585. width: 57%;
  586. height: 80rpx;
  587. border-radius: 999rpx;
  588. background: var(
  589. --线性渐变,
  590. linear-gradient(90deg, rgba(13, 39, 247, 1), rgba(19, 193, 234, 1) 100%)
  591. );
  592. color: #ffffff;
  593. }
  594. }
  595. }
  596. </style>