<template>
	<view class="content">
		<!-- 轮播图 -->
		<top-swiper :imgList="imgList"></top-swiper>
		<!-- 价格 -->
		<view class="good-price flex">
			<view class="new-price">
				¥{{goodItem.price}}
			</view>
			<view class="old-price">
				¥{{goodItem.ot_price}}
			</view>
		</view>
		<!-- 标题 -->
		<view class="good-tit">
			{{goodItem.title}}
		</view>
		<content-text :description="description"></content-text>
		<view class="btn-ts" style="height: 130rpx; background-color: #fff;">

		</view>
		<view class="btm-btn" @click="reservePackage">
			立即预约
		</view>
	</view>
</template>

<script>
	// 头部轮播图
	import topSwiper from './common/topSwiper.vue';
	// 图文详情
	import contentText from './common/contentText.vue';

	import {
		getWholeDetai,
		reservePackage
	} from '@/api/whole.js'
	export default {
		components: {
			topSwiper,
			contentText
		},
		data() {
			return {
				imgList: [],
				goodItem: {},
				good_id: '',
				time_id: '',
				status: 1,
				is_new: 0,//是否是新人 0->是 1->不是
				description: ''
			}
		},
		onLoad(opt) {
			this.good_id = opt.id
			this.time_id = opt.time
			this.status = opt.status
			this.is_new = opt.is_new == 0 ? 1 : 0
			this.getWholeDetai()
		},
		methods: {
			getWholeDetai() {
				let obj = this
				getWholeDetai({}, obj.good_id, obj.time_id, obj.status, obj.is_new).then(({
					data
				}) => {
					obj.goodItem = data.storeInfo
					obj.imgList = data.storeInfo.images
					obj.description = data.storeInfo.description.replace(/\<img/gi, '<img class="rich-img"')
				})
			},
			reservePackage() {
				let obj = this
				let updata = {
					whole_id: obj.good_id,
					time_id: obj.time_id,
					price: obj.goodItem.price,
					to_uid: obj.is_new == 0 ? '':0,
					first_price: obj.is_new == 0?'':0,
					last_id: obj.is_new== 0? '': 0
				}
				reservePackage(updata).then(res => {
					console.log(res)
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.good-price {
		padding-left: 20rpx;
		padding-top: 20rpx;
		justify-content: flex-start;
		background-color: #fff;

		// align-items: f;
		.new-price {
			font-size: 50rpx;
			font-family: PingFang SC;
			font-weight: bold;
			color: #FF4C4C;
		}

		.old-price {
			padding-left: 8rpx;
			font-size: 33rpx;
			font-family: PingFang SC;
			font-weight: bold;
			text-decoration: line-through;
			color: #999999;

		}

	}

	.good-tit {
		padding: 20rpx;
		background-color: #fff;
	}

	.btm-btn {
		position: fixed;
		bottom: 35rpx;
		left: 0;
		right: 0;
		margin: auto;
		width: 699rpx;
		height: 90rpx;
		line-height: 90rpx;
		text-align: center;
		background: linear-gradient(90deg, #FE6F61 0%, #FF4343 100%);
		border-radius: 45rpx;
		font-size: 36rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #FFFFFF;
		// background-color: #fff;
	}

	/* 商品详情中限制图片大小 */
	/deep/ .rich-img {
		width: 100% !important;
		height: auto;
	}
</style>
