| | |
| | | <template> |
| | | <section class="inner-tab-container"> |
| | | <p class="title">{{ t('news') }}</p> |
| | | <assets-head :title="$t('news')" :back-func="() => router.push('/')" /> |
| | | <!-- <p class="title">{{ t('news') }}</p> --> |
| | | <div class="news-container"> |
| | | <van-steps direction="vertical" :active="0"> |
| | | <van-step v-for="(item, index) in list" :key="item.uuid || index"> |
| | | <p class="time">{{ item.createdAt }}</p> |
| | | <p class="context" v-html="item.description"></p> |
| | | <van-step v-for="(item, index) in list" :key="item.url || index"> |
| | | <img v-if="item.urlToImage" :src="item.urlToImage" alt="" class="news-item-img" /> |
| | | <p class="time">{{ item.publishedAt || item.createdAt }}</p> |
| | | <h3 class="news-item-title">{{ item.title || '' }}</h3> |
| | | <p class="context" v-html="item.description || item.content || ''"></p> |
| | | </van-step> |
| | | <!-- <van-step> |
| | | <p class="time">2023-06-15 11:30</p> |
| | |
| | | </template> |
| | | |
| | | <script setup> |
| | | import assetsHead from '@/components/Transform/assets-head/index.vue' |
| | | import { ref, onMounted } from 'vue'; |
| | | import { _getInformationList } from '@/service/etf.api' |
| | | import { _getUsHeadNews } from '@/service/user.api' |
| | | import { useI18n } from 'vue-i18n' |
| | | import { useRouter } from 'vue-router' |
| | | |
| | | const { t } = useI18n() |
| | | const list = ref([]) |
| | | const maxTime = ref('') |
| | | const router = useRouter() |
| | | |
| | | onMounted(async () => { |
| | | getInformationList() |
| | | getNewsList() |
| | | }) |
| | | |
| | | const onLoadMore = () => { |
| | | maxTime.value = list.value[list.value.length - 1].createdAt |
| | | getInformationList() |
| | | const last = list.value[list.value.length - 1] |
| | | maxTime.value = (last && (last.publishedAt || last.createdAt)) || '' |
| | | getNewsList() |
| | | } |
| | | |
| | | const getInformationList = () => { |
| | | _getInformationList(maxTime.value).then(data => { |
| | | list.value = [...list.value, ...data] |
| | | const getNewsList = () => { |
| | | const params = maxTime.value ? { maxTime: maxTime.value } : {} |
| | | _getUsHeadNews(params).then(data => { |
| | | const arr = Array.isArray(data) ? data : (data && data.articles) ? data.articles : [] |
| | | list.value = maxTime.value ? [...list.value, ...arr] : arr |
| | | }) |
| | | } |
| | | |
| | |
| | | .van-step__title { |
| | | color: $text_color !important; |
| | | |
| | | .news-item-img { |
| | | width: 100%; |
| | | max-height: 18rem; |
| | | border-radius: 0.5rem; |
| | | object-fit: cover; |
| | | margin-bottom: 0.8rem; |
| | | } |
| | | |
| | | .time { |
| | | color: #747A8F; |
| | | margin: 5px 0; |
| | | } |
| | | |
| | | .news-item-title { |
| | | font-size: 1.6rem; |
| | | font-weight: 600; |
| | | color: $text_color; |
| | | margin: 0.8rem 0 0.5rem; |
| | | line-height: 1.4; |
| | | } |
| | | } |
| | | |
| | | .van-step__line { |