<template>
	<view class="container">
		<view class="video-box">
			<video id="myVideo" class="my-video" :src="videoUrl" @error="videoErrorCallback" controls></video>
		</view>
		<view class="popup-open" @click="popupShow = true">
			<view class="iconfont iconzhibo-shangpin"></view>
		</view>
		<u-popup v-model="popupShow" mode="bottom">
			<view class="popup-box">
				<view class="popup-close" @click="popupShow = false">收起</view>
				<view class="popup-edit" @click="editVideo()">编辑</view>
				<scroll-view scroll-y="true" class="good-box">
					<view class="good-card" v-for="(item, index) in goodList" :key="index">
						<image class="goods-img" :src="item.imgPath"></image>
						<view class="good-info">
							<view class="good-name">{{item.productName}}</view>
							<view class="good-text">销量：{{item.sellCount}}</view>
							<view class="good-price">
								<text class="goods-spec">￥{{item.bizPrice}}/{{item.unit}}</text>
								<text class="goods-original">原价:{{item.originalPrice}}</text>
							</view>
						</view>
					</view>
				</scroll-view>
			</view>
		</u-popup>
		<u-top-tips ref="uTips"></u-top-tips>
	</view>
</template>

<script>
	const NET = require('@/utils/request')
	const API = require('@/config/api')
	export default {
		data() {
			return {
				videoId: '',
				videoUrl: '',
				popupShow: false,
				goodList: [],
			}
		},
		onLoad(options) {
			this.videoId = options.videoId
			this.videoUrl = uni.getStorageSync("videoUrl")
		},
		onShow() {
			NET.request(API.getVideoBindGoods, {
				videoId: this.videoId
			}, 'GET').then(res => {
				this.goodList = res.data
			}).catch(res => {
				this.$refs.uTips.show({
					title: '获取商品失败',
					type: 'warning',
				})
			})
		},
		methods: {
			//  编辑短视频
			editVideo() {
				uni.navigateTo({
					url: '/pagesMedia/videoForm?type=edit&videoId=' + this.videoId
				});
			},
			//  短视频报错
			videoErrorCallback(e) {},
		},
	}
</script>

<style lang="less" scoped>
	page {
		width: 100%;
		height: 100%;
	}

	.container {
		width: 100%;
		height: 100%;
		float: left;
		position: relative;

		.video-box {
			width: 100%;
			height: 100%;
			float: left;
			position: absolute;

			.my-video {
				width: 100%;
				height: 100%;
				position: absolute;
			}
		}

		.popup-open {
			width: 50px;
			height: 50px;
			position: fixed;
			bottom: 15px;
			right: 15px;
			background: #52A63A;
			border-radius: 50%;
			text-align: center;
			line-height: 50px;
			z-index: 10000;

			.iconzhibo-shangpin {
				color: #FFFFFF;
				font-size: 34px;
			}
		}

		.popup-box {
			width: 100%;
			height: 400px;
			float: left;
			background-color: #FFFFFF;
			border-radius: 15px 15px 0px 0px;
			box-sizing: border-box;
			padding: 16px 0 0 0;
			position: relative;

			.popup-close {
				width: 50%;
				height: 26px;
				float: left;
				box-sizing: border-box;
				padding: 10px 15px 0 15px;
				font-size: 15px;
				font-family: PingFang SC;
				color: #52A63A;
				line-height: 16px;
				margin-bottom: 10px;
			}

			.popup-edit {
				width: 50%;
				height: 26px;
				float: right;
				box-sizing: border-box;
				padding: 10px 15px 0 15px;
				font-size: 15px;
				font-family: PingFang SC;
				color: #52A63A;
				line-height: 16px;
				margin-bottom: 10px;
				text-align: right;
			}

			.good-box {
				width: 100%;
				height: calc(100% - 36px);
				box-sizing: border-box;
				padding: 0 0 10px 0;
				overflow: auto;
				position: relative;

				.good-card {
					width: calc(100% - 30px);
					float: left;
					margin: 5px 15px 10px 15px;
					background: #FFFFFF;
					border-radius: 15px;
					box-shadow: 0px 1px 5px 0px rgba(102, 102, 102, 0.43);
					padding: 12px;
					box-sizing: border-box;

					.goods-img {
						width: 80px;
						height: 80px;
						float: left;
						border-radius: 10px;
						object-fit: cover;
					}

					.good-info {
						width: calc(100% - 86px);
						height: 80px;
						float: right;

						.good-name {
							width: 100%;
							height: 40px;
							float: left;
							font-size: 15px;
							font-family: PingFang SC;
							color: #333333;
							line-height: 20px;
							overflow: hidden;
							text-overflow: ellipsis;
							display: -webkit-box;
							-webkit-line-clamp: 2;
							-webkit-box-orient: vertical;
							word-wrap: break-word;
						}

						.good-price {
							width: 100%;
							height: 20px;
							float: left;
							line-height: 20px;
							font-family: PingFang SC;
							white-space: nowrap;
							margin: 3px 0 3px 0;

							.goods-spec {
								font-size: 15px;
								color: #52A63A;
								margin-right: 6px;
							}

							.goods-original {
								font-size: 12px;
								text-decoration: line-through;
								color: #A67954;
							}
						}
					}
				}
			}
		}
	}
</style>
