Files
jjx-wap/components/index/news.vue
T
2026-10-08 18:34:09 +08:00

132 lines
2.9 KiB
Vue

<template>
<view class="wrap">
<view class="layout-news">
<view class="index-h2">
<view class="big">资讯中心</view>
<!-- <view class="more">更多</view>-->
</view>
<view class="news-box flex justify-between flex-wrap">
<view class="w-100p" v-for="(item, index) in articleList" :key="index">
<view class="item">
<view class="title">{{ item.title }}</view>
<view class="text u-line-1" v-for="(article, articleIndex) in item.list" :key="articleIndex"
@click="jump(`/pages/article/info?id=${article._id}`)">
{{ article.name }}
</view>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
isLogin: false,
articleList: [
{
id: '657451bb6e5d2d335ab78b3a',
title: '市场信息',
list: []
},
{
id: '65745200337a9f07565fb08d',
title: '期货信息',
list: []
},
{
id: '6574520a7ad52d34471a9582',
title: '行情分析',
list: []
},
{
id: '6574521499c62431df5b562c',
title: '行业动态',
list: []
},
],
}
},
methods: {
jump(url) {
vk.navigateTo(url)
},
getArticleList() {
const otherArticleIdList = []
this.articleList.forEach((item, index) => {
otherArticleIdList.push(item.id)
})
this.articleList.forEach((item, index) => {
this.articleList[index].list = []
})
vk.callFunction({
url: 'client/otherArticle/list/pub/getList',
data: {
pageIndex: 1,
pageSize: 500,
parentId: otherArticleIdList
},
success: (data) => {
data.rows.forEach(item => {
this.articleList.forEach((article, articleIndex) => {
if (article.id === item.parentId) {
if (this.articleList[articleIndex].list.length < 5) this.articleList[articleIndex].list.push(item)
}
})
})
}
});
},
},
mounted() {
this.getArticleList()
},
}
</script>
<style lang="scss">
.layout-news {
padding: 10rpx 30rpx;
.news-box {
padding: 10rpx 0;
.item {
margin: 5rpx 10rpx;
//width: 296rpx;
//height: 250rpx;
padding: 10rpx;
background: #ffffff;
box-shadow: 0px 2px 7px 0px rgba(0, 0, 0, 0.12);
.title {
font-size: 30rpx;
line-height: 44rpx;
color: #333333;
}
.text {
//margin-top: 10rpx;
width: 100%;
height: 40rpx;
overflow: hidden;
font-size: 24rpx;
line-height: 40rpx;
color: #333333;
}
}
&:nth-last-of-type(1) {
margin-bottom: 0;
}
&:nth-last-of-type(2) {
margin-bottom: 0;
}
}
}
</style>