Merge branch 'develop' into 'sit'

Develop

See merge request K17_AITS/tra-app!36
This commit is contained in:
田岩
2025-07-17 17:13:34 +08:00
7 changed files with 97 additions and 20 deletions
+32
View File
@@ -157,6 +157,38 @@ export function downloadVoiceFile(url) {
});
});
}
export function getAudioByText(data) {
const token = getToken();
const header = {
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
};
if (token)
header['summary'] = token
let baseUrl = get_base_url();
return new Promise((resolve, reject) => {
uni.request({
url: `${baseUrl}/trastudy/traStdyInfo/readContent`,
header,
method:"POST",
data,
responseType: "arraybuffer",
success(result) {
if(result.statusCode === 200){
resolve(result.data)
}else{
reject(new Error(result))
}
},
fail(error) {
reject(new Error(error));
}
});
});
}
// 对象存储预览 /traoss/tras3/show/{文件ID}
export function previewFile(id, responseType = 'arraybuffer') {
const token = getToken();
+3
View File
@@ -155,6 +155,9 @@ export default class WebSocketUtil {
} else {
console.error('WebSocket连接未打开,无法发送消息');
this.triggerEvent('error', new Error('WebSocket连接未打开'));
setTimeout(()=>{
this.send(message)
},500)
}
return this;
}
+1 -1
View File
@@ -14,7 +14,7 @@
</view>
<view class="total-score">
<view class="score-num">{{props.score}}</view>
<img class="total-score-icon" src="@/static/images/course/score.png" alt="" />
<image class="total-score-icon" src="@/static/images/course/score.png" alt=""></image>
</view>
<view v-for="item,index in props.dataList" :class="['score-item', 'score-item'+(index+1)]">
<view class="score-item-name">{{ item.gradeDimensName }}</view>
+1 -1
View File
@@ -17,7 +17,7 @@
</view>
<view class="total-score">
<view class="score-num">{{props.score}}</view>
<img class="total-score-icon" src="@/static/images/course/score.png" alt="" />
<image class="total-score-icon" src="@/static/images/course/score.png" alt="" ></image>
</view>
<view v-for="item,index in props.dataList" :class="['score-item', 'score-item'+(index+1)]">
<view class="score-item-name">{{ item.gradeDimensName }}</view>
+29 -1
View File
@@ -185,7 +185,7 @@
import { watch, unref, ref, toRefs, computed, nextTick,onMounted } from 'vue'
import ImagePreview from '@/components/image-preview/image-preview.vue'
import VideoPreview from '@/components/image-preview/video-preview.vue'
import { downloadVoiceFile, uploadVoiceFile, } from "@/api/common.js"
import { downloadVoiceFile, uploadVoiceFile, getAudioByText } from "@/api/common.js"
import { studyParagraphOverApi, getAskAboutRawApi } from "@/api/study.js"
import ChartFour from "./chartFour.vue"
import ChartThree from "./chartThree.vue"
@@ -373,6 +373,8 @@ const audioCacheObj = computed(() => storageStore.audioObj)
teachNo: unref(teacherInfo)?.teacherNo, // 必填
content: _content
}
let _url = '/trastudy/traStdyInfo/readContent?' + Object.keys(_params).map(t=>{
return encodeURIComponent(t) + '=' + encodeURIComponent(_params[t])
}).join('&')
@@ -384,6 +386,19 @@ const audioCacheObj = computed(() => storageStore.audioObj)
talkVoiceObj.value.src = url
talkVoiceObj.value.play()
}else{
// getAudioByText(_params).then(res=>{
// // uni.env.USER_DATA_PATH ||
// let filePath = `${'/'}/${dataInfo.value.id}.mp3`
// saveFile(res, filePath, () => {
// voiceLoading.value = false
// itemVoice.value = filePath
// talkVoiceObj.value.src = filePath
// talkVoiceObj.value.play()
// storageStore.setStorage('audio', _url + _params.teachNo, itemVoice.value)
// })
// }).catch(err=>{
// console.log(err)
// })
downloadVoiceFile(_url).then(res=>{
if(res?.data){
common.msg(res.data.message)
@@ -401,6 +416,19 @@ const audioCacheObj = computed(() => storageStore.audioObj)
})
}
}
const saveFile = (buffer,filePath, cb = ()=>{}) => {
let fileManager = uni.getFileSystemManager()
fileManager.writeFile({
filePath: filePath,
data: buffer,
encoding: 'binary',
success: cb,
file: ()=>{
voiceLoading.value = false
console.log('文件保存失败!')
}
})
}
const initVoice = (readType = 'qns', item, isplay=false) => {
if(unref(dataInfo).talkingVoice){
itemVoice.value = unref(dataInfo).talkingVoice
+24 -17
View File
@@ -176,13 +176,8 @@ const flagVal = ref('1')
const isUploadingVoice = ref(false)
// 初始化数据
const getData = async (flag) => {
// if(flag === flagVal.value){
// flagVal.value = '2'
// }else{
// return
// }
try{
await initsocketTask()
initsocketTask()
const { body } = await getCourseStudyInfoApi({crsId: crsId.value})
teacherList.value = body.teacheList.map(t=>({
...t,
@@ -192,8 +187,8 @@ const getData = async (flag) => {
if(body.stdyProgressFlag === 'N'){
step.value = 1
}else{
choiceTeacher.value = body.choiceTeacher
if(startPgrphId.value){
choiceTeacher.value = body.choiceTeacher
sendMessage({
"commond" : 'STDY',
"body" : {
@@ -201,7 +196,6 @@ const getData = async (flag) => {
teacherNo: choiceTeacher.value
}
})
step.value = 2
return
}
common.show('提示', '系统检测到您已存在学习记录,要继续学习吗?',true, '重新学习','继续学习').then((res) => {
@@ -209,7 +203,6 @@ const getData = async (flag) => {
// 继续学习 获取学习历史接口
// 滚动到最下面
scrollToBottomNow()
choiceTeacher.value = body.choiceTeacher
sendMessage({
"commond" : 'STDY',
"body" : {
@@ -374,7 +367,6 @@ const getGraphInfoUnStudy = (flag = 0) => {
if(!_body.chatBody) {
return
}
console.log('prgh', _body)
if(Number(_body.bodyTyp) === 7){
common.show('恭喜你已学完全部知识点', '有什么心得跟我们分享吗?',true, '取消','去评论').then((res) => {
if(res) {
@@ -587,8 +579,20 @@ const stdyId = ref('')
const stdyBatch = ref('')
const logId = ref('')
// ws 初始化逻辑
const initsocketTask = async () => {
await socketStore.creatSocket()
const initsocketTask = () => {
socketStore.creatSocket()
unref(SocketObj).on('open', (res)=>{
if(startPgrphId.value){
sendMessage({
"commond" : 'STDY',
"body" : {
crsId: crsId.value,
teacherNo: choiceTeacher.value
}
})
step.value = 2
}
})
unref(SocketObj).on('message', (res)=>{
const { rtnCode, body, commond } = JSON.parse(res.data)
if(rtnCode === '0000'){
@@ -597,6 +601,7 @@ const initsocketTask = async () => {
stdyBatch.value = body.stdyBatch || ''
logId.value = body.logId || ''
getGraphInfoUnStudy(1)
step.value = 2
}
}else{
// if(['0005', 'QQ0005'].includes(res.rtnCode)) {
@@ -622,13 +627,14 @@ onLoad((params) => {
crsNum.value = params.crsNum||'';
imageId.value = params.imgId || ''
startPgrphId.value = params.pgrphId||'';
getData('1');
console.log('onLoad')
});
const showTalkingModel = ref(false)
// 录音
// onMounted(()=>{
// getData('1');
// })
onMounted(()=>{
getData('1');
console.log('onMounted')
})
onHide(()=>{
if(watchFlag.value === 1) return
changePlayItemId('')
@@ -638,8 +644,9 @@ onHide(()=>{
}).finally(() => {})
})
onShow(()=>{
console.log('onShow')
if(watchFlag.value === 1) return
socketStore.createSocket()
getData('1');
})
const watchFlag = ref(1)
onUnload(()=>{
+7
View File
@@ -415,6 +415,13 @@ import {
onShow(()=>{
if(watchFlag.value === 1) return
socketStore?.createSocket?.()
sendMessage({
"commond" : 'ASK-START',
"body" : {
mascotId: mascotId.value,
deviceImei: ''
}
})
})
onUnload(()=>{
watchFlag.value = 1