特易招,招聘小程序
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.

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