上传文件至 '新闻小程序/pages/home'

This commit is contained in:
link_1999 2022-05-29 14:34:48 +08:00
parent 30c08fbf51
commit a151096acb
2 changed files with 105 additions and 19 deletions

View File

@ -4,18 +4,23 @@ Page({
//存放轮播图数据的列表 //存放轮播图数据的列表
lunboList: [], lunboList: [],
msgList: [ msgList: [
{ title: "上海今日全市进行抗原检测 明日全市进行核酸检测" }, { title: "“奋斗的青春最美丽”————省政府奖学金获得者沈卓玥" },
{ title: "苏州发现奥密克戎新变异株 与全球已知毒株均不同源" }, { title: "学校召开“双高计划”专业群中期验收绩效评价工作会议" },
{ title: "美工作组抵华 参与东航事故调查" }, { title: "习近平勉励广大青年:牢记党的教诲 立志民族复兴" },
{ title: "上海昨日新增本土确诊425例、无症状8581例" }, { title: "同心抗疫 “职”面未来——智慧学院举办线上宣讲会" },
],
topMenuList: [
"路桥学院", "汽车学院",
"海运学院", "航空学院",
"轨道学院", "智慧学院",
"运输学院", "人文学院",
], ],
topMenuList: ["内地新闻", "香港新闻", "两岸新闻", "国际新闻", "军事新闻"],
news_list: [], news_list: [],
selectIndex: 0, selectIndex: 0,
}, },
onLoad: function (options) { onLoad: function (options) {
// 获取轮播图数据 // 获取轮播图数据
wx.cloud.database().collection('lunbotu-news').get() wx.cloud.database().collection('zjjt_lbt').get()
.then(res => { .then(res => {
// console.log('轮播图数据:', res) // console.log('轮播图数据:', res)
this.setData({ this.setData({
@ -36,7 +41,7 @@ Page({
}) })
let len = this.data.news_list.length let len = this.data.news_list.length
console.log('当前list长度', len) console.log('当前list长度', len)
wx.cloud.database().collection('nd-news') wx.cloud.database().collection('lqxy')
.skip(len) .skip(len)
.get() .get()
.then(res => { .then(res => {
@ -62,7 +67,7 @@ Page({
}) })
let len = this.data.news_list.length let len = this.data.news_list.length
console.log('当前list长度', len) console.log('当前list长度', len)
wx.cloud.database().collection('xg-news') wx.cloud.database().collection('qcxy')
.skip(len) .skip(len)
.get() .get()
.then(res => { .then(res => {
@ -88,7 +93,7 @@ Page({
}) })
let len = this.data.news_list.length let len = this.data.news_list.length
console.log('当前list长度', len) console.log('当前list长度', len)
wx.cloud.database().collection('tw-news') wx.cloud.database().collection('hyxy')
.skip(len) .skip(len)
.get() .get()
.then(res => { .then(res => {
@ -114,7 +119,7 @@ Page({
}) })
let len = this.data.news_list.length let len = this.data.news_list.length
console.log('当前list长度', len) console.log('当前list长度', len)
wx.cloud.database().collection('gj-news') wx.cloud.database().collection('hkxy')
.skip(len) .skip(len)
.get() .get()
.then(res => { .then(res => {
@ -140,7 +145,85 @@ Page({
}) })
let len = this.data.news_list.length let len = this.data.news_list.length
console.log('当前list长度', len) console.log('当前list长度', len)
wx.cloud.database().collection('junshi-news') wx.cloud.database().collection('gdxy')
.skip(len)
.get()
.then(res => {
wx.hideLoading()
console.log('新闻列表请求成功:', res)
let datalist = res.data
if (datalist.length <= 0) {
wx.showToast({
title: '数据全部加载完毕',
icon: 'none'
})
}
this.setData({
news_list: this.data.news_list.concat(res.data),
})
})
.catch(res => {
console.log('新闻列表请求失败', res)
})
} else if (index == 5) {
wx.showLoading({
title: '加载中...',
})
let len = this.data.news_list.length
console.log('当前list长度', len)
wx.cloud.database().collection('zhxy')
.skip(len)
.get()
.then(res => {
wx.hideLoading()
console.log('新闻列表请求成功:', res)
let datalist = res.data
if (datalist.length <= 0) {
wx.showToast({
title: '数据全部加载完毕',
icon: 'none'
})
}
this.setData({
news_list: this.data.news_list.concat(res.data),
})
})
.catch(res => {
console.log('新闻列表请求失败', res)
})
} else if (index == 6) {
wx.showLoading({
title: '加载中...',
})
let len = this.data.news_list.length
console.log('当前list长度', len)
wx.cloud.database().collection('ysxy')
.skip(len)
.get()
.then(res => {
wx.hideLoading()
console.log('新闻列表请求成功:', res)
let datalist = res.data
if (datalist.length <= 0) {
wx.showToast({
title: '数据全部加载完毕',
icon: 'none'
})
}
this.setData({
news_list: this.data.news_list.concat(res.data),
})
})
.catch(res => {
console.log('新闻列表请求失败', res)
})
} else if (index == 7) {
wx.showLoading({
title: '加载中...',
})
let len = this.data.news_list.length
console.log('当前list长度', len)
wx.cloud.database().collection('rwxy')
.skip(len) .skip(len)
.get() .get()
.then(res => { .then(res => {
@ -164,7 +247,7 @@ Page({
}, },
// 1获取被点击的标题身上的索引 // 1获取被点击的标题身上的索引
// 2给data中的currentIndex赋值就可以了 // 2给data中的currentIndex赋值就可以了
// 3根据不同的索引来渲染右侧的商品内容 // 3根据不同的索引来渲染底部的内容
handleItemTap(e) { handleItemTap(e) {
this.setData({ this.setData({
news_list: [] news_list: []
@ -176,11 +259,12 @@ Page({
selectIndex: index selectIndex: index
}) })
}, },
lunboDetail(event) { // lunboDetail(event) {
wx.navigateTo({ // wx.navigateTo({
url: '/pages/news-detail/news-detail?id=' + event.currentTarget.dataset.id + '&currentIndex=' + 5, // url: '/pages/news-detail/news-detail?id=' + event.currentTarget.dataset.id + '&currentIndex=' + 9,
}) // })
}, // },
// 点击事件-去往详情页 // 点击事件-去往详情页
gotoDetail(event) { gotoDetail(event) {
wx.navigateTo({ wx.navigateTo({

View File

@ -49,8 +49,10 @@
</view> </view>
<!-- 发布单位与发布时间 --> <!-- 发布单位与发布时间 -->
<view class="publish"> <view class="publish">
<view class="publisher">{{item.news_author}}</view> <!-- <view class="publisher">{{item.news_author}}</view> -->
<view class="create-time">{{item.news_date}}</view> <view wx:if="{{item.news_date != 'None'}}">
<view class="create-time">{{item.news_date}}</view>
</view>
</view> </view>
</view> </view>
</view> </view>