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

361 lines
7.0 KiB

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