tab.vue 4.66 KB
Newer Older
786817560's avatar
786817560 committed
1 2 3 4 5 6 7
<!--
 * @Description: In User Settings Edit
 * @Author: your name
 * @Date: 2019-09-24 12:34:06
 * @LastEditTime: 2019-10-15 13:55:04
 * @LastEditors: Please set LastEditors
 -->
李晓兵's avatar
李晓兵 committed
8
<template>
李晓兵's avatar
李晓兵 committed
9
  <div id="tabBar" style="height: 100%;width:100%;">
李晓兵's avatar
李晓兵 committed
10 11
    <transition>
      <keep-alive>
JingChao's avatar
JingChao committed
12
        <router-view v-if="$route.meta.keepAlive"/>
李晓兵's avatar
李晓兵 committed
13 14 15
      </keep-alive>
    </transition>
    <transition>
JingChao's avatar
JingChao committed
16
      <router-view v-if="!$route.meta.keepAlive"/>
李晓兵's avatar
李晓兵 committed
17
    </transition>
JingChao's avatar
JingChao committed
18
    <tabbar slot="bottom" class="vux-tabbar" icon-class="vux-center">
786817560's avatar
786817560 committed
19
      <tabbar-item :link="{path:'/tab/home-page'}" :selected="$route.path === '/' || $route.path==='/tab/home-page'">
李晓兵's avatar
李晓兵 committed
20 21 22 23
        <img slot="icon-active" src="../assets/image/tab/home@2x.png">
        <img slot="icon" src="../assets/image/tab/n_home@2x.png">
        <span slot="label">主页</span>
      </tabbar-item>
邹骏's avatar
邹骏 committed
24 25 26 27 28
      <tabbar-item :link="{path:'/tab/query-home'}" :selected="$route.path === '/tab/query-home'">
        <img slot="icon-active" src="../assets/image/tab/product@2x.png">
        <img slot="icon" src="../assets/image/tab/n_product@2x.png">
        <span slot="label">产品中心</span>
      </tabbar-item>
李晓兵's avatar
李晓兵 committed
29
      <tabbar-item :link="{path:'/tab/message-center'}" :selected="$route.path === '/tab/message-center'">
李晓兵's avatar
李晓兵 committed
30 31
        <img slot="icon-active" src="../assets/image/tab/message@2x.png">
        <img slot="icon" src="../assets/image/tab/n_message@2x.png">
linxin's avatar
linxin committed
32
        <span slot="label">消息</span>
李晓兵's avatar
李晓兵 committed
33
      </tabbar-item>
Tyh's avatar
Tyh committed
34 35 36 37 38
      <tabbar-item :link="{path:'/tab/function-center'}" :selected="$route.path === '/tab/function-center'">
        <img slot="icon-active" src="../assets/image/tab/function@2x.png">
        <img slot="icon" src="../assets/image/tab/n_function@2x.png">
        <span slot="label">业务办理</span>
      </tabbar-item>
39
      <tabbar-item :selected="$route.path === '/tab/my-info'" @click.native="tabClick">
李晓兵's avatar
李晓兵 committed
40 41 42 43 44 45 46 47 48 49
        <img slot="icon-active" src="../assets/image/tab/my@2x.png">
        <img slot="icon" src="../assets/image/tab/n_my@2x.png">
        <span slot="label">我的</span>
      </tabbar-item>
    </tabbar>
    <!--</view-box>-->
  </div>
</template>

<script>
linxin's avatar
linxin committed
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
export default {
  components: {},
  data () {
    return {
      pathList: [],
      transitionName: '',
    }
  },
  watch: { // 监听路由变化
    $route (to, from) {
      if (this.pathList.includes(to.path)) {
        const index = (this.pathList.findIndex(() => {
          return from.path
        }))
        this.pathList.splice(index, 1)
        this.$router.isBack = 1
      } else {
        this.pathList.push(to.path)
        this.$router.isBack = 2
      }
      if (to.path === '/tab/home-page' || to.path === '/tab/my-info' || to.path === '/tab/message-center' || from.path === '/tab/home-page' || from.path === '/tab/my-info' || from.path === '/tab/message-center') {
        this.$router.isBack = 3
        this.pathList = []
李晓兵's avatar
李晓兵 committed
73
      }
linxin's avatar
linxin committed
74 75 76 77 78 79 80 81 82
      let isBack = this.$router.isBack
      if (isBack === 3) {
        this.transitionName = ''
      } else if (isBack === 2) {
        this.transitionName = 'router-slide-left'
      } else if (isBack === 1) {
        this.transitionName = 'router-slide-right'
      }
      this.$router.isBack = 2
JingChao's avatar
JingChao committed
83
    },
linxin's avatar
linxin committed
84 85 86
  },
  methods: {
    tabClick () {
linxin's avatar
linxin committed
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
      let vm = this
      if (!window.localStorage.getItem('password')) {
        hlsPopup.showConfirm({
          title: '提示',
          content: `请先登录!`,
          onConfirm: data => {
            if (data) {
              vm.$router.push('/login')
            } else {
            }
          },
        })
      } else {
        vm.$router.push('/tab/my-info')
      }
JingChao's avatar
JingChao committed
102
    },
linxin's avatar
linxin committed
103

linxin's avatar
linxin committed
104 105
  },
}
李晓兵's avatar
李晓兵 committed
106 107

</script>
李晓兵's avatar
李晓兵 committed
108 109
<style lang="less">
  #tabBar {
李晓兵's avatar
李晓兵 committed
110

李晓兵's avatar
李晓兵 committed
111 112 113
    .weui-tabbar {
      background-color: #ffffff;
    }
李晓兵's avatar
李晓兵 committed
114

李晓兵's avatar
李晓兵 committed
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
    .weui-tab__panel {
      padding-bottom: 0px !important;
    }
    .weui-tabbar__item.weui-bar__item_on .weui-tabbar__icon, .weui-tabbar__item.weui-bar__item_on .weui-tabbar__icon > i, .weui-tabbar__item.weui-bar__item_on .weui-tabbar__label{
      color: @headerColor;
    }
    .weui-tabbar__item .weui-tabbar__label{
      color: #4A4A4A;
    }
    .weui-tab {
      position: fixed;
      height: 100%;
      bottom: 0;
      width: 100%;

      .vux-tabbar {
        .weui-tabbar__item {
          p {
            font-size: 24px;
          }

          img {
            width: 44px;
            height: 44px;
          }
李晓兵's avatar
李晓兵 committed
140 141 142 143 144 145 146
        }
      }
    }
  }

  // iPhoneX适配
  @media (device-width: 375px) and (device-height: 812px) and (-webkit-min-device-pixel-ratio: 3) {
李晓兵's avatar
李晓兵 committed
147
    .platform-ios {
JingChao's avatar
JingChao committed
148 149 150 151 152
      .weui-tabbar {
        padding-bottom: 34px;
      }
    }
  }
李晓兵's avatar
李晓兵 committed
153 154 155

  @media (device-width: 414px) and (device-height: 896px) {
    .platform-ios {
李晓兵's avatar
李晓兵 committed
156
      .weui-tabbar {
JingChao's avatar
JingChao committed
157
        padding-bottom: 34px;
李晓兵's avatar
李晓兵 committed
158 159 160 161
      }
    }
  }
</style>