瑶都万能墙
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.

324 lines
6.3 KiB

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