<template>
	<view class="container" :style="'overflow:' + (showPage ? 'hidden' : 'visible')" v-if="info">
		<!-- 顶部轮播图区域 -->
		<swiper v-if="info.detail_img" class="swiper" indicator-dots indicator-color="rgba(255, 255, 255, 0.5)" indicator-active-color="#fff" autoplay :interval="3000">
			<swiper-item v-for="(item, index) in info.detail_img.split(',')" :key="index" @click="handleLookImgs(info.detail_img.split(','), index)">
				<view class="swiper-item">
					<img class="img" mode="aspectFill" :src="item" />
				</view>
			</swiper-item>
		</swiper>

		<!-- 周边信息区域 -->
		<view class="info">
			<view class="info_name">{{ info.rname }}</view>
			<view class="info_score">
				<!-- <view class="score_left">5.0</view>
				<view class="score_right">超棒</view> -->
				<view class="score_msg" @click="goPageInfo">简介</view>
				<img class="score_icon" src="../../static/index/right.png" @click="goPageInfo" />
			</view>
			<view class="info_address">
				<img class="address_icon" src="../../static/index/address.png" />
				<text @click="handleLookAddress">{{ info.radress }}</text>
			</view>
		</view>

		<!-- 周边产品区域 -->
		<view class="goods" v-if="goodList.length">
			<view class="goods_title">周边产品</view>
			<!-- 列表区域 -->
			<view class="goods_list">
				<!-- 每一个产品区域 -->
				<view class="item_box" v-for="item in goodList" :key="item.id" @click="handleLookDetail(item)">
					<view class="box_left">
						<view class="left_name">{{ item.product_name }}</view>
						<view class="left_info">产品简介 ></view>
						<view class="left_price">¥{{ item.price }}</view>
					</view>
					<view class="box_right">
						<view class="right_btn">预定</view>
					</view>
				</view>
			</view>
		</view>

		<!-- 查看更多区域 -->
		<view class="more" v-if="showMore" @click="handleShowMore">
			查看更多
			<img class="more_icon" src="../../static/index/down.png" />
		</view>

		<!-- 弹窗区域 -->
		<uv-popup ref="popup" bgColor="none" :safeAreaInsetBottom="false">
			<view class="body_pop">
				<img class="pop_img" mode="aspectFill" :src="info.first_img" />
				<!-- 弹窗关闭图标区域 -->
				<img class="pop_icon" src="../../static/index/close.png" @click="handleClosePop" />
				<view class="pop_name">{{ popInfo.product_name }}</view>

				<view class="pop_desc">
					<mp-html :content="popInfo.product_desc" />
				</view>
				<!-- <view class="pop_title">
					<img class="title_img" src="../../static/index/notice.png" />
					购票须知
				</view>
				<view class="pop_content">16:00点前可订今日，预订后立即可用平均2秒出票凭[入园码先换票再入园</view>
				<view class="pop_content">未使用可随时由请全额退款</view>
				<view class="pop_content">使用日期后1天经核实未使用系统将自动发起退款申请</view>
				<view class="pop_content">换票后，不支持退款</view>
				<view class="pop_content">下单后不支持改期使用说明:</view>
				<view class="pop_content">换票时间:08:00-16:00 换票地址:游客中心取票入园</view>
				<view class="pop_content">费用说明费用包含三爪仑观音岩-[成人票]门票- 1张</view>
				<view class="pop_content">其它说明</view>
				<view class="pop_content">比产品由商家开具发票，若需要发票，请在消费前和商家联系确认开票方法</view>

				<view class="pop_title">
					<img class="title_img" src="../../static/index/phone3.png" />
					联系电话
				</view>
				<view class="pop_phone">13677988964</view> -->
			</view>
		</uv-popup>
	</view>
</template>

<script>
export default {
	data() {
		return {
			// 滚动穿透控制
			showPage: false,
			goodList: [],
			page: 1,
			rows: 3,
			total: null,
			info: null,
			showMore: true,
			popInfo: null
		}
	},
	onLoad(options) {
		this.info = JSON.parse(decodeURIComponent(options.info))
		this.getData()
	},
	methods: {
		async getData() {
			const res = await this.$myRequest({
				url: '/mhotel/applistAround_pd.action',
				data: {
					aid: this.info.id,
					page: this.page,
					rows: this.rows
				}
			})
			// console.log(res)
			if (res.code === 200) {
				this.goodList = [...this.goodList, ...res.rows]
				this.total = res.total
				if (this.goodList.length >= this.total) {
					this.showMore = false
				}
			}
		},
		goPageInfo() {
			uni.navigateTo({
				url: `/pages/rimInfo/rimInfo?desc=${this.info.detail}`
			})
		},
		handleLookDetail(item) {
			this.popInfo = item
			this.showPage = true
			this.$refs.popup.open('bottom')
		},
		// 点击弹窗关闭图标回调
		handleClosePop() {
			this.showPage = false
			this.$refs.popup.close()
		},
		handleLookImgs(urls, current) {
			uni.previewImage({
				urls,
				current
			})
		},
		handleLookAddress() {
			let latitude = this.info.jingwei.split(',')[1] * 1
			let longitude = this.info.jingwei.split(',')[0] * 1

			uni.openLocation({
				latitude,
				longitude,
				name: this.info.rname,
				address: this.info.radress,
				success: () => {}
			})
		},
		handleShowMore() {
			this.page++
			this.getData()
		}
	}
}
</script>

<style lang="scss" scoped>
.container {
	min-height: 100vh;
	background-color: #fff;

	.swiper {
		height: 423rpx;

		.swiper-item {
			width: 100%;
			height: 100%;

			.img {
				width: 100%;
				height: 100%;
			}
		}
	}

	.info {
		margin-top: 20rpx;
		padding: 0 20rpx;

		.info_name {
			font-size: 34rpx;
			font-weight: bold;
			color: #000000;
		}

		.info_score {
			display: flex;
			align-items: center;
			margin-top: 22rpx;
			font-size: 24rpx;

			.score_left {
				padding: 0 10rpx 0 12rpx;
				line-height: 36rpx;
				color: #fff;
				text-align: center;
				font-weight: bold;
				border-radius: 32rpx 0 0 32rpx;
				background-color: #096562;
			}
			.score_right {
				padding: 0 12rpx 0 10rpx;
				line-height: 36rpx;
				color: #096562;
				text-align: center;
				font-weight: bold;
				border-radius: 0 32rpx 32rpx 0;
				background-color: #dff2f2;
			}
			.score_msg {
				// margin-left: 42rpx;
				color: #096562;
			}

			.score_icon {
				margin-top: 5rpx;
				margin-left: 13rpx;
				width: 10rpx;
				height: 20rpx;
			}
		}

		.info_address {
			display: flex;
			align-items: center;
			margin-top: 24rpx;
			height: 83rpx;
			font-size: 28rpx;
			border-top: 1rpx solid #e6e6e6;

			.address_icon {
				margin-right: 8rpx;
				width: 30rpx;
				height: 30rpx;
			}
		}
	}

	.goods {
		padding: 0 20rpx;
		border-top: 1rpx solid #cccccc;

		.goods_title {
			margin-top: 30rpx;
			font-size: 32rpx;
			font-weight: bold;
		}

		.goods_list {
			margin-top: 17rpx;

			.item_box {
				display: flex;
				margin-bottom: 20rpx;
				padding: 0 32rpx 0 24rpx;
				height: 170rpx;
				border-radius: 10rpx;
				background-color: #f2f2f2;

				.box_left {
					flex: 2;
					display: flex;
					flex-direction: column;
					justify-content: space-evenly;
					overflow: hidden;

					.left_name {
						font-size: 28rpx;
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;
					}

					.left_info {
						color: #808080;
						font-size: 24rpx;
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;
					}

					.left_price {
						color: #ff5733;
						font-size: 24rpx;
					}
				}

				.box_right {
					flex: 1;
					display: flex;
					justify-content: flex-end;
					align-items: center;

					.right_btn {
						display: flex;
						justify-content: center;
						align-items: center;
						width: 115rpx;
						height: 60rpx;
						color: #fff;
						font-size: 28rpx;
						border-radius: 10rpx;
						background-color: #ff5733;
					}
				}
			}
		}
	}

	.more {
		display: flex;
		justify-content: center;
		align-items: center;
		padding: 20rpx 0 30rpx 0;
		color: #096663;
		font-size: 24rpx;

		.more_icon {
			width: 38rpx;
			height: 48rpx;
		}
	}

	.body_pop {
		position: relative;
		width: 750rpx;
		height: 85vh;
		border-radius: 22rpx 22rpx 0 0;
		background-color: #fff;
		overflow-y: auto;

		.pop_img {
			width: 100%;
			height: 423rpx;
			border-radius: 20rpx 20rpx 0 0;
		}

		.pop_icon {
			position: absolute;
			top: 20rpx;
			right: 30rpx;
			width: 58rpx;
			height: 58rpx;
		}

		.pop_name {
			padding: 0 20rpx;
			line-height: 90rpx;
			font-size: 32rpx;
			font-weight: bold;
		}

		.pop_desc {
			padding: 0 20rpx;
		}

		.pop_title {
			display: flex;
			align-items: center;
			padding: 12rpx 20rpx 13rpx;
			font-size: 32rpx;
			font-weight: bold;

			.title_img {
				margin-right: 15rpx;
				width: 38rpx;
				height: 38rpx;
			}
		}

		.pop_content {
			padding: 0 20rpx;
			line-height: 40rpx;
			color: #666666;
			font-size: 24rpx;
		}

		.pop_phone {
			margin-left: 50rpx;
			padding-bottom: 50rpx;
			color: #096562;
			font-size: 24rpx;
		}
	}
}
</style>
