category.vue 3.73 KB
<template>
    <LayoutApp :show-back="true">
        <div class="root-content">
            <div class="left-content">
                <Scroll>
                    <div >
                        <li 
                        class="category-left-item" 
                        :class="{'category-left-item-select' : item.isSelect }" 
                        v-for="(item, index) in categoryParent" 
                        :key="index" 
                        :data-id="item"
                        @click="onClick(item)">{{item.name}}</li>
                        
                    </div>
                </Scroll>
            </div>
            <div class="left-right-split-line"></div>
            <div class="right-content">
                <Scroll>
                    <div v-for="(itemSub, index) in categorySubList" :key="index">
                        <p class="sub-title">————{{itemSub.name}}————</p>
                        <div class="category-sub-root">
                            <div class="item-imge-div"
                            v-for="(item, index) in itemSub.sub"
                            :key="index" 
                            :data-id="item.id" 
                            >
                            <ImgSize
                            class="item-imge"
                            :src="item.image" 
                            :width="60" 
                            :height="60"
                            />
                            </div>
                        </div>
                    </div>
                </Scroll>
            </div>

        </div>
    </LayoutApp>
</template>
<script>
import { Scroll }from 'cube-ui'
import {createNamespacedHelpers} from 'vuex';
import Vue from 'vue';
import ImgSize from '../../components/img-size';

const {mapState, mapActions} = createNamespacedHelpers('category');
export default {
  name: 'category',
  components: {
    Scroll,
    ImgSize
  },
  data() {
    return {
      
    };
  },
  mounted() {
    this.fetchCategoryParentList();
    this.fetchBrandList({});
  },
  methods: {
    ...mapActions(['fetchCategoryParentList', 'selectCategoryParent', 'fetchBrandList', 'fetchCategorySubList']),
    onClick(item){
        if(!item.isSelect){
            let id = item.id;
            if(id === "-1"){
                this.fetchBrandList({id});
            }else {
                this.fetchCategorySubList({id})
            }
        }
    },
  },
  computed: {
    ...mapState(['categoryParent','categorySubList']),
  },
};
</script>

<style>
    .root-content{
        width: 100%;
        height: 100%;
        display: flex;
        flex-direction: row;
        background-color: #FFFFFF;

    }
    .left-right-split-line{
        height: 100%;
        width: 1px;
        background-color: #999999;
    }
    .left-content{
        width: 25%;
        height: 100%;
        
    }
    .right-content{
        display: flex;
        flex-direction: column;
        width: 75%;
        height: 100%;
    }
    .category-left-item{
        display: flex;
        width: 100%;
        height: 100px;
        align-items: center;
        justify-content: center;
        font-size: 28px;
        color: #EEEEEE;
        
    }
    .category-left-item-select{
        font-size: 48px;
        color: #000000;
        
    }
    .category-sub-root {
        display: flex;
        flex-flow: row wrap;
        align-content: flex-start;
    }
    .sub-title{
        /* background-color: brown; */
        font-size: 24px;
        color: #000;
        text-align: center;
    }
    .item-imge-div {
        display: flex;
        flex: 0 0 33%;
        height: 150px;
        align-items: center;
        justify-content: center; 
  }
    .item-imge {
        object-fit: contain;
  }

</style>