<template>
	<view class="setMealDetail">
		<image :src="baseImagePath + setMeal.imgUrl" alt="">
			<view class="header-card">
				<view class="header">
					{{setMeal.name}}
				</view>
				<view class="content">
					{{setMeal.title}}
				</view>
				<view class="bottom" v-if="setMeal.invalidDay">
					<view class="left">
						{{setMeal.invalidDay}}前有效
					</view>
					<view class="right" v-if="setMeal.status">
						生效中
					</view>
					<view class="right" v-else>
						已失效
					</view>
				</view>
				<view class="bottom" v-else>
					<view class="left">
						购买后{{setMeal.invalidTime}}天内有效
					</view>
					<view class="right" v-if="setMeal.status">
						生效中
					</view>
					<view class="right" v-else>
						已失效
					</view>
				</view>
			</view>
			<!-- 套餐项目 -->
			<view class="servicesAvailable">
				<view class="header">
					<view class="title">
						套餐项目
					</view>
					<view class="border"></view>
				</view>
				<view class="body" v-for="(item, index) in servicesAvailableList" :key="index">
					<view class="title">
						{{item.sstName}}
					</view>
					<view class="border">

					</view>
					<view class="length">
						×{{item.buyNum}}
					</view>
					<view class="lengths">
						余 <span>{{item.surplusSum}}</span>
					</view>
				</view>
			</view>
			<!-- 可用门店 -->
			<view class="shop">
				<view class="header">
					<view class="title">
						可用门店
					</view>
					<view class="border"></view>
				</view>
				<view class="flexView">
					<view class="body" v-for="(item, index) in shopList" :key="index">
						<image :src="baseImagePath + item.logoUrl" alt="">
							<view class="subbody">
								<view class="title">
									{{item.name}}
								</view>
								<view class="content">
									<view class="location">
										{{item.address}}
									</view>
									<view class="right">
										<image :src="require('../../../static/address.png')" alt="" style="margin-right: 10rpx;">
										<view class="km">
											{{item.distance}}km
										</view>
									</view>
								</view>
							</view>
					</view>
				</view>
			</view>
			<!-- 套餐详情 -->
			<view class="detail">
				<view class="header">
					<view class="title">
						套餐详情
					</view>
					<view class="border"></view>
				</view>
				<view class="content" v-html="setMeal.introduce">
					
				</view>
			</view>
			<view style="height: 200rpx;">

			</view>
			<!-- 底部按钮 -->
			<view class="bottomBtn" v-if="type !== 'my'">
				<view class="leftView">
					<view class="chooseNum">
						<view style="font-size: 26rpx;">
							￥
						</view>
						<view style="font-size: 56rpx;">
							{{setMeal.carPrice}}-{{setMeal.truckPrice}}
						</view>
					</view>
				</view>
				<view class="rightView" @click="routerTo()">
					立即购买
				</view>
			</view>
	</view>
</template>

<script>
	import {
		userPackageDefail
	} from '../../../api/myApi.js'
	const app = getApp()
	export default {
		components: {},
		data() {
			return {
				longitude: app.globalData.longitude,
				latitude: app.globalData.latitude,
				baseImagePath:this.baseImagePath,
				packageId:null,
				setMeal: {},
				shopList: [],
				servicesAvailableList: [],
				type:''
			};
		},
		onLoad(options) {
			this.packageId = options.id
			this.type = options.type
			this.getInfo()
		},
		methods: {
			routerTo(item) {
				this.$yrouter.push({
					path: "/pages/maintenance/setMeal/buySetMeal/index?item=" + JSON.stringify(this.setMeal)
				});
			},
			getInfo(){
				let data = {
					longitude: this.longitude,
					latitude: this.latitude,
					id:this.packageId
				}
				userPackageDefail(data).then(res=>{
					this.setMeal = res.data.packagesVO
					console.log(this.setMeal);
					this.servicesAvailableList = res.data.userPackageSerVOS
					console.log(this.servicesAvailableList);
					this.shopList = res.data.shopVOList
				})
			}
		}
	}
</script>

<style lang="less">
	page {
		background: #EDEDED;
	}

	.bottomBtn {
		width: 690rpx;
		height: 110rpx;
		background: #FFFFFF;
		border: 1px solid #EEEEEE;
		box-shadow: 0px 8rpx 17rpx 0px rgba(168, 165, 165, 0.26);
		border-radius: 55rpx;
		margin-left: 30rpx;
		position: fixed;
		bottom: 67rpx;
		z-index: 9998;

		.leftView {
			float: left;
			height: 100%;
			display: flex;
			align-items: center;
			margin-left: 57rpx;

			.chooseNum {
				font-size: 30rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #FF3C00;
				line-height: 31rpx;
				display: flex;
				align-items: baseline;
			}
		}

		.rightView {
			float: right;
			width: 210rpx;
			height: 108rpx;
			background: linear-gradient(0deg, #005AFF 0%, #0078FF 100%);
			border-radius: 0 55rpx 55rpx 0;
			font-size: 34rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #FEFEFE;
			line-height: 108rpx;
			text-align: center;
		}
	}

	.detail {
		background: #FFFFFF;
		border-radius: 10px;
		margin-top: 20rpx;
		padding: 36rpx 30rpx;

		.header {
			padding-bottom: 36rpx;

			.title {
				font-size: 28rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #333333;
				line-height: 29rpx;
			}

			.border {
				width: 106rpx;
				height: 6rpx;
				background: linear-gradient(90deg, #005BFF 0%, #FFFFFF 100%);
				opacity: 0.6;
			}
		}

		.content {
			font-size: 26rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #666666;
			line-height: 36rpx;
			padding: 0 30rpx 0 0;
			overflow: hidden;
			display: flex;
		}
	}

	.shop {
		max-height: 514rpx;
		background: #FFFFFF;
		border-radius: 10rpx;
		margin-top: 20rpx;
		padding: 36rpx 30rpx 0;

		.header {
			padding-bottom: 36rpx;

			.title {
				font-size: 28rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #333333;
				line-height: 29rpx;
			}

			.border {
				width: 106rpx;
				height: 6rpx;
				background: linear-gradient(90deg, #005BFF 0%, #FFFFFF 100%);
				opacity: 0.6;
			}
		}

		.flexView {
			max-height: 420rpx;
			overflow-x: auto;
			flex-direction: column;
			display: flex;
			flex-wrap: wrap;

			.body {
				width: 655rpx;
				height: 101rpx;
				background: #FFFFFF;
				border-radius: 10rpx;
				display: flex;
				padding-bottom: 36rpx;

				image {
					width: 100rpx;
					height: 100rpx;
				}

				.subbody {
					width: 76%;
					padding: 11rpx 21rpx 11rpx 21rpx;

					.title {
						font-size: 32rpx;
						font-family: PingFang SC;
						font-weight: bold;
						color: #333333;
						line-height: 31rpx;
					}

					.content {
						padding-top: 21rpx;

						.location {
							width: 350rpx;
							font-size: 24rpx;
							font-family: PingFang SC;
							font-weight: 500;
							color: #999999;
							line-height: 31rpx;
							float: left;
							overflow: hidden;
							text-overflow: ellipsis;
							white-space: nowrap;
						}

						.right {
							display: flex;
							align-items: center;
							image {
								width: 23rpx;
								height: 23rpx;
							}

							.km {
								font-size: 24rpx;
								font-family: PingFang SC;
								font-weight: 500;
								color: #333333;
								line-height: 31rpx;
							}
						}
					}
				}
			}
		}

	}

	.servicesAvailable {
		background: #FFFFFF;
		border-radius: 10rpx;
		margin-top: 20rpx;
		padding: 36rpx 30rpx;

		.header {
			padding-bottom: 36rpx;

			.title {
				font-size: 28rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #333333;
				line-height: 29rpx;
			}

			.border {
				width: 106rpx;
				height: 6rpx;
				background: linear-gradient(90deg, #005BFF 0%, #FFFFFF 100%);
				opacity: 0.6;
			}
		}

		.body {
			display: flex;
			padding: 19rpx;
			justify-content: space-around;
			align-items: center;

			.title {
				font-size: 26rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #666666;
				line-height: 29rpx;
			}

			.border {
				width: 354rpx;
				height: 1rpx;
				border-top: 1px dashed #CCCCCC;
			}

			.length {
				font-size: 26rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #666666;
				line-height: 29rpx;
			}

			.lengths {
				font-size: 24rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #666666;
				line-height: 29rpx;

				span {
					color: #005BFF;
				}
			}
		}
	}

	.setMealDetail {
		image {
			width: 100%;
			height: 750rpx;
		}

		.header-card {
			background: #FFFFFF;
			border-radius: 0px 0px 16rpx 16rpx;
			padding: 40rpx 0 0 29rpx;

			.header {
				font-size: 32rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #333333;
				line-height: 31rpx;
				padding-right: 29rpx;
			}

			.content {
				font-size: 26rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #999999;
				line-height: 36rpx;
				padding-top: 25rpx;
				padding-right: 29rpx;
			}

			.bottom {
				display: flex;
				justify-content: space-between;
				padding-top: 37rpx;
				position: relative;

				.left {
					font-size: 26rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #005BFF;
					line-height: 55rpx;
					padding-bottom: 22rpx;
				}

				.right {
					width: 167rpx;
					height: 62rpx;
					background: linear-gradient(-35deg, #FF6000 0%, #FFA800 100%);
					border-radius: 10rpx 0rpx 10rpx 0rpx;
					font-size: 30rpx;
					font-family: PingFang SC;
					font-weight: bold;
					color: #FFFFFF;
					line-height: 62rpx;
					text-align: center;
					position: absolute;
					right: 0;
					bottom: 0;
				}
			}
		}
	}
</style>
