Browse Source

feat(student): 学生端增加作业提交功能并优化作业上传逻辑

- 新增 xy_assignmentSubmitObj 接口用于提交作业
- 修改作业上传逻辑,支持图片和视频上传
- 优化作业提交数据结构,增加学生资源 ID 和内容文本字段
- 调整作业列表页面样式,移除视频边框
master
liutong 10 months ago
parent
commit
7be4dbaa1f
  1. 12
      api/apiRoute.js
  2. 37
      pages/student/index/index.vue

12
api/apiRoute.js

@ -555,7 +555,7 @@ export default {
}) })
}, },
//学生端-- //学生端-获取作业列表
xy_assignment(data = {}) { xy_assignment(data = {}) {
let url = '/xy/assignment' let url = '/xy/assignment'
return http.get(url, data).then(res => { return http.get(url, data).then(res => {
@ -563,6 +563,16 @@ export default {
}) })
}, },
//学生端-提交作业
xy_assignmentSubmitObj(data = {}) {
let url = '/xy/assignment/submitObj'
return http.get(url, data).then(res => {
return res;
})
},

37
pages/student/index/index.vue

@ -149,8 +149,8 @@
// //
uploadApiUrl: ``, uploadApiUrl: ``,
uploadImageApiUrl: `${Api_url}/file/image`, uploadImageApiUrl: `${Api_url}/memberUploadImage`,//
uploadVideoApiUrl: `${Api_url}/file/video`, uploadVideoApiUrl: `${Api_url}/memberUploadVideo`,//
member_info: {},// member_info: {},//
@ -386,15 +386,15 @@
// //
async submitJob(item) { async submitJob(item) {
let type = item.content_type // 12 let type = item.content_type // 123
try { try {
// //
let uploadRes = await this.uploadFile(type) let uploadRes = await this.uploadFile(type)
// console.log('', uploadRes) console.log('上传结果', uploadRes)
// //
if (!uploadRes.data.path) { if (!uploadRes.data.url) {
return return
} }
@ -402,22 +402,28 @@
let data = { let data = {
id: item.id, // id id: item.id, // id
student_file: uploadRes.data.path, // student_file: uploadRes.data.path, //
student_file_type: type, // 12 resources_id:this.member_info.id, // id
student_content: '', // content_text:uploadRes.data.url
} }
// //
await this.assignmentsSubmit(data) await this.assignmentsSubmit(data)
} catch (error) { } catch (error) {
console.error('上传或提交作业失败:', error) console.error('上传或提交作业失败:', error)
alert('上传或提交作业失败') //alert('')
//
uni.showToast({
title: '上传或提交作业失败',
icon: 'none'
})
} }
}, },
// (/) type=12 // (/) type=123
async uploadFile(type) { async uploadFile(type) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (type == 1) { if (type == 1) {
//
this.uploadApiUrl = this.uploadImageApiUrl this.uploadApiUrl = this.uploadImageApiUrl
uni.chooseImage({ uni.chooseImage({
count: 1, count: 1,
@ -437,7 +443,8 @@
reject(error) reject(error)
} }
}) })
} else { } else if(type == 2){
//
this.uploadApiUrl = this.uploadVideoApiUrl this.uploadApiUrl = this.uploadVideoApiUrl
uni.chooseVideo({ uni.chooseVideo({
count: 1, count: 1,
@ -506,12 +513,11 @@
// //
async assignmentsSubmit(item) { async assignmentsSubmit(item) {
let data = { let data = {
id: item.id, // id resources_id:item.resources_id, // id
student_file: item.student_file, // id:item.id,
student_file_type: item.student_file_type, // 12 content_text:item.content_text
student_content: item.student_content, //
} }
let res = await memberApi.assignmentsSubmit(data) let res = await apiRoute.xy_assignmentSubmitObj(data)
if (res.code != 1) { if (res.code != 1) {
uni.showToast({ uni.showToast({
title: res.msg, title: res.msg,
@ -832,7 +838,6 @@
margin-top: 20rpx; margin-top: 20rpx;
border-radius: 15rpx; border-radius: 15rpx;
.video{ .video{
border: 1px solid red;
width: 100%; width: 100%;
border-radius: 15rpx; border-radius: 15rpx;
} }

Loading…
Cancel
Save