<template> <view class="goods_content" v-if="dataList.length"> <view v-if="style_setting.arrange == 1" class="goods_box" :style="[{'background-color': style_setting.bg_color}, style_setting.listType === 3 ? {'padding': '24rpx 0'} : null]"> <view v-for="(item, key) in dataList" :key="key" class="goods_item" :style="width ? {'width':width} : ''"> <view :class="style_setting.listType === 2 ? 'image_box2' : 'image_box'"> <image v-if="style_setting.sign_show" class="logo" :style="{'width': style_setting.sign_size*2+'rpx','height': style_setting.sign_size*2+'rpx'}" :src="style_setting.sign_url"></image> <image class="goods_img" :src="item.default_image || $noGoodsImg" @click="$jumpGoodDetail(item.goods_id)"></image> </view> <text class="goods_name1" v-if="style_setting.title_show">{{item.goods_name}}</text> <text class="goods_sub_name1" v-if="style_setting.sub_title_show">{{item.goods_subname || ' '}}</text> <view class="goods_price1" v-if="isLogin"> <text v-if="style_setting.price_show">¥{{item.price}}</text> <i class="eosfont icon_cart" v-if="style_setting.cart_show" @click="$addCart(item.spec_id,1,isLogin)"></i> </view> <view v-else class="unshow_price1">登录显示价格</view> </view> <view v-if="spaceArray.length" v-for="(item, key) in spaceArray" :key="key+65535" :style="width ? {'width':width} : ''"></view> </view> <uni-swiper-dot v-else :info="dataList" :dotsStyles="{'width': 4,'height':4, 'bottom':5,'border':'none','selectedBorder':'none'}" mode="dot" :current="current"> <swiper class="swiper_content" @change="change" :autoplay="true" :style="style_setting.listType === 2 ? {'height': '536rpx'} : {'height': '346rpx'}"> <swiper-item v-for="(val, index) in dataList" :key="index" class="goods_box2"> <view v-for="(item, key) in val" :key="key" class="goods_item" :style="width ? {'width':width} : ''"> <view :class="style_setting.listType === 2 ? 'image_box2' : 'image_box'"> <image v-if="style_setting.sign_show" class="logo" :style="{'width': style_setting.sign_size*2+'rpx','height': style_setting.sign_size*2+'rpx'}" :src="style_setting.sign_url"></image> <image class="goods_img" :src="item.default_image || $noGoodsImg" @click="$jumpGoodDetail(item.goods_id)"></image> </view> <text class="goods_name" v-if="style_setting.title_show">{{item.goods_name}}</text> <text class="goods_sub_name" v-if="style_setting.sub_title_show">{{item.goods_subname || ' '}}</text> <view class="goods_price" v-if="isLogin"> <text v-if="style_setting.price_show">¥{{item.price}}</text> <i class="eosfont icon_cart" v-if="style_setting.cart_show" @click="$addCart(item.spec_id,1,isLogin)"></i> </view> <view v-else class="unshow_price">登录显示价格</view> </view> <view v-if="spaceArray.length" v-for="(item, key) in spaceArray" :key="key+65535" :style="width ? {'width':width} : ''"></view> </swiper-item> </swiper> </uni-swiper-dot> </view> </template> <script> import uniSwiperDot from "@/components/uni-swiper-dot/uni-swiper-dot.vue" export default { props: { wrapper_props: { type: Object }, isLogin: { type: Number, default: 0 } }, data() { return { dataList: [], style_setting: this.wrapper_props.style_setting, width: '', spaceArray: [],// 商品不足补足空余部分 current: 0 } }, methods: { change(e) { this.current = e.detail.current; } }, mounted() { const { listType, arrange, goods_data_type, width, additional_goods_show, goods_num } = this.style_setting; const { goods_list, cate_goods_list, buy_goods_list } =this.wrapper_props; if(listType == 2) { this.width = '320rpx'; } else if (listType == 3) { this.width = '230rpx'; } else { this.width = width * 2 + 'rpx'; } let list = []; if(goods_data_type === 3) { list = goods_list; } else if (goods_data_type === 1) { let cgl = cate_goods_list || []; list = additional_goods_show ? cgl.concat(goods_list || []).slice(0,goods_num) : cgl } else { let bgl = buy_goods_list || []; list = additional_goods_show ? bgl.concat(goods_list || []).slice(0,goods_num) : bgl } const space = listType - list.length % listType; if(space !== listType) { this.spaceArray = new Array(space); } this.dataList = list; if(arrange == 2) { let array = []; for (var i = 0, j = list.length; i < j; i += listType) { array.push(list.slice(i, i + listType)); } this.dataList = array; } }, components: { uniSwiperDot } } </script> <style lang="less" scoped> .swiper_content { width: 702rpx; margin: 0 auto; box-sizing: border-box; background: #fff; padding: 0 24rpx; } .goods_content, .swiper_content { border-radius: 0 0 16rpx 16rpx; margin-bottom: 20rpx; } .goods_box, .goods_box2 { display: flex; justify-content: space-between; flex-wrap: wrap; width: 702rpx; margin: 0 auto; padding: 24rpx; box-sizing: border-box; .goods_item { margin-bottom: 20rpx; display: flex; flex-direction: column; align-items: center; } } .unshow_price { font-size: 20rpx; width: 90%; text-align: left; } .unshow_price1 { font-size: 20rpx; width: 160rpx; text-align: left; } .needAfter::after { // content: ''; flex: auto; } .image_box, .image_box2 { width: 160rpx; height: 160rpx; position: relative; margin-bottom: 8rpx; .logo { position: absolute; left: 0; top: 0; z-index: 2; } .goods_img { width: 100%; height: 100%; } } .image_box2 { width:320rpx; height: 320rpx; } .goods_name1, .goods_sub_name1, .goods_price1 { width: 160rpx !important; margin: 0 auto; } .goods_name, .goods_name1 { font-size: 22rpx; color: #212121; font-weight: 500; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; height: 32rpx; line-height: 32rpx; margin-bottom: 6rpx; width: 90%; } .goods_sub_name, .goods_sub_name1 { font-size: 22rpx; color: #6e6e6e; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 90%; } .goods_price, .goods_price1 { width: 90%; position: relative; top: -4rpx; height: 40rpx; line-height: 40rpx; display: flex; justify-content: space-between; text { font-size: 24rpx; color: #c3a070; } .icon_cart { font-size: 30rpx; } // i { // display: inline-block; // width: 40rpx; // height: 40rpx; // background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADgAAAA4CAAAAACN7WTCAAABfElEQVRIx2P4TyZgGNU4qnFUIxEafx87+eYvORqvVFRUbiTLxstTSktW/yHHj7/2FRa9ICtw/kzM2wa2/MTmzZs2gTAEbL3yi0Co7sye/A9IfcpGBVlZU/7i1/g4o/gryObzEJtgdm4uyliDX+PXgpQn2Ly0LaUNv8Z/PYl7sGlcnTiRQMpZETsXm8aJccsJaDwTXfULU9/3ouiDBDS+j4z5jKnxU3T4IwIaf+SFXMXUeCsk+jOh3NEfuBpT4+bAwl+ENK7x68bUOMOvl2B+vOmd8h1d7F+F9xKCGj/5e75DF/sc6X6MoMbfOS7oiv6/dnF5SbjomODYhV4O7HIM+ExY4z5b+1lr1gPBurVr16xZs3rVipnetpV/CWv8XmiFAbzuElPKfd4wpb8PCPr7+yeAwMRJK14Mt5L822ZQmJ6FhOOHTSDOub/EaFwVCwYfwJxFYHbcR2I03stJTk5OgqaC6xkgTjdRNv7//R0I/sEKaWTOaI08qnHoaQQAAyi97TBEkioAAAAASUVORK5CYII=) no-repeat; // background-size: 100% 100%; // } } </style>