<template>
	<view class="shortVideo" :style="{paddingLeft:prConfig+'rpx',paddingRight:prConfig+'rpx',marginTop:mbCongfig+'rpx',background:bgColor}" v-show="!isSortType" v-if="videoList.length">
		<view class="nav acea-row row-between-wrapper">
			<view class="title skeleton-radius">短视频</view>
			<view class="more skeleton-radius" @click="more">更多<text class="iconfont icon-you"></text></view>
		</view>
		<view class="list on" v-if="itemStyle">
			<scroll-view scroll-x="true" class="scroll" show-scrollbar="false">
				<view class="item skeleton-radius" v-for="(item,index) in videoList" :key="index" @click="more">
					<view class="pictrue">
						<image :src="item.image"></image>
						<view class="like">
							<text class="iconfont icon-shipindianzan-weidian1"></text>{{item.like_num}}
						</view>
					</view>
				</view>
			</scroll-view>
		</view>
		<view class="list" v-else>
			<view class="item acea-row row-between" v-for="(item,index) in videoList" :key="index">
				<view class="pictrue skeleton-radius" @click="more">
					<image :src="item.image"></image>
					<view class="like">
						<text class="iconfont icon-shipindianzan-weidian1"></text>{{item.like_num}}
					</view>
				</view>
				<view class="text">
					<view class="conter">
						<view class="header acea-row row-middle skeleton-radius">
							<image :src="item.type_image"></image>
							<view class="name line1">{{item.type_name}}</view>
						</view>
						<view class="info line2 skeleton-radius">{{item.desc}}</view>
					</view>
					<view class="goodsList acea-row row-middle">
						<view class="pictrue skeleton-radius" v-for="(j,jindex) in item.product_info" :key="jindex" v-if="jindex<3">
							<image :src="j.image"></image>
							<view class="money" v-if="jindex<2">¥{{j.price}}</view>
							<view class="num" v-else>+{{item.product_num-2}}</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		diyVideoList
	} from '@/api/short-video.js';
	export default {
		name: 'shortVideo',
		props: {
			dataConfig: {
				type: Object,
				default: () => {}
			},
			isSortType: {
				type: String | Number,
				default: 0
			}
		},
		data() {
			return {
				videoList: [],
				bgColor: this.dataConfig.bgColor.color[0].item,
				mbCongfig: this.dataConfig.mbCongfig.val*2,
				prConfig: this.dataConfig.prConfig.val*2, //背景边距
				itemStyle: this.dataConfig.itemStyle.type,
				numConfig: this.dataConfig.numConfig.val
			}
		},
		created() {},
		mounted() {
			this.getVideoList();
		},
		methods: {
			getVideoList: function() {
				let that = this;
				let limit = this.$config.LIMIT;
				diyVideoList({
					page: 1,
					limit: this.numConfig >= limit ? limit : this.numConfig
				}).then(res => {
					that.videoList = res.data;
				});
			},
			more(){
				uni.navigateTo({
					//#ifdef APP
					url: '/pages/short_video/appSwiper/index',
					//#endif
					//#ifndef APP
					url: '/pages/short_video/nvueSwiper/index',
					//#endif
				})
			}
		}
	}
</script>

<style lang="scss">
	.shortVideo {
		.scroll {
		  white-space: nowrap; 
		  display: flex;
		}
		.nav {
			width: 100%;
			height: 90rpx;

			.title {
				font-weight: 600;
				color: #333333;
				font-size: 30rpx;
			}

			.more {
				font-weight: 400;
				color: #999999;
				font-size: 24rpx;

				.iconfont {
					font-size: 24rpx;
				}
			}
		}

		.list {
			padding-bottom: 1rpx;
			&.on {
				flex-wrap: nowrap;
				overflow: hidden;
				padding-bottom: 20rpx;

				.item {
					margin-right: 24rpx;
					margin-bottom: 0;
					display: inline-block;
					&:last-of-type{
						margin-right: 0;
					}

					.pictrue {
						margin-right: 0;
					}
				}
			}

			.item {
				margin-bottom: 40rpx;

				.pictrue {
					width: 226rpx;
					height: 300rpx;
					border-radius: 8rpx;
					position: relative;
					margin-right: 30rpx;

					image {
						width: 100%;
						height: 100%;
						border-radius: 8rpx;
					}

					.like {
						position: absolute;
						bottom: 8rpx;
						left: 14rpx;
						font-size: 20rpx;
						font-weight: 400;
						color: #FFFFFF;

						.iconfont {
							font-size: 24rpx;
							margin-right: 6rpx;
						}
					}
				}

				.text {
					flex: 1;

					.goodsList {
						margin-top: 34rpx;
						overflow: hidden;

						.pictrue {
							width: 128rpx;
							height: 128rpx;
							border-radius: 6rpx;
							position: relative;
							margin-right: 24rpx;

							&:nth-of-type(3n) {
								margin-right: 0;
							}

							image {
								width: 100%;
								height: 100%;
								display: block;
								border-radius: 6rpx;
							}
							
							.num{
								position: absolute;
								top:50%;
								left:50%;
								margin-left: -22rpx;
								margin-top: -22rpx;
								color: #fff;
								font-size: 30rpx;
								font-weight: 400;
							}

							.money {
								position: absolute;
								color: #fff;
								font-size: 22rpx;
								bottom: 8rpx;
								left: 50%;
								margin-left: -40rpx;
							}
						}
					}

					.conter {
						height: 134rpx;

						.header {
							.name {
								flex: 1;
								width: 300rpx;
							}

							image {
								width: 36rpx;
								height: 36rpx;
								border: 1px solid #FFFFFF;
								display: block;
								margin-right: 10rpx;
								border-radius: 50%;
							}

							font-weight: 500;
							color: #333333;
							font-size: 28rpx;
						}

						.info {
							font-weight: 400;
							color: #666666;
							font-size: 24rpx;
							margin-top: 20rpx;
						}
					}
				}
			}
		}
	}
</style>
