首页初次对接口

This commit is contained in:
clay
2022-12-25 16:05:39 +08:00
parent 4050e638f0
commit fd6f5b5390
7 changed files with 305 additions and 191 deletions

View File

@@ -1,7 +1,7 @@
<template>
<view>
<view class="xw_content" v-for="(item,index) in newsList" :key="index" @click="clickNews(index)">
<u--image :src="item.src" width="192rpx" height="122rpx" :lazy-load="true">
<view class="xw_content" v-for="(item,index) in newsList" :key="index" @click="clickNews(item)">
<u--image :src="item.cover" width="192rpx" height="122rpx" :lazy-load="true">
</u--image>
<view class="xw_right">
<view class="xw_title">
@@ -9,10 +9,10 @@
</view>
<view style="display: flex;">
<text class="xw_time">
{{item.time}}
{{item.pub_time}}
</text>
<text class="xw_time xw_place">
{{item.place}}
{{item.pub_name}}
</text>
</view>
</view>
@@ -24,35 +24,43 @@
export default {
data() {
return {
newsList: [{
src: '/static/report/zhanwei_xf.png',
title: '2022近50款食品饮料新品创新的方向都在这里',
time: '2022-12-03 09:59',
place: '第一食品资讯官方账号'
},
{
src: '/static/report/zhanwei_xf.png',
title: '食品企业如何开发新产品?创新思维又发挥着怎样的效应呢?',
time: '2022-10-18 14:43',
place: '腾讯新闻 '
},
{
src: '/static/report/zhanwei_xf.png',
title: '食品企业如何开发新产品?创新思维又发挥着怎样的效应呢?',
time: '2022-10-18 14:43',
place: '腾讯新闻'
},
newsList: [
// {
// src: '/static/report/zhanwei_xf.png',
// title: '2022近50款食品饮料新品创新的方向都在这里',
// time: '2022-12-03 09:59',
// place: '第一食品资讯官方账号'
// },
// {
// src: '/static/report/zhanwei_xf.png',
// title: '食品企业如何开发新产品?创新思维又发挥着怎样的效应呢?',
// time: '2022-10-18 14:43',
// place: '腾讯新闻 '
// },
],
}
},
created() {
this.getNews()
},
methods: {
//获取行业新闻
// {
// pageSize: 2,
// pageNum: 1
// }
getNews() {
this.$apiServe.getNews().then(res => {
// console.log('行业新闻', res.data.data)
this.newsList = res.data.data
}).finally(_ => {})
},
// 跳转到新闻详情页
clickNews(index) {
if (index == 0) {
uni.navigateTo({
url: '../../packageReport/xwDetail/xwDetail'
})
}
clickNews(item) {
uni.navigateTo({
url: '../../packageReport/xwDetail/xwDetail?id=' + item.id
})
},
}
}