<script setup lang="ts">
import router from '@/router'

const props = defineProps<{
  order: Api.ScenicOrderListVo
}>()

// 订单状态映射（hbOrderStatus）
const statusMap: Record<number, { text: string, color: string }> = {
  0: { text: '待支付', color: '#FF9500' },
  60: { text: '已取消', color: '#999999' },
  70: { text: '已支付', color: '#52C41A' },
  80: { text: '已完成', color: '#52C41A' },
}
// 订单项点击
function handleOrderClick(order: Api.ScenicOrderListVo) {
  router.push({ name: 'attractions-order-detail', params: { orderNo: String(order.orderNumber) } })
}
const statusInfo = computed(() => {
  const status = props.order?.hbOrderStatus as number
  return statusMap[status] ?? { text: '', color: '#999999' }
})
</script>

<template>
  <view class="mb-20rpx rounded-16rpx bg-#FFF p-24rpx" @click="handleOrderClick(order)">
    <view class="flex items-center justify-between">
      <view class="text-32rpx font-bold">
        {{ order?.viewName }}
      </view>
      <view class="text-28rpx" :style="{ color: statusInfo.color }">
        {{ statusInfo.text }}
      </view>
    </view>
    <view class="mt-20rpx flex items-center gap-20rpx">
      <image v-if="order?.img" :src="order.img" class="h-160rpx w-160rpx rounded-8rpx" mode="aspectFill" />
      <view v-else class="h-160rpx w-160rpx flex items-center justify-center rounded-8rpx bg-#f5f5f5 text-#999">
        暂无图片
      </view>
      <view class="flex-1">
        <view class="line-clamp-2 text-28rpx font-bold">
          {{ order?.productName }}
        </view>
        <view class="mt-20rpx text-24rpx text-#666">
          游玩日期：{{ order?.travelDate }}
        </view>
      </view>
    </view>
    <view class="mt-24rpx flex items-center justify-between text-24rpx text-#999">
      <view>订单编号:{{ order?.orderNumber }}</view>
      <view>共1件商品</view>
    </view>
    <view class="mt-20rpx flex items-center justify-between">
      <view class="text-24rpx text-#999">
        下单时间:{{ order?.createTime }}
      </view>
      <view>
        <text class="text-24rpx">
          合计:
        </text>
        <text class="text-26rpx text-#FF4A39 font-bold">
          ￥
        </text>
        <text class="text-bold text-32rpx text-#FF4A39">
          {{ order?.actualTotal }}
        </text>
      </view>
    </view>
  </view>
</template>

<style lang="scss" scoped></style>
