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

449 lines
9.8 KiB

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