<template>

	<view v-if="loading" class="skeleton-container">
		<!-- 骨架屏 - 异常状态 -->
		<view class="skeleton-status-section">
			<view class="skeleton-line skeleton-status-text"></view>
		</view>

		<!-- 骨架屏 - 关联订单 -->
		<view class="skeleton-section">
			<view class="skeleton-line skeleton-section-title"></view>
			<view class="skeleton-order-info">
				<view class="skeleton-line skeleton-order-id"></view>
				<view class="skeleton-line skeleton-order-item"></view>
				<view class="skeleton-line skeleton-order-time"></view>
			</view>
		</view>

		<!-- 骨架屏 - 异常详情 -->
		<view class="skeleton-section">
			<view class="skeleton-line skeleton-section-title"></view>
			<view class="skeleton-detail-content">
				<view class="skeleton-line skeleton-report-title"></view>
				<view class="skeleton-line skeleton-report-desc"></view>
				<view class="skeleton-image-container">
					<view class="skeleton-image"></view>
					<view class="skeleton-image"></view>
				</view>
				<view class="skeleton-line skeleton-report-time"></view>
			</view>
		</view>

		<!-- 骨架屏 - 处理结果 -->
		<view class="skeleton-section">
			<view class="skeleton-line skeleton-section-title"></view>
			<view class="skeleton-result-content">
				<view class="skeleton-line skeleton-result-item"></view>
				<view class="skeleton-line skeleton-result-time"></view>
				<view class="skeleton-line skeleton-result-item"></view>
			</view>
		</view>

		<!-- 骨架屏 - 补充说明 -->
		<view class="skeleton-section">
			<view class="skeleton-line skeleton-section-title"></view>
			<view class="skeleton-textarea"></view>
		</view>

		<!-- 骨架屏 - 底部按钮 -->
		<view class="skeleton-bottom-button">
			<view class="skeleton-button"></view>
		</view>
	</view>


	<view v-else class="abnormal-detail-page">
		<!-- 异常状态 -->
		<view class="status-section">
			<text class="status-text">异常已上报 · {{ orderInfo.state=='售后中'?'处理中':'已完成'   }}</text>
		</view>

		<!-- 关联订单 -->
		<view class="order-section">
			<view class="section-title">关联订单</view>
			<view class="order-info">
				<view class="order-item">
					<text class="order-label">订单号：</text>
					<text class="order-value">{{ orderInfo.orderId }}</text>
				</view>
				<view class="order-item"  style="display:  flex; align-items: center;" >
					<image :src="Service.GetIconImg(goods.img)"  v-for="(goods,imgIndex) in JSON.parse(orderInfo.detail)" :key="imgIndex"  :style="{ 'transform': imgIndex!==0? 'translateX(-20rpx)':'' }" style="  width: 80rpx; height: 80rpx; border-radius: 50%;" mode=""></image>
					<view class="" style="margin-left: 20rpx;" >
						共{{JSON.parse(orderInfo.detail).length}}件商品
					</view>
				</view>
				<view class="order-item">
					<text class="order-value" style="color: #999999;">{{ Service.formatDate(orderInfo.addTime,1) }}</text>
				</view>
			</view>
		</view>

		<!-- 异常详情 -->
		<view class="detail-section">
			<view class="section-title">异常详情</view>
			<view class="detail-content"
				style="padding: 20rpx 30rpx;  background-color: #fafafa; border-radius: 20rpx; ">
				<view class="report-section">
					<view class="report-header">
						<text class="report-title">{{serviceInfo.type }}</text>
					</view>
					<view class="report-desc">
						<text>{{ serviceInfo.remark }}</text>
					</view>

					<!-- 图片展示区 -->
					<view class="image-container">
						<view v-for="(img,imgIndex) in JSON.parse(serviceInfo.img )" class="image-placeholder">
							<image :src="Service.GetMateUrlByImg(img.url)" mode="" style="width: 100%; height: 100%;" ></image>
						</view>
					</view>

					<view class="report-time">
						<text>{{ serviceInfo.addTime }}</text>
					</view>
				</view>
			</view>
		</view>

		<!-- 处理结果 -->
		<view v-if="serviceInfo.reply" class="result-section">
			<view class="section-title">处理结果</view>
			<view class="result-content">
				<view class="result-item">
					<text class="result-text">{{serviceInfo.reply }}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script setup lang="ts">
	import { ref } from 'vue'
	import { onLoad } from '@dcloudio/uni-app'
	import { CNRiderOrderService } from '@/Service/CN/CNRiderOrderService'
	import { Service } from '@/Service/Service'
	
	
	// 补充说明文本
	const supplementText = ref<string>('')

	let loading = ref(true)

	let orderInfo=ref<any>({})
	let serviceInfo=ref<any>()
	
	let orderId = ref()
	// 页面加载时的逻辑
	onLoad((data : any) => {
		orderId.value = data.orderId
		getData()
	})


	const getData = () => {
		CNRiderOrderService.GetOrderServiceInfo(orderId.value).then(res => {
			loading.value = false
			if(res.data){
				orderInfo.value=res.data.orderInfo
				serviceInfo.value=res.data.serviceInfo
			}
		})
	}



</script>

<style lang="scss">
	page{
		background-color: #fff;
	}
	.abnormal-detail-page {
		overflow: hidden;

		// 状态区域样式
		.status-section {
			background-color: #fff0f0;
			padding: 30rpx 30rpx;
			margin: 20rpx;
			border-radius: 20rpx;

			.status-text {
				color: #FF4D4F;
				font-size: 28rpx;
				font-weight: 600;
			}
		}

		// 通用区块样式
		.order-section,
		.detail-section,
		.result-section,
		.supplement-section {
			background-color: #fff;
			padding: 30rpx;

			.section-title {
				font-size: 30rpx;
				font-weight: 600;
				color: #333;
				margin-bottom: 20rpx;
			}
		}

		// 订单信息样式
		.order-info {
			background-color: #FAFAFA;
			padding: 20rpx 30rpx;
			border-radius: 20rpx;

			.order-item {
				margin-bottom: 16rpx;
				font-size: 28rpx;

				.order-label {
					color: #666;
				}

				.order-value {
					color: #333;
				}
			}
		}

		// 异常详情样式
		.report-section {
			.report-header {
				display: flex;
				align-items: center;
				margin-bottom: 16rpx;

				.report-title {
					font-size: 28rpx;
					font-weight: 500;
					color: #007aff;
					margin-left: 8rpx;
				}
			}

			.report-desc {
				margin-bottom: 20rpx;

				text {
					font-size: 28rpx;
					color: #333;
					line-height: 42rpx;
				}
			}

			// 图片容器样式
			.image-container {
				display: flex;
				gap: 20rpx;
				margin-bottom: 20rpx;

				.image-placeholder {
					width: 200rpx;
					height: 200rpx;
					overflow: hidden;
					background-color: #fff;
					border-radius: 8rpx;
				}
			}

			.report-time {
				text {
					font-size: 24rpx;
					color: #999;
				}
			}
		}

		// 处理结果样式
		.result-content {
			background-color: #FAFAFA;
			padding: 20rpx 30rpx;
			border-radius: 20rpx;

			.result-item {
				margin-bottom: 16rpx;

				.result-text {
					font-size: 28rpx;
					color: #07c160;
				}
			}

			.result-time {
				margin-bottom: 20rpx;

				text {
					font-size: 24rpx;
					color: #999;
				}
			}
		}

		// 补充说明样式
		.supplement-input {
			border: 2rpx solid #e0e0e0;
			border-radius: 12rpx;
			padding: 20rpx;
			font-size: 28rpx;
			color: #333;
			background-color: #fafafa;

			&::placeholder {
				color: #999;
			}
		}

		// 底部按钮样式
		.bottom-button {
			position: fixed;
			bottom: 0;
			left: 0;
			right: 0;
			background-color: #fff;
			padding: 20rpx 30rpx;
			box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);

			.submit-btn {
				height: 90rpx;
				line-height: 90rpx;
				font-size: 32rpx;
				border-radius: 45rpx;
			}
		}
	}


	// 骨架屏基础样式
	.skeleton-loading {
		background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
		background-size: 200% 100%;
		animation: skeleton-loading 1.5s infinite;
		border-radius: 8rpx;
	}

	@keyframes skeleton-loading {
		0% {
			background-position: 200% 0;
		}

		100% {
			background-position: -200% 0;
		}
	}

	// 骨架屏容器样式
	.skeleton-container {
		padding: 0 30rpx;
		background-color: #fff;
		min-height: 100vh;
	}

	// 骨架屏各模块通用样式
	.skeleton-section {
		margin-bottom: 30rpx;
	}

	.skeleton-line {
		height: 32rpx;
		background-color: #f0f0f0;
		margin-bottom: 20rpx;
		border-radius: 8rpx;

	}

	// 异常状态骨架样式
	.skeleton-status-section {
		padding: 30rpx 0;
		margin-bottom: 30rpx;
		background-color: #fff0f0;
		border-radius: 20rpx;
		padding-left: 30rpx;
		padding-right: 30rpx;
	}

	.skeleton-status-text {
		width: 60%;
		height: 40rpx;
		margin-bottom: 0;
	}

	// 区块标题骨架样式
	.skeleton-section-title {
		width: 20%;
		height: 36rpx;
		margin-bottom: 20rpx;
	}

	// 订单信息骨架样式
	.skeleton-order-info {
		background-color: #f9f9f9;
		padding: 20rpx 20rpx;
		border-radius: 12rpx;
	}

	.skeleton-order-id {
		width: 80%;
		height: 30rpx;
	}

	.skeleton-order-item {
		width: 40%;
		height: 30rpx;
	}

	.skeleton-order-time {
		width: 50%;
		height: 28rpx;
		margin-bottom: 0;
	}

	// 异常详情骨架样式
	.skeleton-detail-content {
		background-color: #fafafa;
		padding: 20rpx 30rpx;
		border-radius: 20rpx;
	}

	.skeleton-report-title {
		width: 30%;
		height: 32rpx;
		margin-bottom: 30rpx;
	}

	.skeleton-report-desc {
		width: 70%;
		height: 30rpx;
		margin-bottom: 30rpx;
	}

	.skeleton-image-container {
		display: flex;
		margin-bottom: 30rpx;
	}

	.skeleton-image {
		width: 200rpx;
		height: 200rpx;
		background-color: #f0f0f0;
		margin-right: 20rpx;
		border-radius: 12rpx;

	}

	.skeleton-report-time {
		width: 50%;
		height: 28rpx;
		margin-bottom: 0;
	}

	// 处理结果骨架样式
	.skeleton-result-content {
		background-color: #f9f9f9;
		padding: 20rpx 20rpx;
		border-radius: 12rpx;
	}

	.skeleton-result-item {
		width: 50%;
		height: 30rpx;
	}

	.skeleton-result-time {
		width: 50%;
		height: 28rpx;
	}

	// 补充说明骨架样式
	.skeleton-textarea {
		height: 200rpx;
		background-color: #f9f9f9;
		border-radius: 12rpx;
		margin-bottom: 140rpx;

	}

	// 底部按钮骨架样式
	.skeleton-bottom-button {
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		padding: 30rpx;
		background-color: #fff;
		box-shadow: 0 -2rpx 20rpx rgba(0, 0, 0, 0.05);
	}

	.skeleton-button {
		height: 100rpx;
		background-color: #f0f0f0;
		border-radius: 50rpx;

	}
</style>