index-page.vue 2.09 KB
<template>
  <LayoutApp :show-back="false" :title="title">
    <div class="body">
      <div class="content">
        <router-view></router-view>
      </div>
      <div class="footer">
        <Tabs :value="tabIndex" @click="onClick"></Tabs>
      </div>
    </div>
  </LayoutApp>
</template>

<script>

import Tabs from './components/tabs';
import { mapState, mapMutations } from 'vuex';

export default {
  name: 'IndexPage',
  props: ['tabIndex', 'title'],
  components: {
    Tabs
  },
  computed: {
    ...mapState(['yoho'])
  },
  mounted() {
    this.SET_QUERY(this.$route.query ? this.$route.query : {});
  },
  methods: {
    ...mapMutations(['SET_QUERY']),
    onClick(index) {
      this.$store.dispatch('reportYas', {
        params: {
          param: { TAB_ID: index + 1 },
          appop: 'XY_UFO_MAIN_TAB'
        }
      });
      switch (index) {
        case 0: {
          this.go('ChannelPage');
          break;
        }
        case 1: {
          this.go('CategoryPage');
          break;
        }
        case 2: {
          this.$yoho.auth({
            refer: '/xianyu/index/news'
          }).then((res) => {
            if (res) {
              this.go('NewsPage');
            }
          });
          break;
        }
        case 3: {
          this.$yoho.auth({
            refer: '/xianyu/index/mine'
          }).then((res) => {
            if (res) {
              this.go('MinePage');
            }
          });
          break;
        }
        default: {
          this.go('ChannelPage');
        }
      }
    },
    go(name) {
      this.$router.replace({
        name,
        query: {
          ...this.yoho.context.query
        }
      });
    }
  }
};
</script>

<style lang="scss" scoped>

* {
  transition: none !important;
  transform: none !important;
}

.body {
  display: flex;
  flex-direction: column;
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
}

.content {
  flex: 1;
  overflow: hidden;
  background-color: white;
  position: relative;
}

.footer {
  border-top: 1px solid #eee;
  height: 100px;
  width: 100%;
  background-color: white;
}
</style>