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

331 lines
6.4 KiB

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