You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
211 lines
5.4 KiB
211 lines
5.4 KiB
<template> |
|
<view class="page"> |
|
<view v-if="practices.length" class="list"> |
|
<view v-for="(item, i) in practices" :key="i" class="item" @click="toDetail(item)"> |
|
<view class="c-name">{{ item.projectName }}</view> |
|
<view class="line">得分:{{ item.score || 0 }}  耗时:{{ item.timeSum }}min</view> |
|
<view class="line">练习开始时间:{{ item.startTime }}</view> |
|
<view class="line">练习结束时间:{{ item.submitTime }}</view> |
|
<view class="btn">成绩报告</view> |
|
</view> |
|
</view> |
|
</view> |
|
</template> |
|
|
|
<script> |
|
import OSS from '@/libs/Oss/upload' |
|
import { practiceByStudentDetail, exportExamPaperReport } from '@/apis/modules/course.js' |
|
export default { |
|
data() { |
|
return { |
|
cid: '', |
|
projectId: '', |
|
paperId: '', |
|
practices: [], |
|
reachBottom: 0, // 是否是上拉加载。0->否,1->是,-1->加载完所有数据 |
|
status: 'more', // 上拉加载状态 more|loading|noMore |
|
page: 1, |
|
pageSize: 10, |
|
} |
|
}, |
|
// 下拉刷新 |
|
onPullDownRefresh() { |
|
this.initList() |
|
setTimeout(() => { |
|
uni.stopPullDownRefresh() |
|
}, 1500) |
|
}, |
|
// 上拉加载 |
|
onReachBottom() { |
|
if (this.reachBottom >= 0) { |
|
this.reachBottom = 1 |
|
this.status = 'loading' |
|
this.getList() |
|
} |
|
}, |
|
onShow() { |
|
const pages = getCurrentPages() |
|
const { options } = pages[pages.length - 1] |
|
this.cid = options.cid |
|
this.projectId = options.projectId |
|
this.paperId = options.paperId |
|
this.initList() |
|
}, |
|
methods: { |
|
// 练习成绩 |
|
async getList () { |
|
const { data } = await practiceByStudentDetail({ |
|
page: this.page, |
|
pageSize: this.pageSize, |
|
projectId: this.projectId, |
|
paperId: this.paperId, |
|
cid: this.cid |
|
}) |
|
this.practices = this.reachBottom > 0 ? [...this.practices, ...data.records] : data.records |
|
this.page++ // 每次获取了数据后page+1 |
|
const noMore = this.practices.length === data.total // 是否加载完所有数据 |
|
this.status = noMore ? 'noMore' : 'more' // 加载完了则设置为noMore |
|
this.reachBottom = noMore ? -1 : 0 // 加载完了则设置为-1 |
|
}, |
|
initList() { |
|
this.page = 1 |
|
this.reachBottom = 0 |
|
this.getList() |
|
}, |
|
saveFile(fileData) { |
|
console.log('url:', fileData) |
|
uni.downloadFile({ |
|
// url: 'https://eduvessel.com/images/occupationlab/ac校赛试卷四.docx', |
|
url: fileData, |
|
success: function(res) { |
|
console.log(11, res) |
|
uni.hideLoading(); |
|
// uni.showLoading({ |
|
// title: '正在打开', |
|
// mask: true |
|
// }) |
|
// 新开页面打开文档,支持格式:doc, xls, ppt, pdf, docx, xlsx, pptx。 |
|
uni.openDocument({ |
|
filePath: res.tempFilePath, |
|
fileType: 'docx', // 文件类型,指定文件类型打开文件,有效值 doc, xls, ppt, pdf, docx, xlsx, pptx |
|
showMenu: true, // 允许出现分享功能 |
|
success: res => { |
|
uni.hideLoading() |
|
}, |
|
fail: openError => { |
|
uni.hideLoading() |
|
} |
|
}) |
|
}, |
|
fail: function(err) { |
|
uni.hideLoading() |
|
} |
|
}) |
|
}, |
|
// 跳转 |
|
async toDetail(row) { |
|
// uni.showLoading({ |
|
// title: '加载中', |
|
// mask: true |
|
// }) |
|
|
|
// const that = this |
|
// uni.request({ |
|
// header: { |
|
// token: uni.getStorageSync('token') |
|
// }, |
|
// url: 'https://izhixinyun.com/exam/exam/paper/exportExamPaperReport?reportId=73157', |
|
// method: 'GET', // 请求类型,默认为GET |
|
// data: {}, |
|
// // responseType: 'blob', |
|
// success: (res) => { |
|
// console.log(4444, res) |
|
// OSS(res.data, ({ url }) => { |
|
// console.log('ffff:', url) |
|
// // that.saveFile(url) |
|
// }) |
|
// }, |
|
// fail: err => { |
|
// console.log('fail:',fail) |
|
// uni.showToast({ |
|
// title: '请求失败!', |
|
// icon: 'none' |
|
// }) |
|
// }, |
|
// }) |
|
// return |
|
|
|
// const res = await exportExamPaperReport({ |
|
// reportId: row.reportId |
|
// }) |
|
// this.saveFile(res) |
|
|
|
// return |
|
// 下载文件资源到本地 |
|
uni.downloadFile({ |
|
// url: 'https://eduvessel.com/images/occupationlab/ac校赛试卷四.docx', |
|
url: 'https://huoran.oss-cn-shenzhen.aliyuncs.com/1732592617329.docx', |
|
success: function(res) { |
|
console.log(11, res) |
|
uni.hideLoading(); |
|
uni.showLoading({ |
|
title: '正在打开', |
|
mask: true |
|
}) |
|
// 新开页面打开文档,支持格式:doc, xls, ppt, pdf, docx, xlsx, pptx。 |
|
uni.openDocument({ |
|
filePath: res.tempFilePath, |
|
fileType: 'docx', // 文件类型,指定文件类型打开文件,有效值 doc, xls, ppt, pdf, docx, xlsx, pptx |
|
showMenu: true, // 允许出现分享功能 |
|
success: res => { |
|
uni.hideLoading() |
|
}, |
|
fail: openError => { |
|
uni.hideLoading() |
|
} |
|
}) |
|
}, |
|
fail: function(err) { |
|
uni.hideLoading() |
|
} |
|
}) |
|
}, |
|
} |
|
} |
|
</script> |
|
|
|
<style scoped lang="scss"> |
|
.page { |
|
padding: 10rpx 30rpx; |
|
background-color: #fff; |
|
} |
|
.list { |
|
.item { |
|
position: relative; |
|
padding: 20rpx 0; |
|
&:not(:last-child) { |
|
border-bottom: 1px solid #e6e6e6; |
|
} |
|
} |
|
.c-name { |
|
font-size: 32rpx; |
|
font-weight: 600; |
|
color: #333; |
|
} |
|
.line { |
|
margin-top: 14rpx; |
|
font-size: 26rpx; |
|
color: #828282; |
|
} |
|
.btn { |
|
position: absolute; |
|
bottom: 20rpx; |
|
right: 0; |
|
padding: 10rpx 30rpx; |
|
font-size: 28rpx; |
|
color: #fff; |
|
background-color: #007EFF; |
|
border-radius: 36rpx; |
|
} |
|
} |
|
</style>
|
|
|