From 7be4dbaa1f3470292c4b30a335dcad394b558b59 Mon Sep 17 00:00:00 2001 From: liutong <836164388@qq.com> Date: Wed, 11 Jun 2025 10:51:53 +0800 Subject: [PATCH] =?UTF-8?q?feat(student):=20=E5=AD=A6=E7=94=9F=E7=AB=AF?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BD=9C=E4=B8=9A=E6=8F=90=E4=BA=A4=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=B9=B6=E4=BC=98=E5=8C=96=E4=BD=9C=E4=B8=9A=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 xy_assignmentSubmitObj 接口用于提交作业 - 修改作业上传逻辑,支持图片和视频上传 - 优化作业提交数据结构,增加学生资源 ID 和内容文本字段 - 调整作业列表页面样式,移除视频边框 --- api/apiRoute.js | 12 +++++++++++- pages/student/index/index.vue | 37 ++++++++++++++++++++--------------- 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/api/apiRoute.js b/api/apiRoute.js index 840c772..749a5a7 100644 --- a/api/apiRoute.js +++ b/api/apiRoute.js @@ -555,7 +555,7 @@ export default { }) }, - //学生端-- + //学生端-获取作业列表 xy_assignment(data = {}) { let url = '/xy/assignment' 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; + }) + }, + + + diff --git a/pages/student/index/index.vue b/pages/student/index/index.vue index c5ac969..d8862b9 100644 --- a/pages/student/index/index.vue +++ b/pages/student/index/index.vue @@ -149,8 +149,8 @@ //上传接口地址 uploadApiUrl: ``, - uploadImageApiUrl: `${Api_url}/file/image`, - uploadVideoApiUrl: `${Api_url}/file/video`, + uploadImageApiUrl: `${Api_url}/memberUploadImage`,//图片上传接口 + uploadVideoApiUrl: `${Api_url}/memberUploadVideo`,//视频上传接口 member_info: {},//学生信息 @@ -386,15 +386,15 @@ // 上传作业 async submitJob(item) { - let type = item.content_type // 作业类型1图片2视频 + let type = item.content_type // 作业类型1图片2视频3文本 try { // 等待上传文件的返回结果 let uploadRes = await this.uploadFile(type) - // console.log('上传结果', uploadRes) + console.log('上传结果', uploadRes) // 检查上传结果 - if (!uploadRes.data.path) { + if (!uploadRes.data.url) { return } @@ -402,22 +402,28 @@ let data = { id: item.id, // 作业列表id student_file: uploadRes.data.path, // 附件 - student_file_type: type, // 作业类型1图片2视频 - student_content: '', // 内容 + resources_id:this.member_info.id, // 学生资源id + content_text:uploadRes.data.url } // 提交作业 await this.assignmentsSubmit(data) } catch (error) { console.error('上传或提交作业失败:', error) - alert('上传或提交作业失败') + //alert('上传或提交作业失败') + //提示 + uni.showToast({ + title: '上传或提交作业失败', + icon: 'none' + }) } }, -// 上传单文件(视频/图片) type=作业类型1图片2视频 +// 上传单文件(视频/图片) type=作业类型1图片2视频3文本 async uploadFile(type) { return new Promise((resolve, reject) => { if (type == 1) { + //图片作业 this.uploadApiUrl = this.uploadImageApiUrl uni.chooseImage({ count: 1, @@ -437,7 +443,8 @@ reject(error) } }) - } else { + } else if(type == 2){ + //视频作业 this.uploadApiUrl = this.uploadVideoApiUrl uni.chooseVideo({ count: 1, @@ -506,12 +513,11 @@ // 提交作业接口 async assignmentsSubmit(item) { let data = { - id: item.id, // 作业列表id - student_file: item.student_file, // 附件 - student_file_type: item.student_file_type, // 作业类型1图片2视频 - student_content: item.student_content, // 内容 + resources_id:item.resources_id, // 学生资源id + id:item.id, + content_text:item.content_text } - let res = await memberApi.assignmentsSubmit(data) + let res = await apiRoute.xy_assignmentSubmitObj(data) if (res.code != 1) { uni.showToast({ title: res.msg, @@ -832,7 +838,6 @@ margin-top: 20rpx; border-radius: 15rpx; .video{ - border: 1px solid red; width: 100%; border-radius: 15rpx; }