<script setup lang="ts">
import { ref } from 'vue'
import { getNews, type NewsData } from '@/api/home'
import { queryFieldMethod } from '@/utils/queryFieldMethod'
import { useRouter } from 'vue-router'

const creditDynamics = ref<NewsData[]>([])
const router = useRouter()
const init = async ()=>{
  //获取信用动态 数据
  const res3 = await getNews(queryFieldMethod('special_column','credit_dynamics'))
  if(res3.code == 200){
    creditDynamics.value = res3.data.slice(0,5);
  }
}
const toDetail = (id:number|undefined)=>{
  if(!id){
    return
  }
  router.push({
    path:'/newsDetail',
    query:{
      id
    }
  })
}
init()
</script>

<template>
  <div class="mt-15px bg-white mt-15px">
    <div class="w-117px border-solid border-#003aac border-b-3px h-32px">
      <img src="/src/assets/img/小图标1.png" />
      <span class="text-#003aac text-16px font-bold ">最新动态</span>
    </div>
    <div v-for="(item,index) in creditDynamics" :key="index">
      <div class="mt-20px mb-20px">
        <div class="w-266px mr-auto ml-auto line-clamp-2 bold text-13px">{{item.title}}</div>
        <div class="text-#ff9900 text-13px cursor-pointer text-right mr-10px mt-5px" @click="toDetail(item.id)">查看更多></div>
      </div>
      <div class="h-1px bg-gray"></div>
    </div>
  </div>
</template>

<style scoped>

</style>