8c7f633541
- var→const/let, function→arrow/class across all 13 JS files - Timer: prototype→class with ES6 getters - plan days: IIFE→Array.from declarative generation - storage/plan: unified formatDate via util.js - Bugfix: getPlanDay now filters by planId (plan switch accuracy) - Bugfix: getTodayRecord searches all months (cross-month boundary) - WXML/WXSS unchanged; public API unchanged
38 lines
737 B
JavaScript
38 lines
737 B
JavaScript
const themeMod = require('../utils/theme')
|
|
|
|
Component({
|
|
data: {
|
|
selected: 0,
|
|
themeStyle: ''
|
|
},
|
|
|
|
lifetimes: {
|
|
attached() {
|
|
const theme = themeMod.getCurrentTheme()
|
|
this.setData({ themeStyle: themeMod.getThemeStyle(theme) })
|
|
}
|
|
},
|
|
|
|
pageLifetimes: {
|
|
show() {
|
|
const theme = themeMod.getCurrentTheme()
|
|
this.setData({ themeStyle: themeMod.getThemeStyle(theme) })
|
|
}
|
|
},
|
|
|
|
methods: {
|
|
switchTab(e) {
|
|
const index = e.currentTarget.dataset.index
|
|
const pages = [
|
|
'/pages/index/index',
|
|
'/pages/records/records',
|
|
'/pages/settings/settings'
|
|
]
|
|
|
|
if (index === this.data.selected) return
|
|
|
|
wx.switchTab({ url: pages[index] })
|
|
}
|
|
}
|
|
})
|