product-prefer.vue 3.31 KB
<template>
<div class="product-prefer">
    <div class='title-wrap'>{{title}}</div>
    <div class="list-wrap">
        <div class="product-item" v-for="item in preferList" :key="item.url">
            <product-link :value="item">
                <img-format :src="item.default_images" :w="250" :h="335" :lazy="true"></img-format>
                <p class="product-name">{{item.product_name}}</p>
            </product-link>
            <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>
export default {
    name: 'ProductPrefer',
    props: {
        title: String,
        skn: [Number, String],
        shopId: [Number, String],
        lazy: [Boolean]
    },
    data() {
        return {
            preferList: []
        };
    },
    methods: {
        loadlList() {
            if (this.skn && this.shopId) {
                this.$api.get('/product/mightLike', {
                    skn: this.skn,
                    shopId: this.shopId
                }).then(res => {
                    this.preferList = res.data || [];
                });
            }
        }
    },
    mounted() {
        this.loadlList();
    }
};
</script>
<style lang="scss">
.product-prefer {
    position: relative;
    margin-top: 20px;
    background: #fff;
    border-top: 1px solid #eee;
    border-bottom: 1px solid #eee;
    padding: 30px;
    word-wrap: break-word;
    margin-bottom: 99px;

    .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>