From 9cff70c1ef014da23271835df8cfe27d0d123da1 Mon Sep 17 00:00:00 2001
From: link_1999 <1402246900@qq.com>
Date: Wed, 6 Apr 2022 20:21:47 +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 | 12 ++++---
新闻小程序/pages/home/home.wxml | 38 ++++++++++++++++-----
新闻小程序/pages/home/home.wxss | 59 ++++++++++++++++++++++++++++-----
3 files changed, 88 insertions(+), 21 deletions(-)
diff --git a/新闻小程序/pages/home/home.js b/新闻小程序/pages/home/home.js
index d3cb6dc..6750a6b 100644
--- a/新闻小程序/pages/home/home.js
+++ b/新闻小程序/pages/home/home.js
@@ -7,8 +7,9 @@ Page({
{ title: "上海今日全市进行抗原检测 明日全市进行核酸检测" },
{ title: "苏州发现奥密克戎新变异株 与全球已知毒株均不同源" },
{ title: "美工作组抵华 参与东航事故调查" },
+ { title: "上海昨日新增本土确诊425例、无症状8581例" },
],
- list: [],
+ news_list: [],
},
onLoad: function (options) {
// 获取轮播图数据
@@ -37,14 +38,14 @@ Page({
wx.showLoading({
title: '加载中...',
})
- let len = this.data.list.length
+ let len = this.data.news_list.length
console.log('当前list长度', len)
wx.cloud.database().collection('neidi-news')
.skip(len)
.get()
.then(res => {
wx.hideLoading()
- // console.log('请求成功', res)
+ console.log('新闻列表请求成功:', res)
let datalist = res.data
if (datalist.length <= 0) {
wx.showToast({
@@ -53,11 +54,12 @@ Page({
})
}
this.setData({
- list: this.data.list.concat(res.data)
+ news_list: this.data.news_list.concat(res.data),
+ news_image: res.data.news_img,
})
})
.catch(res => {
- console.log('请求失败', res)
+ console.log('新闻列表请求失败', res)
})
},
/**
diff --git a/新闻小程序/pages/home/home.wxml b/新闻小程序/pages/home/home.wxml
index 5aca49e..d3017e2 100644
--- a/新闻小程序/pages/home/home.wxml
+++ b/新闻小程序/pages/home/home.wxml
@@ -1,6 +1,6 @@
-
+
{{item.title}}
@@ -8,6 +8,15 @@
+
+
+ 内地新闻
+ 香港新闻
+ 台湾新闻
+ 国际新闻
+ 军事新闻
+
+
@@ -17,12 +26,25 @@
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+ {{item.news_title}}
- {{item.news_title}}
- {{item.news_date}}----------{{item.news_author}}
+
+
+
+ {{item.news_author}}
+ {{item.news_date}}
+
+
-
\ No newline at end of file
+
+
\ No newline at end of file
diff --git a/新闻小程序/pages/home/home.wxss b/新闻小程序/pages/home/home.wxss
index 29205da..4e3e892 100644
--- a/新闻小程序/pages/home/home.wxss
+++ b/新闻小程序/pages/home/home.wxss
@@ -30,19 +30,62 @@ swiper image {
align-items: center;
color: white
}
+/* 新闻板块导航栏 */
+.types {
+ width: 100%;
+ height: auto;
+ white-space: nowrap;
+ border-bottom: 1px solid;
+ border-bottom-color: black;
+ background-color: rgba(153, 151, 151, 0.151);
+}
+.type-item {
+ font-size: 18px;
+ width: rpx;
+ display: inline-block;
+ margin: 10rpx 20rpx;
+}
+
+
/* 新闻列表 */
+.news-list {
+ background-color: rgba(128, 128, 128, 0.137);
+}
.newsItem {
- border: 1px solid black;
- margin: 20rpx;
- height: 150rpx;
- background-color: white;
+ padding: 30rpx 30rpx 30rpx 30rpx;
}
+ /* 新闻图片 */
+.news_image {
+ width: 250rpx;
+ height: 175rpx;
+}
+ /* 新闻标题 */
.news_title {
- font-size: larger;
+ font-size: 20px;
+ margin-left: 15rpx;
}
-.news_date {
- font-size: small;
+ /* 发布单位 */
+.publish {
+ display: flex;
+ flex-direction: row;
+ font-size: 14px;
color: grey;
+ margin-top: 10rpx;
+ border-bottom: 1px solid;
+ border-bottom-color: rgb(163, 147, 147);
+}
+ /* 发布时间 */
+.create-time {
+ margin-left: 30rpx;
+ margin-bottom: 20rpx;
+}
+ /* 标题图文框 */
+.pic-words {
+ display: flex;
+ flex-direction: row;
+}
+ /* 标题 */
+.title-words {
+ width: 500rpx;
}
-