From a151096acb1e80125dd6ac2885f6d53009e4e5fa Mon Sep 17 00:00:00 2001 From: link_1999 <1402246900@qq.com> Date: Sun, 29 May 2022 14:34:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E8=87=B3?= =?UTF-8?q?=20'=E6=96=B0=E9=97=BB=E5=B0=8F=E7=A8=8B=E5=BA=8F/pages/home'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 新闻小程序/pages/home/home.js | 118 +++++++++++++++++++++++++++----- 新闻小程序/pages/home/home.wxml | 6 +- 2 files changed, 105 insertions(+), 19 deletions(-) diff --git a/新闻小程序/pages/home/home.js b/新闻小程序/pages/home/home.js index d580b3b..801c04f 100644 --- a/新闻小程序/pages/home/home.js +++ b/新闻小程序/pages/home/home.js @@ -4,18 +4,23 @@ Page({ //存放轮播图数据的列表 lunboList: [], msgList: [ - { title: "上海今日全市进行抗原检测 明日全市进行核酸检测" }, - { title: "苏州发现奥密克戎新变异株 与全球已知毒株均不同源" }, - { title: "美工作组抵华 参与东航事故调查" }, - { title: "上海昨日新增本土确诊425例、无症状8581例" }, + { title: "“奋斗的青春最美丽”————省政府奖学金获得者沈卓玥" }, + { title: "学校召开“双高计划”专业群中期验收绩效评价工作会议" }, + { title: "习近平勉励广大青年:牢记党的教诲 立志民族复兴" }, + { title: "同心抗疫 “职”面未来——智慧学院举办线上宣讲会" }, + ], + topMenuList: [ + "路桥学院", "汽车学院", + "海运学院", "航空学院", + "轨道学院", "智慧学院", + "运输学院", "人文学院", ], - topMenuList: ["内地新闻", "香港新闻", "两岸新闻", "国际新闻", "军事新闻"], news_list: [], selectIndex: 0, }, onLoad: function (options) { // 获取轮播图数据 - wx.cloud.database().collection('lunbotu-news').get() + wx.cloud.database().collection('zjjt_lbt').get() .then(res => { // console.log('轮播图数据:', res) this.setData({ @@ -36,7 +41,7 @@ Page({ }) let len = this.data.news_list.length console.log('当前list长度', len) - wx.cloud.database().collection('nd-news') + wx.cloud.database().collection('lqxy') .skip(len) .get() .then(res => { @@ -62,7 +67,7 @@ Page({ }) let len = this.data.news_list.length console.log('当前list长度', len) - wx.cloud.database().collection('xg-news') + wx.cloud.database().collection('qcxy') .skip(len) .get() .then(res => { @@ -88,7 +93,7 @@ Page({ }) let len = this.data.news_list.length console.log('当前list长度', len) - wx.cloud.database().collection('tw-news') + wx.cloud.database().collection('hyxy') .skip(len) .get() .then(res => { @@ -114,7 +119,7 @@ Page({ }) let len = this.data.news_list.length console.log('当前list长度', len) - wx.cloud.database().collection('gj-news') + wx.cloud.database().collection('hkxy') .skip(len) .get() .then(res => { @@ -140,7 +145,85 @@ Page({ }) let len = this.data.news_list.length 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) .get() .then(res => { @@ -164,7 +247,7 @@ Page({ }, // 1获取被点击的标题身上的索引 // 2给data中的currentIndex赋值就可以了 - // 3根据不同的索引来渲染右侧的商品内容 + // 3根据不同的索引来渲染底部的内容 handleItemTap(e) { this.setData({ news_list: [] @@ -176,11 +259,12 @@ Page({ selectIndex: index }) }, - lunboDetail(event) { - wx.navigateTo({ - url: '/pages/news-detail/news-detail?id=' + event.currentTarget.dataset.id + '¤tIndex=' + 5, - }) - }, + // lunboDetail(event) { + // wx.navigateTo({ + // url: '/pages/news-detail/news-detail?id=' + event.currentTarget.dataset.id + '¤tIndex=' + 9, + // }) + // }, + // 点击事件-去往详情页 gotoDetail(event) { wx.navigateTo({ diff --git a/新闻小程序/pages/home/home.wxml b/新闻小程序/pages/home/home.wxml index 459e903..4bed9dd 100644 --- a/新闻小程序/pages/home/home.wxml +++ b/新闻小程序/pages/home/home.wxml @@ -49,8 +49,10 @@ - {{item.news_author}} - {{item.news_date}} + + + {{item.news_date}} + \ No newline at end of file