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

452 lines
10 KiB

9 months ago
7 months ago
9 months ago
4 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
7 months ago
9 months ago
7 months ago
9 months ago
9 months ago
7 months ago
9 months ago
9 months ago
9 months ago
9 months ago
4 weeks ago
9 months ago
4 weeks ago
7 months ago
9 months ago
9 months ago
9 months ago
7 months ago
7 months ago
9 months ago
7 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
7 months ago
9 months ago
7 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
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
9 months ago
7 months ago
9 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
9 months ago
7 months ago
7 months ago
9 months ago
4 weeks ago
9 months ago
9 months ago
7 months ago
7 months ago
9 months ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 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. init(){
  195. this.$refs.dropDown.init()
  196. },
  197. initData(){
  198. if(this.addressList.length == 0){
  199. setTimeout(this.initData, 500)
  200. }
  201. // 工种
  202. this.jobTypeList.forEach(n => {
  203. this.typeId.child.push({
  204. label: n.name,
  205. value: n.id,
  206. })
  207. })
  208. this.list[0].tag = this.typeId.child
  209. // 工作性质
  210. this.natureList.forEach(n => {
  211. this.natureId.child.push({
  212. label: n.name,
  213. value: n.id,
  214. })
  215. })
  216. this.list[1].tag = this.natureId.child
  217. // if(this.addressList[0]){
  218. // this.areaId.value = this.addressList[0].id
  219. // this.areaId.label = this.addressList[0].adress
  220. // this.defaultValue.slice(0, 1, this.addressList[0].id)
  221. // this.$forceUpdate()
  222. // }
  223. // 地址
  224. this.addressList.forEach(n => {
  225. this.areaId.child.push({
  226. label: n.adress,
  227. value: n.id,
  228. })
  229. })
  230. this.list[2].tag = this.areaId.child
  231. },
  232. clickTag(item, i){
  233. item.index = i
  234. },
  235. change(e) {},
  236. /**
  237. * 点击每个筛选项回调
  238. * @param {Object} e { name, active, type } = e
  239. */
  240. selectMenu(e) {
  241. const {
  242. name,
  243. active,
  244. type
  245. } = e;
  246. this.activeName = name;
  247. // 地址选择使用AddressPicker组件
  248. if(name === 'areaId'){
  249. this.$refs.addressPicker.open()
  250. return
  251. }
  252. // 智能推荐弹窗
  253. if(type == 1){
  254. this.$refs.popup.open()
  255. return
  256. }
  257. const find = this.result.find(item => item.name == this.activeName);
  258. if (find) {
  259. const findIndex = this[this.activeName]
  260. .child.findIndex(item => item.label == find.label && item
  261. .value == find.value);
  262. this[this.activeName].activeIndex = findIndex;
  263. } else {
  264. this[this.activeName].activeIndex = 0;
  265. }
  266. },
  267. /**
  268. * 点击菜单回调处理
  269. * @param {Object} item 选中项 { label,value } = e
  270. */
  271. clickItem(e) {
  272. // 下面有重新赋值,所以用let
  273. let {
  274. label,
  275. value
  276. } = e;
  277. const findIndex = this.result.findIndex(item => item.name == this.activeName);
  278. if (this.defaultValue.indexOf(value) > -1 && this[this.activeName].label) {
  279. label = this[this.activeName].label;
  280. }
  281. // 已经存在筛选项
  282. if (findIndex > -1) {
  283. this.$set(this.result, findIndex, {
  284. name: this.activeName,
  285. label,
  286. value
  287. })
  288. } else {
  289. this.result.push({
  290. name: this.activeName,
  291. label,
  292. value
  293. });
  294. }
  295. this.result = this.result.filter(item => this.defaultValue.indexOf(item.value) == -1);
  296. console.log('this.result', this.result);
  297. this.$emit('clickItem', this.result)
  298. },
  299. submit(){
  300. this.result = []
  301. this.list.forEach(n => {
  302. // 地址选择使用AddressPicker的结果
  303. if(n.type === 'areaId' && this.popupSelectedAddress) {
  304. this.result.push({
  305. name: n.type,
  306. label: this.popupSelectedAddress,
  307. value: this.popupSelectedAddress
  308. })
  309. } else {
  310. // 其他选项使用tag选择
  311. let t = n.tag[n.index]
  312. this.result.push({
  313. name: n.type,
  314. label : t.label,
  315. value : t.value
  316. })
  317. }
  318. })
  319. this.result = this.result.filter(item => this.defaultValue.indexOf(item.value) == -1);
  320. this.$emit('clickItem', this.result)
  321. this.$refs.popup.close()
  322. },
  323. // 弹窗中打开地址选择器
  324. openAddressPickerInPopup() {
  325. this.$refs.addressPicker.open()
  326. },
  327. // 地址选择确认回调
  328. onAddressConfirm(addressResult) {
  329. // 更新弹窗中的地址显示
  330. this.popupSelectedAddress = addressResult.fullAddress
  331. // 更新areaId的状态
  332. this.areaId.label = addressResult.fullAddress
  333. this.areaId.value = addressResult.selectedAddress.adress
  334. console.log('addressResult', addressResult);
  335. // 调用clickItem来更新result数组并触发父组件事件
  336. this.clickItem({
  337. label: addressResult.fullAddress,
  338. value: addressResult.selectedAddress.adress,
  339. })
  340. // 关闭下拉菜单 - 通过发送事件来关闭
  341. uni.$emit(`${this.sign}_CLOSEPOPUP`)
  342. },
  343. }
  344. }
  345. </script>
  346. <style scoped lang="scss">
  347. .page{
  348. .popup{
  349. width: 80vw;
  350. padding: 40rpx;
  351. .list{
  352. .item{
  353. margin-top: 20rpx;
  354. .title{
  355. font-weight: 900;
  356. font-size: 30rpx;
  357. }
  358. .tagList{
  359. display: flex;
  360. flex-wrap: wrap;
  361. padding: 10rpx 0;
  362. view{
  363. background: rgba($uni-color, 0.1);
  364. padding: 10rpx 20rpx;
  365. margin: 10rpx;
  366. border-radius: 10rpx;
  367. font-size: 26rpx;
  368. }
  369. .act{
  370. color: #fff;
  371. background: $uni-color;
  372. }
  373. }
  374. .address-selector {
  375. display: flex;
  376. justify-content: space-between;
  377. align-items: center;
  378. background: rgba($uni-color, 0.1);
  379. padding: 10rpx 20rpx;
  380. margin: 10rpx;
  381. border-radius: 10rpx;
  382. font-size: 26rpx;
  383. .selected-address {
  384. flex: 1;
  385. color: #333;
  386. }
  387. .arrow {
  388. margin-left: 10rpx;
  389. }
  390. }
  391. }
  392. }
  393. .btn {
  394. display: flex;
  395. justify-content: center;
  396. width: 100%;
  397. margin-top: 20rpx;
  398. .a {
  399. display: flex;
  400. justify-content: center;
  401. align-items: center;
  402. width: 90%;
  403. color: #FFF;
  404. background-color: $uni-color;
  405. border: 1px solid rgba($uni-color, 0.2);
  406. border-radius: 100rpx;
  407. font-size: 30rpx;
  408. }
  409. }
  410. }
  411. }
  412. </style>