126 lines
3.9 KiB
Vue
126 lines
3.9 KiB
Vue
|
<template>
|
||
|
<page-meta><navigation-bar :title="$tt('navBar.dynamic')" title-align="center"
|
||
|
background-color="#007AFF" /></page-meta>
|
||
|
<view class="container">
|
||
|
<u-swiper v-if="listSwiper.length" :list="listSwiper" keyName="imgUrl" indicator indicatorMode="line"
|
||
|
@click="gotoSwiperDetail" circular></u-swiper>
|
||
|
<view v-for="(item, index) in list" :key="index">
|
||
|
<view
|
||
|
style="margin-top:30px;display:flex;flex-direction:row; justify-content:space-between;align-items: flex-end;">
|
||
|
<view><u--text prefixIcon="grid-fill" iconStyle="font-size: 16px;color:#606266"
|
||
|
:text="item.categoryName" bold color="#606266"></u--text></view>
|
||
|
<view @click="gotoCategoryTrend(item.categoryId, item.categoryName)"><u--text
|
||
|
:text="$tt('scene.seeMore')" color="#606266" customStyle="font-size:12px;"></u--text></view>
|
||
|
</view>
|
||
|
<u-line margin="5px 0 15px 0"></u-line>
|
||
|
<view v-for="(subItem, i) in item.newsList" :key="i"
|
||
|
style="display:flex;align-items: center;margin-bottom:15px;">
|
||
|
<view style="margin-right:10px;">
|
||
|
<u--image :src="subItem.imgUrl" @click="gotoDetail(subItem.newsId)" mode="aspectFill" radius="5"
|
||
|
width="120" height="80">
|
||
|
<template v-slot:loading>
|
||
|
<u-loading-icon></u-loading-icon>
|
||
|
</template>
|
||
|
</u--image>
|
||
|
</view>
|
||
|
<view>
|
||
|
<u--text lines="2" lineHeight="24" size="16" @click="gotoDetail(subItem.newsId)"
|
||
|
:text="subItem.title"></u--text>
|
||
|
<view style="display:flex;margin-top:6px;">
|
||
|
<view style="margin-right:20px;">
|
||
|
<u--text prefixIcon="account" iconStyle="color:#606266;font-size:14px;margin-right:3px;"
|
||
|
size="12" color="#606266" mode="name" :text="subItem.author"></u--text>
|
||
|
</view>
|
||
|
<view>
|
||
|
<u--text prefixIcon="calendar" iconStyle="color:#606266;font-size:14px;margin-right:3px;"
|
||
|
size="12" color="#606266" mode="date" :text="subItem.createTime"></u--text>
|
||
|
</view>
|
||
|
</view>
|
||
|
</view>
|
||
|
</view>
|
||
|
</view>
|
||
|
|
||
|
<u-empty mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png"
|
||
|
:show="listSwiper.length === 0 && list.length === 0" marginTop="30"></u-empty>
|
||
|
<u-loading-page :loading="loading" bg-color="#eef3f7" loadingText="XCWL.cn"></u-loading-page>
|
||
|
</view>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
|
import projectConfig from '@/env.config.js';
|
||
|
import { bannerListTrend, listTrend, topListTrend } from '@/apis/modules/trend';
|
||
|
|
||
|
export default {
|
||
|
data () {
|
||
|
return {
|
||
|
loading: false,
|
||
|
// 置顶新闻列表
|
||
|
list: [],
|
||
|
// Banner图列表
|
||
|
listSwiper: [],
|
||
|
queryParams: {
|
||
|
pageNum: 1,
|
||
|
pageSize: 10,
|
||
|
totalCount: 10
|
||
|
},
|
||
|
};
|
||
|
},
|
||
|
onShow () {
|
||
|
this.getbannerListTrend();
|
||
|
this.getlistTrend();
|
||
|
},
|
||
|
methods: {
|
||
|
gotoSwiperDetail (e) {
|
||
|
this.gotoDetail(this.listSwiper[e].newsId);
|
||
|
},
|
||
|
gotoDetail (newsId) {
|
||
|
uni.navigateTo({
|
||
|
url: '/pagesA/list/trend/trendDetail?newsId=' + newsId
|
||
|
});
|
||
|
},
|
||
|
gotoCategoryTrend (categoryId, categoryName) {
|
||
|
uni.navigateTo({
|
||
|
url: '/pagesA/list/trend/categoryTrend?categoryId=' + categoryId + '&categoryName=' +
|
||
|
categoryName
|
||
|
});
|
||
|
},
|
||
|
getbannerListTrend () {
|
||
|
bannerListTrend().then(res => {
|
||
|
let { code, data } = res;
|
||
|
if (code === 200) {
|
||
|
if (data && data.length > 3) {
|
||
|
data = data.slice(0, 3);
|
||
|
}
|
||
|
this.listSwiper = data && data.map(item => {
|
||
|
item.imgUrl = projectConfig.baseUrl + item.imgUrl;
|
||
|
return item;
|
||
|
});
|
||
|
}
|
||
|
})
|
||
|
},
|
||
|
getlistTrend () {
|
||
|
topListTrend().then(res => {
|
||
|
let { code, data } = res;
|
||
|
if (data && data.length > 6) {
|
||
|
data = data.slice(0, 6);
|
||
|
}
|
||
|
this.list = data && data.map((item, i) => {
|
||
|
item.newsList.map((subItem, index) => {
|
||
|
subItem.imgUrl = projectConfig.baseUrl + subItem.imgUrl;
|
||
|
return subItem;
|
||
|
});
|
||
|
return item;
|
||
|
});
|
||
|
this.loading = false;
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
</script>
|
||
|
|
||
|
<style lang="scss" scoped>
|
||
|
.container {
|
||
|
padding: 10px;
|
||
|
padding-bottom: 100px;
|
||
|
}
|
||
|
</style>
|