71 lines
2.0 KiB
JavaScript
71 lines
2.0 KiB
JavaScript
|
|
const app = getApp()
|
||
|
|
|
||
|
|
Page({
|
||
|
|
data: {
|
||
|
|
timeRanges: ['今日', '本周', '自定义区间'],
|
||
|
|
activeTimeRange: 0,
|
||
|
|
contentTypes: ['单词', '句子'],
|
||
|
|
activeContentType: 0,
|
||
|
|
modes: ['中文 -> 英文拼写', '英文 -> 中文释义', '英文挖空填空'],
|
||
|
|
activeMode: 0,
|
||
|
|
onlyReview: true,
|
||
|
|
shuffle: false,
|
||
|
|
questionCount: 30,
|
||
|
|
},
|
||
|
|
onLoad() {
|
||
|
|
const plan = app.globalData.reviewPlan
|
||
|
|
this.setData({
|
||
|
|
activeTimeRange: plan.timeRangeIndex,
|
||
|
|
activeContentType: plan.contentTypeIndex,
|
||
|
|
activeMode: plan.modeIndex,
|
||
|
|
onlyReview: plan.onlyReview,
|
||
|
|
shuffle: plan.shuffle,
|
||
|
|
questionCount: plan.questionCount,
|
||
|
|
})
|
||
|
|
},
|
||
|
|
persistPatch(patch) {
|
||
|
|
app.globalData.reviewPlan = { ...app.globalData.reviewPlan, ...patch }
|
||
|
|
},
|
||
|
|
setTimeRange(e) {
|
||
|
|
const activeTimeRange = Number(e.currentTarget.dataset.index)
|
||
|
|
this.setData({ activeTimeRange })
|
||
|
|
this.persistPatch({ timeRangeIndex: activeTimeRange })
|
||
|
|
},
|
||
|
|
setContentType(e) {
|
||
|
|
const activeContentType = Number(e.currentTarget.dataset.index)
|
||
|
|
this.setData({ activeContentType })
|
||
|
|
this.persistPatch({ contentTypeIndex: activeContentType })
|
||
|
|
},
|
||
|
|
setMode(e) {
|
||
|
|
const activeMode = Number(e.currentTarget.dataset.index)
|
||
|
|
this.setData({ activeMode })
|
||
|
|
this.persistPatch({ modeIndex: activeMode })
|
||
|
|
},
|
||
|
|
toggleOnlyReview() {
|
||
|
|
const onlyReview = !this.data.onlyReview
|
||
|
|
this.setData({ onlyReview })
|
||
|
|
this.persistPatch({ onlyReview })
|
||
|
|
},
|
||
|
|
toggleShuffle() {
|
||
|
|
const shuffle = !this.data.shuffle
|
||
|
|
this.setData({ shuffle })
|
||
|
|
this.persistPatch({ shuffle })
|
||
|
|
},
|
||
|
|
onQuestionCountInput(e) {
|
||
|
|
const questionCount = e.detail.value
|
||
|
|
this.setData({ questionCount })
|
||
|
|
this.persistPatch({ questionCount })
|
||
|
|
},
|
||
|
|
startReview() {
|
||
|
|
app.globalData.reviewSession = {
|
||
|
|
deck: [],
|
||
|
|
currentIndex: 0,
|
||
|
|
correctCount: 0,
|
||
|
|
wrongCount: 0,
|
||
|
|
completed: false,
|
||
|
|
currentAnswer: '',
|
||
|
|
}
|
||
|
|
wx.navigateTo({ url: '/pages/review-session/review-session' })
|
||
|
|
},
|
||
|
|
})
|