bug修复

This commit is contained in:
yanghang
2025-07-01 09:09:53 +08:00
parent 67bf8f945d
commit ad2a9449bd
2 changed files with 42 additions and 31 deletions
+8 -6
View File
@@ -65,7 +65,7 @@
<view class="user-info">
<view class="avatar-box">
<!-- <ImagePreview class="img-box" :imgId="''"></ImagePreview> -->
<img class="img-box" :src="userInfo.imageAddr" alt="" fit="contain" style="width: 100%; height: 100%;"/>
<img class="img-box" :src="userInfo.imagePath" alt="" fit="contain" style="width: 100%; height: 100%;"/>
</view>
<view class="ai-name">
{{ userInfo.userName }}
@@ -97,7 +97,7 @@
style="width: 100%;height: 100%;"
></image>
</view>
<view class="icon text-btn" @click="translateVoice(item)"></view>
<view class="icon text-btn" v-if="type === 1" @click="translateVoice(item)"></view>
<view class="icon text-right-btn" @click="translateVoice(item)">完成</view>
<view class="icon text-right-btn" @click="translateVoice(item)">撤回</view>
</view>
@@ -107,7 +107,7 @@
<view class="user-info">
<view class="avatar-box">
<!-- <ImagePreview class="img-box" :imgId="''"></ImagePreview> -->
<img class="img-box" :src="userInfo.imageAddr" alt="" fit="contain" style="width: 100%; height: 100%;"/>
<img class="img-box" :src="userInfo.imagePath" alt="" fit="contain" style="width: 100%; height: 100%;"/>
</view>
<view class="ai-name">
{{ userInfo.userName }}
@@ -148,6 +148,7 @@ import { getUserInfo } from '@/common/common';
})
const { type, dataInfo, activeVoiceId } = toRefs(props)
const emit = defineEmits(['changePlay', 'nextQuestion'])
// 声音播放初始化
const talkVoiceObj = uni.createInnerAudioContext()
const userInfo = computed(() => getUserInfo())
watch(() => props.activeVoiceId,(val) => {
@@ -160,7 +161,6 @@ import { getUserInfo } from '@/common/common';
})
talkVoiceObj.onEnded(()=>{
// talkVoiceObj.src = ''
emit('changePlay',unref(dataInfo)?.id)
})
talkVoiceObj.onError(()=>{
@@ -171,8 +171,8 @@ import { getUserInfo } from '@/common/common';
talkVoiceObj.pause()
emit('changePlay',unref(dataInfo)?.id)
}
// 重播
const restartPlay = () => {
console.log(userInfo)
if(talkVoiceObj.src){
talkVoiceObj.seek(0)
talkVoiceObj.play()
@@ -205,7 +205,9 @@ import { getUserInfo } from '@/common/common';
}
}
const playQnsVoice = (readType = 'qns', item) =>{
if(item.type === 2){
console.log(unref(dataInfo))
if(type.value === 2){
// 录音
playVoice(readType)
return
}
+34 -25
View File
@@ -37,7 +37,7 @@
<uv-icon class="arrow-icon" name="arrow-left" @click="common.navigateBack()"/>
课程学习
</view>
<view class="talking-list">
<view class="talking-list" id="scroll-box" ref="scrollBoxRef">
<view class="study-num">
<view class="color-blue">{{ showOrder }}</view> / {{ pgrphNum }}
</view>
@@ -95,7 +95,7 @@
</template>
<script setup>
import { reactive, ref, computed, unref, onMounted, onUnmounted, getCurrentInstance } from 'vue';
import { reactive, ref, computed, unref, onMounted, onUnmounted, getCurrentInstance, nextTick } from 'vue';
import { onLoad,onShow,onHide } from '@dcloudio/uni-app';
import {
previewFile,
@@ -139,7 +139,6 @@ const inputRef = ref('')
const getData = async () => {
try{
const { body } = await getCourseStudyInfoApi({crsId: crsId.value})
console.log(3)
initsocketTask()
if(body.stdyProgressFlag === 'N'){
step.value = 1
@@ -149,14 +148,11 @@ const getData = async () => {
voiceObj: null
}))
}else{
console.log(2)
common.show('提示信息', '此门课程已有学习历史,请选择是否继续学习?',true, '重新开始','继续学习').then((res) => {
console.log(res)
if(res) {
// 继续学习 获取学习历史接口
// 滚动到最下面
scrollToBottomNow()
choiceTeacher.value = body.choiceTeacher
sendMessage({
"commond" : 'STDY',
@@ -210,7 +206,7 @@ const choiceTeacherInfo = computed(()=>{
return teacherList.value.find(t=> t.teacherNo === choiceTeacher.value)
})
const keyboardIsShow = ref(false)
// 发送文本
const showKeyboard = () => {
if(keyboardIsShow.value){
if(answerValue.value){
@@ -227,9 +223,11 @@ const showKeyboard = () => {
talkingList.value.push({
crsId: crsId.value,
pgrphId: unref(lastTalkingInfo).pgrphId,
qnsId: unref(lastTalkingInfo).qnsId,
talkingContent: answerValue.value,
talkingVoice: '',
type: 2,
userInfo: {...choiceTeacherInfo.value},
id: _id
})
scrollToBottomNow()
@@ -292,13 +290,13 @@ const nextStep = () => {
const pgrphNum = ref(1)
const showOrder = ref(0)
// 获取段落
const getGraphInfoUnStudy = () => {
queryTraStdyBatchWaitParagraphInfoApi({
crsId: crsId.value,
stdyId: unref(stdyId),
stdyBatch: unref(stdyBatch)
}).then(res=>{
console.log(res)
let _id = new Date().getTime() + 'id'
lastTalkingInfo.value = {
...res.body,
@@ -322,7 +320,6 @@ const getQuestionInfoUnStudy = (pgrphId) => {
stdyBatch: unref(stdyBatch),
pgrphId
}).then(res=>{
console.log(res)
let _id = new Date().getTime() + 'id'
lastTalkingInfo.value = {
...res.body,
@@ -349,15 +346,23 @@ const nextQuestionSuccess = (info) => {
// getGraphInfoUnStudy()
getQuestionInfoUnStudy(info.pgrphId)
}
const scrollBoxRef = ref()
const scrollToBottomNow = () => {
let _arr = talkingList.value || []
if(_arr.length && _arr.length > 0){
let _last = talkingList.value[talkingList.value.length - 1]
uni.pageScrollTo({
selector: '#item' + _last.id,
duration: 300
setTimeout(() => {
// let scrollElem = scrollBoxRef.value.$el
let scrollElem = document.getElementById('scroll-box')
scrollElem.scrollTo({
top: scrollElem.scrollHeight, behavior: 'smooth'
})
}
// let _arr = talkingList.value || []
// if(_arr.length && _arr.length > 0){
// let _last = talkingList.value[talkingList.value.length - 1]
// uni.pageScrollTo({
// selector: '#item' + _last.id,
// duration: 300
// })
// }
},200)
}
const reconnectTimer = null // 重连timer
@@ -365,7 +370,7 @@ const isManualClose = ref(false) // 是否手动关闭
const stdyId = ref('')
const stdyBatch = ref('')
// ws 初始化逻辑
const initsocketTask = () => {
socketStore.creatSocket()
unref(SocketObj).on('message', (res)=>{
@@ -400,6 +405,7 @@ const closeWebSocket = () => {
uni.closeSocket({})
}
}
// ws 结束
onLoad((params) => {
crsId.value = params.crsId||'';
@@ -429,20 +435,20 @@ const recordObj = {}
const initRecord = () => {}
// #endif
onMounted(()=>{
// getData();
getData();
initRecord?.()
})
onShow(()=>{
getData();
// getData();
})
onHide(()=>{
closeWebSocket()
// onHide(()=>{
// teacherVoiceObj.stop()
// teacherVoiceObj.src = ''
// })
onUnmounted(()=>{
teacherVoiceObj.stop()
teacherVoiceObj.src = ''
})
// onUnmounted(()=>{
// closeWebSocket()
// })
const playRecord = () => {
audioObj.src = audioPath.value
unref(audioObj).play()
@@ -490,24 +496,27 @@ const hideOverlayTalking = (obj) => {
talkingList.value.push({
crsId: crsId.value,
pgrphId: unref(lastTalkingInfo).pgrphId,
qnsId: unref(lastTalkingInfo).qnsId,
talkingContent: '',
talkingVoice: audioPath.value,
type: 1,
userInfo: {...choiceTeacherInfo.value},
id: _id
})
// #endif
//#ifdef APP-PLUS
commonUploadVoiceFile(audioPath.value, '/trastudy/traStdyInfo/studyAnswerVoiceUp', _data).then(res=>{
console.log(JSON.parse(res.data))
let _res = JSON.parse(res.data)
if(_res.rtnCode === '0000'){
let _id = new Date().getTime() + 'id'
talkingList.value.push({
crsId: crsId.value,
pgrphId: unref(lastTalkingInfo).pgrphId,
qnsId: unref(lastTalkingInfo).qnsId,
talkingContent: '',
talkingVoice: audioPath.value,
type: 1,
userInfo: {...choiceTeacherInfo.value},
id: _id
})
scrollToBottomNow()