prefer-list.vue 2.76 KB
<template>
    <div>
        <div class='title-wrap'>{{title}}</div>
        <div class="list-wrap">
            <div class="product-item" v-for="item in list" :key="item.url">
                <a :href="item.url">
                    <a v-good-href="item">
                        <img-lazy :src="{src: item.default_images, width: 250, height: 335}" :lazy="lazy"></img-lazy>
                        <p class="product-name">{{item.product_name}}</p>
                    </a>
                </a>
                <div class="price">
                    <span class="sale" :class="{'discount': item.sales_price !== item.market_price}" v-if="item.sales_price">¥{{item
                        .sales_price}}</span>
                    <span class="market" :class="{'line-through': item.sales_price}" v-if="item.sales_price !== item.market_price">¥{{item.market_price}}</span>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
import ImgLazy from 'component/tool/img-lazy.vue';

export default {
    props: {
        list: {},
        title: {},
        lazy: {
            type: Boolean,
            default: false
        }
    },
    components: {ImgLazy}
};
</script>
<style>
    .title-wrap {
        height: 80px;
        font-size: 32px;
        color: #000;
        text-align: left;
        line-height: 80px;
        font-family: "BrownStd", "PingFang SC", Helvetica, Roboto, "Heiti SC", "\9ED1\4F53", Arial;
    }

    .list-wrap {
        width: 690px;
        max-width: 690px;
        overflow-y: hidden;
        overflow-x: auto;
        white-space: nowrap;

        .product-item {
            display: inline-block;
            width: 250px;
            padding: 0;
            margin-right: 20px;
            text-align: left;

            img {
               width: 100%;
               display: block;
            }

            .product-name {
                margin-top: 20px;
                font-size: 22px;
                color: #000;
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;
            }

            .price .sale {
                margin-top: 10px;
                color: #b0b0b0;
                font-size: 22px;
                display: inline-block;
                margin-left: 7px;
                vertical-align: bottom;

                &.discount {
                    color: #000;
                }
            }

            .price .market {
                margin-left: 5px;
                font-size: 18px;
                margin-top: 10px;
                color: #b0b0b0;
            }


            .line-through {
                text-decoration: line-through;
            }
        }

        .item-list:nth-child(odd) {
            padding-right: 1px;
        }
    }
</style>