<template>
  <view class="mt-32 mx-30">
    <ie-card title="最新动态">
      <view class="wrap mt-20 bg-white rounded-15">
        <view class="mb-20" 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 { News } from '@/types/news';
const newsList = ref<News[]>([]);

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

const handleClick = async (data: News) => {
  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>