<template>
  <div class="mainPage">
    <div>
      <nav class="nav">
        <a v-for="(item, index) in navList" :key="index" @click="navClick(item)">
          <img :src="item.BookTypeImg" alt>
          <span>{{item.BookTypeName}}</span>
        </a>
      </nav>
    </div>
  </div>
</template>

<script>
import { mapState, createNamespacedHelpers } from 'vuex'
const { mapState: mapBookState, mapActions: mapBookAction } = createNamespacedHelpers('book')
export default {
  data () {
    return {
      caseid: '',
    }
  },
  created () {
    this.caseid = this.$route.query.caseid
    this.getBookType({
      caseid: this.caseid,
      page: 1,
      pagesize: 10000,
    })
  },
  computed: {
    ...mapBookState({
      navList: x => x.types.list
    })
  },
  components: {
  },
  methods: {
    ...mapBookAction(['getBookType']),
    navClick (item) {
      this.$router.push({ name: 'booksList', query: { type: item.BookTypeId, caseid: this.caseid } })
    }
  }
}
</script>

<style lang="scss" scoped>
.mainPage {
  > div {
    width: 100%;
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    .nav {
      width: 100%;
      position: relative;
      overflow: hidden;
      font-size: 0;
      > a {
        display: inline-block;
        width: 25%;
        text-align: center;
        margin-top: 0.15rem;
        img {
          height: 0.48rem;
        }
        span {
          width: 100%;
          display: inline-block;
          text-align: center;
          font-size: 0.12rem;
          line-height: 0.22rem;
          margin: 0.08rem auto 0;
        }
      }
    }
  }
}
</style>
