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

308 lines
5.9 KiB

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