Commit a489113d authored by Facius's avatar Facius

feat: 学练记录

parent de370eef
...@@ -78,6 +78,7 @@ ...@@ -78,6 +78,7 @@
:chartData="chartData" :chartData="chartData"
:canvas2d="true" :canvas2d="true"
:inScrollView="true" :inScrollView="true"
fontColor="#9EA5BB"
canvasId="scroll-viewid" canvasId="scroll-viewid"
:pageScrollTop="pageScrollTop" :pageScrollTop="pageScrollTop"
background="none" background="none"
...@@ -149,7 +150,20 @@ export default { ...@@ -149,7 +150,20 @@ export default {
}, },
chartData: { chartData: {
categories: [], categories: [],
series: [], series: [
{
name: '答题数',
pointShape: 'circle',
legendShape: 'circle',
data: [],
},
{
name: '正确数',
pointShape: 'circle',
legendShape: 'circle',
data: [],
},
],
}, },
} }
}, },
...@@ -179,33 +193,33 @@ export default { ...@@ -179,33 +193,33 @@ export default {
}, },
methods: { methods: {
chartInit() { chartInit() {
this.chartData.series = [ // this.chartData.series = [
{ // {
name: '答题数', // name: '答题数',
pointShape: 'circle', // pointShape: 'circle',
legendShape: 'circle', // legendShape: 'circle',
data: [ // data: [
[10000, 55], // 【日期, 数值】 // [10000, 55], // 【日期, 数值】
[30000, 25], // [30000, 25],
[50000, 55], // [50000, 55],
[70000, 25], // [70000, 25],
[90000, 55], // [90000, 55],
], // ],
}, // },
{ // {
name: '正确率', // name: '正确数',
pointShape: 'circle', // pointShape: 'circle',
legendShape: 'circle', // legendShape: 'circle',
data: [ // data: [
[0, 25], // [0, 25],
[20000, 55], // [20000, 55],
[40000, 25], // [40000, 25],
[60000, 55], // [60000, 55],
[80000, 25], // [80000, 25],
], // ],
}, // },
] // ]
this.studyRecord() this.studyRecord(this.nearlySevenDays())
}, },
// 每日一练统计 // 每日一练统计
everyTaskList(year, month) { everyTaskList(year, month) {
...@@ -232,31 +246,52 @@ export default { ...@@ -232,31 +246,52 @@ export default {
}) })
}, },
// 练习分析 // 练习分析
studyRecord(start, end) { studyRecord(params) {
var params = {}
if (!start || !end) {
// 近七天
end = new Date().getTime()
start = new Date().setDate(new Date().getDay() - 6)
}
console.log(
'---------start---------',
start,
'---------start---------',
end
)
params = {
startDate: this.$u.timeFormat(start, 'yyyy-mm-dd'),
endDate: this.$u.timeFormat(end, 'yyyy-mm-dd'),
}
this.$u.api this.$u.api
.studyRecord(this.questionWarehouseId, params) .studyRecord(this.questionWarehouseId, params)
.then((res) => { .then((res) => {
console.log('----------studyRecord------------', res) console.log('----------studyRecord------------', res)
// this.days = []
// for (var item of res) { this.chartData.series[0].data = []
// this.days.push(item.time.replace(/\-0/g, '\-')) this.chartData.series[1].data = []
// } for (var item in res) {
// this.chartData.series[0].data.push([20210801, res[item].totalCount])
// this.chartData.series[0].data.push([20210802, res[item].totalCount])
// this.chartData.series[0].data.push([20210805, res[item].totalCount])
// this.chartData.series[0].data.push([20210804, res[item].totalCount])
// this.chartData.series[0].data.push([20210806, res[item].totalCount])
// this.chartData.series[0].data.push([20210807, res[item].totalCount])
// this.chartData.series[0].data.push([20210808, res[item].totalCount])
// this.chartData.series[0].data.push([20210809, res[item].totalCount])
// this.chartData.series[0].data.push([20210810, res[item].totalCount])
// this.chartData.series[1].data.push([20210801, res[item].rightCount])
// this.chartData.series[1].data.push([20210802, res[item].rightCount])
// this.chartData.series[1].data.push([20210803, res[item].rightCount])
// this.chartData.series[1].data.push([20210804, res[item].rightCount])
// this.chartData.series[1].data.push([20210805, res[item].rightCount])
// this.chartData.series[1].data.push([20210806, res[item].rightCount])
// this.chartData.series[1].data.push([20210807, res[item].rightCount])
// this.chartData.series[1].data.push([20210808, res[item].rightCount])
// this.chartData.series[1].data.push([20210809, res[item].rightCount])
this.chartData.categories.push(item.replace(/\-/g, '.'))
// this.chartData.categories.push(item.replace(/\-/g, '.'))
// this.chartData.categories.push(item.replace(/\-/g, '.'))
// this.chartData.categories.push(item.replace(/\-/g, '.'))
// this.chartData.categories.push(item.replace(/\-/g, '.'))
this.chartData.series[0].data.push(res[item].totalCount)
// this.chartData.series[0].data.push(res[item].totalCount)
// this.chartData.series[0].data.push(res[item].totalCount)
// this.chartData.series[0].data.push(res[item].totalCount)
// this.chartData.series[0].data.push(res[item].totalCount)
this.chartData.series[1].data.push(res[item].rightCount)
// this.chartData.series[1].data.push(res[item].rightCount)
// this.chartData.series[1].data.push(res[item].rightCount)
// this.chartData.series[1].data.push(res[item].rightCount)
// this.chartData.series[1].data.push(res[item].totalCount)
}
}) })
.catch((err) => { .catch((err) => {
console.log(err) console.log(err)
...@@ -294,24 +329,34 @@ export default { ...@@ -294,24 +329,34 @@ export default {
handleChangeMonth(e) { handleChangeMonth(e) {
this.everyTaskList(e.year, e.month) this.everyTaskList(e.year, e.month)
}, },
handleClick() {},
handleClickRange(index) { handleClickRange(index) {
for (var item of this.items) { for (var item of this.items) {
item.selected = false item.selected = false
} }
this.items[index].selected = true this.items[index].selected = true
if (index == 2) { this.showSelect = index == 2
this.showSelect = true var param = {}
} else { if (index == 0) {
this.showSelect = false param = this.nearlySevenDays()
// 修改图表 } else if (index == 1) {
// ... param = this.nearlyThirtyDays()
} else if (index == 2) {
console.log(this.rangeDay0, this.rangeDay1)
param = {
startDate: this.rangeDay0,
endDate: this.rangeDay1,
}
} }
this.studyRecord(param)
}, },
handleConform(e, index) { handleConform(e, index) {
this['rangeDay' + index] = e.target.value this['rangeDay' + index] = e.target.value
console.log(this.rangeDay0, this.rangeDay1)
// 修改图表 // 修改图表
// ... this.studyRecord({
startDate: this.rangeDay0,
endDate: this.rangeDay1,
})
}, },
getDate() { getDate() {
return this.$u.timeFormat(new Date().getTime(), 'yyyy-mm-dd') return this.$u.timeFormat(new Date().getTime(), 'yyyy-mm-dd')
...@@ -321,6 +366,21 @@ export default { ...@@ -321,6 +366,21 @@ export default {
this.currentLoadStatus == 'loading' this.currentLoadStatus == 'loading'
this.queryExamRecord() this.queryExamRecord()
}, },
nearlySevenDays() {
return this.nearlyDays(5)
},
nearlyThirtyDays() {
return this.nearlyDays(28)
},
nearlyDays(day) {
var end = new Date().getTime()
var start = new Date().setDate(new Date().getDay() - day)
var params = {
startDate: this.$u.timeFormat(start, 'yyyy-mm-dd'),
endDate: this.$u.timeFormat(end, 'yyyy-mm-dd'),
}
return params
},
}, },
} }
</script> </script>
...@@ -398,7 +458,7 @@ export default { ...@@ -398,7 +458,7 @@ export default {
margin-right: 8rpx; margin-right: 8rpx;
} }
.range-item { .range-item {
margin-left: 30rpx; // margin-left: 30rpx;
font-size: 24rpx; font-size: 24rpx;
color: #9ea5bb; color: #9ea5bb;
background-color: #e8ebf3; background-color: #e8ebf3;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment