<template>
  <div class="application-detail">
    <img src="@/assets/img/banner/banner_pub.png" alt="" srcset="" class="banner">
    <div class="detail-con">
      <h1 class="box-title" id="title">{{newDetail.title}}</h1>
      <div id="desc" v-html="newDetail.content"></div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { Search } from "@element-plus/icons-vue";
import { useAll } from "~/api/pubAll/service";
import { showLoadingToast, closeToast } from "vant";
const user = useUserStore();
const { getNewsDetail, getpreNext } = useAll();
const route = useRoute();
const nuxtApp = useNuxtApp();
const newDetail: any = ref({});
async function getNewsDetailFun() {
  let res: any = await getNewsDetail(route.query.code);
  if (res.httpCode == 200) {
    newDetail.value = res.data;
    user.value.adminTitle = newDetail.value.title
  }
}
watch(
  () => route.query.code,
  async () => {
    window.scrollTo({
      top: 0,
      behavior: "smooth",
    });

    // 显示加载
    const toast = showLoadingToast({
      message: "Loading...",
      forbidClick: true,
      duration: 0,
    });

    // 等待请求完成
    await getNewsDetailFun();
    // 关闭加载
    toast.close();
  }
);
onMounted(async () => {
  // 显示加载
  const toast = showLoadingToast({
    message: "Loading...",
    forbidClick: true,
    duration: 0,
  });

  // 等待请求完成
  await getNewsDetailFun();
  // 关闭加载
  toast.close();
});
</script>
<style scoped lang="scss">
.application-detail {
  min-height: 100vh;
  background: #fff;
  padding: 0;
  .banner {
    width: 100%;
    margin-bottom: 20px;
  }
  .detail-con {
    padding: 0 15px 40px;
  }
  .box-title {
    font-size: 16px;
    color: #333;
    text-align: center;
    margin-bottom: 12px;
    line-height: 24px;
  }
  .box-cen {
    font-size: 12px;
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    color: #666;
    .box-autor {
      color: $mainColor;
      margin-right: 5px;
    }
  }
}
</style>
