From 4248ed0e59ee88078a7fb1bf9b31408268a56879 Mon Sep 17 00:00:00 2001 From: yanghang Date: Wed, 25 Jun 2025 08:42:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=A6=E4=B9=A0=E9=A1=B5=E9=9D=A2=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E8=81=94=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 2 + src/api/common.js | 10 +- src/api/course.js | 12 +- src/api/study.js | 12 ++ .../image-preview/image-preview.vue | 5 + src/pages/course/components/talkingItem.vue | 2 +- src/pages/course/study.vue | 124 ++++++++++++++---- src/static/images/course/study-bg.png | Bin 0 -> 796419 bytes 8 files changed, 127 insertions(+), 40 deletions(-) create mode 100644 src/api/study.js create mode 100644 src/static/images/course/study-bg.png diff --git a/.env.development b/.env.development index 9e88b879..a427c2f9 100644 --- a/.env.development +++ b/.env.development @@ -13,4 +13,6 @@ VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7001' app入口 # VITE_APP_BASE_API_Url = 'http://25.18.122.65:7001' +# VITE_APP_BASE_API_Url = 'http://25.16.122.65:7001' +# VITE_APP_BASE_API_Url = 'http://25.18.122.66:9786' diff --git a/src/api/common.js b/src/api/common.js index 8570d706..4eeb3a85 100644 --- a/src/api/common.js +++ b/src/api/common.js @@ -79,15 +79,7 @@ export function previewFile(id, responseType = 'arraybuffer') { header, responseType, success(result) { - //#ifdef APP-PLUS - let _header = result.header['Content-Type'].split(';')[0] - // #endif - //#ifndef APP-PLUS - let _header = result.header['content-type'].split(';')[0] - // #endif - // let base64 = new Blob([result.data],{type:result.header['content-type'].split(';')[0]}) - let base64 = `data:${_header};base64,` + uni.arrayBufferToBase64(result.data) - resolve(base64) + resolve(result) }, fail(error) { reject(new Error(error)); diff --git a/src/api/course.js b/src/api/course.js index a24eedf7..0631c95f 100644 --- a/src/api/course.js +++ b/src/api/course.js @@ -1,6 +1,8 @@ import request from '@/api/request' const base_url = '/traapp' +const course_base_url = '/trastudy' + // 获取课程分类树接口 export const getCourseTypeListApi = (data) => { @@ -29,7 +31,7 @@ export const getTraTagListApi = (data) => { // 全部模块 export const queryCrsInfoByCatalogApi = (data) => { return request({ - url: base_url + '/crsInfo/queryCrsInfoByCatalog', + url: course_base_url + '/crsInfo/queryCrsInfoByCatalog', method: 'post', data }); @@ -37,7 +39,7 @@ export const queryCrsInfoByCatalogApi = (data) => { // 生产线模块- export const queryCrsInfoByPrdLineApi = (data) => { return request({ - url: base_url + '/crsInfo/queryCrsInfoByPrdLine', + url: course_base_url + '/crsInfo/queryCrsInfoByPrdLine', method: 'post', data }); @@ -45,7 +47,7 @@ export const queryCrsInfoByPrdLineApi = (data) => { // 最新 export const queryCrsInfoByLastnewApi = (data) => { return request({ - url: base_url + '/crsInfo/queryCrsInfoByLastnew', + url: course_base_url + '/crsInfo/queryCrsInfoByLastnew', method: 'post', data }); @@ -53,7 +55,7 @@ export const queryCrsInfoByLastnewApi = (data) => { // 最热 export const queryCrsInfoByPopularApi = (data) => { return request({ - url: base_url + '/crsInfo/queryCrsInfoByPopular', + url: course_base_url + '/crsInfo/queryCrsInfoByPopular', method: 'post', data }); @@ -61,7 +63,7 @@ export const queryCrsInfoByPopularApi = (data) => { // 推荐 export const queryCrsInfoByRecmdApi = (data) => { return request({ - url: base_url + '/crsInfo/queryCrsInfoByRecmd', + url: course_base_url + '/crsInfo/queryCrsInfoByRecmd', method: 'post', data }); diff --git a/src/api/study.js b/src/api/study.js new file mode 100644 index 00000000..bb329ee5 --- /dev/null +++ b/src/api/study.js @@ -0,0 +1,12 @@ +import request from '@/api/request' + +const base_url = '/trastudy' + +// 获取课程分类树接口 +export const getCourseStudyInfoApi = (data) => { + return request({ + url: base_url + '/traStdyInfo/queryTraStdyProgressAndTeacher', + method: 'post', + data + }); +}; \ No newline at end of file diff --git a/src/components/image-preview/image-preview.vue b/src/components/image-preview/image-preview.vue index cee0bf65..8a87ce8b 100644 --- a/src/components/image-preview/image-preview.vue +++ b/src/components/image-preview/image-preview.vue @@ -53,7 +53,12 @@ }); }else{ previewFile(id).then((result) => { + //#ifdef APP-PLUS + let _header = result.header['Content-Type'].split(';')[0] + // #endif + //#ifndef APP-PLUS let _header = result.header['content-type'].split(';')[0] + // #endif let base64 = `data:${_header};base64,` + uni.arrayBufferToBase64(result.data) this.imgUrlShow = base64; }); diff --git a/src/pages/course/components/talkingItem.vue b/src/pages/course/components/talkingItem.vue index 2918d6c2..09fcbc06 100644 --- a/src/pages/course/components/talkingItem.vue +++ b/src/pages/course/components/talkingItem.vue @@ -115,7 +115,7 @@ .talking-info{ padding: 20rpx; border-radius: 15rpx; - background-color: #aaa; + background-color: #fff; .talking-gif{ width: 140rpx; height: 38rpx; diff --git a/src/pages/course/study.vue b/src/pages/course/study.vue index 025df81a..75aa7dc6 100644 --- a/src/pages/course/study.vue +++ b/src/pages/course/study.vue @@ -9,27 +9,27 @@ - - + + - + - 李想 - 描述:产品 + {{item.teacherName}} + 描述:{{item.teacheDesc || '--'}} - 00:26 + - + - + 开启学习之旅 @@ -42,7 +42,6 @@ 1/20 - {{audioPath}} @@ -83,14 +82,30 @@ import { reactive, ref, computed, unref, onMounted } from 'vue'; import { onLoad } from '@dcloudio/uni-app'; import { previewFile, downloadFile } from "@/api/common.js" +import { getToken } from '@/common/common.js' +import { get_base_url } from '@/api/request' +import { getCourseStudyInfoApi } from "@/api/study.js" import common from '@/common/common'; import TalkingItem from '@/pages/course/components/talkingItem.vue' import ImagePreview from '@/components/image-preview/image-preview.vue' const crsNum = ref(''); -const step = ref(2) -const chooseVoiceId = ref('') +const crsId = ref(''); +const step = ref(0) +const teacherList = ref([]) +const choiceTeacher = ref('') const videoUrlShow = ref('') const getData = async () => { + try{ + const { body } = await getCourseStudyInfoApi({crsId: crsId.value}) + if(body.stdyProgressFlag === 'N'){ + step.value = 1 + teacherList.value = body.teacheList + }else{ + choiceTeacher.value = body.choiceTeacher + } + }catch{ + + } // downloadFile('S3F0250181220722025062409312400000331622').then(res=>{ // console.log(res) // audioObj.value = uni.createInnerAudioContext() @@ -100,15 +115,59 @@ const getData = async () => { // videoUrlShow.value = res.tempFilePath // }) }; +let WS = {} +const nextStep = () => { + console.log(choiceTeacher.value) + if(choiceTeacher.value){ + initWS() + } +} +const initWS = async () => { + let _params = { + url: get_base_url() + '/trastudy/trasoket/open', + header:{ + Summary: getToken(), + 'Content-Type': 'application/json;charset=UTF-8' + }, + } + console.log(_params) + WS = uni.connectSocket({ + ..._params, + success(res){ + console.log(res) + }, + file(err){ + console.log(err) + } + }) + console.log(WS) + WS.onOpen = () =>{ + console.log('建立链接') + step.value = 2 + } + // WS.onmessage = (event) => { + // console.log(event) + // } + // WS.onerror = (event) => { + // console.log(event) + // } + // WS.onclose = () => { + // // 重连 + // // initWS() + // } +} onLoad((params) => { - crsNum.value = params.crsNum; + crsId.value = params.crsId||''; + crsNum.value = params.crsNum||''; getData(); }); const showTalkingModel = ref(false) // 录音 const audioPath = ref('') const audioObj = uni.createInnerAudioContext() -const recordObj = uni.getRecorderManager() +//#ifdef APP-PLUS +// app端 +const recordObj = uni.getRecorderManager() const initRecord = () => { unref(recordObj)?.onStop((res)=>{ audioPath.value = res.tempFilePath @@ -120,6 +179,13 @@ const startRecord = () => { const stopRecord = () => { unref(recordObj).stop() } +onMounted(()=>{ + initRecord() +}) +// #endif +//#ifndef APP-PLUS +const recordObj = {} +// #endif const playRecord = () => { audioObj.src = audioPath.value unref(audioObj).play() @@ -134,7 +200,7 @@ const systemInfo = uni.getSystemInfoSync() const widowHeight = systemInfo.windowHeight // 计算是否超出按下盒子位置 const isOut = computed(() => { - let moveVal = (widowHeight - baseY.value)/165 * 234 + let moveVal = (widowHeight - baseY.value)/140 * 234 return (widowHeight - moveVal) > touchY.value }) const showOverlayTalking = (obj) => { @@ -146,21 +212,21 @@ const showOverlayTalking = (obj) => { } const hideOverlayTalking = (obj) => { showTalkingModel.value = false - if(isOut.value){ - console.log('取消发送') - }else{ + //#ifdef APP-PLUS + stopRecord() + // #endif + if(!isOut.value){ console.log('发送') - stopRecord() } + // else{ + // console.log('取消发送') + // } } const handleMove = (obj) => { touchX.value = obj.changedTouches[0].pageX touchY.value = obj.changedTouches[0].pageY } -onMounted(()=>{ - initRecord() -})