2026-01-14 12:50:00 +08:00
|
|
|
|
const app = getApp()
|
|
|
|
|
|
|
|
|
|
|
|
Page({
|
|
|
|
|
|
data: {
|
2026-01-21 15:49:12 +08:00
|
|
|
|
statusBarHeight: 44,
|
|
|
|
|
|
navBarHeight: 88,
|
|
|
|
|
|
totalSections: 62,
|
2026-02-02 18:16:15 +08:00
|
|
|
|
purchasedCount: 0,
|
|
|
|
|
|
hasFullBook: false,
|
2026-01-21 15:49:12 +08:00
|
|
|
|
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: '真实的赚钱' }
|
|
|
|
|
|
],
|
2026-02-02 18:16:15 +08:00
|
|
|
|
latestSection: { id: '9.14', title: '大健康私域:一个月150万的70后', part: '真实的赚钱' },
|
2026-01-21 15:49:12 +08:00
|
|
|
|
partsList: [
|
2026-01-31 22:37:05 +08:00
|
|
|
|
{ id: 'part-1', number: '01', title: '真实的人', subtitle: '人性观察与社交逻辑' },
|
|
|
|
|
|
{ id: 'part-2', number: '02', title: '真实的行业', subtitle: '社会运作的底层规则' },
|
|
|
|
|
|
{ id: 'part-3', number: '03', title: '真实的错误', subtitle: '错过机会比失败更贵' },
|
|
|
|
|
|
{ id: 'part-4', number: '04', title: '真实的赚钱', subtitle: '所有行业的杠杆结构' },
|
|
|
|
|
|
{ id: 'part-5', number: '05', title: '真实的未来', subtitle: '人与系统的关系' }
|
2026-02-02 18:16:15 +08:00
|
|
|
|
]
|
2026-01-14 12:50:00 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
2026-01-25 19:37:59 +08:00
|
|
|
|
onLoad(options) {
|
2026-02-02 18:16:15 +08:00
|
|
|
|
this.setNavBarHeight()
|
|
|
|
|
|
if (options && options.ref) app.handleReferralCode({ query: options })
|
|
|
|
|
|
this.loadBookData()
|
2026-01-21 15:49:12 +08:00
|
|
|
|
this.updateUserStatus()
|
2026-01-14 12:50:00 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
2026-02-02 18:16:15 +08:00
|
|
|
|
setNavBarHeight() {
|
|
|
|
|
|
const statusBarHeight = app.globalData.statusBarHeight || 44
|
|
|
|
|
|
const navBarHeight = app.globalData.navBarHeight || (statusBarHeight + 44)
|
|
|
|
|
|
this.setData({ statusBarHeight, navBarHeight })
|
2026-01-14 12:50:00 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
2026-02-02 18:16:15 +08:00
|
|
|
|
onShow() {
|
|
|
|
|
|
if (typeof this.getTabBar === 'function' && this.getTabBar()) this.getTabBar().setData({ selected: 0 })
|
|
|
|
|
|
this.setNavBarHeight()
|
|
|
|
|
|
this.updateUserStatus()
|
2026-01-25 19:37:59 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
2026-02-02 18:16:15 +08:00
|
|
|
|
loadBookData() {
|
|
|
|
|
|
app.request('/api/book/all-chapters').then((res) => {
|
|
|
|
|
|
if (res && res.data) this.setData({ totalSections: res.totalSections || 62 })
|
|
|
|
|
|
}).catch(() => {})
|
2026-01-14 12:50:00 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
2026-01-21 15:49:12 +08:00
|
|
|
|
updateUserStatus() {
|
2026-02-02 18:16:15 +08:00
|
|
|
|
const { hasFullBook, purchasedSections } = app.globalData
|
|
|
|
|
|
const total = this.data.totalSections || 62
|
|
|
|
|
|
const count = hasFullBook ? total : (purchasedSections?.length || 0)
|
|
|
|
|
|
this.setData({ hasFullBook, purchasedCount: count })
|
2026-01-25 19:37:59 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
2026-02-02 18:16:15 +08:00
|
|
|
|
goToChapters() { wx.switchTab({ url: '/pages/chapters/chapters' }) },
|
|
|
|
|
|
goToSearch() { wx.navigateTo({ url: '/pages/search/search' }) },
|
2026-01-21 15:49:12 +08:00
|
|
|
|
goToRead(e) {
|
|
|
|
|
|
const id = e.currentTarget.dataset.id
|
2026-02-02 18:16:15 +08:00
|
|
|
|
wx.navigateTo({ url: '/pages/read/read?id=' + (id || '') })
|
2026-01-14 12:50:00 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
2026-02-02 18:16:15 +08:00
|
|
|
|
onPullDownRefresh() {
|
|
|
|
|
|
this.loadBookData()
|
2026-01-21 15:49:12 +08:00
|
|
|
|
this.updateUserStatus()
|
|
|
|
|
|
wx.stopPullDownRefresh()
|
2026-01-14 12:50:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|