feat(fe): 首页最近记录只留最新6条 + 查看全部入口,去掉无限滚动

首页是速览,记录多了不该无限加载。固定拉最新 6 条,有更多就露出
「查看全部记录 ›」跳到能分页筛选的全部记录页;移除滚动分页/加载更多。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Blizzard
2026-07-31 14:45:29 +08:00
parent 2f2757267e
commit 282306b919
2 changed files with 10 additions and 11 deletions
+8 -8
View File
@@ -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;
+2 -3
View File
@@ -2,8 +2,7 @@
<view class="top-bar on-band"><pet-switch bind:add="onAddPet"></pet-switch></view>
<scroll-view class="page-scroll" scroll-y="{{true}}" enhanced="{{true}}" show-scrollbar="{{false}}"
bindscrolltolower="loadMore">
<scroll-view class="page-scroll" scroll-y="{{true}}" enhanced="{{true}}" show-scrollbar="{{false}}">
<view class="page-body">
<!-- 门面:宠物名片。点进去编辑档案 -->
<view class="card hero-card" bindtap="onHeroTap">
@@ -110,7 +109,7 @@
<view class="empty lg">还没有记录。点上面的「记一笔」开始,
体重趋势和健康洞察都会从这些记录里长出来。</view>
</view>
<view wx:if="{{hasMore}}" class="tl-more" bindtap="loadMore">加载更多</view>
<view wx:if="{{hasMore}}" class="tl-more" bindtap="goHistory">查看全部记录 </view>
</view>
</scroll-view>