screen.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  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.$emit('updateRecord')
  207. uni.navigateBack();
  208. },
  209. /**
  210. * @param {Object} index 外层下标
  211. * @param {Object} name 外层名称
  212. * @param {Object} info 内层对象
  213. * @param {Object} ind 内层下标
  214. * 选择右侧的筛选
  215. * 薪资单选,其余可以多选
  216. */
  217. selectHyList(index, name, info, ind) {
  218. //选中
  219. if (name == "薪资范围(单选)") {
  220. // 薪资单选
  221. this.list[1].list.map((item, index) => {
  222. item.select = false;
  223. info.select = true;
  224. });
  225. } else {
  226. //其余多选
  227. if (info.value == "不限") {
  228. this.list[index].list.map((item, index) => {
  229. item.select = false;
  230. info.select = true;
  231. });
  232. } else {
  233. this.list[index].list.map((item, ind) => {
  234. if (item.value == "不限") {
  235. item.select = false;
  236. }
  237. });
  238. info.select = !info.select;
  239. }
  240. }
  241. this.$forceUpdate();
  242. },
  243. /**
  244. * @param {Object} index
  245. * 点击切换分类
  246. */
  247. change_click_index(index) {
  248. this.current = index;
  249. //解决最后一个 ***来回*** 问题 (由于点击左侧导航,右侧锚点位置信息变化,此时滚动事件也随之滚动。)
  250. uni.setStorageSync("resolve", "last");
  251. setTimeout(() => {
  252. uni.removeStorageSync("resolve");
  253. }, 400);
  254. },
  255. scrolls(e) {
  256. if (!uni.getStorageSync("resolve")) {
  257. // this.get_node_details(e);
  258. }
  259. },
  260. /**
  261. * @param {Object} options
  262. * 获取节点信息
  263. */
  264. get_node_details(options) {
  265. const query = uni.createSelectorQuery().in(this); //获得实例
  266. //获取多个节点方式
  267. query
  268. .selectAll(".list-r-item")
  269. .boundingClientRect((data) => {
  270. this.top_list = data.map((item) => {
  271. return Math.ceil(item.top);
  272. });
  273. this.async_detail_msg(options);
  274. })
  275. .exec();
  276. },
  277. /**
  278. * @param {Object} options
  279. * 设置滚动的位置
  280. */
  281. async_detail_msg(options) {
  282. //options 为滚动信息。 options.detail.scrollTop 值为相对于scroll-view。
  283. let top_page = options.detail.scrollTop + this.top_list[0];
  284. for (let i = 0; i < this.top_list.length; i++) {
  285. let node1 = this.top_list[i];
  286. let node2 = this.top_list[i + 1];
  287. if (node2 && top_page >= node1 && top_page < node2) {
  288. this.current = i;
  289. break;
  290. } else if (node2 && top_page === node2) {
  291. this.current = i + 1;
  292. break;
  293. }
  294. }
  295. },
  296. /**
  297. * 获取学历列表
  298. */
  299. getSchools() {
  300. this.$Request
  301. .get("/app/dict/list", {
  302. type: "学历",
  303. })
  304. .then((res) => {
  305. if (res.code == 0) {
  306. let list = [
  307. {
  308. value: "不限",
  309. },
  310. ];
  311. let obj = {
  312. name: "学历要求",
  313. list: [...list, ...res.data],
  314. };
  315. console.log(obj, "学历");
  316. this.getMoney(obj);
  317. }
  318. });
  319. },
  320. /**
  321. * 获取薪资 列表
  322. */
  323. getMoney(obj1) {
  324. this.$Request
  325. .get("/app/dict/list", {
  326. type: "薪资 ",
  327. })
  328. .then((res) => {
  329. if (res.code == 0) {
  330. let list = [
  331. {
  332. value: "不限",
  333. },
  334. ];
  335. let obj = {
  336. name: "薪资范围(单选)",
  337. list: [...list, ...res.data],
  338. };
  339. this.getJy(obj1, obj);
  340. }
  341. });
  342. },
  343. /**
  344. * 获取工作经验列表
  345. */
  346. getJy(obj1, obj2) {
  347. this.$Request
  348. .get("/app/dict/list", {
  349. type: "工作经验 ",
  350. })
  351. .then((res) => {
  352. if (res.code == 0) {
  353. let list = [
  354. {
  355. value: "不限",
  356. },
  357. ];
  358. let obj = {
  359. name: "经验要求",
  360. list: [...list, ...res.data],
  361. };
  362. this.getGm(obj1, obj2, obj);
  363. }
  364. });
  365. },
  366. /**
  367. * 获取公司规模列表
  368. */
  369. getGm(obj1, obj2, obj3) {
  370. this.$Request
  371. .get("/app/dict/list", {
  372. type: "公司规模 ",
  373. })
  374. .then((res) => {
  375. if (res.code == 0) {
  376. let list = [
  377. {
  378. value: "不限",
  379. },
  380. ];
  381. let obj = {
  382. name: "公司规模",
  383. list: [...list, ...res.data],
  384. };
  385. this.getIndustryList(obj1, obj2, obj3, obj);
  386. }
  387. });
  388. },
  389. /**
  390. * 获取行业列表
  391. */
  392. getIndustryList(obj1, obj2, obj3, obj4) {
  393. this.$Request.get("/app/industry/getIndustryList").then((res) => {
  394. if (res.code == 0) {
  395. let list = [
  396. {
  397. value: "不限",
  398. },
  399. ];
  400. let arrAy = [];
  401. res.data.map((item) => {
  402. arrAy = [...arrAy, ...item.childrenList];
  403. });
  404. let arrs = JSON.parse(JSON.stringify(arrAy).replace(/industryName/g, "value"));
  405. let obj = {
  406. name: "行业",
  407. list: [...list, ...arrs],
  408. };
  409. let arr = [];
  410. arr[0] = obj1;
  411. arr[1] = obj2;
  412. arr[2] = obj3;
  413. arr[3] = obj4;
  414. arr[4] = obj;
  415. arr.map((item) => {
  416. item.list.map((ite) => {
  417. ite.select = false;
  418. });
  419. });
  420. this.list = arr;
  421. if (uni.getStorageSync("filter")) {
  422. let filter = uni.getStorageSync("filter");
  423. let arrs = [];
  424. filter.map((item) => {
  425. item.list.map((ite) => {
  426. arrs.push(ite.value);
  427. });
  428. });
  429. console.log(this.list, "list");
  430. console.log(arrs, "list");
  431. this.list.map((item, index) => {
  432. item.list.map((ite, ind) => {
  433. arrs.map((it, ins) => {
  434. if (ite.value == it) {
  435. ite.select = true;
  436. }
  437. });
  438. });
  439. });
  440. }
  441. if (uni.getStorageSync("browse")) {
  442. let browse = uni.getStorageSync("browse");
  443. let arrs = [];
  444. browse.map((item) => {
  445. item.list.map((ite) => {
  446. arrs.push(ite.value);
  447. });
  448. });
  449. this.list.map((item, index) => {
  450. item.list.map((ite, ind) => {
  451. arrs.map((it, ins) => {
  452. if (ite.value == it) {
  453. ite.select = true;
  454. }
  455. });
  456. });
  457. });
  458. }
  459. if (uni.getStorageSync("isCompyBrowse")) {
  460. let isCompyBrowse = uni.getStorageSync("isCompyBrowse");
  461. let arrs = [];
  462. isCompyBrowse.map((item) => {
  463. item.list.map((ite) => {
  464. arrs.push(ite.value);
  465. });
  466. });
  467. this.list.map((item, index) => {
  468. item.list.map((ite, ind) => {
  469. arrs.map((it, ins) => {
  470. if (ite.value == it) {
  471. ite.select = true;
  472. }
  473. });
  474. });
  475. });
  476. }
  477. if (uni.getStorageSync("isCompyHistory")) {
  478. let isCompyHistory = uni.getStorageSync("isCompyHistory");
  479. let arrs = [];
  480. isCompyHistory.map((item) => {
  481. item.list.map((ite) => {
  482. arrs.push(ite.value);
  483. });
  484. });
  485. this.list.map((item, index) => {
  486. item.list.map((ite, ind) => {
  487. arrs.map((it, ins) => {
  488. if (ite.value == it) {
  489. ite.select = true;
  490. }
  491. });
  492. });
  493. });
  494. }
  495. }
  496. });
  497. },
  498. },
  499. };
  500. </script>
  501. <style lang="scss">
  502. page {
  503. background-color: #ffffff;
  504. }
  505. .activeRight {
  506. color: rgba(1, 107, 246, 1) !important;
  507. background-color: rgba(153, 196, 250, 0.4) !important;
  508. border-radius: 18rpx !important;
  509. border: 0.5px solid rgba(1, 107, 246, 1);
  510. }
  511. .active {
  512. border-left: 8rpx solid #016bf6 !important;
  513. color: #016bf6 !important;
  514. }
  515. .list {
  516. width: 100%;
  517. /* #ifdef H5 */
  518. height: calc(100vh - 200rpx);
  519. /* #endif */
  520. /* #ifndef H5 */
  521. height: calc(100vh - 120rpx);
  522. /* #endif */
  523. .list-l {
  524. width: 30%;
  525. height: 100%;
  526. .list-l-item {
  527. margin-top: 40rpx;
  528. font-size: 28rpx;
  529. color: #121212;
  530. padding-left: 20rpx;
  531. border-left: 8rpx solid #ffffff;
  532. }
  533. }
  534. .list-r {
  535. width: 100%;
  536. height: 100%;
  537. border-left: 1rpx solid #f2f2f7;
  538. box-sizing: border-box;
  539. .list-r-item {
  540. width: 100%;
  541. margin-top: 40rpx;
  542. .list-r-item-title {
  543. width: 100%;
  544. color: #121212;
  545. font-size: 32rpx;
  546. font-weight: bold;
  547. padding-left: 30rpx;
  548. }
  549. .list-r-item-childs {
  550. width: 100%;
  551. .list-r-item-childs-i {
  552. width: calc((100% - 120rpx) / 2);
  553. margin-top: 20rpx;
  554. padding-top: 16rpx;
  555. padding-bottom: 16rpx;
  556. padding-left: 16rpx;
  557. padding-right: 16rpx;
  558. font-size: 26rpx;
  559. color: #121212;
  560. background: rgba(245, 248, 254, 1);
  561. text-align: center;
  562. border-radius: 18rpx;
  563. }
  564. }
  565. }
  566. }
  567. }
  568. .bottom {
  569. width: 100%;
  570. height: 120rpx;
  571. position: fixed;
  572. bottom: 0;
  573. background-color: #ffffff;
  574. .bottom-box {
  575. width: 686rpx;
  576. height: 70rpx;
  577. margin-top: 20rpx;
  578. .bottom-box-left {
  579. width: 40%;
  580. height: 80rpx;
  581. color: #ffffff;
  582. border-radius: 999rpx;
  583. background: rgba(153, 196, 250, 1);
  584. }
  585. .bottom-box-right {
  586. width: 57%;
  587. height: 80rpx;
  588. border-radius: 999rpx;
  589. background: var(
  590. --线性渐变,
  591. linear-gradient(90deg, rgba(13, 39, 247, 1), rgba(19, 193, 234, 1) 100%)
  592. );
  593. color: #ffffff;
  594. }
  595. }
  596. }
  597. </style>