From b0d3372b7c7a9ce183ae6ceb158f2bb03aaca3bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=93=E6=B4=81?= <209192278@qq.com> Date: Sun, 26 Feb 2023 22:10:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=8D=A2=E6=96=B0=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/news/news.vue | 11 ++++++---- components/productsByTime/productsByTime.vue | 21 +++++++++++--------- service/request.js | 2 +- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/components/news/news.vue b/components/news/news.vue index d3f0f81..3766bb7 100644 --- a/components/news/news.vue +++ b/components/news/news.vue @@ -43,11 +43,14 @@ }).then(res => { let newsData = res.data.data console.log('新闻', newsData); - for (const item of newsData) { - item.pub_time_str = dateFormat(item.pub_time_str) + if (newsData) { + for (const item of newsData) { + item.pub_time_str = dateFormat(item.pub_time_str) + } + // newsData = newsData.slice(0, 3) + this.newsList = newsData } - // newsData = newsData.slice(0, 3) - this.newsList = newsData + }).finally(_ => {}) }, // 跳转到新闻详情页 diff --git a/components/productsByTime/productsByTime.vue b/components/productsByTime/productsByTime.vue index beaa698..1099077 100644 --- a/components/productsByTime/productsByTime.vue +++ b/components/productsByTime/productsByTime.vue @@ -59,16 +59,19 @@ pageNum: this.pageNum }).then(res => { let tags = res.data.data - for (const item of tags) { - let tag = item.tags - this.tagsArray = tag.split(',') - item.tags = this.tagsArray[0] + if (tags) { + for (const item of tags) { + let tag = item.tags + this.tagsArray = tag.split(',') + item.tags = this.tagsArray[0] + } + this.$emit("getTimeLength", tags.length); + // 用于触底刷新 为数据赋值:通过展开运算符的形式,进行新旧数据的拼接 + this.productList = [...this.productList, ...res.data.data] + //这用于上架时间和点赞量的数据切换 + // this.productList = res.data.data } - this.$emit("getTimeLength", tags.length); - // 用于触底刷新 为数据赋值:通过展开运算符的形式,进行新旧数据的拼接 - this.productList = [...this.productList, ...res.data.data] - //这用于上架时间和点赞量的数据切换 - // this.productList = res.data.data + }).finally(_ => { }) diff --git a/service/request.js b/service/request.js index f5e760a..4e1cebe 100644 --- a/service/request.js +++ b/service/request.js @@ -1,4 +1,4 @@ -const serverHost = 'https://pupil.hchyun.com/api' // https://api-ugo-web.itheima.net' +const serverHost = 'https://www.foodtops.cn/api' // https://api-ugo-web.itheima.net' function isOutTime(res) { if (res.data.message === '请先登录') { uni.showToast('登录信息已过期,请重新登录')