<template>
	<view>
		<view class="u-skeleton">
			<view class="product-picture u-skeleton-rect">
				<swiper class="service-show-swiper" :indicator-dots="true" v-if="showFlag === 0">
					<swiper-item v-for="(img,index) in detail.confinement_picture_video" :key="index">
						<video :src="img.picture" style="width: 100%;height: 100%;" play-btn-position="center"></video>
					</swiper-item>
				</swiper>

				<swiper class="product-picture-swiper" :indicator-dots="true"
					@change="e => swiperIndex = e.detail.current + 1" v-if="showFlag === 1">
					<swiper-item v-for="(img,index) in detail.confinement_picture" :key="index">
						<u-image height="100%" width="100%" :src="img.picture" mode="aspectFit">
						</u-image>
					</swiper-item>
				</swiper>


				<view class="service-show-btn">
					<view class="service-show-btn-img" @click="showFlag = 1">
						<image src="../../static/pic.png">
						</image>
						<view class="service-show-btn-img__num">{{detail.confinement_picture.length}}</view>
					</view>
					<view class="service-show-btn-video" v-if="detail.confinement_picture_video.length>0"
						@click="showFlag = 0">
						<image src="../../static/video.png">
						</image>
						<view class="service-show-btn-img__num">{{detail.confinement_picture_video.length}}</view>
					</view>
				</view>
			</view>

			<view class="product-price u-skeleton-rect">
				￥ <span style="font-size: 34rpx;">{{detail.price}}</span>
			</view>


			<view class="product-info">
				<view class="product-info-name u-skeleton-rect">
					{{detail.name}}
				</view>

				<view class="product-info-label ">
					<view class="product-info-label-item"
						v-for="(item,index) in featuredLabelSplit(detail.featured_label)" :key="index">
						{{item}}
					</view>
				</view>

				<view class="product-info-shop u-skeleton-fillet">
					<view class="product-info-shop-top">
						<view class="product-info-shop-top-img">
							<u-image :src="detail.service.cover_picture" width="100" height="100" border-radius="100%">
							</u-image>
						</view>
						<view class="product-info-shop-top-name">
							<view>{{detail.service.name}}</view>
							<view>{{detail.service.subheading}}</view>
						</view>
						<view class="product-info-shop-top-more" @click="toService(detail.service.id)">
							<text>更多</text>
							<u-icon name="arrow-right" size="25" color="#A0A0A0"></u-icon>
						</view>
					</view>

					<view class="product-info-shop-bottom">
						<view class="product-info-shop-bottom-icon">
							<u-image mode="asseptFit" src="/packages/packageCarecenter/static/position.png" height="26"
								width="22">
							</u-image>
						</view>
						<view class="product-info-shop-bottom-text">
							{{detail.service.address}}
						</view>
						<view class="product-info-shop-bottom-arrow" @click="toMap">
							<u-icon name="arrow-right" size="25" color="#A0A0A0"></u-icon>
						</view>
					</view>
				</view>
			</view>

			<view class="service-baseinfo-center-store u-skeleton-fillet">

				<video :src="detail.video" v-if="detail.video" style="width: 100%;" play-btn-position="center"></video>
				<u-image :src="detail.cover_picture" v-else mode="aspectFill" height="397" width="100%"
					border-radius="30" @load="$u.debounce(init,100)">
				</u-image>

				<view class="service-baseinfo-center-store-tag">
					<image src="/packages/packageCarecenter/static/huangguan.png"></image>
					<view class="service-baseinfo-center-store-tag-text">
						孕育邦探店
					</view>
				</view>
			</view>
			<view class="combo u-skeleton-rect">
				<view class="combo-title">
					套餐介绍
				</view>
				<view class="combo-content">
					<view class="combo-content-item" v-for="(item,index) in detail.set" :key="index">
						<view class="combo-content-item-name">{{item.content}}</view>
						<view class="combo-content-item-content">{{item.name}}</view>
					</view>
				</view>
			</view>

			<view class="facility u-skeleton-rect">
				<view class="facility-title">
					设备详情
				</view>
				<view class="facility-content">
					<view class="facility-content-item" v-for="(item,index) in detail.facility" :key="index">
						<view class="facility-content-item-icon iconfont" :class="'icon-'+item.remark"></view>
						<view class="facility-content-item-name">{{item.value}}</view>
					</view>
				</view>
			</view>

			<view style="width: 100%;background: #fff;padding: 20rpx 28rpx;">
				<u-parse :html="detail.content"></u-parse>
			</view>
		</view>

		<u-skeleton :loading="loading" :animation="true" bgColor="#FFF"></u-skeleton>
	</view>
</template>

<script>
	import {
		weixin
	} from '@/utils/weixin.js'
	export default {
		data() {
			return {
				showFlag: 1,
				loading: true,
				swiperIndex: 1,
				detail: {},
			}
		},
		methods: {
			toMap() {
				this.$u.throttle(() => {
					uni.openLocation({
						latitude: Number(this.detail.service.latitude),
						longitude: Number(this.detail.service.longitude),
						name: this.detail.name
					})
				})
			},
			toService(id) {
				this.$u.throttle(() => {
					uni.navigateTo({
						url: `/packages/packageCarecenter/pages/careCenter/serviceDetail?id=${id}`
					})
				})
			},
			featuredLabelSplit(res) {
				if (res) {
					return res.split(",")
				}
				return []
			},
			getProductDetail(id) {
				weixin.request({
					newUrl: true,
					api: '/api/member/get-confinement-product-item',
					data: {
						id
					},
					utilSuccess: (res) => {
						let confinement_picture_video = [];
						let confinement_picture = [];
						res.confinement_picture.map(item => {
							if (item.picture.indexOf("mp4") > -1) {
								confinement_picture_video.push(item)
							} else {
								confinement_picture.push(item)
							}
						})

						this.detail = res;
						this.detail.confinement_picture_video = confinement_picture_video;
						this.detail.confinement_picture = confinement_picture;
						this.loading = false
						console.log(res);
					}
				})
			}
		},
		computed: {

		},
		onLoad(option) {
			this.getProductDetail(option.id)
		}
	}
</script>

<style scoped lang="scss">
	.service-show {
		width: 100%;
		height: 360rpx;

		position: relative;

		&>video {
			width: 100%;
			height: 100%;
		}

		&-swiper {
			width: 100%;
			height: 100%;
		}

		&-btn {
			display: flex;

			z-index: 3;
			position: absolute;
			bottom: 30rpx;
			right: 33rpx;

			&-img {
				color: #fff;
				height: 47rpx;
				background: #252526;
				border-radius: 16rpx;
				opacity: 0.3;
				display: flex;
				align-items: center;

				margin-right: 14rpx;

				&>image {
					width: 24rpx;
					height: 21rpx;

					padding-left: 20rpx;
					padding-right: 10rpx;
				}

				&__num {
					font-size: 24rpx;
					color: #FFFFF0;
					font-weight: 400;

					padding-right: 20rpx;
				}
			}

			&-video {
				color: #fff;
				height: 47rpx;
				background: #252526;
				border-radius: 16rpx;
				opacity: 0.3;
				display: flex;
				align-items: center;

				&>image {
					width: 24rpx;
					height: 21rpx;

					padding-left: 20rpx;
					padding-right: 10rpx;
				}

				&__num {
					font-size: 24rpx;
					color: #FFFFF0;
					font-weight: 400;

					padding-right: 20rpx;
				}
			}
		}
	}

	.product-picture {
		height: 417rpx;
		width: 100%;

		position: relative;

		&-swiper {
			width: 100%;
			height: 100%;
		}

		&-num {
			color: #fff;
			background: #252526;
			border-radius: 16rpx;
			opacity: 0.3;

			padding: 7rpx 20rpx;
			position: absolute;
			bottom: 20rpx;
			right: 27rpx;
		}
	}

	.product-price {
		font-weight: 400;
		color: #FF578A;
		font-size: 24rpx;
		background-color: #FFEFF4;

		padding: 55rpx 21rpx;
	}

	.product-info {
		background: #fff;

		padding-bottom: 41rpx;

		&-name {
			font-weight: 400;
			color: #333333;
			font-size: 34rpx;

			padding: 46rpx 34rpx 0 34rpx;
		}

		&-label {
			display: flex;
			flex-wrap: wrap;

			margin-top: 21rpx;
			padding: 0 32rpx;

			&-item {
				background: rgba(255, 87, 138, 0.1);
				border-radius: 12rpx;
				font-weight: 400;
				color: #FF578A;
				font-size: 24rpx;

				padding: 10rpx 15rpx;
				margin-right: 15rpx;
			}
		}

		&-shop {
			background: linear-gradient(180deg, #555455 0%, #1F1D1D 100%);
			border-radius: 40rpx;

			margin: 35rpx 30rpx 0 30rpx;
			padding: 0 30rpx 0 36rpx;

			&-top {
				display: flex;
				align-items: center;

				padding-top: 23rpx;

				&-img {}

				&-name {
					color: #fff;
					flex: 1;

					margin-left: 20rpx;

					&>view:nth-child(1) {
						font-weight: 400;
						color: #FFFFFF;
						font-size: 30rpx;
					}

					&>view:nth-child(2) {
						display: inline-block;
						text-align: center;
						border-radius: 12rpx;
						font-size: 24rpx;
						font-weight: 400;
						color: #FFFFFF;
						background-color: #FF578A;

						padding: 4rpx 11rpx;
						margin-top: 10rpx;
					}
				}

				&-more {
					font-size: 24rpx;
					color: #A0A0A0;
					font-weight: 400;
					align-self: flex-start;

					padding-right: 26rpx;
					padding-top: 6rpx;
				}
			}

			&-bottom {
				display: flex;
				align-items: flex-start;

				padding-right: 26rpx;
				padding-left: 8rpx;
				padding-bottom: 42rpx;
				margin-top: 37rpx;

				&-text {
					flex: 1;
					font-weight: 400;
					color: #FFFFFF;
					font-size: 24rpx;

					padding: 0 23rpx 0 10rpx;
				}
			}
		}
	}

	.combo {

		background-color: #fff;

		margin-top: 34rpx;
		padding: 0 28rpx;

		&-title {
			font-size: 34rpx;
			font-weight: 400;
			color: #333333;

			padding-top: 51rpx;
			padding-left: 6rpx;
			padding-bottom: 55rpx;
		}

		&-content {
			display: flex;
			flex-wrap: wrap;

			&>view:nth-last-child(1) {
				margin-right: 0;
			}

			&-item {
				text-align: center;
				border: 1px solid #191B1A;
				border-radius: 24rpx;
				flex: 0;
				height: 135rpx;

				margin-right: 14rpx;
				margin-bottom: 12rpx;

				&-name {
					font-size: 30rpx;
					font-weight: 400;
					color: #333333;
					white-space: nowrap;
					word-wrap: keep-all;

					padding: 27rpx 24rpx 18rpx 24rpx;
				}

				&-content {
					background-color: #191B1A;
					color: #fff;
					border-radius: 0 0 24rpx 24rpx;
					white-space: nowrap;
					word-wrap: keep-all;

					padding: 8rpx 24rpx;
				}
			}
		}

	}




	.service-baseinfo {
		width: 100%;
		background: linear-gradient(90deg, #555455 0%, #1F1D1D 100%);

		padding-bottom: 38rpx;

		&-center {

			margin-top: 28rpx;





			&-store {

				position: relative;
				margin-top: 30rpx;
				padding: 0 33rpx;

				&-tag {
					display: flex;
					align-items: center;
					background: linear-gradient(90deg, #FFFFFF 0%, #FFF0F0 100%);
					border-bottom-left-radius: 20rpx;
					border-bottom-right-radius: 20rpx;

					padding: 9rpx 18rpx;
					position: absolute;
					top: 0;
					left: 76rpx;

					&>image {
						width: 25rpx;
						height: 25rpx;
					}

					&-text {
						font-size: 24rpx;
						font-weight: 400;
						color: #FF578A;

						padding-left: 11rpx;
					}
				}
			}
		}
	}

	.facility {
		background-color: #fff;

		&-title {
			padding: 73rpx 0 44rpx 34rpx;
			font-weight: 400;
			color: #333333;
			font-size: 34rpx;
		}

		&-content {
			display: flex;
			flex-wrap: wrap;

			padding: 44rpx 64rpx 66rpx 64rpx;

			&-item {
				flex-basis: 25%;
				font-size: 24rpx;
				font-weight: 400;
				color: #333333;
				text-align: center;

				margin-bottom: 24rpx;

				&-icon {
					width: 55rpx;
					height: 55rpx;
					font-size: 55rpx;

					margin: auto;
				}

				&-name {

					padding-top: 13rpx;
				}
			}
		}

	}

	::v-deep .u-image__image {
		display: block !important;
	}
</style>
