<template>
	<view class="order-card">
		<!-- 用户信息 -->
		<view class="user-info">
			<image class="avatar"
				src="https://img20.360buyimg.com/da/jfs/t1/141592/25/8861/261559/5f68d8c1E33ed78ab/698ad655bfcfbaed.png"
				mode="aspectFill"></image>
			<view class="user-details">
				<text class="username">微信用户（南**）</text>
				<text class="date">共卖出7本书</text>
				<text class="date">来自河南省郑州市中牟县</text>
			</view>

			<view class="user-details right-items">
				<text class="date">2024-06-01 17:00:00</text>
				<text class="status" :style="{ color: statusColor }">[待收货审核]</text>
			</view>
		</view>

		<!-- 订单信息 -->
		<view class="order-info">

		</view>

		<!-- 订单详情 -->
		<view class="order-details">
			<view class="detail-row">
				<view class="flex-1">
					<text>订单ID：</text>
					<text class="link" @click="copyToClipboard(orderId)">{{ orderId }}</text>
				</view>
				<view class="flex-1" style="flex:1.3">
					<text>运单号：</text>
					<text class="link" @click="copyToClipboard(trackingId)">{{ trackingId }}</text>
				</view>
			</view>
			<view class="detail-row">
				<text class="flex-1">预估金额：{{ estimatedAmount }}</text>
				<text class="flex-1" style="flex:1.3">审核金额：{{ auditAmount }}</text>
			</view>
			<view class="detail-row">
				<text>内部备注：{{ internalNote }}</text>
			</view>
		</view>

		<!-- 操作按钮 -->
		<view class="action-buttons">
			<u-button size="small" type="primary" @click="handleAudit">到货审核</u-button>
			<u-button size="small" @click="handleView">查看</u-button>
		</view>
	</view>
</template>

<script setup>
	import {
		ref
	} from 'vue'

	// 模拟数据
	const orderId = ref('66478425')
	const trackingId = ref('DPK202356410215')
	const estimatedAmount = ref('66.6元')
	const auditAmount = ref('待核算')
	const internalNote = ref('已反馈')
	const statusColor = ref('#FF4D4F')

	// 复制到剪贴板
	const copyToClipboard = (text) => {
		uni.setClipboardData({
			data: text,
			success: () => {
				uni.showToast({
					title: '复制成功',
					icon: 'success'
				})
			}
		})
	}

	// 到货审核
	const handleAudit = () => {
		console.log('到货审核')
		// 处理到货审核逻辑
	}

	// 查看
	const handleView = () => {
		console.log('查看')
		// 处理查看逻辑
	}
</script>

<style lang="scss" scoped>
	.order-card {
		background: #FFFFFF;
		border-radius: 8rpx;
		padding: 20rpx;
		margin-bottom: 20rpx;
		box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);

		.user-info {
			display: flex;
			align-items: flex-start;
			margin-bottom: 20rpx;

			.avatar {
				width: 80rpx;
				height: 80rpx;
				border-radius: 40rpx;
				margin-right: 20rpx;
			}

			.user-details {
				flex: 1;
				display: flex;
				flex-direction: column;

				&.right-items {
					align-items: flex-end;
				}

				.username {
					font-size: 28rpx;
					color: #333333;
					margin-bottom: 4rpx;
				}

				.date {
					font-size: 24rpx;
					color: #999999;
				}

				.status {
					font-size: 24rpx;
					font-weight: bold;
				}
			}
		}

		.order-details {
			font-size: 26rpx;
			color: #333333;
			margin-bottom: 20rpx;

			.detail-row {
				display: flex;
				justify-content: space-between;
				margin-bottom: 8rpx;

				.link {
					color: #007BFF;
					text-decoration: underline;
					cursor: pointer;
				}
			}
		}

		.action-buttons {
			display: flex;
			justify-content: space-between;

			:deep(.u-button) {
				flex: 1;
				margin: 0 10rpx;
				height: 60rpx;
				font-size: 26rpx;
			}
		}
	}
</style>