|
13 | 13 | :inWhiteList="true"></u-link>
|
14 | 14 | </view>
|
15 | 15 | <view class="uni-panel" v-for="(item, index) in list" :key="item.id">
|
16 |
| - <view class="uni-panel-h" :class="activeOpen === item.id ? 'uni-panel-h-on' : ''" @click="triggerCollapse(index, item.id)"> |
| 16 | + <view class="uni-panel-h" :class="item.open ? 'uni-panel-h-on' : ''" @click="triggerCollapse(index, item.id)"> |
17 | 17 | <text class="uni-panel-text">{{item.name}}</text>
|
18 |
| - <text class="uni-panel-icon uni-icon" :class="activeOpen === item.id ? 'uni-panel-icon-on' : ''">{{item.pages ? '' : ''}}</text> |
| 18 | + <text class="uni-panel-icon uni-icon" :class="item.open ? 'uni-panel-icon-on' : ''">{{item.pages ? '' : ''}}</text> |
19 | 19 | </view>
|
20 |
| - <view class="uni-panel-c" v-if="activeOpen === item.id"> |
| 20 | + <view class="uni-panel-c" v-if="item.open"> |
21 | 21 | <view :class="{'left-win-active': leftWinActive === item2.url && hasLeftWin, 'pc-hide': item2.name === '设置TabBar' && hasLeftWin}" class="uni-navigate-item" v-for="(item2,key) in item.pages" :key="key" :url="item.url" @click="goDetailPage(item.id, item2.url)">
|
22 | 22 | <text class="uni-navigate-text">{{item2.name ? item2.name : item2}}</text>
|
23 | 23 | <text class="uni-navigate-icon uni-icon"></text>
|
|
29 | 29 | </template>
|
30 | 30 | <script>
|
31 | 31 | import setTabBar from '@/components/api-set-tabbar.nvue';
|
32 |
| - import { mapState, mapMutations } from 'vuex'; |
33 | 32 | export default {
|
34 | 33 | components: {
|
35 | 34 | setTabBar
|
36 | 35 | },
|
| 36 | + props: { |
| 37 | + hasLeftWin: { |
| 38 | + type: Boolean |
| 39 | + }, |
| 40 | + leftWinActive: { |
| 41 | + type: String |
| 42 | + } |
| 43 | + }, |
37 | 44 | data() {
|
38 | 45 | // 暂时这么写,后面看怎么优化。
|
39 | 46 | let mediaPages = [{
|
|
413 | 420 | onHide() {
|
414 | 421 | this.leaveSetTabBarPage();
|
415 | 422 | },
|
416 |
| - computed: { |
417 |
| - ...mapState({ |
418 |
| - hasLeftWin: state => !state.noMatchLeftWindow, |
419 |
| - leftWinActive: state => state.leftWinActive.split('/')[3], |
420 |
| - activeOpen: state => state.activeOpen |
421 |
| - }) |
422 |
| - }, |
| 423 | + |
423 | 424 | // #ifdef H5
|
424 | 425 | watch:{
|
425 | 426 | $route: {
|
426 | 427 | immediate: true,
|
427 | 428 | handler(newRoute) {
|
428 | 429 | if (newRoute.matched.length) {
|
429 |
| - this.setLeftWinActive(newRoute.path) |
430 | 430 | let path = newRoute.path.split('/')[3]
|
431 | 431 | for (const item of this.list) {
|
432 | 432 | if (Array.isArray(item.pages)) {
|
433 | 433 | for (const page of item.pages) {
|
434 |
| - if (page === path) { |
435 |
| - this.setActiveOpen(item.id) |
436 |
| - } |
437 |
| - if (page.url && page.url === path) { |
438 |
| - this.setActiveOpen(item.id) |
| 434 | + if (page === path || page.url && page.url === path) { |
| 435 | + item.open = true |
439 | 436 | }
|
440 | 437 | }
|
441 | 438 | }
|
|
446 | 443 | },
|
447 | 444 | // #endif
|
448 | 445 | methods: {
|
449 |
| - ...mapMutations(['setLeftWinActive', 'setActiveOpen']), |
450 | 446 | triggerCollapse(e, id) {
|
451 | 447 | if (!this.list[e].pages) {
|
452 | 448 | this.goDetailPage('', this.list[e].url);
|
453 | 449 | return;
|
454 | 450 | }
|
455 |
| - if (id === this.activeOpen) { |
456 |
| - id = '' |
| 451 | + for (var i = 0; i < this.list.length; ++i) { |
| 452 | + if (e === i) { |
| 453 | + this.list[i].open = !this.list[i].open; |
| 454 | + } else { |
| 455 | + this.list[i].open = false; |
| 456 | + } |
457 | 457 | }
|
458 |
| - this.setActiveOpen(id) |
459 | 458 | },
|
460 | 459 | goDetailPage(panel, e) {
|
461 | 460 | if (e === 'set-tabbar') {
|
|
0 commit comments