|
@@ -28,7 +28,7 @@
|
|
</view>
|
|
</view>
|
|
<view style=" width:100%; margin-top: -30rpx;">
|
|
<view style=" width:100%; margin-top: -30rpx;">
|
|
<qiun-data-charts type="column" :chartData="todayData.studyColumn" :loadingType="4"
|
|
<qiun-data-charts type="column" :chartData="todayData.studyColumn" :loadingType="4"
|
|
- tooltipFormat='tooltipHour' :canvas2d="true" canvasId="canvasId9839618" />
|
|
|
|
|
|
+ tooltipFormat='tooltipHour' :canvas2d="true" canvasId="canvasId9839618"/>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
|
|
|
|
@@ -72,6 +72,14 @@
|
|
computed: {
|
|
computed: {
|
|
...mapState('m_chart', ['todayData']),
|
|
...mapState('m_chart', ['todayData']),
|
|
},
|
|
},
|
|
|
|
+ watch: {
|
|
|
|
+ historyData: {
|
|
|
|
+ handler(newValue){
|
|
|
|
+ this.saveToStudyChart()
|
|
|
|
+ },
|
|
|
|
+ immediate: true
|
|
|
|
+ },
|
|
|
|
+ },
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
//模块名
|
|
//模块名
|
|
@@ -121,9 +129,10 @@
|
|
historyData: {
|
|
historyData: {
|
|
study: [2, 3, 2.5, 3, 2, 1, 3],
|
|
study: [2, 3, 2.5, 3, 2, 1, 3],
|
|
rest: [1, 2, 0.5, 3, 0.5, 3.5, 2],
|
|
rest: [1, 2, 0.5, 3, 0.5, 3.5, 2],
|
|
- exercise: [],
|
|
|
|
- sleep: []
|
|
|
|
- }
|
|
|
|
|
|
+ exercise: [0.1, 0.2, 0.5, 0.3, 0.5, 1.5, 0.2],
|
|
|
|
+ sleep: [8, 9, 8, 8.5, 7.8, 8, 7.6]
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
|
|
};
|
|
};
|
|
},
|
|
},
|
|
@@ -138,16 +147,66 @@
|
|
},
|
|
},
|
|
//点击卡片唤起picker
|
|
//点击卡片唤起picker
|
|
setTime(index) {
|
|
setTime(index) {
|
|
- this.cardCurrent = index
|
|
|
|
- this.setTimePicker = true
|
|
|
|
|
|
+ if (this.moduleData[index].numData === '记录一下') {
|
|
|
|
+ this.cardCurrent = index
|
|
|
|
+ this.setTimePicker = true
|
|
|
|
+ } else {
|
|
|
|
+ uni.$showMsg('今日已记录,明日再来吧')
|
|
|
|
+ }
|
|
|
|
+
|
|
},
|
|
},
|
|
- //确定
|
|
|
|
|
|
+ //记录数据
|
|
pickerConfirm(e) {
|
|
pickerConfirm(e) {
|
|
if (e.value[0] === '0小时') {
|
|
if (e.value[0] === '0小时') {
|
|
this.moduleData[this.cardCurrent].numData = e.value[1]
|
|
this.moduleData[this.cardCurrent].numData = e.value[1]
|
|
} else {
|
|
} else {
|
|
this.moduleData[this.cardCurrent].numData = e.value[0] + e.value[1]
|
|
this.moduleData[this.cardCurrent].numData = e.value[0] + e.value[1]
|
|
}
|
|
}
|
|
|
|
+ //转换为数据记录到图表中
|
|
|
|
+ if (this.moduleData[this.cardCurrent].numData.search('小时') == -1) {
|
|
|
|
+ let timeData = parseFloat(parseInt(this.moduleData[this.cardCurrent].numData.replace('分钟', '')) / 60).toFixed(1)
|
|
|
|
+ console.log(timeData)
|
|
|
|
+ switch (this.cardCurrent) {
|
|
|
|
+ case 0:
|
|
|
|
+ this.historyData.study.push(timeData)
|
|
|
|
+ this.historyData.study.shift()
|
|
|
|
+ break
|
|
|
|
+ case 1:
|
|
|
|
+ this.historyData.rest.push(timeData)
|
|
|
|
+ this.historyData.rest.shift()
|
|
|
|
+ break
|
|
|
|
+ case 2:
|
|
|
|
+ this.historyData.exercise.push(timeData)
|
|
|
|
+ this.historyData.exercise.shift()
|
|
|
|
+ break
|
|
|
|
+ case 3:
|
|
|
|
+ this.historyData.sleep.push(timeData)
|
|
|
|
+ this.historyData.sleep.shift()
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ let timeTemp = this.moduleData[this.cardCurrent].numData.replace('小时', '.').replace('分钟', '').split('.')
|
|
|
|
+ let timeData = parseInt(timeTemp[0]) + parseFloat((timeTemp[1] / 60).toFixed(1))
|
|
|
|
+ console.log(timeData)
|
|
|
|
+ switch (this.cardCurrent) {
|
|
|
|
+ case 0:
|
|
|
|
+ this.historyData.study.push(timeData)
|
|
|
|
+ this.historyData.study.shift()
|
|
|
|
+ break
|
|
|
|
+ case 1:
|
|
|
|
+ this.historyData.rest.push(timeData)
|
|
|
|
+ this.historyData.rest.shift()
|
|
|
|
+ break
|
|
|
|
+ case 2:
|
|
|
|
+ this.historyData.exercise.push(timeData)
|
|
|
|
+ this.historyData.exercise.shift()
|
|
|
|
+ break
|
|
|
|
+ case 3:
|
|
|
|
+ this.historyData.sleep.push(timeData)
|
|
|
|
+ this.historyData.sleep.shift()
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+ }
|
|
uni.$showMsg('记录完成', 1000)
|
|
uni.$showMsg('记录完成', 1000)
|
|
this.setTimePicker = false
|
|
this.setTimePicker = false
|
|
},
|
|
},
|
|
@@ -155,9 +214,6 @@
|
|
pickerCancel() {
|
|
pickerCancel() {
|
|
uni.$showMsg('取消选择', 1000)
|
|
uni.$showMsg('取消选择', 1000)
|
|
this.setTimePicker = false
|
|
this.setTimePicker = false
|
|
- },
|
|
|
|
- stringToNum(){
|
|
|
|
-
|
|
|
|
},
|
|
},
|
|
//记录到图表
|
|
//记录到图表
|
|
saveToStudyChart() {
|
|
saveToStudyChart() {
|
|
@@ -165,17 +221,25 @@
|
|
categories: [],
|
|
categories: [],
|
|
series: [{
|
|
series: [{
|
|
name: '自主学习',
|
|
name: '自主学习',
|
|
- data: []
|
|
|
|
|
|
+ data: this.historyData.study
|
|
}, {
|
|
}, {
|
|
name: '娱乐放松',
|
|
name: '娱乐放松',
|
|
- data: []
|
|
|
|
|
|
+ data: this.historyData.rest
|
|
}]
|
|
}]
|
|
}
|
|
}
|
|
//时间
|
|
//时间
|
|
studyColumn.categories = this.$getRecentDateArray(7)
|
|
studyColumn.categories = this.$getRecentDateArray(7)
|
|
//数据
|
|
//数据
|
|
- studyColumn.series[0].data = this.historyData.study
|
|
|
|
- studyColumn.series[1].data = this.historyData.rest
|
|
|
|
|
|
+ switch (this.cardCurrent) {
|
|
|
|
+ case 0:
|
|
|
|
+ studyColumn.series[0].data = this.historyData.study
|
|
|
|
+ break
|
|
|
|
+ case 1:
|
|
|
|
+ studyColumn.series[1].data = this.historyData.rest
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+ //解除对象指向同一块内存(拷贝)
|
|
|
|
+ // let studyColumnTemp = JSON.parse(JSON.stringify(studyColumn))
|
|
//存储
|
|
//存储
|
|
this.updateStudyColumn(studyColumn)
|
|
this.updateStudyColumn(studyColumn)
|
|
}
|
|
}
|