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

311 lines
6.3 KiB

7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 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']),
  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. methods: {
  176. clickTag(item, i){
  177. console.log(i);
  178. item.index = i
  179. },
  180. change(e) {},
  181. /**
  182. * 点击每个筛选项回调
  183. * @param {Object} e { name, active, type } = e
  184. */
  185. selectMenu(e) {
  186. const {
  187. name,
  188. active,
  189. type
  190. } = e;
  191. this.activeName = name;
  192. if(type == 1){
  193. this.$refs.popup.open()
  194. return
  195. }
  196. const find = this.result.find(item => item.name == this.activeName);
  197. if (find) {
  198. const findIndex = this[this.activeName]
  199. .child.findIndex(item => item.label == find.label && item
  200. .value == find.value);
  201. this[this.activeName].activeIndex = findIndex;
  202. } else {
  203. this[this.activeName].activeIndex = 0;
  204. }
  205. },
  206. /**
  207. * 点击菜单回调处理
  208. * @param {Object} item 选中项 { label,value } = e
  209. */
  210. clickItem(e) {
  211. // 下面有重新赋值,所以用let
  212. let {
  213. label,
  214. value
  215. } = e;
  216. const findIndex = this.result.findIndex(item => item.name == this.activeName);
  217. if (this.defaultValue.indexOf(value) > -1 && this[this.activeName].label) {
  218. label = this[this.activeName].label;
  219. }
  220. // 已经存在筛选项
  221. if (findIndex > -1) {
  222. this.$set(this.result, findIndex, {
  223. name: this.activeName,
  224. label,
  225. value
  226. })
  227. } else {
  228. this.result.push({
  229. name: this.activeName,
  230. label,
  231. value
  232. });
  233. }
  234. this.result = this.result.filter(item => this.defaultValue.indexOf(item.value) == -1);
  235. this.$emit('clickItem', this.result)
  236. },
  237. submit(){
  238. },
  239. }
  240. }
  241. </script>
  242. <style scoped lang="scss">
  243. .page{
  244. .popup{
  245. width: 80vw;
  246. padding: 40rpx;
  247. .list{
  248. .item{
  249. margin-top: 20rpx;
  250. .title{
  251. font-weight: 900;
  252. font-size: 30rpx;
  253. }
  254. .tagList{
  255. display: flex;
  256. flex-wrap: wrap;
  257. padding: 10rpx 0;
  258. view{
  259. background: rgba($uni-color, 0.1);
  260. padding: 10rpx 20rpx;
  261. margin: 10rpx;
  262. border-radius: 10rpx;
  263. font-size: 26rpx;
  264. }
  265. .act{
  266. color: #fff;
  267. background: $uni-color;
  268. }
  269. }
  270. }
  271. }
  272. .btn {
  273. display: flex;
  274. justify-content: center;
  275. width: 100%;
  276. margin-top: 20rpx;
  277. .a {
  278. display: flex;
  279. justify-content: center;
  280. align-items: center;
  281. width: 90%;
  282. color: #FFF;
  283. background-color: $uni-color;
  284. border: 1px solid rgba($uni-color, 0.2);
  285. border-radius: 100rpx;
  286. font-size: 30rpx;
  287. }
  288. }
  289. }
  290. }
  291. </style>