hotrecommd.vue 5.73 KB
Newer Older
王建威's avatar
王建威 committed
1
<template>
王建威's avatar
王建威 committed
2 3
	<view class="hot_main_content" :style="[fixFlag ? {'padding-top': '100rpx'} : null]" ref="fix">
		<view class="clearfix scrollbar" :class="{'fixed': fixFlag}">
王建威's avatar
王建威 committed
4 5 6 7 8 9 10 11 12
			<view class="hot_head_left">
				<view>
					<text class="hot_title">
						<i v-if="style_setting.icon_url_show" class="hot_icon" :style="{'background-image':'url('+style_setting.icon_url+')'}"></i>
						{{style_setting.title}}
					</text>
					<text class="hot_sub_title">{{style_setting.sub_title}}</text>
				</view>
			</view>
王建威's avatar
王建威 committed
13
			<view class="hot_cate_list" :style="[fixFlag ? {'padding-right': '60rpx'} : null]">
王建威's avatar
王建威 committed
14 15 16 17
				<text class="hot_cate_item" v-for="(item, key) in cate_list" :key="key" @click="changeCate(key)" :class="key === hotIndex ? 'act' : ''" v-if="item.goods_list.length">
					<text>{{item.cate_name}}</text>
					<text>{{item.sub_title}}</text>
				</text>
王建威's avatar
王建威 committed
18 19
			</view>
		</view>
王建威's avatar
王建威 committed
20 21 22
		<view v-for="(val, key) in cate_list" :key="key" v-if="key === hotIndex">
			<view v-if="val.goods_list" class="flex_goods">
				<view class="hot_goods_item" v-for="(item, index) in val.goods_list" :key="index">
王建威's avatar
王建威 committed
23
					<image class="hot_goods_icon" v-if="style_setting.angle_sign" :src="style_setting.angle_sign_url"></image>
王建威's avatar
王建威 committed
24 25 26 27 28 29 30 31 32
					<image class="hot_goods_img" :src="item.default_image || $noGoodsImg" @click="$jumpGoodDetail(item.goods_id)"></image>
					<text class="hot_goods_name" v-if="style_setting.title_show">{{item.goods_name}}</text>
					<text class="hot_goods_subname" v-if="style_setting.sub_title_show">{{item.goods_subname || ' '}}</text>
					<view class="between_price">
						<view class="between_left" v-if="style_setting.price_show">
							<text class="hot_pro_price" v-if="isLogin">{{item.price}}</text>
							<!-- <text class="hot_price">{{item.price}}</text> -->
							<text class="hot_pro_price" v-else>登录显示价格</text>
						</view>
王建威's avatar
王建威 committed
33
						<i class="eosfont hot_cart_icon" v-if="style_setting.cart_show" @click="$addCart(item.spec_id, 1,isLogin)">&#xe7e6;</i>
王建威's avatar
王建威 committed
34 35 36
					</view>
				</view>
			</view>
王建威's avatar
王建威 committed
37
			<view v-else class="nogoods">暂无此类商品</view>
王建威's avatar
王建威 committed
38 39 40 41 42 43 44 45 46
		</view>
	</view>
</template>

<script>
	export default {
		props:{
			wrapper_props: {
				type: Object
王建威's avatar
王建威 committed
47 48 49 50
			},
			isLogin: {
				type: Number,
				default: 0
王建威's avatar
王建威 committed
51 52 53 54 55 56
			}
		},
		data() {
			return {
				style_setting: this.wrapper_props.style_setting,
				cate_list: this.wrapper_props.cate_list,
王建威's avatar
王建威 committed
57 58
				hotIndex: 0,
				fixFlag: false
王建威's avatar
王建威 committed
59 60
			}
		},
王建威's avatar
王建威 committed
61 62 63 64 65 66 67 68 69
		mounted() {
			var flag = true;
			this.cate_list.map((item, index) => {
				if(item.goods_list.length && flag) {
					this.hotIndex = index;
					flag = false;
				}
			});
		},
王建威's avatar
王建威 committed
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
		methods: {
			changeCate(index) {
				this.hotIndex = index
			}
		}
	}
</script>

<style lang="less" scoped>
	.clearfix::after {
		content: "";
		display: block;
		height: 0;
		clear:both;
		visibility: hidden;
	}
	.hot_main_content {
王建威's avatar
王建威 committed
87
		width: 702rpx;
王建威's avatar
王建威 committed
88
		margin: 0 auto;
王建威's avatar
王建威 committed
89 90 91 92 93 94 95 96 97 98 99 100 101
		.scrollbar {
			padding: 28rpx 0 20rpx;
		}
		.fixed {
			position: fixed;
			left: 0;
			top: 100rpx;
			background-color: #f8f8f8;
			z-index: 10;
			width: 100%;
			padding: 28rpx 24rpx 20rpx;
			box-shadow:0px 4px 16px 0px rgba(0,0,0,0.3);
		}
王建威's avatar
王建威 committed
102 103 104 105 106 107 108 109 110 111 112
	}
	.hot_head_left {
		display: inline-block;
		float: left;
	}
	.hot_icon {
		display: inline-block;
		width: 28rpx;
		height: 28rpx;
		background-repeat: no-repeat;
		background-size: 100% 100%;
王建威's avatar
王建威 committed
113
		margin-right: 8rpx;
王建威's avatar
王建威 committed
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
	}
	.hot_title {
		font-size: 32rpx;
		font-family: PingFangSC-Medium,PingFang SC;
		font-weight: 500;
		color: #464646;
		line-height: 44rpx;
		display: block;
	}
	.hot_sub_title {
		font-size: 22rpx;
		color: #7c7c7c;
		line-height: 32rpx;
		display: block;
	}
	.hot_cate_list {
		white-space: nowrap;
		overflow: scroll;
		position: relative;
王建威's avatar
王建威 committed
133
		left: 20rpx;
王建威's avatar
王建威 committed
134
		height: 88rpx;
王建威's avatar
王建威 committed
135
		padding-right: 18rpx;
王建威's avatar
王建威 committed
136 137 138 139 140 141 142 143
	}
	.hot_cate_list::-webkit-scrollbar {
		display: none;
	}
	.hot_cate_item {
		width: 164rpx;
		display: inline-block;
		text-align: center;
王建威's avatar
王建威 committed
144
		position: relative;
王建威's avatar
王建威 committed
145 146 147 148 149 150 151 152 153 154 155 156 157
		margin-left: 10rpx;
		text:nth-of-type(1) {
			display: block;
			font-family: PingFangSC-Medium,PingFang SC;
			font-weight: 500;
			color: #464646;
			font-size: 32rpx;
		}
		text:nth-of-type(2) {
			display: block;
			font-size: 22rpx;
			color: #7C7C7C;
		}
王建威's avatar
王建威 committed
158 159 160 161 162 163 164 165 166 167
	}
	.hot_cate_item.act::after {
		content: '';
		width: 40rpx;
		height: 2px;
		border-radius: 1px;
		background: #000;
		position: absolute;
		left: 50%;
		margin-left: -20rpx;
王建威's avatar
王建威 committed
168
		bottom: -8rpx;
王建威's avatar
王建威 committed
169 170 171 172
	}
	.nogoods {
		padding: 40rpx;
		text-align: center;
王建威's avatar
王建威 committed
173 174 175 176 177 178 179 180 181
	}
	.flex_goods {
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;
		.hot_goods_item {
			position: relative;
			width: 346rpx;
			text-align: center;
王建威's avatar
王建威 committed
182
			margin-bottom: 20rpx;
王建威's avatar
王建威 committed
183
			background: #fff;
王建威's avatar
王建威 committed
184
			padding: 32rpx 0 24rpx;
王建威's avatar
王建威 committed
185
			border-radius: 16rpx;
王建威's avatar
王建威 committed
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242
			.hot_goods_icon {
				position: absolute;
				left: 0;
				top: 0;
				width: 80rpx;
				height: 80rpx;
				z-index: 2;
			}
			.hot_goods_img {
				width: 280rpx;
				height: 280rpx;
			}
			.hot_goods_name, .hot_goods_subname {
				width: 280rpx;
				display: block;
				text-align: left;
				font-size: 26rpx;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
				margin: 0 auto;
			}
			.hot_goods_name {			
				color: #212121;
				margin-top: 16rpx;
			}
			.hot_goods_subname {
				color: #6e6e6e;
			}
		}
		.between_price {
			position: relative;
			width: 280rpx;
			height: 44rpx;
			margin: 12rpx auto 0;
			.between_left {
				position: absolute;
				left: 0;
			}
			text {
				display: block;
				text-align: left;
			}
			.hot_pro_price {
				font-size: 32rpx;
				font-family: PingFangSC-Regular,PingFang SC;
				font-weight: 400;
				color: #c3a070;
			}
			.hot_price {
				font-size: 24rpx;
				font-family: PingFangSC-Light,PingFang SC;
				font-weight: 300;
				color: #aeaeae;
				text-decoration: line-through;
			}
			.hot_cart_icon {
王建威's avatar
王建威 committed
243
				font-size: 30rpx;
王建威's avatar
王建威 committed
244 245
				position: absolute;
				right: 0;
王建威's avatar
王建威 committed
246
				top: 6rpx;
王建威's avatar
王建威 committed
247 248 249 250
			}
		}
	}
</style>