<route lang="json5" type="page">
{
  style: {
    navigationBarTitleText: '最新时讯',
    navigationStyle: 'custom',
  },
}
</route>
<template>
  <view class="news-page">
    <NavBar />
    <view class="py-15" v-if="newsList.length > 0">
      <view
        class="bg-white rounded-10 overflow-hidden p-15 mx-15 mb-15"
        v-for="item in newsList"
        :key="item.id"
        @click="handleNewsDetail(item.id)"
      >
        <image class="rounded-10 w-full h-160" :src="item.image" mode="aspectFill" />
        <view class="mt-10 flex-1 flex flex-col justify-between">
          <view class="text-14">{{ item.name }}</view>
          <view class="text-12 text-#999 mt-10">{{ item.source }}</view>
        </view>
      </view>
    </view>
    <wd-status-tip v-else image="content" tip="暂无内容" />
  </view>
</template>

<script setup lang="ts">
import NavBar from '@/components/NavBar.vue'
import { getIntroductionAPI } from '@/service'

const { list: newsList } = useListPageRequest((params) =>
  getIntroductionAPI({ type: 1, ...params }),
)

const handleNewsDetail = (id: number) => {
  uni.navigateTo({
    url: `/pages-sub/news-detail/index?id=${id}`,
  })
}
</script>

<style scoped>
.news-page {
  background: linear-gradient(180deg, #3a90f2 0%, #f7f7f7 100%);
}
</style>
