From 282306b9196ee99484d08f55dbd034fcc8b228c2 Mon Sep 17 00:00:00 2001 From: Blizzard Date: Fri, 31 Jul 2026 14:45:29 +0800 Subject: [PATCH] =?UTF-8?q?feat(fe):=20=E9=A6=96=E9=A1=B5=E6=9C=80?= =?UTF-8?q?=E8=BF=91=E8=AE=B0=E5=BD=95=E5=8F=AA=E7=95=99=E6=9C=80=E6=96=B0?= =?UTF-8?q?6=E6=9D=A1=20+=20=E6=9F=A5=E7=9C=8B=E5=85=A8=E9=83=A8=E5=85=A5?= =?UTF-8?q?=E5=8F=A3=EF=BC=8C=E5=8E=BB=E6=8E=89=E6=97=A0=E9=99=90=E6=BB=9A?= =?UTF-8?q?=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 首页是速览,记录多了不该无限加载。固定拉最新 6 条,有更多就露出 「查看全部记录 ›」跳到能分页筛选的全部记录页;移除滚动分页/加载更多。 Co-Authored-By: Claude Opus 5 --- pets-fe/pages/home/home.js | 16 ++++++++-------- pets-fe/pages/home/home.wxml | 5 ++--- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/pets-fe/pages/home/home.js b/pets-fe/pages/home/home.js index cb9c9f0..c7491b6 100644 --- a/pets-fe/pages/home/home.js +++ b/pets-fe/pages/home/home.js @@ -23,7 +23,8 @@ function fmtWhen(iso) { return d.getMonth() + 1 + '月' + d.getDate() + '日'; } -const TL_PAGE = 10; +// 首页最近记录只是速览,固定最新几条,翻全量去「全部记录」页,避免首页无限滚 +const TL_LIMIT = 6; Page({ data: { @@ -38,7 +39,6 @@ Page({ needNextPlan: false, monthCost: 0, timeline: [], - tlPage: 1, hasMore: false, }, onLoad() { @@ -127,11 +127,11 @@ Page({ .then((b) => this.setData({ monthCost: (b && b.total) || 0 })) .catch(() => this.setData({ monthCost: 0 })); }, - loadTimeline(page) { + loadTimeline() { const id = store.currentPetId(); if (!id) return; api - .getRecords(id, { page, pageSize: TL_PAGE }) + .getRecords(id, { page: 1, pageSize: TL_LIMIT }) .then((res) => { const list = (res.list || []).map((r) => ({ id: r.id, @@ -142,13 +142,13 @@ Page({ image: r.image_url || '', timeText: fmtWhen(r.occurred_at), })); - const merged = page === 1 ? list : this.data.timeline.concat(list); - this.setData({ timeline: merged, tlPage: page, hasMore: merged.length < (res.total || 0) }); + // 有更多就露出「查看全部」入口,跳到能分页筛选的全部记录页 + this.setData({ timeline: list, hasMore: (res.total || 0) > list.length }); }) .catch(() => {}); }, - loadMore() { - if (this.data.hasMore) this.loadTimeline(this.data.tlPage + 1); + goHistory() { + wx.navigateTo({ url: '/pages/history/history' }); }, previewImage(e) { const url = e.currentTarget.dataset.url; diff --git a/pets-fe/pages/home/home.wxml b/pets-fe/pages/home/home.wxml index 87e37a2..7ac843e 100644 --- a/pets-fe/pages/home/home.wxml +++ b/pets-fe/pages/home/home.wxml @@ -2,8 +2,7 @@ - + @@ -110,7 +109,7 @@ 还没有记录。点上面的「记一笔」开始, 体重趋势和健康洞察都会从这些记录里长出来。 - 加载更多 + 查看全部记录 ›