resource-new-product-list.vue 4 KB
<template>
    <resource class="no-padding-right" v-if="showFloor">
        <ul class="resource-blk-new-products" v-if="value.data.showType == 1">
            <li class="product-item" v-for="(item, pi) in value.data.list" :key="pi">
                <product-link :value="item" class="link" :yas="value" :yas-f="index" :yas-i="pi"></product-link>
                <img-format :lazy="lazy" :src="item.default_images" :w="188" :h="250"></img-format>
                <div class="ellipsis">
                    <p class="title" v-if="item.brand_name">{{item.brand_name}}</p>
                    <p class="title" v-if="item.product_name">{{item.product_name}}</p>
                    <p class="price" v-if="item.sales_price">¥{{item.sales_price}}</p>
                </div>
            </li>
        </ul>
        <ul class="resource-blk-new-products" v-if="value.data.showType == 2">
            <div class="one">
                <li class="product-item" v-for="(item, pi) in value.data.list" :key="pi" v-if="pi % 2 == 0">
                    <product-link :value="item" class="link" :yas="value" :yas-f="index" :yas-i="pi"></product-link>
                    <img-format :lazy="lazy" :src="item.default_images" :w="188" :h="250"></img-format>
                    <div class="ellipsis">
                        <p class="title" v-if="item.brand_name">{{item.brand_name}}</p>
                        <p class="title" v-if="item.product_name">{{item.product_name}}</p>
                        <p class="price" v-if="item.sales_price">¥{{item.sales_price}}</p>
                    </div>
                </li>
            </div>
            <div class="two">
                <li class="product-item" v-for="(item, pi) in value.data.list" :key="pi" v-if="pi % 2 == 1">
                    <product-link :value="item" class="link" :yas="value" :yas-f="index" :yas-i="pi"></product-link>
                    <img-format :lazy="lazy" :src="item.default_images" :w="188" :h="250"></img-format>
                    <div class="ellipsis">
                        <p class="title" v-if="item.brand_name">{{item.brand_name}}</p>
                        <p class="title" v-if="item.product_name">{{item.product_name}}</p>
                        <p class="price" v-if="item.sales_price">¥{{item.sales_price}}</p>
                    </div>
                </li>
            </div>
        </ul>
    </resource>
</template>

<script>
import Resource from './resource';

export default {
    name: 'ResourceBlkNewProductList',
    props: {
        value: Object,
        lazy: Boolean,
        index: Number
    },
    computed: {
        showFloor() {
            return this.value.data.showType === 1 && this.value.data.list && this.value.data.list.length > 3 ||
                this.value.data.showType === 2 && this.value.data.list && this.value.data.list.length > 7;
        }
    },
    components: {Resource}
};
</script>

<style lang="scss">
    .resource-blk-new-products {
        width: 100%;
        overflow-x: scroll;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
        overflow-y: hidden;

        li.product-item {
            position: relative;
            display: inline-block;
            padding-right: 20px;
            text-align: center;
            line-height: 40px;
            width: 208px;

            .link {
                position: absolute;
                top: 0;
                right: 0;
                bottom: 0;
                left: 0;
            }

            img {
                width: 188px;
                height: 250px;
            }

            .ellipsis > p {
                text-overflow: ellipsis;
                white-space: nowrap;
                overflow: hidden;
                font-size: 24px;
                max-width: 188px;
                line-height: 1;
                margin-top: 24px;
                font-family: HelveticaNeue , Tahoma, Arial, HiraginoSansGB-W3, "PingFang SC", "Heiti SC";

                &.price {
                    font-size: 28px;
                }
            }
        }
    }
</style>