<template>
	<view class="item-box">
		<view class="item-titBox">
			<text class="item-tit">学车必备</text>
			<!-- <text class="item-tit-right" @click="$utils.route.goPage('/pages/carVideo/index')">更多类型 ></text> -->
		</view>
		<loadSke :loading='pddLoading' :list='pddList'>
			<view class="flex-box">
				<view class="film-box" v-for="(item,index) in pddList" :key='index'
					@click="pddGoApp({appId:item.we_app_info.app_id,path:item.we_app_info.page_path})">
					<image :src="item.goods_image_url" mode="widthFix" 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>
						<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 v-if="pddDataLoading" class="bottom-loading">
					<loading />
				</view>
			</view>
		</loadSke>
	</view>
</template>

<script>
	export default {
		name:"m-home-pdd",
		data:()=>({
			pddList: [],
			pddLoading: true,
			limit: 6,
			page: 0,
			pddDataLoading: false,
		}),
		mounted() {
			this.init()
		},
		methods: {
			pddGoApp(data) {
				this.$utils.goMiniApp(JSON.stringify(data))
			},
			onBottom() {
				if (this.pddDataLoading) return
				this.pddDataLoading = true
				this.page++
				this.$api.home.getPddWxData({
					limit: this.limit,
					offset: this.page * this.limit
				}).then(res => {
					this.pddList = this.pddList.concat(res)
					this.$nextTick(() => {
						this.pddLoading = false
						this.pddDataLoading = false
					})
				})
			},
			init() {
				this.$api.home.getPddWxData({
					limit: this.limit,
					offset: this.page * this.limit
				}).then(res => {
					this.pddList = res
					this.$nextTick(() => {
						this.pddLoading = false
					})
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.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 {
			width: 100%;
			display: flex;
			justify-content: center;
			align-items: flex-start;
			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%;
				}

				.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;
						}
					}

				}

			}

		}

		.bottom-loading {
			margin-top: 5rpx;
			padding: 10rpx;
		}
	}
</style>
