特易招,招聘小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

602 lines
14 KiB

11 months ago
8 months ago
11 months ago
2 months ago
8 months ago
11 months ago
8 months ago
11 months ago
10 months ago
8 months ago
10 months ago
11 months ago
8 months ago
11 months ago
8 months ago
11 months ago
8 months ago
11 months ago
11 months ago
8 months ago
10 months ago
11 months ago
11 months ago
10 months ago
2 months ago
11 months ago
2 months ago
2 months ago
8 months ago
11 months ago
10 months ago
11 months ago
8 months ago
11 months ago
8 months ago
11 months ago
8 months ago
11 months ago
8 months ago
10 months ago
11 months ago
10 months ago
11 months ago
8 months ago
11 months ago
8 months ago
11 months ago
8 months ago
11 months ago
8 months ago
11 months ago
11 months ago
10 months ago
10 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
10 months ago
8 months ago
10 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
10 months ago
8 months ago
8 months ago
11 months ago
2 months ago
2 months ago
11 months ago
11 months ago
8 months ago
8 months ago
8 months ago
11 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
11 months ago
11 months ago
11 months ago
  1. <template>
  2. <view class="page">
  3. <uv-drop-down ref="dropDown"
  4. :sign="sign"
  5. text-active-color="#3796F8"
  6. :extra-icon="{name:'arrow-down-fill',color:'#666',size:'26rpx'}"
  7. :extra-active-icon="{name:'arrow-up-fill',color:'#3796F8',size:'26rpx'}"
  8. :defaultValue="defaultValue"
  9. :custom-style="{padding: '0 30rpx'}"
  10. @click="selectMenu">
  11. <uv-drop-down-item name="areaId" type="1"
  12. :label="dropItem('areaId').label"
  13. :value="dropItem('areaId').value">
  14. </uv-drop-down-item>
  15. <uv-drop-down-item
  16. name="typeId" type="1"
  17. :label="dropItem('typeId').label"
  18. :value="dropItem('typeId').value">
  19. </uv-drop-down-item>
  20. <uv-drop-down-item
  21. name="natureId" type="2"
  22. :label="dropItem('natureId').label"
  23. :value="dropItem('natureId').value">
  24. </uv-drop-down-item>
  25. <uv-drop-down-item
  26. name="vip_type"
  27. type="1"
  28. label='智能推荐'
  29. :value="0">
  30. </uv-drop-down-item>
  31. </uv-drop-down>
  32. <uv-drop-down-popup
  33. :sign="sign"
  34. :click-overlay-on-close="true"
  35. :currentDropItem="currentDropItem"
  36. @clickItem="clickItem"
  37. @popupChange="change"></uv-drop-down-popup>
  38. <uv-popup ref="popup" :round="30"
  39. :safeAreaInsetBottom="false">
  40. <view class="popup">
  41. <view class="list">
  42. <view class="item"
  43. v-for="(item, index) in list"
  44. :key="item.type">
  45. <view class="title">
  46. {{ role ? item.bossTitle : item.title }}
  47. </view>
  48. <!-- 地址选择使用AddressPicker组件 -->
  49. <view v-if="item.type === 'areaId'" class="address-selector" @click="openAddressPickerInPopup">
  50. <view class="selected-address">
  51. {{ popupSelectedAddress || '请选择工作地区' }}
  52. </view>
  53. <view class="arrow">
  54. <uv-icon name="arrow-right" size="30rpx"></uv-icon>
  55. </view>
  56. </view>
  57. <!-- 工种选择使用JobTypePicker组件 -->
  58. <view v-else-if="item.type === 'typeId'" class="job-type-selector" @click="openJobTypePickerInPopup">
  59. <view class="selected-job-type">
  60. {{ popupSelectedJobType || '请选择工种' }}
  61. </view>
  62. <view class="arrow">
  63. <uv-icon name="arrow-right" size="30rpx"></uv-icon>
  64. </view>
  65. </view>
  66. <!-- 其他选项使用tagList -->
  67. <view v-else class="tagList">
  68. <view
  69. :class="{act : i == item.index}"
  70. @click="clickTag(item, i)"
  71. v-for="(t, i) in item.tag"
  72. :key="t.label">
  73. {{ t.label }}
  74. </view>
  75. </view>
  76. </view>
  77. </view>
  78. <view class="btn" @click="submit">
  79. <button class="a">提交</button>
  80. </view>
  81. </view>
  82. </uv-popup>
  83. <!-- 地址选择组件 -->
  84. <AddressPicker ref="addressPicker" showSelectWholeCity @confirm="onAddressConfirm">
  85. <template #custom-options>
  86. <view class="address-item select-all-item" @click="selectAllAreas">
  87. <uv-icon name="checkmark-circle" size="30rpx" color="#3796F8"></uv-icon>
  88. 选择全部地区
  89. </view>
  90. </template>
  91. </AddressPicker>
  92. <!-- 工种选择组件 -->
  93. <JobTypePicker ref="jobTypePicker" @confirm="onJobTypeConfirm">
  94. <template #custom-options>
  95. <view class="job-type-item select-all-item" @click="selectAllJobTypes">
  96. <uv-icon name="checkmark-circle" size="30rpx" color="#3796F8"></uv-icon>
  97. 选择全部工种
  98. </view>
  99. </template>
  100. </JobTypePicker>
  101. </view>
  102. </template>
  103. <script>
  104. import {
  105. mapState,
  106. } from 'vuex'
  107. import AddressPicker from '@/components/AddressPicker.vue'
  108. import JobTypePicker from '@/components/JobTypePicker.vue'
  109. export default {
  110. components: {
  111. AddressPicker,
  112. JobTypePicker
  113. },
  114. props : {
  115. sign : {
  116. default : 'dropDown_1'
  117. },
  118. },
  119. data() {
  120. return {
  121. // 表示value等于这些值,就属于默认值
  122. defaultValue: [0, 'all', 'all'],
  123. // 筛选结果
  124. result: [],
  125. activeName: 'areaId',
  126. areaId: {
  127. label: '地点',
  128. value: 0,
  129. activeIndex: 0,
  130. color: '#333',
  131. activeColor: '#3796F8',
  132. child: [
  133. {
  134. label: '全部',
  135. value: 0,
  136. },
  137. ]
  138. },
  139. typeId: {
  140. label: '工种',
  141. value: 'all',
  142. activeIndex: 0,
  143. color: '#333',
  144. activeColor: '#3796F8',
  145. child: [
  146. {
  147. label: '全部',
  148. value: 'all'
  149. },
  150. ]
  151. },
  152. natureId: {
  153. label: '性质',
  154. value: 'all',
  155. activeIndex: 0,
  156. color: '#333',
  157. activeColor: '#3796F8',
  158. child: [
  159. {
  160. label: '全部',
  161. value: 'all'
  162. },
  163. ]
  164. },
  165. list : [
  166. // {
  167. // title : '您目前所属的年龄段',
  168. // tag : ['18岁~35岁', '35岁~45岁', '45岁~50岁', '50岁以上'],
  169. // index : 0,
  170. // },
  171. {
  172. title : '您希望从事的工种',
  173. bossTitle : '您希望招工的工种',
  174. tag : [],
  175. index : 0,
  176. type : 'typeId',
  177. },
  178. {
  179. title : '您希望从事的工作性质',
  180. bossTitle : '您希望招工的工作性质',
  181. tag : [],
  182. index : 0,
  183. type : 'natureId',
  184. },
  185. {
  186. title : '您希望从事的工作地区',
  187. bossTitle : '您希望招工的工作地区',
  188. tag : [],
  189. index : 0,
  190. type : 'areaId',
  191. },
  192. ],
  193. popupSelectedAddress: '', // 弹窗中选中的地址
  194. popupSelectedJobType: '', // 弹窗中选中的工种
  195. }
  196. },
  197. computed : {
  198. dropItem(name) {
  199. return (name) => {
  200. const result = {};
  201. const find = this.result.find(item => item.name === name);
  202. if (find) {
  203. result.label = find.label;
  204. result.value = find.value;
  205. } else {
  206. result.label = this[name].label;
  207. result.value = this[name].value;
  208. }
  209. return result;
  210. }
  211. },
  212. // 获取当前下拉筛选项
  213. currentDropItem() {
  214. return this[this.activeName];
  215. },
  216. ...mapState(['jobTypeList', 'natureList', 'addressList']),
  217. },
  218. mounted() {
  219. setTimeout(this.initData, 500)
  220. },
  221. methods: {
  222. init(){
  223. this.$refs.dropDown.init()
  224. },
  225. initData(){
  226. if(this.addressList.length == 0){
  227. setTimeout(this.initData, 500)
  228. }
  229. // 工种
  230. this.jobTypeList.forEach(n => {
  231. this.typeId.child.push({
  232. label: n.name,
  233. value: n.id,
  234. })
  235. })
  236. this.list[0].tag = this.typeId.child
  237. // 工作性质
  238. this.natureList.forEach(n => {
  239. this.natureId.child.push({
  240. label: n.name,
  241. value: n.id,
  242. })
  243. })
  244. this.list[1].tag = this.natureId.child
  245. // if(this.addressList[0]){
  246. // this.areaId.value = this.addressList[0].id
  247. // this.areaId.label = this.addressList[0].adress
  248. // this.defaultValue.slice(0, 1, this.addressList[0].id)
  249. // this.$forceUpdate()
  250. // }
  251. // 地址
  252. this.addressList.forEach(n => {
  253. this.areaId.child.push({
  254. label: n.adress,
  255. value: n.id,
  256. })
  257. })
  258. this.list[2].tag = this.areaId.child
  259. },
  260. clickTag(item, i){
  261. item.index = i
  262. },
  263. change(e) {},
  264. /**
  265. * 点击每个筛选项回调
  266. * @param {Object} e { name, active, type } = e
  267. */
  268. selectMenu(e) {
  269. const {
  270. name,
  271. active,
  272. type
  273. } = e;
  274. this.activeName = name;
  275. // 地址选择使用AddressPicker组件
  276. if(name === 'areaId'){
  277. this.$refs.addressPicker.open()
  278. return
  279. }
  280. // 工种选择使用JobTypePicker组件
  281. if(name === 'typeId'){
  282. this.$refs.jobTypePicker.open()
  283. return
  284. }
  285. // 智能推荐弹窗
  286. if(type == 1){
  287. this.$refs.popup.open()
  288. return
  289. }
  290. const find = this.result.find(item => item.name == this.activeName);
  291. if (find) {
  292. const findIndex = this[this.activeName]
  293. .child.findIndex(item => item.label == find.label && item
  294. .value == find.value);
  295. this[this.activeName].activeIndex = findIndex;
  296. } else {
  297. this[this.activeName].activeIndex = 0;
  298. }
  299. },
  300. /**
  301. * 点击菜单回调处理
  302. * @param {Object} item 选中项 { label,value } = e
  303. */
  304. clickItem(e) {
  305. // 下面有重新赋值,所以用let
  306. let {
  307. label,
  308. value
  309. } = e;
  310. const findIndex = this.result.findIndex(item => item.name == this.activeName);
  311. if (this.defaultValue.indexOf(value) > -1 && this[this.activeName].label) {
  312. label = this[this.activeName].label;
  313. }
  314. // 已经存在筛选项
  315. if (findIndex > -1) {
  316. this.$set(this.result, findIndex, {
  317. name: this.activeName,
  318. label,
  319. value
  320. })
  321. } else {
  322. this.result.push({
  323. name: this.activeName,
  324. label,
  325. value
  326. });
  327. }
  328. this.result = this.result.filter(item => this.defaultValue.indexOf(item.value) == -1);
  329. console.log('this.result', this.result);
  330. this.$emit('clickItem', this.result)
  331. },
  332. submit(){
  333. this.result = []
  334. this.list.forEach(n => {
  335. // 地址选择使用AddressPicker的结果
  336. if(n.type === 'areaId' && this.popupSelectedAddress) {
  337. this.result.push({
  338. name: n.type,
  339. label: this.popupSelectedAddress,
  340. value: this.popupSelectedAddress == '全部地区' ? 'all' : this.areaId.value // 使用存储的ID值
  341. })
  342. } else if(n.type === 'typeId' && this.popupSelectedJobType) {
  343. // 工种选择使用JobTypePicker的结果
  344. this.result.push({
  345. name: n.type,
  346. label: this.popupSelectedJobType,
  347. value: this.popupSelectedJobType == '全部工种' ? 'all' : this.typeId.value // 使用存储的ID值
  348. })
  349. } else {
  350. // 其他选项使用tag选择
  351. let t = n.tag[n.index]
  352. this.result.push({
  353. name: n.type,
  354. label : t.label,
  355. value : t.value
  356. })
  357. }
  358. })
  359. this.result = this.result.filter(item => this.defaultValue.indexOf(item.value) == -1);
  360. this.$emit('clickItem', this.result)
  361. this.$refs.popup.close()
  362. },
  363. // 弹窗中打开地址选择器
  364. openAddressPickerInPopup() {
  365. this.activeName = 'areaId'
  366. this.$refs.addressPicker.open()
  367. },
  368. // 弹窗中打开工种选择器
  369. openJobTypePickerInPopup() {
  370. this.activeName = 'typeId'
  371. this.$refs.jobTypePicker.open()
  372. },
  373. // 地址选择确认回调
  374. onAddressConfirm(addressResult) {
  375. // 更新弹窗中的地址显示
  376. this.popupSelectedAddress = addressResult.fullAddress
  377. // 更新areaId的状态
  378. this.areaId.label = addressResult.fullAddress
  379. this.areaId.value = addressResult.selectedId // 使用ID而不是地址文本
  380. console.log('addressResult', addressResult);
  381. // 调用clickItem来更新result数组并触发父组件事件
  382. this.clickItem({
  383. label: addressResult.fullAddress,
  384. value: addressResult.selectedId, // 传ID给后端
  385. })
  386. // 关闭下拉菜单 - 通过发送事件来关闭
  387. uni.$emit(`${this.sign}_CLOSEPOPUP`)
  388. },
  389. // 选择全部地区
  390. selectAllAreas() {
  391. // 更新弹窗中的地址显示
  392. this.popupSelectedAddress = '全部地区'
  393. // 更新areaId的状态
  394. this.areaId.label = '地点'
  395. this.areaId.value = 'all'
  396. // 调用clickItem来更新result数组并触发父组件事件
  397. this.clickItem({
  398. label: '地点',
  399. value: 'all',
  400. })
  401. // 关闭地址选择器
  402. this.$refs.addressPicker.close()
  403. // 关闭下拉菜单
  404. uni.$emit(`${this.sign}_CLOSEPOPUP`)
  405. },
  406. // 工种选择确认回调
  407. onJobTypeConfirm(jobTypeResult) {
  408. // 更新弹窗中的工种显示
  409. this.popupSelectedJobType = jobTypeResult.fullJobType
  410. // 更新typeId的状态
  411. this.typeId.label = jobTypeResult.fullJobType
  412. this.typeId.value = jobTypeResult.selectedId // 使用ID而不是工种文本
  413. console.log('jobTypeResult', jobTypeResult);
  414. // 调用clickItem来更新result数组并触发父组件事件
  415. this.clickItem({
  416. label: jobTypeResult.fullJobType,
  417. value: jobTypeResult.selectedId, // 传ID给后端
  418. })
  419. // 关闭下拉菜单 - 通过发送事件来关闭
  420. uni.$emit(`${this.sign}_CLOSEPOPUP`)
  421. },
  422. // 选择全部工种
  423. selectAllJobTypes() {
  424. // 更新弹窗中的工种显示
  425. this.popupSelectedJobType = '全部工种'
  426. // 更新typeId的状态
  427. this.typeId.label = '工种'
  428. this.typeId.value = 'all'
  429. // 调用clickItem来更新result数组并触发父组件事件
  430. this.clickItem({
  431. label: '工种',
  432. value: 'all',
  433. })
  434. // 关闭工种选择器
  435. this.$refs.jobTypePicker.close()
  436. // 关闭下拉菜单
  437. uni.$emit(`${this.sign}_CLOSEPOPUP`)
  438. },
  439. }
  440. }
  441. </script>
  442. <style scoped lang="scss">
  443. .page{
  444. // 全部地区按钮样式
  445. ::v-deep .select-all-item {
  446. display: flex;
  447. align-items: center;
  448. color: #3796F8;
  449. background: rgba(#3796F8, 0.1);
  450. font-weight: bold;
  451. padding: 30rpx 20rpx;
  452. font-size: 28rpx;
  453. border-bottom: 1px solid #f0f0f0;
  454. uv-icon {
  455. margin-right: 10rpx;
  456. }
  457. }
  458. .popup{
  459. width: 80vw;
  460. padding: 40rpx;
  461. .list{
  462. .item{
  463. margin-top: 20rpx;
  464. .title{
  465. font-weight: 900;
  466. font-size: 30rpx;
  467. }
  468. .tagList{
  469. display: flex;
  470. flex-wrap: wrap;
  471. padding: 10rpx 0;
  472. view{
  473. background: rgba($uni-color, 0.1);
  474. padding: 10rpx 20rpx;
  475. margin: 10rpx;
  476. border-radius: 10rpx;
  477. font-size: 26rpx;
  478. }
  479. .act{
  480. color: #fff;
  481. background: $uni-color;
  482. }
  483. }
  484. .address-selector {
  485. display: flex;
  486. justify-content: space-between;
  487. align-items: center;
  488. background: rgba($uni-color, 0.1);
  489. padding: 10rpx 20rpx;
  490. margin: 10rpx;
  491. border-radius: 10rpx;
  492. font-size: 26rpx;
  493. .selected-address {
  494. flex: 1;
  495. color: #333;
  496. }
  497. .arrow {
  498. margin-left: 10rpx;
  499. }
  500. }
  501. .job-type-selector {
  502. display: flex;
  503. justify-content: space-between;
  504. align-items: center;
  505. background: rgba($uni-color, 0.1);
  506. padding: 10rpx 20rpx;
  507. margin: 10rpx;
  508. border-radius: 10rpx;
  509. font-size: 26rpx;
  510. .selected-job-type {
  511. flex: 1;
  512. color: #333;
  513. }
  514. .arrow {
  515. margin-left: 10rpx;
  516. }
  517. }
  518. }
  519. }
  520. .btn {
  521. display: flex;
  522. justify-content: center;
  523. width: 100%;
  524. margin-top: 20rpx;
  525. .a {
  526. display: flex;
  527. justify-content: center;
  528. align-items: center;
  529. width: 90%;
  530. color: #FFF;
  531. background-color: $uni-color;
  532. border: 1px solid rgba($uni-color, 0.2);
  533. border-radius: 100rpx;
  534. font-size: 30rpx;
  535. }
  536. }
  537. }
  538. }
  539. </style>