This commit is contained in:
Alex-larget
2026-03-24 15:44:08 +08:00
parent 346e8ab057
commit 28ad08da84
62 changed files with 814 additions and 840 deletions

View File

@@ -33,16 +33,12 @@ Page({
hasFullBook: false,
readCount: 0,
// 书籍数据
totalSections: 62,
// 书籍数据totalSections 来自 book/parts初始用 app.getTotalSections() 兜底)
totalSections: 0, // onLoad 后由 loadBookData 更新
bookData: [],
// 推荐章节
featuredSections: [
{ id: '1.1', title: '荷包:电动车出租的被动收入模式', tag: '免费', tagClass: 'tag-free', part: '真实的人' },
{ id: '3.1', title: '3000万流水如何跑出来', tag: '热门', tagClass: 'tag-pink', part: '真实的行业' },
{ id: '8.1', title: '流量杠杆:抖音、Soul、飞书', tag: '推荐', tagClass: 'tag-purple', part: '真实的赚钱' }
],
// 推荐章节(来自 recommended/hot API初始为空避免占位错误
featuredSections: [],
// Banner 推荐(优先用 recommended API 第一条,回退 latest-chapters
bannerSection: null,
@@ -277,21 +273,21 @@ Page({
if (res?.success) {
const total = res.totalSections ?? 0
const parts = res.parts || []
app.globalData.totalSections = total || 62
app.globalData.totalSections = (total != null && total > 0) ? total : app.getTotalSections()
this.setData({
totalSections: app.globalData.totalSections,
partCount: parts.length || 5
})
}
} catch (e) {
this.setData({ totalSections: app.globalData.totalSections || 62, partCount: 5 })
this.setData({ totalSections: app.getTotalSections(), partCount: 5 })
}
},
// 更新用户状态(已读数 = 用户实际打开过的章节数,仅统计有权限阅读的)
updateUserStatus() {
const { isLoggedIn, hasFullBook, purchasedSections } = app.globalData
const readCount = Math.min(app.getReadCount(), this.data.totalSections || 62)
const readCount = Math.min(app.getReadCount(), this.data.totalSections || app.getTotalSections())
this.setData({
isLoggedIn,
hasFullBook,