screen.vue 13 KB

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