goodslist.vue 7.41 KB
Newer Older
王建威's avatar
王建威 committed
1
<template>
王建威's avatar
王建威 committed
2
	<view class="goods_content" v-if="dataList.length">
王建威's avatar
王建威 committed
3 4 5
		<view v-if="style_setting.arrange == 1" class="goods_box" :style="[{'background-color': style_setting.bg_color}, style_setting.listType === 2 ? {'padding': '24rpx'} : (style_setting.listType === 3 ? {padding: '24rpx 32rpx'} : {'padding':'24rpx 14rpx'})]">
			<view v-for="(item, key) in dataList" :key="key" class="goods_item" :style="{width: width+'rpx'}">
				<view :class="style_setting.listType === 2 ? 'image_box2' : 'image_box'" :style="{width: width+'rpx',height:width+'rpx'}">
王建威's avatar
王建威 committed
6 7 8
					<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>
王建威's avatar
王建威 committed
9 10 11
				<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">
王建威's avatar
王建威 committed
12
					<text v-if="style_setting.price_show">{{item.price}}</text>
王建威's avatar
王建威 committed
13
					<i class="eosfont icon_cart" v-if="style_setting.cart_show" @click="$addCart(item.spec_id,1,isLogin)">&#xe7e6;</i>
王建威's avatar
王建威 committed
14
				</view>
王建威's avatar
王建威 committed
15
				<view v-else class="unshow_price">登录显示价格</view>
王建威's avatar
王建威 committed
16
			</view>
王建威's avatar
王建威 committed
17
			<view v-if="spaceArray.length" v-for="(item, key) in spaceArray" :key="key+65535" :style="width ? {'width':width+'rpx'} : ''"></view>
王建威's avatar
王建威 committed
18
		</view>
王建威's avatar
王建威 committed
19
		<uni-swiper-dot v-else :info="dataList" :dotsStyles="{'width': 4,'height':4, 'bottom':15,'border':'none','selectedBorder':'none'}" mode="dot" :current="current">
王建威's avatar
王建威 committed
20 21 22 23
			<swiper class="swiper_content" @change="change" :autoplay="false" :style="[style_setting.listType === 2 ? {'height': '536rpx'} : {'height': width+180+'rpx'}, {'background-color': style_setting.bg_color}]">
				<swiper-item v-for="(val, index) in dataList" :key="index" class="goods_box2" :style="style_setting.listType === 3 || style_setting.listType === 2 ? {'padding': '24rpx'} : {'padding':'24rpx 14rpx'}">
					<view v-for="(item, key) in val" :key="key" class="goods_item" :style="{width: width+'rpx'}">
						<view :class="style_setting.listType === 2 ? 'image_box2' : 'image_box'" :style="{width: width+'rpx',height:width+'rpx'}">
王建威's avatar
王建威 committed
24 25 26 27 28 29 30
							<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>
王建威's avatar
王建威 committed
31
							<i class="eosfont icon_cart" v-if="style_setting.cart_show" @click="$addCart(item.spec_id,1,isLogin)">&#xe7e6;</i>
王建威's avatar
王建威 committed
32
						</view>
王建威's avatar
王建威 committed
33
						<view v-else class="unshow_price">登录显示价</view>
王建威's avatar
王建威 committed
34
					</view>
王建威's avatar
王建威 committed
35
					<view v-if="spaceArray.length && val.length < style_setting.listType" v-for="(v, key) in spaceArray" :key="key+65535" :style="width ? {'width':width+'rpx'} : ''"></view>
王建威's avatar
王建威 committed
36 37 38
				</swiper-item>
			</swiper>
		</uni-swiper-dot>
王建威's avatar
王建威 committed
39 40 41 42
	</view>
</template>

<script>
王建威's avatar
王建威 committed
43
	import uniSwiperDot from "@/components/uni-swiper-dot/uni-swiper-dot.vue"
王建威's avatar
王建威 committed
44 45 46 47
	export default {
		props: {
			wrapper_props: {
				type: Object
王建威's avatar
王建威 committed
48 49 50 51
			},
			isLogin: {
				type: Number,
				default: 0
王建威's avatar
王建威 committed
52 53 54 55 56 57
			}
		},
		data() {
			return {
				dataList: [],
				style_setting: this.wrapper_props.style_setting,
王建威's avatar
王建威 committed
58 59 60 61 62 63 64 65
				width: '',
				spaceArray: [],// 商品不足补足空余部分
				current: 0
			}
		},
		methods: {
			change(e) {
				this.current = e.detail.current;
王建威's avatar
王建威 committed
66 67 68
			}
		},
		mounted() {
王建威's avatar
王建威 committed
69 70
			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;
王建威's avatar
王建威 committed
71
			if(listType == 2) {
王建威's avatar
王建威 committed
72
				this.width = '320';
王建威's avatar
王建威 committed
73
			} else {
王建威's avatar
王建威 committed
74
				this.width = width * 2;
王建威's avatar
王建威 committed
75 76 77 78
			}
			let list = [];
			if(goods_data_type === 3) {
				list = goods_list;
王建威's avatar
王建威 committed
79
			} else if (goods_data_type === 1) {
王建威's avatar
王建威 committed
80
				let cgl = cate_goods_list || [];
王建威's avatar
王建威 committed
81
				list = additional_goods_show ? cgl.concat(goods_list || []).slice(0,goods_num) : cgl
王建威's avatar
王建威 committed
82
			} else {
王建威's avatar
王建威 committed
83
				let bgl = buy_goods_list || [];
王建威's avatar
王建威 committed
84
				list = additional_goods_show ? bgl.concat(goods_list || []).slice(0,goods_num) : bgl
王建威's avatar
王建威 committed
85
			}
王建威's avatar
王建威 committed
86 87 88 89
			const space = listType - list.length % listType;
			if(space !== listType) {
				this.spaceArray = new Array(space);
			}
王建威's avatar
王建威 committed
90 91 92 93 94 95 96 97
			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;
			}
王建威's avatar
王建威 committed
98 99 100
		},
		components: {
			uniSwiperDot
王建威's avatar
王建威 committed
101 102 103 104 105 106 107 108 109
		}
	}
</script>

<style lang="less" scoped>
	.swiper_content {
		width: 702rpx;
		margin: 0 auto;
		box-sizing: border-box;
王建威's avatar
王建威 committed
110
		background: #fff;
王建威's avatar
王建威 committed
111
	}
王建威's avatar
王建威 committed
112 113 114
	.goods_content, .swiper_content {
		border-radius: 0 0 16rpx 16rpx;
	}
王建威's avatar
王建威 committed
115 116 117 118 119 120
	.goods_box, .goods_box2 {
		display: flex;
		justify-content: space-between;
		flex-wrap: wrap;
		width: 702rpx;
		margin: 0 auto;
王建威's avatar
王建威 committed
121
		padding: 24rpx 20rpx;
王建威's avatar
王建威 committed
122 123 124 125 126 127 128 129
		box-sizing: border-box;
		.goods_item {
			margin-bottom: 20rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
		}
	}
王建威's avatar
王建威 committed
130
	.unshow_price {
王建威's avatar
王建威 committed
131
		font-size: 20rpx;
王建威's avatar
王建威 committed
132
		text-align: left;
王建威's avatar
王建威 committed
133
		width: 100%;
王建威's avatar
王建威 committed
134
	}
王建威's avatar
王建威 committed
135 136 137 138 139
	// .unshow_price1 {
	// 	font-size: 20rpx;
	// 	width: 160rpx;
	// 	text-align: left;
	// }
王建威's avatar
王建威 committed
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
	.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;
	}
王建威's avatar
王建威 committed
164 165 166 167
	// .goods_name1, .goods_sub_name1, .goods_price1 {
	// 	width: 160rpx !important;
	// 	margin: 0 auto;
	// }
王建威's avatar
王建威 committed
168
	.goods_name, .goods_name1 {
王建威's avatar
王建威 committed
169 170 171 172 173 174 175 176 177 178
		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;
王建威's avatar
王建威 committed
179
		width: 100%;
王建威's avatar
王建威 committed
180
	}
王建威's avatar
王建威 committed
181
	.goods_sub_name, .goods_sub_name1 {
王建威's avatar
王建威 committed
182 183 184 185 186 187
		font-size: 22rpx;
		color: #6e6e6e;
		display: block;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
王建威's avatar
王建威 committed
188
		width: 100%;
王建威's avatar
王建威 committed
189
	}
王建威's avatar
王建威 committed
190
	.goods_price, .goods_price1 {
王建威's avatar
王建威 committed
191 192 193 194 195 196
		position: relative;
		top: -4rpx;
		height: 40rpx;
		line-height: 40rpx;
		display: flex;
		justify-content: space-between;
王建威's avatar
王建威 committed
197
		width: 100%;
王建威's avatar
王建威 committed
198 199 200 201
		text {
			font-size: 24rpx;
			color: #c3a070;
		}
王建威's avatar
王建威 committed
202 203
		.icon_cart {
			font-size: 30rpx;
王建威's avatar
王建威 committed
204
		}
王建威's avatar
王建威 committed
205 206 207 208 209 210 211
		// 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%;
		// }
王建威's avatar
王建威 committed
212 213
	}
</style>