brand-list.vue 2.98 KB
<template>
    <div class="brand-list-box">
        <div v-for="item in brandList" class="per-brand-box">
            <div class="index"><a href="#{{item.index}}" name="{{item.index}}">{{item.index}}</a></div>
            <div class="brand-big-box clearfix">
                <div class="brand-box" v-for="brand in item.brands">
                    <a href="{{brand.domain | brandUrl}}">
                        <div class="brand-logo">
                            <img v-lazy="brand.logo | resize 150 150" alt="{{brand.name}}">
                        </div>
                        <span class="brand-name">{{brand.name}}</span>
                    </a>
                </div>
            </div>
        </div>
    </div>
    <index-list class="index-list" v-bind:index-list="indexList"></index-list>
</template>
<style>
    .brand-list-box {
        width: 100%;
        padding: 0 30px;

        .per-brand-box {
            .index {
                padding: 18px 0;

                a {
                    font-size: 36px;
                }
            }
        }

        .brand-big-box {
            width: 100%;
        }

        .brand-box {
            width: 24%;
            height: 180px;
            float: left;
            overflow: hidden;
            text-align: center;
            margin: 0 0.5%;

            .brand-logo {
                height: 150px;
                overflow: hidden;

                img {
                    width: 100%;
                }
            }

            .brand-name {
                width: 100%;
                color: #d0d0d0;
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
                display: inline-block;
            }
        }
    }

    .index-list {
        top: 90px !important;
    }
</style>
<script>
    const $ = require('jquery');
    const bus = require('common/vue-bus');
    const tip = require('common/tip');
    const indexList = require('component/tool/index-list.vue');

    module.exports = {
        props: ['channel'],
        data() {
            return {
                brandList: [],
                indexList: []
            };
        },
        watch: {
            channel() {
                this.getBrandList();
            }
        },
        methods: {
            getBrandList() {
                let data = {
                    channel: this.channel
                };

                $.ajax({
                    url: '/brand/list.json',
                    data: data
                }).then(result => {
                    this.brandList = result.brandList;
                    this.indexList = result.indexList;
                }).fail(() => {
                    tip('网络错误');
                });
            }
        },
        components: {
            indexList
        },
        created() {
            this.getBrandList();
            bus.$on('channel.change', (page, channel) => {
                this.channel = channel;
            });
        }
    };
</script>