Commit d79bb612 authored by Facius's avatar Facius

feat: 学练记录页面:日历、记录

parent 7e984544
...@@ -89,6 +89,13 @@ let learnApiFun = function(vm) { ...@@ -89,6 +89,13 @@ let learnApiFun = function(vm) {
// 检查是否具有体验资格 // 检查是否具有体验资格
let checkGetQuestion = async (questionWarehouseId) => let checkGetQuestion = async (questionWarehouseId) =>
await vm.$u.get('/rest/question/checkGetQuestion/' + questionWarehouseId) await vm.$u.get('/rest/question/checkGetQuestion/' + questionWarehouseId)
// 每日一练统计
let everyTaskList = async (questionWarehouseId, params = {}) =>
await vm.$u.get(
'/rest/question/query/everyTaskList/' + questionWarehouseId,
params
)
const learnApi = { const learnApi = {
getQuestion, getQuestion,
getQuestionTotal, getQuestionTotal,
...@@ -111,6 +118,7 @@ let learnApiFun = function(vm) { ...@@ -111,6 +118,7 @@ let learnApiFun = function(vm) {
bindCard, bindCard,
searchQuestion, searchQuestion,
checkGetQuestion, checkGetQuestion,
everyTaskList,
} }
return learnApi return learnApi
} }
......
This diff is collapsed.
...@@ -8,10 +8,10 @@ ...@@ -8,10 +8,10 @@
<view <view
v-if="key == 'result'" v-if="key == 'result'"
:class="['result-text', { passed: passed }]" :class="['result-text', { passed: passed }]"
>{{ resultText }}</view >{{ data[key] }}</view
> >
<view v-else class="content-text">{{ info[key] }}</view> <view v-else class="content-text">{{ data[key] }}</view>
<view class="unit-text">{{ units[key] }}</view> <view v-if="units[key]" class="unit-text">{{ units[key] }}</view>
</view> </view>
</view> </view>
</view> </view>
...@@ -32,26 +32,48 @@ export default { ...@@ -32,26 +32,48 @@ export default {
return {} return {}
}, },
computed: { computed: {
data() {
return {
take: this.take,
point: this.info.point,
result: this.resultText,
}
},
take() {
if (this.info.startDatetime && this.info.endDatetime) {
let timesStart = new Date(
this.info.startDatetime.replace(/\-/g, '/')
).getTime()
let timesEnd = new Date(
this.info.endDatetime.replace(/\-/g, '/')
).getTime()
return Math.ceil((timesEnd - timesStart) / 1000 / 60)
}
return 0
},
timeText() { timeText() {
return this.$u.timeFormat(this.info.date, 'yyyy.mm.dd') return this.info.endDatetime
? this.info.endDatetime.split(' ')[0].replace(/\-/g, '.')
: this.$u.timeFormat(new Date().getTime(), 'yyyy.mm.dd')
}, },
labels() { labels() {
return { return {
time: '模考用时', take: '模考用时',
score: '模考成绩', point: '模考成绩',
result: '是否及格', result: '是否及格',
} }
}, },
units() { units() {
return { return {
time: '分钟', take: '分钟',
score: '分', point: '分',
result: '', result: '',
} }
}, },
passed() { passed() {
// 及格、不及格 // 及格、不及格
return this.info.score >= 60 return this.info.point >= 60
}, },
resultText() { resultText() {
return this.passed ? '及格' : '不及格' return this.passed ? '及格' : '不及格'
...@@ -83,6 +105,7 @@ export default { ...@@ -83,6 +105,7 @@ export default {
padding-top: 16rpx; padding-top: 16rpx;
display: flex; display: flex;
align-items: flex-end; align-items: flex-end;
justify-content: center;
.result-text { .result-text {
font-size: 44rpx; font-size: 44rpx;
color: #fa5a49; color: #fa5a49;
...@@ -103,7 +126,7 @@ export default { ...@@ -103,7 +126,7 @@ export default {
.unit-text { .unit-text {
padding-left: 14rpx; padding-left: 14rpx;
font-weight: 400; font-weight: 400;
margin-bottom: 11rpx; margin-bottom: 12rpx;
} }
} }
} }
......
...@@ -413,8 +413,10 @@ export default { ...@@ -413,8 +413,10 @@ export default {
if (this.info.id) { if (this.info.id) {
// 跳转到学练记录 // 跳转到学练记录
this.$u.route({ this.$u.route({
url: 'pages/learn/record?part=', url: 'pages/learn/record?key=',
key, params: {
key: key,
},
}) })
} else { } else {
this.$refs.uToast.show({ this.$refs.uToast.show({
......
...@@ -16,78 +16,103 @@ ...@@ -16,78 +16,103 @@
<image class="xunzhang-image" :src="xunzhangImage"></image> <image class="xunzhang-image" :src="xunzhangImage"></image>
</view> </view>
<view class="body-view"> <view class="body-view">
<view class="date-view"> <scroll-view
<view class="content-title" id="part-days">每日一练</view> scroll-y="true"
<view class="date-content"></view> class="scroll-view"
</view> @scrolltolower="reachBottom"
<view class="charts-view"> scroll-anchoring
<view class="content-title" id="part-total">练习分析</view> enable-back-to-top
<view class="range-view"> :scroll-into-view="scrollId"
<view class="range-title">日期范围</view> >
<view <view class="date-view">
v-for="(item, index) in items" <view class="content-title" id="part-days">每日一练</view>
:key="index" <view class="date-content">
:class="['range-item', { selected: item.selected }]" <Calendar
@click="handleClickRange(index)" :initialDays="days"
>{{ item.title }}</view @change="handleChangeMonth"
> ></Calendar>
</view>
</view> </view>
<view v-if="showSelect" class="days-select-view"> <view class="charts-view">
<picker <view class="content-title" id="part-total">练习分析</view>
mode="date" <view class="range-view">
:value="rangeDay0" <view class="range-title">日期范围</view>
:end="rangeDay1" <view
@change="handleConform($event, 0)" v-for="(item, index) in items"
> :key="index"
<view class="date-picker-content" hover-class="hover-class"> :class="['range-item', { selected: item.selected }]"
<view class="input-view">{{ rangeDay0 }}</view> @click="handleClickRange(index)"
<u-icon name="arrow-down"></u-icon> >{{ item.title }}</view
</view> >
</picker> </view>
<view class="line-view">-</view> <view v-if="showSelect" class="days-select-view">
<picker <picker
mode="date" mode="date"
:value="rangeDay1" :value="rangeDay0"
:start="rangeDay0" :end="rangeDay1"
:end="getDate()" @change="handleConform($event, 0)"
@change="handleConform($event, 1)" >
> <view class="date-picker-content" hover-class="hover-class">
<view class="date-picker-content" hover-class="hover-class"> <view class="input-view">{{ rangeDay0 }}</view>
<view class="input-view">{{ rangeDay1 }}</view> <u-icon name="arrow-down"></u-icon>
<u-icon name="arrow-down"></u-icon> </view>
</view> </picker>
</picker> <view class="line-view">-</view>
<picker
mode="date"
:value="rangeDay1"
:start="rangeDay0"
:end="getDate()"
@change="handleConform($event, 1)"
>
<view class="date-picker-content" hover-class="hover-class">
<view class="input-view">{{ rangeDay1 }}</view>
<u-icon name="arrow-down"></u-icon>
</view>
</picker>
</view>
<view class="charts-content"> </view>
</view> </view>
<view class="charts-content"> </view> <view class="list-view">
</view> <view class="content-title" id="part-today">模考成绩</view>
<view class="list-view"> <view class="list-content">
<view class="content-title" id="part-today">模考成绩</view> <RecordCell
<view class="list-content"> v-for="(item, index) in lists"
<RecordCell :key="index"
v-for="(item, index) in showedList" :info="item"
:key="index" ></RecordCell>
:info="item"
></RecordCell> <!-- <view class="show-more" @click="showAll = true" v-if="!showAll">
<view class="show-more" @click="showAll = true" v-if="!showAll"> <u-icon name="arrow-down"></u-icon>
<u-icon name="arrow-down"></u-icon> <text>查看更多</text>
<text>查看更多</text> </view> -->
</view> </view>
<u-loadmore
v-show="
(recordParams.current == 1 && loaded) || recordParams.current > 1
"
:status="currentLoadStatus"
></u-loadmore>
</view> </view>
</view> </scroll-view>
</view> </view>
</view> </view>
</template> </template>
<script> <script>
import RecordCell from '@/components/record-cell' import RecordCell from '@/components/record-cell'
import Calendar from '@/components/calendar'
export default { export default {
components: { RecordCell }, components: { RecordCell, Calendar },
data() { data() {
return { return {
lists: [], lists: [],
days: [],
showSelect: false, showSelect: false,
showAll: false, showAll: false,
scrollId: null, scrollId: null,
loaded: false,
items: [ items: [
{ {
title: '近7天', title: '近7天',
...@@ -102,9 +127,13 @@ export default { ...@@ -102,9 +127,13 @@ export default {
selected: false, selected: false,
}, },
], ],
currentLoadStatus: 'loading',
rangeDay0: this.getDate(), // 自定义开始日期 rangeDay0: this.getDate(), // 自定义开始日期
rangeDay1: this.getDate(), // 自定义结束日期 rangeDay1: this.getDate(), // 自定义结束日期
recordParams: {
current: 0,
size: 15,
},
} }
}, },
...@@ -119,23 +148,74 @@ export default { ...@@ -119,23 +148,74 @@ export default {
day: true, day: true,
} }
}, },
showedList() {
return this.showAll ? this.lists : this.lists.slice(0, 2)
},
}, },
onLoad(e) { onLoad(e) {
if (e && e.key) { if (e && e.key) {
this.$nextTick(() => { this.$nextTick(() => {
this.scrollId = 'part-' + e.key setTimeout(() => {
this.scrollId = 'part-' + e.key
}, 500)
}) })
} }
this.lists = [ this.queryExamRecord()
{ time: 36, score: 80, date: new Date().getTime },
{ time: 100, score: 40, date: new Date().getTime },
{ time: 40, score: 60, date: new Date().getTime },
]
}, },
methods: { methods: {
// 每日一练统计
everyTaskList(year, month) {
var params = {
startDate: this.$u.timeFormat(
new Date(year, month - 1, 1).getTime(),
'yyyy-mm-dd'
),
endDate: this.$u.timeFormat(
new Date(year, month, 0).getTime(),
'yyyy-mm-dd'
),
}
this.$u.api
.everyTaskList(this.questionWarehouseId, params)
.then((res) => {
this.days = []
for (var item of res) {
this.days.push(item.time.replace(/\-0/g, '\-'))
}
})
.catch((err) => {
console.log(err)
})
},
// 模考记录
queryExamRecord() {
this.recordParams.current += 1
;(this.recordParams.model = {
questionWarehouseId: this.questionWarehouseId,
}),
this.$u.api
.queryExamRecord(this.recordParams)
.then((res) => {
this.loaded = true
if (this.recordParams.current == 1) {
this.lists = []
}
if ((res.records || []).length > 0) {
this.lists.push(...res.records)
}
this.currentLoadStatus =
res.total > this.lists.length &&
(res.records || []).length == this.recordParams.size
? 'loadmore'
: 'nomore'
})
.catch((err) => {
this.loaded = true
console.log(err)
})
},
handleChangeMonth(e) {
this.everyTaskList(e.year, e.month)
},
handleClick() {}, handleClick() {},
handleClickRange(index) { handleClickRange(index) {
for (var item of this.items) { for (var item of this.items) {
...@@ -158,17 +238,16 @@ export default { ...@@ -158,17 +238,16 @@ export default {
getDate() { getDate() {
return this.$u.timeFormat(new Date().getTime(), 'yyyy-mm-dd') return this.$u.timeFormat(new Date().getTime(), 'yyyy-mm-dd')
}, },
reachBottom() {
if (this.currentLoadStatus != 'loadmore') return
this.currentLoadStatus == 'loading'
this.queryExamRecord()
},
}, },
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
::-webkit-scrollbar {
width: 0;
height: 0;
color: transparent;
display: none;
}
.record-view { .record-view {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
...@@ -207,26 +286,35 @@ export default { ...@@ -207,26 +286,35 @@ export default {
} }
} }
.body-view { .body-view {
::-webkit-scrollbar {
width: 0;
height: 0;
color: transparent;
display: none;
}
border-radius: 24rpx 24rpx 0 0; border-radius: 24rpx 24rpx 0 0;
background-color: #ffffff; background-color: #ffffff;
height: 100%; height: 100%;
padding: 10rpx 0 0rpx 0;
overflow: auto; overflow: auto;
padding: 24rpx 30rpx 44rpx 30rpx; .scroll-view {
height: 100%;
}
.date-view { .date-view {
.date-content { .date-content {
min-height: 648rpx; min-height: 650rpx;
} }
} }
.content-title { .content-title {
font-size: 32rpx; font-size: 32rpx;
color: #191c27; color: #191c27;
font-weight: bold; font-weight: bold;
padding: 20rpx 30rpx 0rpx 30rpx;
} }
.charts-view { .charts-view {
.range-view { .range-view {
display: flex; display: flex;
margin-top: 40rpx; margin: 40rpx 30rpx 40rpx 30rpx;
margin-bottom: 40rpx;
.range-title { .range-title {
font-size: 28rpx; font-size: 28rpx;
color: #9ea5bb; color: #9ea5bb;
...@@ -275,7 +363,10 @@ export default { ...@@ -275,7 +363,10 @@ export default {
} }
} }
.list-view { .list-view {
padding-bottom: 20rpx;
.list-content { .list-content {
padding: 0 30rpx 20rpx 30rpx;
.show-more { .show-more {
display: flex; display: flex;
justify-content: center; justify-content: center;
......
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