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

277 lines
5.6 KiB

6 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="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 }}
  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. export default {
  63. data() {
  64. return {
  65. // 表示value等于这些值,就属于默认值
  66. defaultValue: [0, 'all'],
  67. // 筛选结果
  68. result: [],
  69. activeName: 'area',
  70. area: {
  71. label: '全国',
  72. value: 0,
  73. activeIndex: 0,
  74. color: '#333',
  75. activeColor: '#3796F8',
  76. child: [
  77. {
  78. label: '全国',
  79. value: 0,
  80. },
  81. {
  82. label: '金牌讲解员',
  83. value: 1
  84. },
  85. {
  86. label: '专业讲解员',
  87. value: 2
  88. },
  89. ]
  90. },
  91. craft: {
  92. label: '工种',
  93. value: 'all',
  94. activeIndex: 0,
  95. color: '#333',
  96. activeColor: '#3796F8',
  97. child: [
  98. {
  99. label: '全部',
  100. value: 'all'
  101. },
  102. ]
  103. },
  104. list : [
  105. {
  106. title : '您目前所属的年龄段',
  107. tag : ['18岁~35岁', '35岁~45岁', '45岁~50岁', '50岁以上'],
  108. index : 0,
  109. },
  110. {
  111. title : '您希望从事的工种',
  112. tag : ['电工', '焊工', '叉车', '其他'],
  113. index : 0,
  114. },
  115. {
  116. title : '您希望从事的工作性质',
  117. tag : ['全职', '临时工',],
  118. index : 0,
  119. },
  120. ]
  121. }
  122. },
  123. computed : {
  124. dropItem(name) {
  125. return (name) => {
  126. const result = {};
  127. const find = this.result.find(item => item.name === name);
  128. if (find) {
  129. result.label = find.label;
  130. result.value = find.value;
  131. } else {
  132. result.label = this[name].label;
  133. result.value = this[name].value;
  134. }
  135. return result;
  136. }
  137. },
  138. // 获取当前下拉筛选项
  139. currentDropItem() {
  140. return this[this.activeName];
  141. },
  142. },
  143. methods: {
  144. clickTag(item, i){
  145. console.log(i);
  146. item.index = i
  147. },
  148. change(e) {},
  149. /**
  150. * 点击每个筛选项回调
  151. * @param {Object} e { name, active, type } = e
  152. */
  153. selectMenu(e) {
  154. const {
  155. name,
  156. active,
  157. type
  158. } = e;
  159. this.activeName = name;
  160. if(type == 1){
  161. this.$refs.popup.open()
  162. return
  163. }
  164. const find = this.result.find(item => item.name == this.activeName);
  165. if (find) {
  166. const findIndex = this[this.activeName]
  167. .child.findIndex(item => item.label == find.label && item
  168. .value == find.value);
  169. this[this.activeName].activeIndex = findIndex;
  170. } else {
  171. this[this.activeName].activeIndex = 0;
  172. }
  173. },
  174. /**
  175. * 点击菜单回调处理
  176. * @param {Object} item 选中项 { label,value } = e
  177. */
  178. clickItem(e) {
  179. // 下面有重新赋值,所以用let
  180. let {
  181. label,
  182. value
  183. } = e;
  184. const findIndex = this.result.findIndex(item => item.name == this.activeName);
  185. if (this.defaultValue.indexOf(value) > -1 && this[this.activeName].label) {
  186. label = this[this.activeName].label;
  187. }
  188. // 已经存在筛选项
  189. if (findIndex > -1) {
  190. this.$set(this.result, findIndex, {
  191. name: this.activeName,
  192. label,
  193. value
  194. })
  195. } else {
  196. this.result.push({
  197. name: this.activeName,
  198. label,
  199. value
  200. });
  201. }
  202. this.result = this.result.filter(item => this.defaultValue.indexOf(item.value) == -1);
  203. this.$emit('clickItem', this.result)
  204. },
  205. submit(){
  206. },
  207. }
  208. }
  209. </script>
  210. <style scoped lang="scss">
  211. .page{
  212. .popup{
  213. width: 80vw;
  214. padding: 40rpx;
  215. .list{
  216. .item{
  217. margin-top: 20rpx;
  218. .title{
  219. font-weight: 900;
  220. font-size: 30rpx;
  221. }
  222. .tagList{
  223. display: flex;
  224. flex-wrap: wrap;
  225. padding: 10rpx 0;
  226. view{
  227. background: rgba($uni-color, 0.1);
  228. padding: 10rpx 20rpx;
  229. margin: 10rpx;
  230. border-radius: 10rpx;
  231. font-size: 26rpx;
  232. }
  233. .act{
  234. color: #fff;
  235. background: $uni-color;
  236. }
  237. }
  238. }
  239. }
  240. .btn {
  241. display: flex;
  242. justify-content: center;
  243. width: 100%;
  244. margin-top: 20rpx;
  245. .a {
  246. display: flex;
  247. justify-content: center;
  248. align-items: center;
  249. width: 90%;
  250. color: #FFF;
  251. background-color: $uni-color;
  252. border: 1px solid rgba($uni-color, 0.2);
  253. border-radius: 100rpx;
  254. font-size: 30rpx;
  255. }
  256. }
  257. }
  258. }
  259. </style>