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

309 lines
6.2 KiB

4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 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 }}
  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. label: '金牌讲解员',
  91. value: 1
  92. },
  93. {
  94. label: '专业讲解员',
  95. value: 2
  96. },
  97. ]
  98. },
  99. craft: {
  100. label: '工种',
  101. value: 'all',
  102. activeIndex: 0,
  103. color: '#333',
  104. activeColor: '#3796F8',
  105. child: [
  106. {
  107. label: '全部',
  108. value: 'all'
  109. },
  110. ]
  111. },
  112. nature: {
  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. list : [
  126. {
  127. title : '您目前所属的年龄段',
  128. tag : ['18岁~35岁', '35岁~45岁', '45岁~50岁', '50岁以上'],
  129. index : 0,
  130. },
  131. {
  132. title : '您希望从事的工种',
  133. tag : ['电工', '焊工', '叉车', '其他'],
  134. index : 0,
  135. },
  136. {
  137. title : '您希望从事的工作性质',
  138. tag : ['全职', '临时工',],
  139. index : 0,
  140. },
  141. ]
  142. }
  143. },
  144. computed : {
  145. dropItem(name) {
  146. return (name) => {
  147. const result = {};
  148. const find = this.result.find(item => item.name === name);
  149. if (find) {
  150. result.label = find.label;
  151. result.value = find.value;
  152. } else {
  153. result.label = this[name].label;
  154. result.value = this[name].value;
  155. }
  156. return result;
  157. }
  158. },
  159. // 获取当前下拉筛选项
  160. currentDropItem() {
  161. return this[this.activeName];
  162. },
  163. ...mapState(['jobTypeList']),
  164. },
  165. mounted() {
  166. console.log('=================================');
  167. this.jobTypeList.forEach(n => {
  168. this.craft.child.push({
  169. label: n.name,
  170. value: n.id,
  171. })
  172. })
  173. },
  174. methods: {
  175. clickTag(item, i){
  176. console.log(i);
  177. item.index = i
  178. },
  179. change(e) {},
  180. /**
  181. * 点击每个筛选项回调
  182. * @param {Object} e { name, active, type } = e
  183. */
  184. selectMenu(e) {
  185. const {
  186. name,
  187. active,
  188. type
  189. } = e;
  190. this.activeName = name;
  191. if(type == 1){
  192. this.$refs.popup.open()
  193. return
  194. }
  195. const find = this.result.find(item => item.name == this.activeName);
  196. if (find) {
  197. const findIndex = this[this.activeName]
  198. .child.findIndex(item => item.label == find.label && item
  199. .value == find.value);
  200. this[this.activeName].activeIndex = findIndex;
  201. } else {
  202. this[this.activeName].activeIndex = 0;
  203. }
  204. },
  205. /**
  206. * 点击菜单回调处理
  207. * @param {Object} item 选中项 { label,value } = e
  208. */
  209. clickItem(e) {
  210. // 下面有重新赋值,所以用let
  211. let {
  212. label,
  213. value
  214. } = e;
  215. const findIndex = this.result.findIndex(item => item.name == this.activeName);
  216. if (this.defaultValue.indexOf(value) > -1 && this[this.activeName].label) {
  217. label = this[this.activeName].label;
  218. }
  219. // 已经存在筛选项
  220. if (findIndex > -1) {
  221. this.$set(this.result, findIndex, {
  222. name: this.activeName,
  223. label,
  224. value
  225. })
  226. } else {
  227. this.result.push({
  228. name: this.activeName,
  229. label,
  230. value
  231. });
  232. }
  233. this.result = this.result.filter(item => this.defaultValue.indexOf(item.value) == -1);
  234. this.$emit('clickItem', this.result)
  235. },
  236. submit(){
  237. },
  238. }
  239. }
  240. </script>
  241. <style scoped lang="scss">
  242. .page{
  243. .popup{
  244. width: 80vw;
  245. padding: 40rpx;
  246. .list{
  247. .item{
  248. margin-top: 20rpx;
  249. .title{
  250. font-weight: 900;
  251. font-size: 30rpx;
  252. }
  253. .tagList{
  254. display: flex;
  255. flex-wrap: wrap;
  256. padding: 10rpx 0;
  257. view{
  258. background: rgba($uni-color, 0.1);
  259. padding: 10rpx 20rpx;
  260. margin: 10rpx;
  261. border-radius: 10rpx;
  262. font-size: 26rpx;
  263. }
  264. .act{
  265. color: #fff;
  266. background: $uni-color;
  267. }
  268. }
  269. }
  270. }
  271. .btn {
  272. display: flex;
  273. justify-content: center;
  274. width: 100%;
  275. margin-top: 20rpx;
  276. .a {
  277. display: flex;
  278. justify-content: center;
  279. align-items: center;
  280. width: 90%;
  281. color: #FFF;
  282. background-color: $uni-color;
  283. border: 1px solid rgba($uni-color, 0.2);
  284. border-radius: 100rpx;
  285. font-size: 30rpx;
  286. }
  287. }
  288. }
  289. }
  290. </style>