screenComp.vue 12 KB

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