Commit a489113d authored by Facius's avatar Facius

feat: 学练记录

parent de370eef
......@@ -78,6 +78,7 @@
:chartData="chartData"
:canvas2d="true"
:inScrollView="true"
fontColor="#9EA5BB"
canvasId="scroll-viewid"
:pageScrollTop="pageScrollTop"
background="none"
......@@ -149,7 +150,20 @@ export default {
},
chartData: {
categories: [],
series: [],
series: [
{
name: '答题数',
pointShape: 'circle',
legendShape: 'circle',
data: [],
},
{
name: '正确数',
pointShape: 'circle',
legendShape: 'circle',
data: [],
},
],
},
}
},
......@@ -179,33 +193,33 @@ export default {
},
methods: {
chartInit() {
this.chartData.series = [
{
name: '答题数',
pointShape: 'circle',
legendShape: 'circle',
data: [
[10000, 55], // 【日期, 数值】
[30000, 25],
[50000, 55],
[70000, 25],
[90000, 55],
],
},
{
name: '正确率',
pointShape: 'circle',
legendShape: 'circle',
data: [
[0, 25],
[20000, 55],
[40000, 25],
[60000, 55],
[80000, 25],
],
},
]
this.studyRecord()
// this.chartData.series = [
// {
// name: '答题数',
// pointShape: 'circle',
// legendShape: 'circle',
// data: [
// [10000, 55], // 【日期, 数值】
// [30000, 25],
// [50000, 55],
// [70000, 25],
// [90000, 55],
// ],
// },
// {
// name: '正确数',
// pointShape: 'circle',
// legendShape: 'circle',
// data: [
// [0, 25],
// [20000, 55],
// [40000, 25],
// [60000, 55],
// [80000, 25],
// ],
// },
// ]
this.studyRecord(this.nearlySevenDays())
},
// 每日一练统计
everyTaskList(year, month) {
......@@ -232,31 +246,52 @@ export default {
})
},
// 练习分析
studyRecord(start, end) {
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'),
}
studyRecord(params) {
this.$u.api
.studyRecord(this.questionWarehouseId, params)
.then((res) => {
console.log('----------studyRecord------------', res)
// this.days = []
// for (var item of res) {
// this.days.push(item.time.replace(/\-0/g, '\-'))
// }
this.chartData.series[0].data = []
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) => {
console.log(err)
......@@ -294,24 +329,34 @@ export default {
handleChangeMonth(e) {
this.everyTaskList(e.year, e.month)
},
handleClick() {},
handleClickRange(index) {
for (var item of this.items) {
item.selected = false
}
this.items[index].selected = true
if (index == 2) {
this.showSelect = true
} else {
this.showSelect = false
// 修改图表
// ...
this.showSelect = index == 2
var param = {}
if (index == 0) {
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) {
this['rangeDay' + index] = e.target.value
console.log(this.rangeDay0, this.rangeDay1)
// 修改图表
// ...
this.studyRecord({
startDate: this.rangeDay0,
endDate: this.rangeDay1,
})
},
getDate() {
return this.$u.timeFormat(new Date().getTime(), 'yyyy-mm-dd')
......@@ -321,6 +366,21 @@ export default {
this.currentLoadStatus == 'loading'
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>
......@@ -398,7 +458,7 @@ export default {
margin-right: 8rpx;
}
.range-item {
margin-left: 30rpx;
// margin-left: 30rpx;
font-size: 24rpx;
color: #9ea5bb;
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