<template>
	<view class="service-detail-page">
		<!-- 顶部主图区域 -->
		<view class="hero-section">
			<image :src="serviceData.heroImg" class="hero-img" mode="aspectFill"></image>
			<view class="hero-overlay"></view>
			<view class="hero-title-box">
				<text class="hero-main-title">{{ serviceData.heroTitle }}</text>
				<text class="hero-sub-title">{{ serviceData.heroSubTitle }}</text>
			</view>
		</view>

		<!-- 购买数据 -->
		<view class="info-section card">
			<view class="service-price-row">
				<view class="price-box">
					<text class="price-label">订单服务费:</text>
					<text class="price-symbol">￥</text>
					<text class="price-num">{{ serviceData.price }}</text>
					<text class="price-unit">{{ serviceData.unit }}</text>
				</view>
				<text class="bought-count">{{ serviceData.booked }}</text>
			</view>
			<text class="service-name-text">{{ serviceData.title }}</text>
		</view>

		<!-- 详情选项卡 -->
		<view class="tab-section card">
			<view class="tab-header">
				<view :class="['tab-btn', { active: activeTab === 'intro' }]" @click="activeTab = 'intro'">
					<text>服务介绍</text>
				</view>
				<view :class="['tab-btn', { active: activeTab === 'notice' }]" @click="activeTab = 'notice'">
					<text>下单须知</text>
				</view>
			</view>

			<view class="tab-content" v-if="activeTab === 'intro'">
				<text class="content-title">服务介绍</text>
				<rich-text :nodes="serviceData.intro" class="content-text"></rich-text>
				<view class="intro-images" v-if="serviceData.introImages && serviceData.introImages.length">
					<image v-for="(img, idx) in serviceData.introImages" :key="idx" :src="img" class="intro-img"
						mode="widthFix"></image>
				</view>
			</view>

			<view class="tab-content" v-if="activeTab === 'notice'">
				<text class="content-title">下单须知</text>
				<rich-text :nodes="serviceData.notice" class="content-text"></rich-text>
			</view>
		</view>

		<!-- 底部操作栏 -->
		<view class="footer-bar safe-bottom">
			<button class="buy-btn" @click="goToOrderApply">立即预约</button>
		</view>
	</view>
</template>

<script setup>
import { ref, computed } from 'vue'
import { onLoad } from '@dcloudio/uni-app'

const activeTab = ref('intro')
const serviceKey = ref('接送')

const serviceConfigs = {
	'接送': {
		type: 'transport',
		title: '宠物接送',
		heroTitle: '专业宠物托运',
		heroSubTitle: '专业速度快 安全服务好',
		heroImg: 'https://images.unsplash.com/photo-1544568100-847a948585b9?q=80&w=600&auto=format&fit=crop',
		price: '40',
		unit: '起',
		booked: '158+ 人已约',
		intro: '宠物接送对于有出行需求的宠物主们来说，是解决距离难题的最佳选择。<br><br>✨ <b>服务特色：</b><br>专车专送、不拼车、无应激，配有专业航空箱，全天候接单响应。',
		introImages: ['/static/images/transport-guide.png'],
		notice: '<div style="background:#fdfaf5;border:1px solid #f9ecec;border-radius:10px;padding:14px;margin-bottom:16px;"><b>📜 服务细节</b><br>1. 请提前至少一天预约出行时间。<br>2. 接送期间发送状态视频及定位。<br>3. 价格按实际公里数计算。</div><div style="background:#fdfaf5;border:1px solid #f9ecec;border-radius:10px;padding:14px;"><b>⚠️ 禁忌项</b><br>1. 孕期宠物严禁长途颠簸。<br>2. 传染病宠物谢绝托运。<br>3. 出发前4小时内请勿大量喂食。</div>'
	},
	'托运': {
		type: 'transport',
		title: '跨区托运',
		heroTitle: '跨区宠物托运',
		heroSubTitle: '全国直达 安全高效',
		heroImg: 'https://images.unsplash.com/photo-1544568100-847a948585b9?q=80&w=600&auto=format&fit=crop',
		price: '199',
		unit: '起',
		booked: '286+ 人已约',
		intro: '宠物长途托运包含汽车、航空等多种方式可选。一站式服务。<br><br>✨ <b>服务特色：</b><br>恒温车厢保障、到达后专属客服报平安。',
		introImages: ['/static/images/transport-guide.png'],
		notice: '<div style="background:#fdfaf5;border:1px solid #f9ecec;border-radius:10px;padding:14px;margin-bottom:16px;"><b>📜 服务细节</b><br>1. 长途托运需提前3天预约。<br>2. 提供加固航空箱。<br>3. 客服1对1跟踪行程。</div>'
	},
	'喂养': {
		type: 'feed',
		title: '上门喂遛',
		heroTitle: '贴心上门喂遛',
		heroSubTitle: '解放双手 贴心陪伴',
		heroImg: 'https://images.unsplash.com/photo-1548247416-ec66f4900b2e?q=80&w=600&auto=format&fit=crop',
		price: '35',
		unit: ' / 次起',
		booked: '1240+ 人已约',
		intro: '专业宠托师上门喂食、铲屎及陪玩/遛狗服务。<br><br>✨ <b>服务特色：</b><br>每次服务30~60分钟，提供手机直播或录像。',
		introImages: ['https://images.unsplash.com/photo-1583511655857-d19b40a7a54e?w=600&q=80'],
		notice: '<div style="background:#fdfaf5;border:1px solid #f9ecec;border-radius:10px;padding:14px;"><b>📜 服务细节</b><br>1. 确认入户方式。<br>2. 离场提供照片及视频汇报单。</div>'
	},
	'洗护': {
		type: 'wash',
		title: '上门洗护SPA',
		heroTitle: '高端上门洗护',
		heroSubTitle: '足不出户 尊享SPA',
		heroImg: 'https://images.unsplash.com/photo-1516734212186-a967f81ad0d7?q=80&w=600&auto=format&fit=crop',
		price: '98',
		unit: ' / 次起',
		booked: '842+ 人已约',
		intro: '宠物美容师带全套设备上门，提供洗沐、剪甲、清耳道等全方位护理。<br><br>✨ <b>服务特色：</b><br>纯手工精细揉搓洗浴，低敏无泪植物配方。',
		introImages: ['https://images.unsplash.com/photo-1516734212186-a967f81ad0d7?w=600&q=80'],
		notice: '<div style="background:#fdfaf5;border:1px solid #f9ecec;border-radius:10px;padding:14px;"><b>📜 服务细节</b><br>1. 请确保家中有热水及洗浴空间。<br>2. 费用依宠物体型及毛长而定。</div>'
	}
}

onLoad((options) => {
	if (options && options.service) {
		serviceKey.value = decodeURIComponent(options.service)
	}
})

const serviceData = computed(() => {
	const key = Object.keys(serviceConfigs).find(k => serviceKey.value.includes(k)) || '接送'
	return serviceConfigs[key]
})

const goToOrderApply = () => {
	uni.navigateTo({
		url: `/pages/order/apply/index?service=${serviceData.value.type}`
	})
}
</script>

<style lang="scss" scoped>
.service-detail-page { background-color: #f5f5f5; min-height: 100vh; padding-bottom: 160rpx; }
.hero-section { position: relative; width: 100%; height: 640rpx; overflow: hidden; }
.hero-img { width: 100%; height: 100%; }
.hero-overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: linear-gradient(to bottom, rgba(0, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0) 40%, rgba(0, 0, 0, 0.4) 80%, rgba(0, 0, 0, 0.7) 100%); }
.hero-title-box { position: absolute; bottom: 48rpx; left: 40rpx; right: 40rpx; z-index: 2; }
.hero-main-title { display: block; font-size: 52rpx; font-weight: 900; color: #fff; margin-bottom: 12rpx; }
.hero-sub-title { display: block; font-size: 28rpx; color: rgba(255, 255, 255, 0.9); font-weight: 600; }
.card { background-color: #fff; margin-bottom: 20rpx; }
.info-section { padding: 32rpx 40rpx; position: relative; z-index: 3; border-radius: 24rpx 24rpx 0 0; margin-top: -24rpx; }
.service-price-row { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 20rpx; }
.price-box { display: flex; align-items: baseline; color: #f44336; }
.price-label { font-size: 26rpx; color: #333; font-weight: bold; margin-right: 12rpx; }
.price-symbol { font-size: 28rpx; font-weight: bold; }
.price-num { font-size: 56rpx; font-weight: 900; line-height: 1; }
.price-unit { font-size: 24rpx; color: #999; margin-left: 4rpx; }
.bought-count { font-size: 24rpx; color: #999; background: #f5f5f5; padding: 4rpx 16rpx; border-radius: 20rpx; }
.service-name-text { font-size: 32rpx; color: #111; font-weight: bold; }
.tab-section { padding: 0; }
.tab-header { display: flex; border-bottom: 1rpx solid #f0f0f0; }
.tab-btn { flex: 1; text-align: center; padding: 24rpx 0; font-size: 28rpx; color: #666; position: relative; }
.tab-btn.active { color: #fcd53f; font-weight: bold; }
.tab-btn.active::after { content: ''; position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); width: 60rpx; height: 6rpx; background: #fcd53f; border-radius: 6rpx; }
.tab-content { padding: 40rpx 32rpx; }
.content-title { display: block; font-size: 32rpx; color: #333; font-weight: 900; margin-bottom: 24rpx; padding-left: 20rpx; position: relative; }
.content-title::before { content: ''; position: absolute; left: 0; top: 4rpx; bottom: 4rpx; width: 8rpx; background: #fcd53f; border-radius: 4rpx; }
.content-text { font-size: 28rpx; color: #555; line-height: 1.8; }
.intro-images { margin-top: 32rpx; display: flex; flex-direction: column; gap: 24rpx; }
.intro-img { width: 100%; border-radius: 20rpx; }
.footer-bar { position: fixed; bottom: 0; left: 0; right: 0; padding: 20rpx 32rpx 40rpx; background-color: #fff; z-index: 10; box-shadow: 0 -4rpx 20rpx rgba(0, 0, 0, 0.05); }
.buy-btn { width: 100%; height: 92rpx; font-size: 32rpx; font-weight: bold; color: #333; background: linear-gradient(90deg, #ffd53f, #ff9500); border: none; border-radius: 46rpx; line-height: 92rpx; }
</style>
