<template>
  <div class="bg-white  rounded-[10px] p-[12px] mb-[12px]" v-if="hasConsumerData">
    <div v-for="(item, index) in consumerList" :key="index">
      <div class="flex mb-[8px] text-[12px]">
        <span class="w-60 text-ink-400">{{ t("order.user.guestName") }}</span>
        <span class="text-ink-600">{{ item.visitorName }}</span>
      </div>
    </div>
    <div class="flex text-[12px]">
      <span class="w-60 text-ink-400">{{ t("order.user.phone") }}</span>
      <span class="text-ink-600">{{ contactPhone }}</span>
    </div>
  </div>
</template>

<script setup>
import { defineProps, computed } from "vue";
import { useI18n } from "vue-i18n";

const { t } = useI18n();

const props = defineProps({
  orderData: {
    type: Object,
    required: true,
    default: () => ({
      createTime: "",
      consumerInfoList: [],
      orderStatus: "0", // 订单状态 0-待支付 1-待确认 2-待使用 3-已取消 4-退款中 5-已关闭 6-已完成
      orderType: "0", // 0-酒店订单, 1-门票订单, 2-餐饮
    }),
  },
});

// 使用计算属性处理用户信息列表，提供更好的响应性和缓存
const consumerList = computed(() => props.orderData.consumerInfoList || []);

// 联系电话
const contactPhone = computed(() => consumerList.value[0]?.contactPhone);

// 检查是否有用户数据
const hasConsumerData = computed(() => consumerList.value.length);
</script>

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