gengxin
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
const memoryCards = require('../../data/memoryCards')
|
||||
const {
|
||||
getProgress,
|
||||
getSettings,
|
||||
saveSettings,
|
||||
} = require('../../utils/storage')
|
||||
const {
|
||||
getCollectedMemories,
|
||||
} = require('../../utils/memoryCollection')
|
||||
const { chapterRoute } = require('../../utils/chapterRoute')
|
||||
|
||||
function twoDigits(value) {
|
||||
return String(value).padStart(2, '0')
|
||||
}
|
||||
|
||||
Page({
|
||||
data: {
|
||||
memories: [],
|
||||
memoryCount: 0,
|
||||
fontScale: 'large',
|
||||
},
|
||||
|
||||
onShow() {
|
||||
const progress = getProgress()
|
||||
const settings = getSettings()
|
||||
const memories = getCollectedMemories(progress, memoryCards).map(
|
||||
(memory, index) => ({
|
||||
...memory,
|
||||
chapterLabel: `第${twoDigits(memory.chapterNumber)}回`,
|
||||
pageLabel: `第${index + 1}页`,
|
||||
characterInitial: memory.characterName.slice(0, 1),
|
||||
}),
|
||||
)
|
||||
this.setData({
|
||||
memories,
|
||||
memoryCount: memories.length,
|
||||
fontScale: settings.fontScale === 'xlarge' ? 'xlarge' : 'large',
|
||||
})
|
||||
},
|
||||
|
||||
goBack() {
|
||||
wx.reLaunch({ url: '/pages/home/home' })
|
||||
},
|
||||
|
||||
openCatalog() {
|
||||
wx.navigateTo({ url: '/pages/catalog/catalog' })
|
||||
},
|
||||
|
||||
openChapter(event) {
|
||||
const chapter = Number(event.currentTarget.dataset.chapter) || 1
|
||||
wx.navigateTo({
|
||||
url: chapterRoute(chapter),
|
||||
})
|
||||
},
|
||||
|
||||
toggleFont() {
|
||||
const fontScale = this.data.fontScale === 'large' ? 'xlarge' : 'large'
|
||||
const settings = getSettings()
|
||||
settings.fontScale = fontScale
|
||||
saveSettings(settings)
|
||||
this.setData({ fontScale })
|
||||
},
|
||||
|
||||
onShareAppMessage() {
|
||||
return {
|
||||
title: '我的桂香岁月:饭桌边,也有值得带回家说的话',
|
||||
path: '/pages/home/home',
|
||||
}
|
||||
},
|
||||
|
||||
onShareTimeline() {
|
||||
return {
|
||||
title: '我的桂香岁月:饭桌边,也有值得带回家说的话',
|
||||
query: '',
|
||||
}
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user