<template>
	<view class="home">
		<view class="top-list">
			<loadSke :loading='topLoading' :list='bannerList'>
				<swiper class="swiper-box" :current="current" autoplay circular indicator-dots>
					<swiper-item v-for="(item,index) in bannerList" :key='index'>
						<image @click="clickJumpType(item)" class="image" :src="item.fileUrl" mode="aspectFill" :draggable="false" />
					</swiper-item>
				</swiper>

				<view class="eat-box">
					<view class="eat" v-for="(item,index) in couponList" :key='index' @click="clickJumpType(item)">
						<image :src="item.fileUrl" mode="scaleToFill" class="img"></image>
						<view class="text-box">
							<text class="text-1">{{item.pictureName}}</text>
							<text class="text-2">{{item.dataDescribe.toString()}}</text>
						</view>
					</view>
				</view>

				<view class="menu-box">
					<view class="menu" v-for="(item,index) in menuList" :key='index' @click="clickJumpType(item)">
						<image :src="item.fileUrl" mode="scaleToFill" class="img"></image>
						<text class="text-1">{{item.pictureName}}</text>
						<text class="text-2">{{item.dataDescribe || '暂无描述'}}</text>
					</view>
				</view>
			</loadSke>
		</view>

		<view class="item-box">
			<view class="item-titBox">
				<text class="item-tit">限时特价</text>
				<!-- <text class="item-tit-right" @tap='go()'>更多视频 ></text> -->
			</view>
			<loadSke :loading='pddLoading' :list='pddList'>
				<view class="flex-box">
					<view class="film-box" v-for="(item,index) in pddList" :key='index' @click="goMiniApp(JSON.stringify({appId:item.we_app_info.app_id,path:item.we_app_info.page_path}))">
						<image :src="item.goods_image_url" mode="scaleToFill" class="img" draggable></image>
						<view class="bottom-box">
							<view class="tit">
								<text class="text-1">{{item.goods_name}}</text>
							</view>
							<view class="des-box">
								<view class="des">{{item.unified_tags}}</view>
								<!-- <view class="des">演员:高山南 山崎和佳奈 小山 山崎和佳奈 小山 ...</view> -->
							</view>
							<view class="buy-box">
								<text class="price">{{'¥'+(item.min_group_price)/100}}</text>
								<button type="default" class="buy">活动价 {{'¥'+(item.min_group_price-item.coupon_discount)/100}}</button>
							</view>

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

				<!-- <view class="ad-video">
					<ad unit-id="adunit-173f2958099a2b25" ad-type="video" ad-theme="white"></ad>
				</view> -->
			</loadSke>

		</view>


	</view>



</template>

<script>
	import {
		getHomePageDataList,
		getPDD,
		getPddWxData
	} from '@/api/home.js'
	export default {
		data: () => ({
			bannerList: [],
			couponList: [],
			menuList: [],
			topLoading: true,
			pddList: [],
			pddLoading: true
		}),
		mounted() {
			this.init()
		},
		methods: {
			init() {
				getHomePageDataList().then(res => {
					this.bannerList = res.data.carouselChart
					this.couponList = res.data.coupon.slice(0, 4)
					this.menuList = res.data.menu
					this.$nextTick(() => {
						this.topLoading = false
					})
				})
				getPddWxData().then(res => {
					this.pddList = res
					this.$nextTick(() => {
						this.pddLoading = false
					})
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.top-list {
		padding: 30rpx;
		box-sizing: border-box;
		width: 100%;
		background-color: #FFFFFF;

		.swiper-box {
			width: 690rpx;
			height: 342rpx;
			overflow: hidden;

			.image {
				width: 100%;
				height: 100%;
				border-radius: 10px;
			}
		}

		.eat-box {
			margin-top: 40rpx;
			display: flex;
			justify-content: space-between;

			.eat {
				width: 144rpx;
				height: 190rpx;
				position: relative;

				.img {
					width: 100%;
					height: 100%;
				}

				.text-box {
					display: flex;
					flex-direction: column;
					justify-content: center;
					align-items: center;
					position: absolute;
					bottom: 10rpx;
					left: 50%;
					width: 100%;
					transform: translateX(-50%);

					.text-1 {
						font-size: 24rpx;
						color: #FFFFFF;
						text-align: center;
					}

					.text-2 {
						font-size: 20rpx;
						color: #FFFFFF;
						text-align: center;
					}
				}

			}
		}

		.menu-box {
			display: flex;
			justify-content: flex-start;
			flex-wrap: wrap;
			margin: 0 -10rpx;

			.menu {
				width: 20%;
				padding: 0 10rpx;
				box-sizing: border-box;
				// height: 121rpx;
				margin-top: 40rpx;
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				align-items: center;

				.img {
					flex-shrink: 0;
					width: 64rpx;
					height: 64rpx;
					border-radius: 50%;
				}

				.text-1 {
					margin-top: 10rpx;
					font-size: 24rpx;
					color: #0F0404;
					text-align: center;
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
				}

				.text-2 {
					font-size: 20rpx;
					color: #666666;
					text-align: center;
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
				}
			}
		}
	}

	.item-box {
		background-color: #fff;
		margin-top: 40rpx;

		.item-titBox {
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 20rpx;
			border-bottom: 1rpx solid #e8e8e8;

			.item-tit {
				border-left: 8rpx solid #E31818;
				font-size: 30rpx;
				padding: 11rpx;
				margin-left: 20rpx;
			}

			.item-tit-right {
				font-size: 26rpx;
				color: #666666;
				line-height: 58rpx;
				padding: 11rpx;
			}
		}

		.flex-box {
			display: flex;
			justify-content: center;
			flex-wrap: wrap;
			background-color: #F8F8F8;
			padding-bottom: 20rpx;

			.film-box {
				width: 334rpx;
				border-radius: 20rpx;
				overflow: hidden;
				background: #FFFFFF;
				margin: 30rpx 11rpx 0;

				.img {
					width: 100%;
					height: 334rpx;
				}

				.bottom-box {
					padding: 30rpx 20rpx;

					.tit {
						display: flex;
						justify-content: space-between;

						.text-1 {
							width: 100%;
							font-size: 26rpx;
							overflow: hidden;
							text-overflow: ellipsis;
							white-space: nowrap;
						}
					}

					.des-box {
						margin-top: 10rpx;

						.des {
							width: 100%;
							font-size: 22rpx;
							color: #666666;
							overflow: hidden;
							text-overflow: ellipsis;
							white-space: nowrap;
						}
					}

					.buy-box {
						margin-top: 20rpx;
						display: flex;
						justify-content: flex-start;
						align-items: center;

						.price {
							// color: #E31818;
							text-decoration: line-through;
							font-size: 34rpx;
						}

						.buy {
							height: 40rpx;
							background: linear-gradient(90deg, #E31818, #ED3E24, #ED4F24);
							border-radius: 20rpx;
							margin-left: 10rpx;
							font-size: 20rpx;
							color: #FFFFFF;
							display: flex;
							justify-content: center;
							align-items: center;
							white-space: nowrap;
						}
					}

				}

			}

		}


	}

	.ad-video {
		margin-top: 40rpx;
	}
</style>
