<template>
	<view class="">
		<view class="goldenBean">
			<view class="title">
				<image src="@/static/img/list1.png"></image>
				<view class="title-t"> {{list}} </view>
				<text class="about">超值体验</text>
				<view class="">
					{{id}}
				</view>
			</view>
			<view class="box">
				<view class="header" :style="indexLoad%2!=1?bgColor[0]:bgColor[1]"  >
					<view class="left">
						<view class="title">
							热门好物推荐
						</view>
						<view class="about">
							买到就是赚到
						</view>
					</view>
					<view class="right">
						<image src="@/static/img/right.png" @click="navto('/pages/product/fenlei?id='+id)"></image>
					</view>
				</view>
				<view class="footer">
					<view class="list">
						<view class="item" v-for="d in jdList"
							@click="navto('/pages/product/product?id=' + d.id + '&is_gold=' + 1)">
							<view class="img">
								<image :src="d.image" mode=""></image>
							</view>
							<view class="name nowarp" :title='d.store_name'>
								{{ d.store_name }}
							</view>
							<view class="price">
								￥{{ d.price }}
							</view>
							<view class="name" style="font-size: 22rpx;color: #999;">
								已售 {{ d.sales || '0'}}
							</view>
						</view>
					</view>
				</view>
			</view>

		</view>
	</view>
</template>

<script>
	import {
		goodsDetail,getProducts
	} from '@/api/product.js'
	export default {
		props: ['data', 'leibie', 'index'],
		mounted() {
			// console.log(this.data);
			console.log(this.leibie, this.index, 'ssss');
			this.list = this.leibie.cate_name
			this.id = this.leibie.id
			console.log(this.id,'eiddidi');
			this.indexLoad = this.index

			// this.leibie.forEach(
			// 	item => {
			// 		this.list = item.cate_name
			// 		console.log(this.list, 'weqeq')
			// 	});
			// for(let arr of this.leibie){arr=>{
			// 	console.log(arr,'2222');
			// }}
		},
		data() {
			return {
				list: '',
				id: '',
				indexLoad: '',
				jdList:[],
				bgColor: [{background: "linear-gradient(43deg, #FFBD70, #FF8F44)"},
					{background: "linear-gradient(90deg, #F75022, #FF8B6C)"},
				]
			}
		},
		onLoad() {
			this.getBargainList()
		},
		// onShow() {
		// 	this.goodsDetail()
		// },
		methods: {
			getBargainList() {
				let that = this;
				getProducts({
						page: that.page,
						limit: that.limit,
						sid:that.id
					})
					.then(function(res) {
						that.jdList = res.data
						console.log(that.jdList,'jdlist');
					})
					.catch(res => {});
			},
			navto(url) {
				uni.navigateTo({
					url: url
				});
			},
			// 获取商品信息
			goodsDetail() {
				let obj = this;
				goodsDetail({}, this.id).then(function({
					data
				}) {
					console.log(data, 'data');
				});
			},
		}
	}
</script>

<style lang="scss" scoped>
	$grey: #95A0B1;
	$text: #333333;
	$red: #FF4C4C;

	// 金豆专区
	.goldenBean {
		font-family: PingFang-SC-Bold;
		margin-top: 20rpx;
		padding: 20rpx;
		background-color: #fff;

		.title {
			display: flex;
			line-height: 40rpx;

			.title-t {
				color: $text;
				font-weight: bold;
				margin: 0 20rpx;
				font-size: 34rpx;
			}

			.about {
				font-size: 24rpx;
				color: $grey;
			}

			image {
				width: 40rpx;
				height: 40rpx;
			}
		}

		.box {
			margin: 20rpx 0;
			border-radius: 10rpx;
			overflow: hidden;

			.header {
				padding: 20rpx;

				padding-bottom: 80rpx;
				width: 100%;
				display: flex;
				justify-content: space-between;
				color: #fff;

				.left {
					line-height: 40rpx;

					.title {
						font-size: 32rpx;
					}

					.about {
						opacity: 0.9;
						font-size: 24rpx;
					}
				}

				.right {
					margin: auto 0;

					image {
						width: 30rpx;
						height: 30rpx;
					}
				}
			}

			.footer {
				height: 300rpx;
				background-color: $page-color-base;
				padding: 20rpx;
				margin-bottom: -50rpx;

				.list {

					display: flex;
					justify-content: space-between;
					overflow: auto;
					border-radius: 10rpx;
					position: relative;
					top: -90rpx;
					background-color: #fff;

					.item {
						padding: 35rpx;
						border-right: solid 1rpx $page-color-base;

						.name {

							font-size: 24rpx;
							color: #3F3F3F;
							width: 150rpx;
							overflow: hidden;
							display: -webkit-box;
							-webkit-box-orient: vertical;
							-webkit-line-clamp: 1;
							border-radius: 10rpx;
							text-overflow: ellipsis;
						}

						.price {
							font-size: 28rpx;
							color: $red;
							font-weight: bold;
						}

						.img {
							overflow: hidden;
							border-radius: 20rpx;

							image {
								width: 150rpx;
								height: 150rpx;
							}
						}
					}
				}
			}
		}
	}
</style>
