187 lines
4.9 KiB
Vue
Raw Permalink Normal View History

2025-05-22 16:37:43 +08:00
<template>
<view class="trend-wrap">
<view class="top-container">
<view class="nav-bar">
<navbar color="#ffffff" :isBack="false">{{$tt('navBar.dynamic')}}</navbar>
</view>
</view>
<view class="main-container">
<u-swiper v-if="listSwiper.length" :list="listSwiper" showTitle height="20vh" radius="15" keyName="imgUrl"
indicator indicatorMode="line" @click="gotoSwiperDetail" circular></u-swiper>
<view class="item" v-if="listSwiper.length !== 0 && list.length !== 0">
<view v-for="(item, index) in list" :key="index">
<view
style="display:flex;flex-direction:row; justify-content:space-between;align-items: flex-end; margin-bottom: 48rpx;">
<view><u--text :text="item.categoryName" bold color="#606266" size="16"></u--text></view>
<view @click="gotoCategoryTrend(item.categoryId, item.categoryName)"><u--text
:text="$tt('scene.seeMore')" color="#666666" customStyle="font-size:12px;"></u--text>
</view>
</view>
<view v-for="(subItem, i) in item.newsList" :key="i"
style="display:flex;align-items: center;margin-bottom:40rpx;">
<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="12" bold @click="gotoDetail(subItem.newsId)"
:text="subItem.title"></u--text>
<view style="display:flex;margin-top:6px;">
<view style="margin-right:20px; font-size: 14px;">
<u--text iconStyle="color:#606266;font-size:14px;margin-right:3px;" lines="1"
size="11" color="#666666" mode="name" :text="subItem.author"></u--text>
</view>
<view>
<u--text iconStyle="color:#606266;font-size:14px;margin-right:3px;" lines="1"
size="11" color="#666666" mode="date" :text="subItem.createTime"></u--text>
</view>
</view>
</view>
</view>
</view>
</view>
<u-empty mode="data" :show="listSwiper.length === 0 && list.length === 0" marginTop="30"></u-empty>
<u-loading-page :loading="loading" bg-color="#eef3f7" loadingText="iot-xcwl.cn"></u-loading-page>
</view>
</view>
</template>
<script>
import projectConfig from '@/env.config.js';
import {
bannerListTrend,
listTrend,
topListTrend
} from '@/apis/modules/trend';
import navbar from '@/components/navBar/index.vue';
export default {
components: {
navbar
},
data() {
return {
loading: false,
list: [], // 置顶新闻列表
listSwiper: [], // Banner图列表
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/trend/detail?newsId=' + newsId
});
},
gotoCategoryTrend(categoryId, categoryName) {
uni.navigateTo({
url: '/pagesA/trend/category?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);
}
console.log(data)
this.listSwiper = data && data.map(item => {
item.imgUrl = projectConfig.baseUrl + item.imgUrl;
item.title = item.title;
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">
page {
height: 100%;
background: $uni-bg-color-grey;
}
</style>
<style lang="scss" scoped>
.trend-wrap {
height: 100vh;
display: flex;
flex-direction: column;
overflow-y: hidden;
.top-container {
position: relative;
background-size: cover;
background-image: url('@/static/common/bg.png');
min-height: 480rpx;
z-index: 0;
}
.main-container {
flex: 1 1 auto;
z-index: -20;
padding: 30rpx;
border-radius: 40rpx 40rpx 0 0;
background: $uni-bg-color-grey;
display: flex;
flex-direction: column;
margin-top: -9.493rem;
z-index: 1;
overflow-y: auto;
.item {
margin-top: 32rpx;
background-color: #fff;
border-radius: 30rpx;
padding: 40rpx;
height: 58vh;
overflow-y: auto;
}
.item:last-child {
padding-bottom: 0;
}
}
}
</style>