swiperList.vue 4.32 KB
<template>
    <div class="items" v-for="item in list" v-if="item.show" v-touch:swipeleft="showbutton($index)"
         v-touch:swiperight="hidebutton($index)"  :class="{showbtn:item.isshowbtn,xiajia:!item.status,shouwan:!item.storage}" v-touch-options:swipe="{ direction: 'horizontal', threshold: 10}">
        <div class="wrap">
            <a :href="item.goodsUrl">
                <img :src='item.image'>
                <div class="right">
                    <div class="main-title">{{item.product_name}}</div>
                    <div class="price">
                        <span class="market" :class="{underline:item.sales_price}">¥{{item.market_price}}</span><span class="sales" v-if="item.sales_price">¥{{item.sales_price}}</span>
                    </div>
                </div>
            </a>
        </div>
        <div class="delete" v-touch:tap="deleteskn($index)"><span><i></i>删除</span></div>
    </div>
</template>
<script>
    module.exports = {
        props: ['list', 'showbutton', 'hidebutton', 'deleteskn']
    };
</script>
<style>
    .items {
        border-bottom: 1px solid #eee;
        overflow: hidden;
        position: relative;

        .wrap {
            padding: 20px 26px 20px 30px;
            height: 203px;
            position: relative;

            a {
                display: block;
                height: 163px;
            }
        }

        img {
            padding: 20px 0 20px 30px;
            width: 150px;
            height: 100%;
            position: absolute;
            left: 0;
            top: 0;
        }

        .right {
            padding-left: 176px;
            width: 100%;
            height: 100%;
            font-size: 30px;

            .main-title {
                overflow: hidden;
                text-overflow: ellipsis;
                display: -webkit-box;
                -webkit-box-orient: vertical;
                -webkit-line-clamp: 2;
            }

            .price {
                margin-bottom: 60px;
                margin-top: 5px;
                text-align: left;
                color: #b0b0b0;
                font-size: 22px;
            }

            .sales {
                color: #f00;
                display: inline-block;
                margin-left: 7px;
            }

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

        .delete {
            position: absolute;
            right: 0;
            top: 0;
            background: #f00;
            color: #fff;
            width: 126px;
            height: 100%;
            text-align: center;
            line-height: 203px;
            display: none;

            i {
                display: block;
                width: 36px;
                height: 46px;
                background: resolve("me/delete.png") no-repeat;
                background-size: 100% 100%;
                margin: 0 auto 14px;
            }

            span {
                display: inline-block;
                vertical-align: middle;
                width: 100%;
                text-align: center;
                line-height: 1;
                font-size: 22px;
            }
        }

        &.showbtn {
            .wrap {
                left: -126px;
            }

            .delete {
                display: block;
            }
        }

        &.xiajia {
            .main-title {
                color: #b0b0b0;
            }

            .price {
                color: #b0b0b0;
            }
        }

        &.shouwan {
            .wrap:after{
                content: '已售完';
                position: absolute;
                bottom: 15px;
                right: 30px;
                width: 95px;
                height: 30px;
                background: #b0b0b0;
                color: #fff;
                text-align: center;
                line-height: 30px;
                border-radius: 16px;
            }
        }

        &.xiajia {
            .wrap:after{
                content: '已下架';
                position: absolute;
                bottom: 15px;
                right: 30px;
                width: 95px;
                height: 30px;
                background: #b0b0b0;
                color: #fff;
                text-align: center;
                line-height: 30px;
                border-radius: 16px;
            }
        }
    }
</style>