Commit 2a95c67ccca24be413c6cdc6edf6f19a746069c5
1 parent
29c972fd52
Exists in
master
首页筛选以及分享修改
Showing
3 changed files
with
145 additions
and
118 deletions
Show diff stats
src/App.vue
| 1 | 1 | <script> |
| 2 | - import Vue from 'vue'; | |
| 3 | - import store from '@/store'; | |
| 2 | +import Vue from 'vue' | |
| 3 | +import store from '@/store' | |
| 4 | 4 | |
| 5 | - export default Vue.extend({ | |
| 6 | - mpType: 'app', | |
| 7 | - onLaunch(options) { | |
| 8 | - const option = options || {}; | |
| 9 | - // 获取用户来源 | |
| 10 | - // console.log('软件启动,输出转来的参数:', option); | |
| 11 | - // console.log('场景值------------------:', option.scene); | |
| 12 | - let loginQueryInfo = option ? option.query : {}; | |
| 13 | - loginQueryInfo = loginQueryInfo || {}; | |
| 14 | - // console.log('loginQueryInfo onShow===>', loginQueryInfo); | |
| 15 | - const scene = decodeURIComponent(loginQueryInfo.scene); | |
| 16 | - // console.log('decodeURIComponent scense====>', scene); | |
| 17 | - let fromInfo = {}; | |
| 5 | +export default Vue.extend({ | |
| 6 | + mpType: 'app', | |
| 7 | + onLaunch(options) { | |
| 8 | + console.log('options', options) | |
| 9 | + const option = options || {} | |
| 10 | + // 获取用户来源 | |
| 11 | + // console.log('软件启动,输出转来的参数:', option); | |
| 12 | + // console.log('场景值------------------:', option.scene); | |
| 13 | + let loginQueryInfo = option ? option.query : {} | |
| 14 | + loginQueryInfo = loginQueryInfo || {} | |
| 15 | + // console.log('loginQueryInfo onShow===>', loginQueryInfo); | |
| 16 | + const scene = decodeURIComponent(loginQueryInfo.scene) | |
| 17 | + // console.log('decodeURIComponent scense====>', scene); | |
| 18 | + let fromInfo = {} | |
| 19 | + const getQueryString = { | |
| 20 | + uid: undefined, | |
| 21 | + sid: undefined, | |
| 22 | + pid: undefined, | |
| 23 | + } | |
| 18 | 24 | |
| 19 | - if(scene.length > 0 ) { | |
| 20 | - const getQueryString = { | |
| 21 | - uid: undefined, | |
| 22 | - sid: undefined, | |
| 23 | - pid: undefined | |
| 24 | - }; | |
| 25 | - const strB = scene.split('&'); | |
| 25 | + if (scene.length > 0) { | |
| 26 | + const strB = unescape(scene).split('&') | |
| 26 | 27 | |
| 27 | - for(let i = 0; i < strB.length; i += 1) { | |
| 28 | - getQueryString[strB[i].split('=')[0]] = unescape(strB[i].split('=')[1]); | |
| 29 | - } | |
| 30 | - fromInfo = { | |
| 31 | - loginQueryInfo, | |
| 32 | - fromuid: getQueryString.uid, | |
| 33 | - fromsid: getQueryString.sid, | |
| 34 | - frompid: getQueryString.pid, | |
| 35 | - scene: option.scene, | |
| 36 | - } | |
| 37 | - store.dispatch('user/setFrom', fromInfo); | |
| 38 | - // console.log('loginQueryInfo.hasOwnProperty=====111===>', getQueryString); | |
| 39 | - } else { | |
| 40 | - // console.log('loginQueryInfo.hasOwnProperty====22222====>', loginQueryInfo); | |
| 41 | - if (loginQueryInfo.hasOwnProperty('sid') == false) { | |
| 42 | - loginQueryInfo.sid = 0; | |
| 43 | - } | |
| 44 | - if (loginQueryInfo.hasOwnProperty('pid') == false) { | |
| 45 | - loginQueryInfo.pid = 0; | |
| 46 | - } | |
| 47 | - if (loginQueryInfo.hasOwnProperty('uid') == false) { | |
| 48 | - loginQueryInfo.uid = 0; | |
| 49 | - } | |
| 50 | - fromInfo = { | |
| 51 | - loginQueryInfo, | |
| 52 | - fromuid: loginQueryInfo.uid, | |
| 53 | - fromsid: loginQueryInfo.sid, | |
| 54 | - frompid: loginQueryInfo.pid, | |
| 55 | - scene: option.scene, | |
| 56 | - } | |
| 57 | - store.dispatch('user/setFrom', fromInfo) | |
| 58 | - } | |
| 28 | + for (let i = 0; i < strB.length; i += 1) { | |
| 29 | + getQueryString[strB[i].split('=')[0]] = unescape(strB[i].split('=')[1]) | |
| 30 | + } | |
| 31 | + fromInfo = { | |
| 32 | + loginQueryInfo, | |
| 33 | + fromuid: getQueryString.uid, | |
| 34 | + fromsid: getQueryString.sid, | |
| 35 | + frompid: getQueryString.pid, | |
| 36 | + scene: option.scene, | |
| 37 | + } | |
| 38 | + store.dispatch('user/setFrom', fromInfo) | |
| 39 | + // console.log('loginQueryInfo.hasOwnProperty=====111===>', getQueryString); | |
| 40 | + } else { | |
| 41 | + // console.log('loginQueryInfo.hasOwnProperty====22222====>', loginQueryInfo); | |
| 42 | + if (loginQueryInfo.hasOwnProperty('sid') === false) { | |
| 43 | + loginQueryInfo.sid = 0 | |
| 44 | + } | |
| 45 | + if (loginQueryInfo.hasOwnProperty('pid') === false) { | |
| 46 | + loginQueryInfo.pid = 0 | |
| 47 | + } | |
| 48 | + if (loginQueryInfo.hasOwnProperty('uid') === false) { | |
| 49 | + loginQueryInfo.uid = 0 | |
| 50 | + } | |
| 51 | + fromInfo = { | |
| 52 | + loginQueryInfo, | |
| 53 | + fromuid: loginQueryInfo.uid, | |
| 54 | + fromsid: loginQueryInfo.sid, | |
| 55 | + frompid: loginQueryInfo.pid, | |
| 56 | + scene: option.scene, | |
| 57 | + } | |
| 58 | + store.dispatch('user/setFrom', fromInfo) | |
| 59 | + } | |
| 59 | 60 | |
| 60 | - // 登陆 | |
| 61 | - const openId = uni.getStorageSync('openid') || ""; | |
| 62 | - if(openId.length <= 10) { | |
| 63 | - uni.clearStorageSync() | |
| 64 | - store.dispatch("user/login", fromInfo); | |
| 65 | - } else { | |
| 66 | - store.dispatch("user/getUserInfo", fromInfo); | |
| 67 | - } | |
| 68 | - }, | |
| 69 | - onShow() { | |
| 70 | - // console.log('App Show') | |
| 71 | - }, | |
| 72 | - onHide() { | |
| 73 | - // console.log('App Hide') | |
| 74 | - }, | |
| 75 | - methods: { | |
| 76 | - } | |
| 77 | - }); | |
| 61 | + // 登陆 | |
| 62 | + const openId = uni.getStorageSync('openid') || '' | |
| 63 | + if (openId.length <= 10) { | |
| 64 | + uni.clearStorageSync() | |
| 65 | + store.dispatch('user/login', fromInfo) | |
| 66 | + } else { | |
| 67 | + store.dispatch('user/getUserInfo', fromInfo) | |
| 68 | + } | |
| 69 | + if (getQueryString.pid) { | |
| 70 | + uni.navigateTo({ | |
| 71 | + url: `/pages/details/details?pid=${getQueryString.pid}`, | |
| 72 | + success: res => {}, | |
| 73 | + fail: () => {}, | |
| 74 | + complete: () => {}, | |
| 75 | + }) | |
| 76 | + } | |
| 77 | + }, | |
| 78 | + onShow() { | |
| 79 | + // console.log('App Show') | |
| 80 | + }, | |
| 81 | + onHide() { | |
| 82 | + // console.log('App Hide') | |
| 83 | + }, | |
| 84 | + methods: { | |
| 85 | + }, | |
| 86 | +}) | |
| 78 | 87 | </script> |
| 79 | 88 | |
| 80 | 89 | <style> |
| 81 | - /*每个页面公共css */ | |
| 90 | +/*每个页面公共css */ | |
| 82 | 91 | </style> | ... | ... |
src/components/HMFilterDropdown/HMFilterDropdown.vue
| ... | ... | @@ -210,33 +210,33 @@ export default { |
| 210 | 210 | componentTop: 0, // 组件top |
| 211 | 211 | isReadNewSelect: false, |
| 212 | 212 | on: [1, 0, 0, 0, 0], |
| 213 | - selectedData: {} | |
| 213 | + selectedData: {}, | |
| 214 | 214 | } |
| 215 | 215 | }, |
| 216 | 216 | props: { |
| 217 | 217 | filterData: { |
| 218 | 218 | value: Array, |
| 219 | - default: [] | |
| 219 | + default: [], | |
| 220 | 220 | }, |
| 221 | 221 | defaultSelected: { |
| 222 | 222 | value: Array, |
| 223 | - default: [] | |
| 223 | + default: [], | |
| 224 | 224 | }, |
| 225 | 225 | updateMenuName: { |
| 226 | 226 | value: Boolean, |
| 227 | - default: true | |
| 227 | + default: true, | |
| 228 | 228 | }, |
| 229 | 229 | dataFormat: { |
| 230 | 230 | value: String, |
| 231 | - default: 'Array' | |
| 232 | - } | |
| 231 | + default: 'Array', | |
| 232 | + }, | |
| 233 | 233 | }, |
| 234 | 234 | watch: { |
| 235 | 235 | filterData: { |
| 236 | 236 | handler () { |
| 237 | 237 | this.initMenu() // filterData重新赋值初始化菜单 |
| 238 | 238 | }, |
| 239 | - immediate: true | |
| 239 | + immediate: true, | |
| 240 | 240 | }, |
| 241 | 241 | defaultSelected (newVal) { |
| 242 | 242 | if (newVal.length === 0) { |
| ... | ... | @@ -245,7 +245,7 @@ export default { |
| 245 | 245 | this.defaultActive = JSON.parse(JSON.stringify(newVal)) |
| 246 | 246 | this.activeMenuArr = JSON.parse(JSON.stringify(newVal)) |
| 247 | 247 | this.shadowActiveMenuArr = JSON.parse(JSON.stringify(newVal)) |
| 248 | - } | |
| 248 | + }, | |
| 249 | 249 | }, |
| 250 | 250 | methods: { |
| 251 | 251 | initMenu () { |
| ... | ... | @@ -257,7 +257,7 @@ export default { |
| 257 | 257 | // 如果没有设置name,则取第一个菜单作为menu.name,filter类型则将"筛选"作为menu.name |
| 258 | 258 | name: tmpitem.name || (tmpitem.type === 'filter' ? '筛选' : tmpitem.submenu[0].name), |
| 259 | 259 | type: tmpitem.type, |
| 260 | - isNoPull: tmpitem.isNoPull | |
| 260 | + isNoPull: tmpitem.isNoPull, | |
| 261 | 261 | }) |
| 262 | 262 | // 初始化选中项数组-ui状态 |
| 263 | 263 | tmpMenuActiveArr.push(this.processActive(tmpitem)) |
| ... | ... | @@ -290,41 +290,41 @@ export default { |
| 290 | 290 | this.$forceUpdate() |
| 291 | 291 | }, |
| 292 | 292 | // 选中 |
| 293 | - selectHierarchyMenu (page_index, level1_index, level2_index, level3_index) { | |
| 293 | + selectHierarchyMenu (pageIndex, level1Index, level2Index, level3Index) { | |
| 294 | 294 | // 读取记录 |
| 295 | - if (level1_index != null && level2_index == null && level3_index == null && this.shadowActiveMenuArr[page_index][0] === level1_index) { | |
| 296 | - this.activeMenuArr.splice(page_index, 1, JSON.parse(JSON.stringify(this.shadowActiveMenuArr[page_index]))) | |
| 295 | + if (level1Index != null && level2Index == null && level3Index == null && this.shadowActiveMenuArr[pageIndex][0] === level1Index) { | |
| 296 | + this.activeMenuArr.splice(pageIndex, 1, JSON.parse(JSON.stringify(this.shadowActiveMenuArr[pageIndex]))) | |
| 297 | 297 | } else { |
| 298 | - this.activeMenuArr[page_index].splice(0, 1, level1_index); | |
| 299 | - (level2_index != null || this.activeMenuArr[page_index].length >= 2) && this.activeMenuArr[page_index].splice(1, 1, level2_index) || this.activeMenuArr[page_index].splice(1, 1); | |
| 300 | - (level3_index != null || this.activeMenuArr[page_index].length >= 3) && this.activeMenuArr[page_index].splice(2, 1, level3_index) || this.activeMenuArr[page_index].splice(2, 1) | |
| 298 | + this.activeMenuArr[pageIndex].splice(0, 1, level1Index); | |
| 299 | + (level2Index != null || this.activeMenuArr[pageIndex].length >= 2) && (this.activeMenuArr[pageIndex].splice(1, 1, level2Index) || this.activeMenuArr[pageIndex].splice(1, 1)); | |
| 300 | + (level3Index != null || this.activeMenuArr[pageIndex].length >= 3) && (this.activeMenuArr[pageIndex].splice(2, 1, level3Index) || this.activeMenuArr[pageIndex].splice(2, 1)) | |
| 301 | 301 | } |
| 302 | 302 | // 写入结果 |
| 303 | - if (level3_index != null || level2_index != null || (level1_index != null && this.subData[page_index].submenu[level1_index].submenu.length == 0) | |
| 303 | + if (level3Index != null || level2Index != null || (level1Index != null && this.subData[pageIndex].submenu[level1Index].submenu.length === 0) | |
| 304 | 304 | ) { |
| 305 | - const sub = this.subData[page_index].submenu[level1_index].submenu[level2_index] | |
| 306 | - this.shadowActiveMenuArr[page_index] = JSON.parse(JSON.stringify(this.activeMenuArr[page_index])) | |
| 305 | + // const sub = this.subData[pageIndex].submenu[level1Index].submenu[level2Index] | |
| 306 | + this.shadowActiveMenuArr[pageIndex] = JSON.parse(JSON.stringify(this.activeMenuArr[pageIndex])) | |
| 307 | 307 | this.togglePage(this.showPage) |
| 308 | 308 | } |
| 309 | 309 | }, |
| 310 | 310 | // 写入结果,筛选 |
| 311 | - setFilterData (page_index) { | |
| 312 | - this.shadowActiveMenuArr[page_index] = JSON.parse(JSON.stringify(this.activeMenuArr[page_index])) | |
| 311 | + setFilterData (pageIndex) { | |
| 312 | + this.shadowActiveMenuArr[pageIndex] = JSON.parse(JSON.stringify(this.activeMenuArr[pageIndex])) | |
| 313 | 313 | this.togglePage(this.showPage) |
| 314 | 314 | }, |
| 315 | 315 | // 重置结果和ui,筛选 |
| 316 | - resetFilterData (page_index) { | |
| 316 | + resetFilterData (pageIndex) { | |
| 317 | 317 | const tmpArr = [] |
| 318 | - let level = this.shadowActiveMenuArr[page_index].length | |
| 318 | + let level = this.shadowActiveMenuArr[pageIndex].length | |
| 319 | 319 | while (level > 0) { |
| 320 | 320 | tmpArr.push([]) |
| 321 | - const box = this.subData[page_index].submenu[level - 1].submenu | |
| 321 | + const box = this.subData[pageIndex].submenu[level - 1].submenu | |
| 322 | 322 | for (let i = 0; i < box.length; i++) { |
| 323 | - this.subData[page_index].submenu[level - 1].submenu[i].selected = false | |
| 323 | + this.subData[pageIndex].submenu[level - 1].submenu[i].selected = false | |
| 324 | 324 | } |
| 325 | 325 | level-- |
| 326 | 326 | } |
| 327 | - this.activeMenuArr[page_index] = JSON.parse(JSON.stringify(tmpArr)) | |
| 327 | + this.activeMenuArr[pageIndex] = JSON.parse(JSON.stringify(tmpArr)) | |
| 328 | 328 | this.$forceUpdate() |
| 329 | 329 | }, |
| 330 | 330 | // 选中筛选类label-UI状态 |
| ... | ... | @@ -372,7 +372,10 @@ export default { |
| 372 | 372 | this.$forceUpdate() |
| 373 | 373 | }, |
| 374 | 374 | // 菜单开关 |
| 375 | - togglePage (index, isRequest = true) { | |
| 375 | + togglePage (index, isRequest = true) { | |
| 376 | + if (!isRequest && this.maskVisibility) { | |
| 377 | + return | |
| 378 | + } | |
| 376 | 379 | if (index === this.showPage) { |
| 377 | 380 | this.hidePageLayer(true, isRequest) |
| 378 | 381 | this.hideMask() |
| ... | ... | @@ -391,12 +394,14 @@ export default { |
| 391 | 394 | }, |
| 392 | 395 | showAll () { |
| 393 | 396 | this.on = [1, 0, 0, 0, 0] |
| 397 | + this.showPage = -1 | |
| 398 | + console.log('showPage-', this.showPage) | |
| 394 | 399 | // 输出 |
| 395 | 400 | this.$emit('search', { |
| 396 | 401 | index: {}, |
| 397 | 402 | value: {}, |
| 398 | 403 | on: this.on, |
| 399 | - selectedData: this.selectedData | |
| 404 | + selectedData: this.selectedData, | |
| 400 | 405 | }) |
| 401 | 406 | }, |
| 402 | 407 | // hide遮罩层 |
| ... | ... | @@ -416,17 +421,17 @@ export default { |
| 416 | 421 | }) |
| 417 | 422 | }, |
| 418 | 423 | // hide菜单页 |
| 419 | - hidePageLayer (isAnimation,isRequset = true) { | |
| 424 | + hidePageLayer (isAnimation, isRequset = true) { | |
| 420 | 425 | this.triangleDeg[this.showPage] = 0 |
| 421 | 426 | const tmpIndex = this.showPage |
| 422 | 427 | if (isAnimation) { |
| 423 | 428 | setTimeout(() => { |
| 424 | 429 | this.pageState.splice(tmpIndex, 1, false) |
| 425 | - }, 200) | |
| 426 | - // debugger | |
| 427 | - if(isRequset){ | |
| 428 | - this.confirm() | |
| 429 | - } | |
| 430 | + }, 200) | |
| 431 | + // debugger | |
| 432 | + if (isRequset) { | |
| 433 | + this.confirm() | |
| 434 | + } | |
| 430 | 435 | } else { |
| 431 | 436 | this.pageState.splice(tmpIndex, 1, false) |
| 432 | 437 | } |
| ... | ... | @@ -478,13 +483,24 @@ export default { |
| 478 | 483 | } |
| 479 | 484 | index[i] = item |
| 480 | 485 | }) |
| 481 | - // 输出 | |
| 482 | - this.$emit('search', { | |
| 483 | - index: index, | |
| 484 | - value: value, | |
| 485 | - on: this.on, | |
| 486 | - selectedData: this.selectedData | |
| 487 | - }) | |
| 486 | + const params = this.selectedData | |
| 487 | + console.log('params--1', params) | |
| 488 | + for (const key in params) { | |
| 489 | + if (params[key].length === 0) { | |
| 490 | + delete params[key] | |
| 491 | + } | |
| 492 | + } | |
| 493 | + // 若筛选未选择 | |
| 494 | + if (Object.getOwnPropertyNames(params).length === 1) { | |
| 495 | + this.showAll() | |
| 496 | + } else { | |
| 497 | + this.$emit('search', { | |
| 498 | + index: index, | |
| 499 | + value: value, | |
| 500 | + on: this.on, | |
| 501 | + selectedData: params, | |
| 502 | + }) | |
| 503 | + } | |
| 488 | 504 | }, |
| 489 | 505 | // show菜单页 |
| 490 | 506 | showPageLayer (index) { |
| ... | ... | @@ -587,7 +603,7 @@ export default { |
| 587 | 603 | }, |
| 588 | 604 | // 计算菜单层级 |
| 589 | 605 | getMaxFloor (treeData) { |
| 590 | - const floor = 0 | |
| 606 | + // const floor = 0 | |
| 591 | 607 | let max = 0 |
| 592 | 608 | function each (data, floor) { |
| 593 | 609 | data.forEach(e => { |
| ... | ... | @@ -603,8 +619,8 @@ export default { |
| 603 | 619 | }, |
| 604 | 620 | discard () { |
| 605 | 621 | |
| 606 | - } | |
| 607 | - } | |
| 622 | + }, | |
| 623 | + }, | |
| 608 | 624 | } |
| 609 | 625 | </script> |
| 610 | 626 | <style lang="scss"> |
| ... | ... | @@ -815,8 +831,8 @@ export default { |
| 815 | 831 | } |
| 816 | 832 | .labels { |
| 817 | 833 | flex-direction: row; |
| 818 | - flex-wrap: wrap; | |
| 819 | - justify-content: space-between; | |
| 834 | + flex-wrap: wrap; | |
| 835 | + justify-content: space-between; | |
| 820 | 836 | .on { |
| 821 | 837 | border-color: #ff6b4a; |
| 822 | 838 | background-color: #ff6b4a; | ... | ... |
src/pages/index/index.vue
| ... | ... | @@ -259,6 +259,8 @@ export default { |
| 259 | 259 | const { on, value, selectedData } = e |
| 260 | 260 | let params = {} |
| 261 | 261 | const selectedPayload = {} |
| 262 | + console.log('on-----', on) | |
| 263 | + // 将传入数组字符串化 | |
| 262 | 264 | for (const key in selectedData) { |
| 263 | 265 | if (Object.prototype.hasOwnProperty.call(selectedData, key)) { |
| 264 | 266 | selectedPayload[key] = selectedData[key].toString() | ... | ... |