<template>
  <div class="flex flex-col bg-liner h-screen overflow-hidden">
    <!-- ✅ 顶部固定导航 -->
    <div class="flex-shrink-0">
      <TopNavBar :title="detailTitle" background="transparent" />
    </div>

    <!-- ✅ 滚动区域 -->
    <div class="flex-full overflow-hidden" scroll-y>
      <div class="pb-24 border-box overflow-hidden">
        <img v-if="coverImage" class="w-full block" :src="coverImage" mode="aspectFill" />

        <div class="pt-16 px-12 pb-24 border-box">
          <div class="color-171717 font-size-16 font-weight-600">{{ detailTitle }}</div>

          <div v-if="publishTime" class="notice-time-tag flex flex-row flex-items-center mt-16">
            <uni-icons type="clock" size="18" color="#5A6780" />
            <span class="color-171717 font-size-12 font-weight-600 ml-8">发布时间：{{ publishTime }}</span>
          </div>

          <div class="mt-16 mx-12 bg-gray w-full height-1"></div>

          <div class="mt-16 color-666 font-size-14 line-height-20">{{ noticeContent }}</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import TopNavBar from "@/components/TopNavBar/index.vue";
import { computed, ref } from "vue";

const noticeData = ref({});

const detailTitle = computed(() => {
  return noticeData.value.entityName?.trim() || "消息详情";
});

const publishTime = computed(() => {
  return noticeData.value.effectiveStartTime?.trim();
});

const coverImage = computed(() => {
  return noticeData.value.eventImage?.trim();
});

const noticeContent = computed(() => {
  return noticeData.value.eventDescription?.trim();
});

// TODO
// onLoad((query = {}) => {
//   if (query.noticeData) {
//     try {
//       noticeData.value = JSON.parse(decodeURIComponent(query.noticeData));
//     } catch (error) {
//       console.warn("noticeData parse failed:", error);
//     }
//   }
// });

</script>

<style lang="scss" scoped>
.notice-time-tag {
  display: inline-flex;
  height: 28px;
  padding: 6px 12px;
  background: linear-gradient(180deg, #f4f7fb 0%, #e9eef6 100%);
  border: 1px solid #d6dde8;
  border-radius: 14px;
  box-sizing: border-box;
}
</style>
