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

319 lines
6.4 KiB

11 months ago
11 months ago
11 months ago
10 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
10 months ago
10 months ago
11 months ago
  1. <template>
  2. <view class="page">
  3. <uv-drop-down ref="dropDown"
  4. sign="dropDown_1"
  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="area" type="2"
  12. :label="dropItem('area').label"
  13. :value="dropItem('area').value">
  14. </uv-drop-down-item>
  15. <uv-drop-down-item
  16. name="craft" type="2"
  17. :label="dropItem('craft').label"
  18. :value="dropItem('craft').value">
  19. </uv-drop-down-item>
  20. <uv-drop-down-item
  21. name="nature" type="2"
  22. :label="dropItem('nature').label"
  23. :value="dropItem('nature').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="dropDown_1"
  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="index">
  45. <view class="title">
  46. {{ item.title }}
  47. </view>
  48. <view class="tagList">
  49. <view
  50. :class="{act : i == item.index}"
  51. @click="clickTag(item, i)"
  52. v-for="(t, i) in item.tag"
  53. :key="t">
  54. {{ t.label }}
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. <view class="btn" @click="submit">
  60. <button class="a">提交</button>
  61. </view>
  62. </view>
  63. </uv-popup>
  64. </view>
  65. </template>
  66. <script>
  67. import {
  68. mapState,
  69. } from 'vuex'
  70. export default {
  71. data() {
  72. return {
  73. // 表示value等于这些值,就属于默认值
  74. defaultValue: [0, 'all', 'all'],
  75. // 筛选结果
  76. result: [],
  77. activeName: 'area',
  78. area: {
  79. label: '全国',
  80. value: 0,
  81. activeIndex: 0,
  82. color: '#333',
  83. activeColor: '#3796F8',
  84. child: [
  85. {
  86. label: '全国',
  87. value: 0,
  88. },
  89. ]
  90. },
  91. craft: {
  92. label: '工种',
  93. value: 'all',
  94. activeIndex: 0,
  95. color: '#333',
  96. activeColor: '#3796F8',
  97. child: [
  98. {
  99. label: '全部',
  100. value: 'all'
  101. },
  102. ]
  103. },
  104. nature: {
  105. label: '性质',
  106. value: 'all',
  107. activeIndex: 0,
  108. color: '#333',
  109. activeColor: '#3796F8',
  110. child: [
  111. {
  112. label: '全部',
  113. value: 'all'
  114. },
  115. ]
  116. },
  117. list : [
  118. // {
  119. // title : '您目前所属的年龄段',
  120. // tag : ['18岁~35岁', '35岁~45岁', '45岁~50岁', '50岁以上'],
  121. // index : 0,
  122. // },
  123. {
  124. title : '您希望从事的工种',
  125. tag : ['电工', '焊工', '叉车', '其他'],
  126. index : 0,
  127. },
  128. {
  129. title : '您希望从事的工作性质',
  130. tag : ['全职', '临时工',],
  131. index : 0,
  132. },
  133. ]
  134. }
  135. },
  136. computed : {
  137. dropItem(name) {
  138. return (name) => {
  139. const result = {};
  140. const find = this.result.find(item => item.name === name);
  141. if (find) {
  142. result.label = find.label;
  143. result.value = find.value;
  144. } else {
  145. result.label = this[name].label;
  146. result.value = this[name].value;
  147. }
  148. return result;
  149. }
  150. },
  151. // 获取当前下拉筛选项
  152. currentDropItem() {
  153. return this[this.activeName];
  154. },
  155. ...mapState(['jobTypeList', 'natureList', 'addressList']),
  156. },
  157. mounted() {
  158. // 工种
  159. this.jobTypeList.forEach(n => {
  160. this.craft.child.push({
  161. label: n.name,
  162. value: n.id,
  163. })
  164. })
  165. this.list[0].tag = this.craft.child
  166. // 工作性质
  167. this.natureList.forEach(n => {
  168. this.nature.child.push({
  169. label: n.name,
  170. value: n.id,
  171. })
  172. })
  173. this.list[1].tag = this.nature.child
  174. // 地址
  175. this.addressList.forEach(n => {
  176. this.area.child.push({
  177. label: n.adress,
  178. value: n.id,
  179. })
  180. })
  181. },
  182. methods: {
  183. clickTag(item, i){
  184. console.log(i);
  185. item.index = i
  186. },
  187. change(e) {},
  188. /**
  189. * 点击每个筛选项回调
  190. * @param {Object} e { name, active, type } = e
  191. */
  192. selectMenu(e) {
  193. const {
  194. name,
  195. active,
  196. type
  197. } = e;
  198. this.activeName = name;
  199. if(type == 1){
  200. this.$refs.popup.open()
  201. return
  202. }
  203. const find = this.result.find(item => item.name == this.activeName);
  204. if (find) {
  205. const findIndex = this[this.activeName]
  206. .child.findIndex(item => item.label == find.label && item
  207. .value == find.value);
  208. this[this.activeName].activeIndex = findIndex;
  209. } else {
  210. this[this.activeName].activeIndex = 0;
  211. }
  212. },
  213. /**
  214. * 点击菜单回调处理
  215. * @param {Object} item 选中项 { label,value } = e
  216. */
  217. clickItem(e) {
  218. // 下面有重新赋值,所以用let
  219. let {
  220. label,
  221. value
  222. } = e;
  223. const findIndex = this.result.findIndex(item => item.name == this.activeName);
  224. if (this.defaultValue.indexOf(value) > -1 && this[this.activeName].label) {
  225. label = this[this.activeName].label;
  226. }
  227. // 已经存在筛选项
  228. if (findIndex > -1) {
  229. this.$set(this.result, findIndex, {
  230. name: this.activeName,
  231. label,
  232. value
  233. })
  234. } else {
  235. this.result.push({
  236. name: this.activeName,
  237. label,
  238. value
  239. });
  240. }
  241. this.result = this.result.filter(item => this.defaultValue.indexOf(item.value) == -1);
  242. this.$emit('clickItem', this.result)
  243. },
  244. submit(){
  245. },
  246. }
  247. }
  248. </script>
  249. <style scoped lang="scss">
  250. .page{
  251. .popup{
  252. width: 80vw;
  253. padding: 40rpx;
  254. .list{
  255. .item{
  256. margin-top: 20rpx;
  257. .title{
  258. font-weight: 900;
  259. font-size: 30rpx;
  260. }
  261. .tagList{
  262. display: flex;
  263. flex-wrap: wrap;
  264. padding: 10rpx 0;
  265. view{
  266. background: rgba($uni-color, 0.1);
  267. padding: 10rpx 20rpx;
  268. margin: 10rpx;
  269. border-radius: 10rpx;
  270. font-size: 26rpx;
  271. }
  272. .act{
  273. color: #fff;
  274. background: $uni-color;
  275. }
  276. }
  277. }
  278. }
  279. .btn {
  280. display: flex;
  281. justify-content: center;
  282. width: 100%;
  283. margin-top: 20rpx;
  284. .a {
  285. display: flex;
  286. justify-content: center;
  287. align-items: center;
  288. width: 90%;
  289. color: #FFF;
  290. background-color: $uni-color;
  291. border: 1px solid rgba($uni-color, 0.2);
  292. border-radius: 100rpx;
  293. font-size: 30rpx;
  294. }
  295. }
  296. }
  297. }
  298. </style>