<template>
  <view class="mt-32 mx-30">
    <ie-card title="最新动态">
      <view class="wrap mt-20 bg-white rounded-15">
        <view class="my-28" v-for="item in newsList" :key="item.id">
          <ie-news-item :data="item" @click="handleClick" />
        </view>
      </view>
    </ie-card>
  </view>
</template>
<script lang="ts" setup>
import { getNewsListNoToken } from '@/api/modules/news';
import { NewsItem } from '@/types/news';
const newsList = ref<NewsItem[]>([]);

const emit = defineEmits<{
  detail: [id: number | string]
}>();

const handleClick = async (data: NewsItem) => {
  emit('detail', data.id);
}
const loadData = async () => {
  const { rows } = await getNewsListNoToken({
    pageNum: 1,
    pageSize: 5
  });
  newsList.value = rows;
}

onShow(() => {
  loadData();
});
</script>
<style lang="scss" scoped></style>