channel-home.vue 5.09 KB
<template>
    <div>
        <search-slider v-model="searchSlider"></search-slider>
        <layout-body class="page-detail">
            <header-box slot="header">
                <span slot="title">
                    {{title[gender]}}
                </span>
                <span slot="right">
                    <i class="icon icon-search-new" @click="searchSliderSwitch"></i>
                </span>
            </header-box>
            <component
                :is="component.template_name"
                v-for="(component, index) in floors.filter(c => ['focus', 'category', 'newSingleImage'].some(k => k === c.template_name) )"
                :value="component.data"
                :key="index"></component>
        </layout-body>
    </div>
</template>

<script>
    import {
        FETCH_CHANNEL_REQUEST,
    } from 'store/channel/types';
    import {mapState} from 'vuex';
    import {
        ResourceCategory,
        ResourceFocusImage,
        ResourceSingleImage,
        ResourceProductList
    } from 'components/resources';
    import {SearchSlider} from 'components/search';

    export default {
        name: 'ChannelHome',
        data() {
            return {
                searchSlider: false,
                title: {
                    men: '男士',
                    women: '女士'
                },
                products: [{
                    src: '//img11.static.yhbimg.com/goodsimg/2017/05/04/12/019698fcd41f21403a12e603ae64dc23f0.jpg?imageMogr2/thumbnail/330x440/background/d2hpdGU=/position/center/quality/80/interlace/1',
                    title: 'HBA',
                    price: '¥1399'
                }, {
                    src: '//img12.static.yhbimg.com/goodsimg/2017/05/21/13/0221fbe4559a7033058b84c898fa59d18a.jpg?imageMogr2/thumbnail/330x440/background/d2hpdGU=/position/center/quality/80/interlace/1',
                    title: 'HBA',
                    price: '¥1399'
                }, {
                    src: '//img12.static.yhbimg.com/goodsimg/2017/05/21/13/0221fbe4559a7033058b84c898fa59d18a.jpg?imageMogr2/thumbnail/330x440/background/d2hpdGU=/position/center/quality/80/interlace/1',
                    title: 'HBA',
                    price: '¥1399'
                }, {
                    src: '//img12.static.yhbimg.com/goodsimg/2017/05/21/13/0221fbe4559a7033058b84c898fa59d18a.jpg?imageMogr2/thumbnail/330x440/background/d2hpdGU=/position/center/quality/80/interlace/1',
                    title: 'HBA',
                    price: '¥1399'
                }, {
                    src: '//img12.static.yhbimg.com/goodsimg/2017/05/21/13/0221fbe4559a7033058b84c898fa59d18a.jpg?imageMogr2/thumbnail/330x440/background/d2hpdGU=/position/center/quality/80/interlace/1',
                    title: 'HBA',
                    price: '¥1399'
                }, {
                    src: '//img12.static.yhbimg.com/goodsimg/2017/05/21/13/0221fbe4559a7033058b84c898fa59d18a.jpg?imageMogr2/thumbnail/330x440/background/d2hpdGU=/position/center/quality/80/interlace/1',
                    title: 'HBA',
                    price: '¥1399'
                }, {
                    src: '//img12.static.yhbimg.com/goodsimg/2017/05/21/13/0221fbe4559a7033058b84c898fa59d18a.jpg?imageMogr2/thumbnail/330x440/background/d2hpdGU=/position/center/quality/80/interlace/1',
                    title: 'HBA',
                    price: '¥1399'
                }, {
                    src: '//img12.static.yhbimg.com/goodsimg/2017/05/21/13/0221fbe4559a7033058b84c898fa59d18a.jpg?imageMogr2/thumbnail/330x440/background/d2hpdGU=/position/center/quality/80/interlace/1',
                    title: 'HBA',
                    price: '¥1399'
                }, {
                    src: '//img12.static.yhbimg.com/goodsimg/2017/05/21/13/0221fbe4559a7033058b84c898fa59d18a.jpg?imageMogr2/thumbnail/330x440/background/d2hpdGU=/position/center/quality/80/interlace/1',
                    title: 'HBA',
                    price: '¥1399'
                }, {
                    src: '//img12.static.yhbimg.com/goodsimg/2017/05/21/13/0221fbe4559a7033058b84c898fa59d18a.jpg?imageMogr2/thumbnail/330x440/background/d2hpdGU=/position/center/quality/80/interlace/1',
                    title: 'HBA',
                    price: '¥1399'
                }]
            }
        },
        methods: {
            searchSliderSwitch() {
                this.searchSlider = !this.searchSlider;
            }
        },
        computed: {
            ...mapState(['channel']),
            gender() {
                return this.$store.state.channel.gender;
            },
            floors() {
                return this.$store.state.channel[this.gender].floors;
            }
        },
        asyncData({store, router: to}) {
            const gender = /\/channel\/men/.test(to.path) ? 'men' : 'women';
            return store.dispatch(FETCH_CHANNEL_REQUEST, gender);
        },
        components: {
            focus: ResourceFocusImage,
            newSingleImage: ResourceSingleImage,
            category: ResourceCategory,
            ResourceProductList,
            SearchSlider
        }
    };
</script>

<style>

</style>