Merge branch 'dev-recording' into develop

This commit is contained in:
田岩
2026-03-11 08:39:59 +08:00
8 changed files with 3032 additions and 2708 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ ENV = 'development'
#VITE_APP_BASE_API_Url = 'https://aits.jlbank.com.cn:7001'
VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7003'
VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7001'
# DEV
+11
View File
@@ -46,4 +46,15 @@
height: 50rpx;
}
}
&.blue{
background-color: #06f;
&.inputMode {
border: 2rpx solid #dedede00;
}
&.action {
background-color: #0066ff99;
}
}
}
+7 -1
View File
@@ -1,6 +1,6 @@
<template>
<view>
<view class="talk-btns-components" :class="{ action: isRecording, inputMode: !isInputVisible }">
<view :class="['talk-btns-components', props.theme, { action: isRecording, inputMode: !isInputVisible }]">
<view class="touch-btn" @click="disabled_click">
<button
v-if="isInputVisible"
@@ -11,7 +11,9 @@
@touchcancel="stopRecord()"
:plain="true"
>
<slot>
<text class="voice-text">{{ isRecording ? '松开发送' : '按住说话' }}</text>
</slot>
</button>
<input
v-if="!isVoiceOnlyMode && !isInputVisible"
@@ -180,6 +182,10 @@
/* '01': '不限制回答方式', '02': '仅文字回答', '03': '仅语音回答'*/
return ['01', '02', '03'].includes(value);
}
},
theme: {
type: String,
default: ''
}
});
// 兼容以前的按钮参数
+60 -22
View File
@@ -623,7 +623,8 @@
};
const downloadFnc = ref(null)
const playVoice = (readType = 'pgth') => {
console.log('playVoice11111111')
console.log(unref(dataInfo))
if (voiceIsPlaying.value) return
let _content = showContent.value;
if (!_content) {
@@ -765,6 +766,37 @@
setTimeout(() => {
setVoiceTime(0);
}, 100);
}else{
console.log(type.value)
if(type.value === 1){
downloadFile(unref(dataInfo).bucketKey)
.then((res) => {
if (res?.data) {
common.msg(res.data.message);
return;
}
voiceLoading.value = false;
itemVoice.value = res.tempFilePath;
talkVoiceObj.value.src = res.tempFilePath;
console.log('talkVoiceObj.value.src', talkVoiceObj.value.src)
if (voiceIsPlaying.value) return
if(unref(dataInfo)?.id !== props.activeVoiceId) return
talkVoiceObj.value.play();
console.log('播放')
storageStore.setStorage('audio', unref(dataInfo)?.id, itemVoice.value);
setTimeout(()=>{
setVoiceTime(0)
},100)
})
.catch((err) => {
console.log('err',err)
voiceLoading.value = false;
emit('changePlay', '');
});
}
}
// else{
// setTimeout(()=>{
@@ -783,33 +815,39 @@
}
})
}
// const setVoiceTime = (sum) => {
// sum += 1;
// if (talkVoiceObj.value.duration) {
// voiceTime.value = (Math.ceil(talkVoiceObj.value.duration) || 0) + 's';
// } else {
// if (sum === 100) {
// voiceTime.value = (unref(dataInfo).voiceTime || 0) + 's';
// return;
// }
// setTimeout(() => {
// setVoiceTime(sum);
// }, 300);
// }
// };
const playQnsVoice = (readType = 'qns', item) => {
console.log(type.value)
if (type.value === 2) {
// 文本转语音
playVoice(readType);
return;
}else{
emit('changePlay', unref(dataInfo)?.id)
if(talkVoiceObj.value && talkVoiceObj.value.src) {
console.log(2)
console.log('talkVoiceObj.value.src', talkVoiceObj.value.src)
talkVoiceObj.value.play()
return
}else{
console.log(3)
talkVoiceObj.value.src = ''
if(unref(dataInfo).talkingVoice){
setTimeout(()=>{
talkVoiceObj.value.src = unref(dataInfo).talkingVoice
talkVoiceObj.value.play()
isPlaying.value = true
},100)
}
// readType 阅读内容类型pgrh段落/qns问题
emit('changePlay', unref(dataInfo)?.id);
setTimeout(() => {
itemVoice.value = item.talkingVoice;
talkVoiceObj.value.src = item.talkingVoice;
talkVoiceObj.value.play();
}, 100);
}
}
// // readType 阅读内容类型pgrh段落/qns问题
// emit('changePlay', unref(dataInfo)?.id);
// setTimeout(() => {
// itemVoice.value = item.talkingVoice;
// talkVoiceObj.value.src = item.talkingVoice;
// talkVoiceObj.value.play();
// }, 100);
};
const translateLoading = ref(false);
// 翻译
+351 -260
View File
@@ -12,19 +12,26 @@
</view>
<view class="voice-list">
<uv-radio-group v-model="choiceTeacher">
<view class="voice-item" v-for="item in teacherList" :key="item.teacherNo" @click="choiceTeacher = item.teacherNo">
<view class="voice-item" v-for="item in teacherList" :key="item.teacherNo"
@click="choiceTeacher = item.teacherNo">
<view class="avatar-box">
<ImagePreview class="img-box" :src="item.imgAddr" :isCache="true" :width="120" :height="160"> </ImagePreview>
<ImagePreview class="img-box" :src="item.imgAddr" :isCache="true" :width="120" :height="160">
</ImagePreview>
</view>
<view class="right-cont">
<view class="right-name">{{ item.teacherName }}</view>
<view class="right-desc">描述{{ item.voiceDesc || '--' }}</view>
<view class="audio-box">
<view :class="['talking-gif', activeVoiceTeachNo === item.teacherNo && !loadingTeacherVoice ? 'is-play' : '']"> </view>
<CommonLoading color="#06f" v-show="activeVoiceTeachNo === item.teacherNo && loadingTeacherVoice" style="float: left" />
<view
:class="['talking-gif', activeVoiceTeachNo === item.teacherNo && !loadingTeacherVoice ? 'is-play' : '']">
</view>
<CommonLoading color="#06f" v-show="activeVoiceTeachNo === item.teacherNo && loadingTeacherVoice"
style="float: left" />
<view class="play-btn" @click="playTeacherVoice(item)">
<image class="icon" v-if="activeVoiceTeachNo !== item.teacherNo" src="@/static/images/course/play-blue.png" style="width: 100%; height: 100%"></image>
<image class="icon" v-else src="@/static/images/course/stop-blue.png" style="width: 100%; height: 100%"></image>
<image class="icon" v-if="activeVoiceTeachNo !== item.teacherNo"
src="@/static/images/course/play-blue.png" style="width: 100%; height: 100%"></image>
<image class="icon" v-else src="@/static/images/course/stop-blue.png"
style="width: 100%; height: 100%"></image>
</view>
</view>
</view>
@@ -46,7 +53,8 @@
课程学习
</view>
<view class="study-num">
<view class="color-black ml-40">学习中<text class="color-gray"><text class="color-black">{{ showOrder }}</text>/{{ pgrphNum }}</text></view>
<view class="color-black ml-40">学习中<text class="color-gray"><text
class="color-black">{{ showOrder }}</text>/{{ pgrphNum }}</text></view>
<view class="bg-block">
<view class="bg-gray">
<view class="bg-blue" :style="`width: ${showOrder/pgrphNum * 100}%;`"></view>
@@ -55,31 +63,19 @@
</view>
<scroll-view class="talking-list" :scroll-y="true" :scroll-top="scrollTop" :show-scrollbar="false" :scroll-with-animation="true">
<scroll-view class="talking-list" :scroll-y="true" :scroll-top="scrollTop" :show-scrollbar="false"
:scroll-with-animation="true">
<!-- <view class="talking-list-cont" id="scroll-box" ref="scrollBoxRef"> -->
<TalkingItem
class="talking-item"
v-for="(item, index) in talkingList"
:key="'item' + item.id"
:type="item.type"
:dataInfo="item"
:activeVoiceId="activeVoiceTalkingItemId"
:isPlaying="activeVoiceTalkingItemId === item.id"
:voiceRate="chooseRate"
:lastQuestionInfo="lastTalkingInfo"
:teacherInfo="choiceTeacherInfo"
:answerMethod="answerMethod"
@changePlay="changePlayItemId"
@nextQuestion="nextQuestionSuccess"
@withdraw="withdrawNow"
@answerQuestion="answerQuestionNow"
@finishQuestion="finishQuestionNow"
:id="'item' + item.id"
:isLast="talkingList.length === index + 1"></TalkingItem>
<TalkingItem class="talking-item" v-for="(item, index) in talkingList" :key="'item' + item.id" :type="item.type"
:dataInfo="item" :activeVoiceId="activeVoiceTalkingItemId" :isPlaying="activeVoiceTalkingItemId === item.id"
:voiceRate="chooseRate" :lastQuestionInfo="lastTalkingInfo" :teacherInfo="choiceTeacherInfo"
:answerMethod="answerMethod" @changePlay="changePlayItemId" @nextQuestion="nextQuestionSuccess"
@withdraw="withdrawNow" @answerQuestion="answerQuestionNow" @finishQuestion="finishQuestionNow"
:id="'item' + item.id" :isLast="talkingList.length === index + 1"></TalkingItem>
<!-- <video v-if="videoUrlShow" :src="videoUrlShow" controls></video> -->
<!-- </view> -->
</scroll-view>
<TouchBtn
<!-- <TouchBtn
v-if="answerMethod !== '03'"
class="talk-btns"
@uploadVoice="uploadRecordNow"
@@ -104,24 +100,14 @@
:adjustPosition="true"
:canAnswerText="canAnswerText"
:answerMethod="answerMethod"
:isDisabled="(lastTalkingInfo.type || 0) !== 4 || ['SN', 'MU', 'JD'].includes(lastTalkingInfo.qnsTyp)" />
:isDisabled="(lastTalkingInfo.type || 0) !== 4 || ['SN', 'MU', 'JD'].includes(lastTalkingInfo.qnsTyp)" /> -->
<touch-btn
class="talk-btns"
ref="touchBtnRef"
@sendLoading="sendLoading"
@submitVoice="submitVoice"
@submitAnswer="submitAnswerNow"
@startRecord="changePlayItemId('')"
:isLoading="isUploadingVoice"
:adjustPosition="true"
:canAnswer="testAnswer"
:canAnswerText="canAnswerText"
<touch-btn class="talk-btns" ref="touchBtnRef" @sendLoading="sendLoading" @submitVoice="submitVoice"
@submitAnswer="submitAnswerNow" @startRecord="changePlayItemId('')" :isLoading="isUploadingVoice"
:adjustPosition="true" :canAnswer="!testAnswer" :canAnswerText="canAnswerText"
:isDisabled="(lastTalkingInfo.type || 0) !== 4 || ['SN', 'MU', 'JD'].includes(lastTalkingInfo.qnsTyp)"
loadingText="只能进行一条回答"
:answerMethod="answerMethod"
/>
loadingText="只能进行一条回答" :answerMethod="answerMethod" />
</view>
<uv-overlay :show="showSeekModel" opacity=".6" @click="showSeekModel = false">
<view class="overlay-box">
@@ -143,9 +129,11 @@
<view class="box-item">
<view class="box-item-title">音色</view>
<uv-radio-group v-model="choiceTeacher" class="box-item-cont">
<view class="overlay-voice-item" v-for="item in teacherList" :key="item.teacherNo" @click="changeTeacherVoiceNow(item)">
<view class="overlay-voice-item" v-for="item in teacherList" :key="item.teacherNo"
@click="changeTeacherVoiceNow(item)">
<view class="overlay-avatar-box">
<ImagePreview class="overlay-img-box" :src="item.imgAddr" :isCache="true" :width="120" :height="160"></ImagePreview>
<ImagePreview class="overlay-img-box" :src="item.imgAddr" :isCache="true" :width="120"
:height="160"></ImagePreview>
</view>
<view class="overlay-teacher-name">{{ item.teacherName }}</view>
<uv-radio :name="item.teacherNo" class="overlay-radio-box" @click.stop />
@@ -163,70 +151,116 @@
</template>
<script setup>
import { reactive, ref, computed, unref, onMounted, onUnmounted, getCurrentInstance, nextTick } from 'vue'
import { onLoad, onShow, onUnload, onHide } from '@dcloudio/uni-app'
import { previewFile, downloadFile, commonUploadVoiceFile, downloadVoiceFile, uploadVoiceFile } from '@/api/common.js'
import { getToken, getPhoneEnvBool } from '@/common/common.js'
import { get_base_url, goto_login_fun } from '@/api/request'
import { getCourseStudyInfoApi,
afreshStudyCourseApi,
queryQuestionEvalateApi,
textChartApi,
setStudyTeacherApi,
setPreviewTeacherApi,
textChartPreviewApi,
previewAfreshStudyCourse,
studyEndApi,
studyStartApi } 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'
import PreviewDetail from '@/components/image-preview/preview-detail.vue'
// import TouchBtn from '@/pages/course/components/touchBtn.vue'
// import TouchBtnOnlyVoice from '@/pages/course/components/touchBtnOnlyVoice.vue'
import {
reactive,
ref,
computed,
unref,
onMounted,
onUnmounted,
getCurrentInstance,
nextTick
} from 'vue'
import {
onLoad,
onShow,
onUnload,
onHide
} from '@dcloudio/uni-app'
import {
previewFile,
downloadFile,
commonUploadVoiceFile,
downloadVoiceFile,
uploadVoiceFile
} from '@/api/common.js'
import {
getToken,
getPhoneEnvBool
} from '@/common/common.js'
import {
get_base_url,
goto_login_fun
} from '@/api/request'
import {
getCourseStudyInfoApi,
afreshStudyCourseApi,
queryQuestionEvalateApi,
textChartApi,
setStudyTeacherApi,
setPreviewTeacherApi,
textChartPreviewApi,
previewAfreshStudyCourse,
studyEndApi,
studyStartApi
} 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'
import PreviewDetail from '@/components/image-preview/preview-detail.vue'
// import TouchBtn from '@/pages/course/components/touchBtn.vue'
// import TouchBtnOnlyVoice from '@/pages/course/components/touchBtnOnlyVoice.vue'
import badge from '@/components/points-and-badge/badge';
import points from '@/components/points-and-badge/points';
import usePointsAndBadge from '@/components/points-and-badge/usePointsAndBadge';
const { pointAndBadgesRun, badgeRef, pointsRef } = usePointsAndBadge();
const {
pointAndBadgesRun,
badgeRef,
pointsRef
} = usePointsAndBadge();
import { useSocketStore } from '@/store/socket.js'
import { useStorageStore } from '@/store/storage.js'
import { storeToRefs } from 'pinia'
import {
useSocketStore
} from '@/store/socket.js'
import {
useStorageStore
} from '@/store/storage.js'
import {
storeToRefs
} from 'pinia'
const socketStore = useSocketStore()
const storageStore = useStorageStore()
const { SocketObj } = storeToRefs(socketStore)
const audioCacheObj = computed(() => storageStore.audioObj)
const socketStore = useSocketStore()
const storageStore = useStorageStore()
const {
SocketObj
} = storeToRefs(socketStore)
const audioCacheObj = computed(() => storageStore.audioObj)
const { proxy } = getCurrentInstance()
const crsNum = ref('')
const crsId = ref('')
const step = ref(0)
const teacherList = ref([])
const choiceTeacher = ref('')
const videoUrlShow = ref('')
const talkingList = ref([])
const activeVoiceTalkingItemId = ref('')
const answerValue = ref('')
const inputRef = ref('')
const flagVal = ref('1')
const isUploadingVoice = ref(false)
const isPreview = ref(false)
const IsAndEnv = ref(getPhoneEnvBool('AND'))
// const badgeRef = ref(null);
// const pointsRef = ref(null);
const {
proxy
} = getCurrentInstance()
const crsNum = ref('')
const crsId = ref('')
const step = ref(0)
const teacherList = ref([])
const choiceTeacher = ref('')
const videoUrlShow = ref('')
const talkingList = ref([])
const activeVoiceTalkingItemId = ref('')
const answerValue = ref('')
const inputRef = ref('')
const flagVal = ref('1')
const isUploadingVoice = ref(false)
const isPreview = ref(false)
const IsAndEnv = ref(getPhoneEnvBool('AND'))
// const badgeRef = ref(null);
// const pointsRef = ref(null);
const ajaxApi = computed(() => (isPreview.value ? textChartPreviewApi : textChartApi))
const ajaxApi = computed(() => (isPreview.value ? textChartPreviewApi : textChartApi))
const { statusBarHeight } = uni.getWindowInfo()
const {
statusBarHeight
} = uni.getWindowInfo()
const pageTopPadding = computed(() => statusBarHeight + 'px')
const pageTopPadding = computed(() => statusBarHeight + 'px')
const isContinue = ref('N')
// 初始化数据
const getData = async flag => {
const isContinue = ref('N')
// 初始化数据
const getData = async flag => {
try {
const { body } = await getCourseStudyInfoApi({
const {
body
} = await getCourseStudyInfoApi({
crsId: crsId.value
})
teacherList.value = body.teacheList.map(t => ({
@@ -284,16 +318,17 @@ const getData = async flag => {
.finally(() => {})
}
}
} catch {
} finally {
} catch {} finally {
watchFlag.value += 1
}
}
const answerMethod = ref('01')
const startStudy = data => {
}
const answerMethod = ref('01')
const startStudy = data => {
studyStartApi(data)
.then(res => {
const { body } = res
const {
body
} = res
stdyId.value = body.stdyId || ''
stdyBatch.value = body.stdyBatch || ''
oldStdyId.value = body.oldStdyId || ''
@@ -305,9 +340,9 @@ const startStudy = data => {
answerMethod.value = body.answerMethod || '01'
})
.catch(err => {})
}
// 重新学习
const resStartStudyNow = ($list = []) => {
}
// 重新学习
const resStartStudyNow = ($list = []) => {
let _ajax = isPreview.value ? previewAfreshStudyCourse : afreshStudyCourseApi
_ajax({
crsId: crsId.value
@@ -328,30 +363,30 @@ const resStartStudyNow = ($list = []) => {
voiceObj: null
}))
})
}
}
const showChangeSeekModelNow = () => {
const showChangeSeekModelNow = () => {
showSeekModel.value = true
}
const showBgModel = ref(false)
const showChangeBgModelNow = () => {
}
const showBgModel = ref(false)
const showChangeBgModelNow = () => {
console.log(222)
changePlayItemId()
showBgModel.value = true
}
// 关闭播放状态
const changePlayItemId = (id = '') => {
}
// 关闭播放状态
const changePlayItemId = (id = '') => {
activeVoiceTalkingItemId.value = id
if (id == '') {
storageStore.setGettingVoiceId(id)
}
}
// 选择的教师对象信息
const choiceTeacherInfo = computed(() => {
}
// 选择的教师对象信息
const choiceTeacherInfo = computed(() => {
return teacherList.value.find(t => t.teacherNo === choiceTeacher.value)
})
})
const changeTeacherVoiceNow = async item => {
const changeTeacherVoiceNow = async item => {
if (item.teacherNo === choiceTeacher.value) return
try {
let _ajax = isPreview.value ? setPreviewTeacherApi : setStudyTeacherApi
@@ -363,21 +398,19 @@ const changeTeacherVoiceNow = async item => {
choiceTeacher.value = item.teacherNo
showBgModel.value = false
}
} catch {
} finally {
} catch {} finally {}
}
}
// 选择教师语音对象
const activeVoiceTeachNo = ref('')
let teacherVoiceObj = uni.createInnerAudioContext()
// 选择教师语音对象
const activeVoiceTeachNo = ref('')
let teacherVoiceObj = uni.createInnerAudioContext()
teacherVoiceObj.onEnded(() => {
teacherVoiceObj.onEnded(() => {
activeVoiceTeachNo.value = ''
teacherVoiceObj.src = ''
})
const loadingTeacherVoice = ref(false)
const playTeacherVoice = item => {
})
const loadingTeacherVoice = ref(false)
const playTeacherVoice = item => {
teacherVoiceObj.stop()
teacherVoiceObj.src = ''
let _isStop = item.teacherNo === activeVoiceTeachNo.value
@@ -404,9 +437,9 @@ const playTeacherVoice = item => {
}
})
}
}
var socketTask = null
const nextStep = () => {
}
var socketTask = null
const nextStep = () => {
if (choiceTeacher.value) {
teacherVoiceObj.destroy()
sendMessage({
@@ -426,28 +459,28 @@ const nextStep = () => {
duration: 1000
})
}
}
}
const pgrphNum = ref(1)
const showOrder = ref(0)
const isLastPgrph = ref(false)
const backRouter = () => {
const pgrphNum = ref(1)
const showOrder = ref(0)
const isLastPgrph = ref(false)
const backRouter = () => {
// common.redirectTo(`/pages/courseDetail/index?crsId=${crsId.value}&crsNum=${crsNum.value}&from=study`)
// uni.$emit('refresh_course_list') // yh0903让去除
common.navigateBack()
}
}
const answerOnlyVoice = computed(() => {
const answerOnlyVoice = computed(() => {
return lastTalkingInfo.value.answerWay === 'V' || (answerMethod.value === '03')
})
})
const canAnswerText = computed(() => {
const canAnswerText = computed(() => {
return '每个问题最多连续发送五次答案!'
})
})
const oldStdyId = ref('')
// 获取段落
const getGraphInfoUnStudy = (flag = 0, lastPgrphId = '') => {
const oldStdyId = ref('')
// 获取段落
const getGraphInfoUnStudy = (flag = 0, lastPgrphId = '') => {
isGetting.value = true
let _id = new Date().getTime() + 'id'
let _data = {
@@ -481,13 +514,15 @@ const getGraphInfoUnStudy = (flag = 0, lastPgrphId = '') => {
})
.finally(() => {})
} else {
pointAndBadgesRun('02', crsId.value, ()=>{
pointAndBadgesRun('02', crsId.value, () => {
common
.show('恭喜你已学完全部知识点', '有什么心得跟我们分享吗?', true, '取消', '去评论')
.then(res => {
if (res) {
// 去评论
common.redirectTo(`/pages/courseDetail/index?tabAct=2&crsId=${crsId.value}&crsNum=${crsNum.value}&from=study&isPreview=true`)
common.redirectTo(
`/pages/courseDetail/index?tabAct=2&crsId=${crsId.value}&crsNum=${crsNum.value}&from=study&isPreview=true`
)
} else {
// 取消
common.navigateBack()
@@ -523,11 +558,11 @@ const getGraphInfoUnStudy = (flag = 0, lastPgrphId = '') => {
.finally(() => {
isGetting.value = false
})
}
const lastTalkingInfo = ref({})
const qstLogId = ref('')
// 获取问题
const getQuestionInfoUnStudy = pgrphId => {
}
const lastTalkingInfo = ref({})
const qstLogId = ref('')
// 获取问题
const getQuestionInfoUnStudy = pgrphId => {
isGetting.value = true
unref(ajaxApi)({
processType: 'QNS-ANSER',
@@ -585,12 +620,12 @@ const getQuestionInfoUnStudy = pgrphId => {
.finally(() => {
isGetting.value = false
})
}
}
const isGetting = ref(false)
const isGetting = ref(false)
// 继续 执行方法
const nextQuestionSuccess = (info, type = 'next') => {
// 继续 执行方法
const nextQuestionSuccess = (info, type = 'next') => {
if (isGetting.value) return
isGetting.value = true
let _id = new Date().getTime() + 'id'
@@ -605,11 +640,11 @@ const nextQuestionSuccess = (info, type = 'next') => {
scrollToBottomNow()
getQuestionInfoUnStudy(info.pgrphId)
} else if (type === 'overGraph') {
overPgrhNow(info,getQuestionInfoUnStudy,_id)
overPgrhNow(info, getQuestionInfoUnStudy, _id)
} else if (type === 'overNextGraph') {
overPgrhNow(info,($id)=>{
overPgrhNow(info, ($id) => {
getGraphInfoUnStudy(0, $id)
},_id)
}, _id)
} else if (type === 'nextGraph') {
talkingList.value.push({
crsId: info.crsId,
@@ -707,8 +742,8 @@ const nextQuestionSuccess = (info, type = 'next') => {
isGetting.value = false
})
}
}
const overPgrhNow = (info,cb = ()=>{},_id) => {
}
const overPgrhNow = (info, cb = () => {}, _id) => {
unref(ajaxApi)({
processType: 'PRGH-OVER',
requestBody: JSON.stringify({
@@ -728,18 +763,18 @@ const overPgrhNow = (info,cb = ()=>{},_id) => {
id: _id
})
scrollToBottomNow(300)
setTimeout(()=>{
setTimeout(() => {
cb(info.pgrphId)
},500)
}, 500)
// cb(info.pgrphId)
})
.finally(() => {
isGetting.value = false
})
}
const scrollBoxRef = ref()
const scrollTop = ref(99999)
const scrollToBottomNow = (time = 500) => {
}
const scrollBoxRef = ref()
const scrollTop = ref(99999)
const scrollToBottomNow = (time = 500) => {
nextTick(() => {
setTimeout(() => {
scrollTop.value += 1
@@ -754,19 +789,23 @@ const scrollToBottomNow = (time = 500) => {
}
}, time)
})
}
}
const reconnectTimer = null // 重连timer
const isManualClose = ref(false) // 是否手动关闭
const reconnectTimer = null // 重连timer
const isManualClose = ref(false) // 是否手动关闭
const stdyId = ref('')
const stdyBatch = ref('')
const logId = ref('')
// ws 初始化逻辑
const initsocketTask = () => {
const stdyId = ref('')
const stdyBatch = ref('')
const logId = ref('')
// ws 初始化逻辑
const initsocketTask = () => {
socketStore.creatSocket()
unref(SocketObj).on('message', res => {
const { rtnCode, body, commond } = JSON.parse(res.data)
const {
rtnCode,
body,
commond
} = JSON.parse(res.data)
if (rtnCode === '0000') {
if (commond === 'STDYBTH' && !stdyId.value) {
stdyId.value = body.stdyId || ''
@@ -782,18 +821,18 @@ const initsocketTask = () => {
// }
}
})
}
const reconnect = () => {
}
const reconnect = () => {
initsocketTask()
}
const sendMessage = data => {
}
const sendMessage = data => {
// unref(SocketObj).send(data)
startStudy(data.body)
}
// ws 结束
const startPgrphId = ref('')
const imageId = ref('')
onLoad(params => {
}
// ws 结束
const startPgrphId = ref('')
const imageId = ref('')
onLoad(params => {
changeAppHeightBottom()
watchFlag.value = 1
isPreview.value = params.isPreview === 'preview'
@@ -801,40 +840,40 @@ onLoad(params => {
crsNum.value = params.crsNum || ''
imageId.value = params.imgId || ''
startPgrphId.value = params.pgrphId || ''
})
const showTalkingModel = ref(false)
// 录音
onMounted(() => {
})
const showTalkingModel = ref(false)
// 录音
onMounted(() => {
// initsocketTask()
getData('1')
})
const keyboardHeight = ref('0px')
const setHeight = res => {
})
const keyboardHeight = ref('0px')
const setHeight = res => {
keyboardHeight.value = res.height + 'px'
// scrollToBottomNow()
}
}
const keyBoardIsHide = computed(() => {
const keyBoardIsHide = computed(() => {
return parseInt(keyboardHeight.value) == 0
})
const bottomHeight = ref('0px')
const totalBotHeight = computed(() => {
})
const bottomHeight = ref('0px')
const totalBotHeight = computed(() => {
return keyBoardIsHide.value ? 0 + 'px' : parseInt(keyboardHeight.value) - parseInt(bottomHeight.value) + 'px'
})
const changeAppHeightBottom = height => {
})
const changeAppHeightBottom = height => {
//#ifdef APP-PLUS
// 获取系统信息
const systemInfo = uni.getSystemInfoSync()
// 计算安全区域底部高度
bottomHeight.value = systemInfo.screenHeight - systemInfo.safeArea.bottom + 'px'
// #endif
}
const closeStudy = () => {
}
const closeStudy = () => {
return studyEndApi({
stdyId: stdyId.value
})
}
onHide(() => {
}
onHide(() => {
changePlayItemId('')
if (!isPreview.value) {
closeStudy()
@@ -852,8 +891,8 @@ onHide(() => {
// common.show('提示信息', '检测到您已离开,即将退出学习页面。',false, '','确认').then((res) => {
// common.redirectTo(`/pages/courseDetail/index?crsId=${crsId.value}&crsNum=${crsNum.value}&from=study`)
// }).finally(() => {})
})
onShow(() => {
})
onShow(() => {
console.log('onShow')
//#ifdef APP-PLUS
uni.onKeyboardHeightChange(setHeight)
@@ -880,9 +919,9 @@ onShow(() => {
// step.value = 2
// }).catch(err => {})
// }
})
const watchFlag = ref(1)
onUnload(() => {
})
const watchFlag = ref(1)
onUnload(() => {
console.log('onUnload')
if (!isPreview.value) {
closeStudy()
@@ -895,17 +934,17 @@ onUnload(() => {
teacherVoiceObj.src = ''
// 0910杨航叫我这么改的
} catch {}
})
const testAnswer = computed(() => {
})
const testAnswer = computed(() => {
if (talkingList.value.length < 5) return true
let _arr = talkingList.value.slice(-5)
let _num = _arr.map(t => [1, 2, 6].indexOf(Number(t.type)) >= 0).filter(t => !!t)
return _num.length < 5
})
})
const sendLoading = () => {
const sendLoading = () => {
if (!testAnswer.value) {
common.msg('每个问题最多连续发送五次答案!')
return
@@ -940,22 +979,65 @@ const sendLoading = () => {
scrollToBottomNow()
// #endif
}
// 新录音组件语音提交
const submitVoice = ({ossKey,text}) => {
if(!ossKey) {
}
// 新录音组件语音提交
const submitVoice = ({
ossKey,
text
}) => {
if (!ossKey) {
common.msg('系统异常,请联系管理员');
} else if (text === '') {
common.msg('未识别到文字');
} else {
let _data = {
stdyId: unref(stdyId),
qnsId: unref(lastTalkingInfo).qnsId, // 问题ID 必输项:true 类型:String
pgrphId: unref(lastTalkingInfo).pgrphId, // 段落ID 必输项:true 类型:String
qstLogId: unref(qstLogId), // 段落ID 必输项:true 类型:String
crsId: crsId.value, // 课程ID 必输项:true 类型:String
stdyBatch: stdyBatch.value, // 学习批次 必输项:true 类型:String
ansterContent: '', // 回答文本内容 必输项:false 类型:String
asrStartTm: unref(lastTalkingInfo).asrStartTm,
ossKey,
text
}
let _id = new Date().getTime() + 'id'
unref(ajaxApi)({
processType: 'ANSER-TEXT',
processType: 'ANSER-VOICE',
requestBody: JSON.stringify(_data)
})
.then(res => {
let _obj = {
crsId: crsId.value,
pgrphId: _data.pgrphId,
qstLogId: _data.qstLogId,
qnsId: _data.qnsId,
talkingContent: text,
bucketKey: ossKey,
text,
talkingVoice: '',
recordId: res.body.chatBody.recordId,
asrStartTm: unref(lastTalkingInfo).asrStartTm,
stdyPgrphId: res.body.chatBody.stdyPgrphId,
type: 1,
isLoading: false,
userInfo: {
...choiceTeacherInfo.value
},
id: _id,
voiceTime: 0
}
}
const uploadRecordNow = (voicePath, voiceTime) => {
talkingList.value.push(_obj)
scrollToBottomNow()
setIsUploadingVoice()
})
.catch((err) => {
setIsUploadingVoice()
})
}
}
const uploadRecordNow = (voicePath, voiceTime) => {
if (!testAnswer.value) {
common.msg('每个问题最多连续发送五次答案!')
return
@@ -1050,8 +1132,8 @@ const uploadRecordNow = (voicePath, voiceTime) => {
})
})
// #endif
}
const setIsUploadingVoice = (flag = false) => {
}
const setIsUploadingVoice = (flag = false) => {
if (flag) {
isUploadingVoice.value = true
} else {
@@ -1059,9 +1141,9 @@ const setIsUploadingVoice = (flag = false) => {
isUploadingVoice.value = false
}, 100)
}
}
// 发送文本
const submitAnswerNow = (val, cb) => {
}
// 发送文本
const submitAnswerNow = (val, cb) => {
if (!testAnswer.value) {
common.msg('每个问题最多连续发送五次答案!')
return
@@ -1108,9 +1190,9 @@ const submitAnswerNow = (val, cb) => {
.catch(() => {
setIsUploadingVoice()
})
}
// 撤回
const withdrawNow = data => {
}
// 撤回
const withdrawNow = data => {
if (isGetting.value) return
isGetting.value = true
unref(ajaxApi)({
@@ -1127,9 +1209,9 @@ const withdrawNow = data => {
.finally(() => {
isGetting.value = false
})
}
const loadingExecLogId = ref('')
const answerQuestionNow = data => {
}
const loadingExecLogId = ref('')
const answerQuestionNow = data => {
if (isGetting.value) return
isGetting.value = true
let _data = {
@@ -1184,9 +1266,9 @@ const answerQuestionNow = data => {
.finally(() => {
isGetting.value = false
})
}
// 完成
const finishQuestionNow = data => {
}
// 完成
const finishQuestionNow = data => {
if (isGetting.value) return
isGetting.value = true
unref(ajaxApi)({
@@ -1234,9 +1316,9 @@ const finishQuestionNow = data => {
.finally(() => {
isGetting.value = false
})
}
// 查询问题回答评分
const getQuestionEvalateRequest = (id, data, num) => {
}
// 查询问题回答评分
const getQuestionEvalateRequest = (id, data, num) => {
if (loadingExecLogId.value) {
unref(ajaxApi)({
processType: 'ANSER-RESULT',
@@ -1288,20 +1370,20 @@ const getQuestionEvalateRequest = (id, data, num) => {
}
})
}
}
}
const showSeekModel = ref(false)
const rateList = ref(['0.5', '0.8', '1.0', '1.5', '2.0'])
const chooseRate = ref('1.0')
const chooseRateNow = item => {
const showSeekModel = ref(false)
const rateList = ref(['0.5', '0.8', '1.0', '1.5', '2.0'])
const chooseRate = ref('1.0')
const chooseRateNow = item => {
chooseRate.value = item
showSeekModel.value = false
teacherVoiceObj.playbackRate = Number(item)
}
}
</script>
<style lang="scss" scoped>
.course-study {
.course-study {
position: relative;
display: flex;
flex-direction: column;
@@ -1380,7 +1462,7 @@ const chooseRateNow = item => {
position: sticky;
top: 0;
.top-desc{
.top-desc {
position: absolute;
bottom: -10rpx;
font-size: 18rpx;
@@ -1388,6 +1470,7 @@ const chooseRateNow = item => {
left: 50%;
transform: translateX(-50%);
}
// margin-bottom: 23rpx;
.arrow-icon {
position: absolute;
@@ -1411,19 +1494,22 @@ const chooseRateNow = item => {
background: url(@/static/images/course/study-bg.png) no-repeat;
border-radius: 30rpx 30rpx 0 0;
font-size: 29rpx;
.color-blue {
color: #06f;
display: inline;
}
.color-black{
.color-black {
color: #333;
position: relative;
height: 44rpx;
line-height: 44rpx;
&.ml-40{
&.ml-40 {
padding-left: 24rpx;
&::before{
&::before {
content: '';
display: block;
width: 12rpx;
@@ -1438,10 +1524,12 @@ const chooseRateNow = item => {
}
}
}
.color-gray{
.color-gray {
color: #999;
}
.bg-block{
.bg-block {
display: block;
width: 100%;
height: 56rpx;
@@ -1449,16 +1537,18 @@ const chooseRateNow = item => {
position: relative;
// margin: 0 30rpx;
}
.bg-gray{
.bg-gray {
width: 100%;
background-color: #ededed;
overflow: hidden;
border-radius: 15rpx;
position: absolute;
top: 13rpx;
left:0;
left: 0;
height: 16rpx;
.bg-blue{
.bg-blue {
height: 100%;
float: left;
background-color: #06f;
@@ -1488,7 +1578,8 @@ const chooseRateNow = item => {
.talk-btns {
height: 150rpx;
background-color: #fff;
padding: 25rpx 30rpx 0;
padding: 25rpx 10rpx 0;
width: 100%;
position: relative;
.touch-btn {
@@ -1653,9 +1744,9 @@ const chooseRateNow = item => {
line-height: 80rpx;
}
}
}
}
.overlay-box {
.overlay-box {
display: flex;
flex-direction: column-reverse;
// justify-content: flex-end;
@@ -1831,5 +1922,5 @@ const chooseRateNow = item => {
}
}
}
}
}
</style>
+2 -2
View File
@@ -163,12 +163,12 @@
const sendReply = (data) => {
console.log(data,'111111111111')
commentRef.value?.setReplyData(data, ()=>{
commentInputRef.value.hideAll(true)
commentInputRef.value?.hideAll(true)
});
}
const hideKeyboradNow = () => {
if (isShowing.value) return
commentInputRef.value.hideAll()
commentInputRef.value?.hideAll()
}
const getData = async () => {
common.loading();
+43 -11
View File
@@ -51,6 +51,15 @@
import {
getPhoneEnvBool
} from '@/common/common.js';
import {
downloadFile,
downloadVoiceFile
} from '@/api/common.js'
import {
useStorageStore
} from '@/store/storage.js';
const storageStore = useStorageStore();
const props = defineProps({
dataInfo: {
default: () => ({}),
@@ -101,14 +110,14 @@
const pauseVoice = (flag) => {
if (!talkUserVoiceObj.value) return
talkUserVoiceObj.value.pause()
if(flag === 'destory') talkVoiceObj.value.destory()
if (flag === 'destory') talkVoiceObj.value.destory()
isPlaying.value = false
emit('changePlay', '')
}
const playVoice = () => {
emit('changePlay', unref(dataInfo)?.id)
talkUserVoiceObj.value.volume = 1
if(isTesting.value){
if (isTesting.value) {
restartPlay()
return
}
@@ -120,14 +129,37 @@
}, 300)
return
} else {
talkUserVoiceObj.value.src = ''
if (unref(dataInfo).talkingVoice) {
setTimeout(() => {
talkUserVoiceObj.value.src = itemVoice.value
talkUserVoiceObj.value.play()
isPlaying.value = true
}, 100)
voiceLoading.value = true;
let _id = unref(dataInfo)?.fileId
storageStore.getStorageById('audio', _id, (url) => {
if (url) {
voiceLoading.value = false;
itemVoice.value = url;
talkVoiceObj.value.src = url;
if (voiceIsPlaying.value) return
if (unref(dataInfo)?.id !== props.activeVoiceId) return
talkVoiceObj.value.play();
} else {
downloadFile(_id)
.then((res) => {
if (res?.data) {
common.msg(res.data.message);
return;
}
voiceLoading.value = false;
itemVoice.value = res.tempFilePath;
talkVoiceObj.value.src = res.tempFilePath;
if (voiceIsPlaying.value) return
if (unref(dataInfo)?.id !== props.activeVoiceId) return
talkVoiceObj.value.play();
storageStore.setStorage('audio', _id, itemVoice.value);
})
.catch((err) => {
voiceLoading.value = false;
emit('changePlay', '');
});
}
});
}
}
const IsAndEnv = getPhoneEnvBool('AND');
@@ -171,10 +203,10 @@
const setVoiceTime = (sum) => {
plus.io.getAudioInfo({
filePath: unref(dataInfo).talkingVoice,
success:(res)=>{
success: (res) => {
voiceTime.value = (Math.floor(res.duration) || 1) + 's'
},
fail:(res)=>{
fail: (res) => {
voiceTime.value = (props.dataInfo.voiceTime || 1) + 's'
}
})
+268 -122
View File
@@ -11,7 +11,9 @@
</view>
<view class="top-desc">内容由AI生成</view>
</view>
<scroll-view :class="[' body-content index-dialog-body', detailInfo.traInterTyp === '01' ? 'talking-type1' : '']" :scroll-y="true" refresher-default-style="none" :scroll-top="scrollTop" :show-scrollbar="false" :scroll-with-animation="false">
<scroll-view :class="[' body-content index-dialog-body', detailInfo.traInterTyp === '01' ? 'talking-type1' : '']"
:scroll-y="true" refresher-default-style="none" :scroll-top="scrollTop" :show-scrollbar="false"
:scroll-with-animation="false">
<view :class="['body-content-role', showRoleInfo ? '' : 'hide-info']">
<view :class="['role-title']">
<ImagePreview class="role-title-avatar" :src="detailInfo.ossAddr" :isCache="true"></ImagePreview>
@@ -21,8 +23,10 @@
<text class="card-title-name">{{ detailInfo.chaName }}</text>
<text class="card-title-age">{{ detailInfo.chaAge }}</text>
<text class="card-title-img">
<image class="card-title-icon" v-if="detailInfo.gender === 'm' || detailInfo.gender === '01'" src="@/static/images/me/man.png"></image>
<image class="card-title-icon" v-if="detailInfo.gender === 'f' || detailInfo.gender === '02'" src="@/static/images/me/wuman.png"></image>
<image class="card-title-icon" v-if="detailInfo.gender === 'm' || detailInfo.gender === '01'"
src="@/static/images/me/man.png"></image>
<image class="card-title-icon" v-if="detailInfo.gender === 'f' || detailInfo.gender === '02'"
src="@/static/images/me/wuman.png"></image>
</text>
</view>
<view class="role-desc"> 预计时长 {{ detailInfo.traStartLimit }} ~ {{ detailInfo.traEndLimit }} 分钟 </view>
@@ -58,29 +62,40 @@
<view class="tip-text">-请点击下方按钮开始{{ detailInfo.traInterTypDesc }}</view>
</view>
<view class="talking-box" v-else>
<TalkingItem
v-for="(item, index) in talkingList"
:talkingType="item.type"
:talkingInfo="item"
:roleInfo="detailInfo"
:traId="traId"
:execId="execId"
:isExam="talkingType === '02'"
:isLast="index + 1 === talkingList.length"
:isAnswering="!answerIsOver"
:activeVoiceId="activeVoiceTalkingItemId"
@handleEvents="talkItemEvents"></TalkingItem>
<TalkingItem v-for="(item, index) in talkingList" :talkingType="item.type" :talkingInfo="item"
:roleInfo="detailInfo" :traId="traId" :execId="execId" :isExam="talkingType === '02'"
:isLast="index + 1 === talkingList.length" :isAnswering="!answerIsOver"
:activeVoiceId="activeVoiceTalkingItemId" @handleEvents="talkItemEvents"></TalkingItem>
</view>
</scroll-view>
<view class="over-btn-box" v-if="detailInfo.traInterTyp === '01'">
<view class="over-btn" @click="overTalking">结束陪练</view>
</view>
<TouchBtn class="body-bottom" @uploadVoice="uploadRecordNow" @startRecord="changePlayItemId('')" formatType="wav" :isLoading="!answerIsOver" :isDisabled="false" v-if="detailInfo.traInterTyp === '01'" />
<!-- <TouchBtn
class="body-bottom"
@uploadVoice="uploadRecordNow"
@startRecord="changePlayItemId('')"
formatType="wav"
:isLoading="!answerIsOver"
:isDisabled="false"
v-if="detailInfo.traInterTyp === '01'" /> -->
<touch-btn class="body-bottom" @submitVoice="submitVoice" @sendLoading="sendLoading" @submitAnswer="submitAnswer"
@startRecord="changePlayItemId('')" :isLoading="!answerIsOver" :isDisabled="false" theme="blue"
answerMethod="03" v-if="detailInfo.traInterTyp === '01'" >
<view class="center-text">
<image class="type-icon" src="@/static/images/sparring/talk-icon.png"></image>
{{'语音对话'}}
</view>
</touch-btn>
<view class="body-bottom" v-else>
<view class="body-bottom-btn" @click="beforeToTalking">
<view class="center-text">
<image class="type-icon" src="@/static/images/sparring/video-icon.png" v-if="detailInfo.traInterTyp === '03'"></image>
<image class="type-icon" src="@/static/images/sparring/phone-icon.png" v-else-if="detailInfo.traInterTyp === '02'"></image>
<image class="type-icon" src="@/static/images/sparring/video-icon.png"
v-if="detailInfo.traInterTyp === '03'"></image>
<image class="type-icon" src="@/static/images/sparring/phone-icon.png"
v-else-if="detailInfo.traInterTyp === '02'"></image>
<image v-else class="type-icon" src="@/static/images/sparring/talk-icon.png"></image>
{{ detailInfo.traInterTypDesc }}
</view>
@@ -93,50 +108,85 @@
</template>
<script setup>
import { ref, unref, onMounted, computed, nextTick } from 'vue'
import { onShow, onHide, onLoad, onUnload, onLaunch, onBackPress } from '@dcloudio/uni-app'
import common from '@/common/common'
import { getPhoneEnvBool } from '@/common/common'
import TouchBtn from './components/touchBtn.vue'
import ImagePreview from '@/components/image-preview/image-preview.vue'
import { commonUploadVoiceFile } from '@/api/common.js'
import { queryTraPartnerCharacterInfoById, partnerChatReportTrigger, checkTraPartnerInfoById } from '@/api/sparring.js'
import { useSocketStore } from '@/store/socket.js'
import { useStorageStore } from '@/store/storage.js'
import { storeToRefs } from 'pinia'
import TalkingItem from './components/talking-item.vue'
import badge from '@/components/points-and-badge/badge'
import points from '@/components/points-and-badge/points'
import usePointsAndBadge from '@/components/points-and-badge/usePointsAndBadge'
import {
ref,
unref,
onMounted,
computed,
nextTick
} from 'vue'
import {
onShow,
onHide,
onLoad,
onUnload,
onLaunch,
onBackPress
} from '@dcloudio/uni-app'
import common from '@/common/common'
import {
getPhoneEnvBool
} from '@/common/common'
// import TouchBtn from './components/touchBtn.vue'
import ImagePreview from '@/components/image-preview/image-preview.vue'
import {
commonUploadVoiceFile
} from '@/api/common.js'
import {
queryTraPartnerCharacterInfoById,
partnerChatReportTrigger,
checkTraPartnerInfoById
} from '@/api/sparring.js'
import {
useSocketStore
} from '@/store/socket.js'
import {
useStorageStore
} from '@/store/storage.js'
import {
storeToRefs
} from 'pinia'
import TalkingItem from './components/talking-item.vue'
import badge from '@/components/points-and-badge/badge'
import points from '@/components/points-and-badge/points'
import usePointsAndBadge from '@/components/points-and-badge/usePointsAndBadge'
import { initRecord } from '@/composables/useExamSubject.js'
import permissionApi from '@/common/permission'
const { pointAndBadgesRun, badgeRef, pointsRef } = usePointsAndBadge()
const socketStore = useSocketStore()
const { SocketObj } = storeToRefs(socketStore)
import {
initRecord
} from '@/composables/useExamSubject.js'
import permissionApi from '@/common/permission'
const {
pointAndBadgesRun,
badgeRef,
pointsRef
} = usePointsAndBadge()
const socketStore = useSocketStore()
const {
SocketObj
} = storeToRefs(socketStore)
const traId = ref('')
const chaId = ref('')
const talkingType = ref('')
// const badgeRef = ref(null);
// const pointsRef = ref(null);
const isPreview = ref(false)
const detailInfo = ref({})
const currentIndex = ref(0)
const showRoleInfo = ref(false)
const showLoading = ref(true)
const talkingList = ref([])
// {
// type: 'answer',
// talkingText: 'asad我是回答内容',
// isLoading: false,
// id: new Date().getTime(),
// },
const askData = ref({})
const execId = ref('')
const answerIsOver = ref(true)
const traId = ref('')
const chaId = ref('')
const talkingType = ref('')
// const badgeRef = ref(null);
// const pointsRef = ref(null);
const isPreview = ref(false)
const detailInfo = ref({})
const currentIndex = ref(0)
const showRoleInfo = ref(false)
const showLoading = ref(true)
const talkingList = ref([])
// {
// type: 'answer',
// talkingText: 'asad我是回答内容',
// isLoading: false,
// id: new Date().getTime(),
// },
const askData = ref({})
const execId = ref('')
const answerIsOver = ref(true)
const getDetailInfo = () => {
const getDetailInfo = () => {
queryTraPartnerCharacterInfoById({
traId: traId.value,
chaId: chaId.value
@@ -152,22 +202,79 @@ const getDetailInfo = () => {
showLoading.value = false
}, Math.random() * 1000 + 500)
})
}
const scrollTop = ref(99999)
const scrollToBottomNow = (time = 100) => {
}
const scrollTop = ref(99999)
const scrollToBottomNow = (time = 100) => {
nextTick(() => {
setTimeout(() => {
scrollTop.value += 100
scrollTop.value += 100
}, time)
})
}
const uploadRecordNow = (voicePath, voiceTime) => {
}
// 新发送语音
const submitVoice = ({
ossKey,
text
}) => {
console.log('新发送语音', ossKey, text);
if (!ossKey) {
uni.showToast({
title: '系统异常,请联系管理员',
icon: 'none',
duration: 1000
});
} else if (text) {
if (!execId.value) {
common.show('提示', '网络连接失败,请重新加载', false).then(res => {
if (res) {
common.redirectTo('/pages/sparring/tip?traId=' + traId.value + '&chaId=' + chaId.value + '&type=' +
talkingType.value + '&isPreview=' + (isPreview.value ? '1' : ''))
}
})
return
}
askData.value = {
execId: execId.value,
intrctWay: '02', //01-文本;02-语音;03-图片
intrctContent: text,
fileId: ossKey,
ossFileAddr: `/traoss/tras3/show/${ossKey}`,
talkingVoice: '',
voiceTime: 0
}
sendMessage({
commond: 'ASK',
body: askData.value
})
} else {
talkingList.value.pop();
uni.showToast({
title: '未识别到文字',
icon: 'none',
duration: 1000
});
}
}
// 新发送语音前loading动画
const sendLoading = () => {
talkingList.value.push({
type: 'question',
talkingText: '',
isLoading: true
});
scrollToBottomNow();
}
const uploadRecordNow = (voicePath, voiceTime) => {
console.log(voicePath, voiceTime)
if (!execId.value) {
common.show('提示', '网络连接失败,请重新加载', false).then(res => {
if (res) {
common.redirectTo('/pages/sparring/tip?traId=' + traId.value + '&chaId=' + chaId.value + '&type=' + talkingType.value + '&isPreview=' + (isPreview.value ? '1' : ''))
common.redirectTo('/pages/sparring/tip?traId=' + traId.value + '&chaId=' + chaId.value + '&type=' +
talkingType.value + '&isPreview=' + (isPreview.value ? '1' : ''))
}
})
return
@@ -220,8 +327,8 @@ const uploadRecordNow = (voicePath, voiceTime) => {
})
})
// #endif
}
const beforeToTalking = () => {
}
const beforeToTalking = () => {
if (isPreview.value) {
toTalking()
return
@@ -235,8 +342,8 @@ const beforeToTalking = () => {
common.show('提示', res.body.message, false)
}
})
}
const toTalking = async () => {
}
const toTalking = async () => {
try {
//#ifdef APP-PLUS
console.log('申请权限')
@@ -262,18 +369,24 @@ const toTalking = async () => {
} else if (detailInfo.value.traInterTyp === '03') {
_gotUrl = '/pages/sparring/talk' // 没改好,暂时跳到一个页
}
common.redirectTo(_gotUrl + '?traId=' + traId.value + '&chaId=' + chaId.value + '&type=' + talkingType.value + '&traInterTyp=' + detailInfo.value.traInterTyp + '&isPreview=' + (isPreview.value ? '1' : '0'))
common.redirectTo(_gotUrl + '?traId=' + traId.value + '&chaId=' + chaId.value + '&type=' + talkingType.value +
'&traInterTyp=' + detailInfo.value.traInterTyp + '&isPreview=' + (isPreview.value ? '1' : '0'))
} catch (err) {
console.error('申请权限失败')
}
}
const activeVoiceTalkingItemId = ref('')
// 关闭播放状态
const changePlayItemId = (id = '') => {
}
const activeVoiceTalkingItemId = ref('')
// 关闭播放状态
const changePlayItemId = (id = '') => {
activeVoiceTalkingItemId.value = id
}
}
const talkItemEvents = ({ type, data, id, info = {} }) => {
const talkItemEvents = ({
type,
data,
id,
info = {}
}) => {
switch (type) {
case 'changePlay':
activeVoiceTalkingItemId.value = id
@@ -284,16 +397,16 @@ const talkItemEvents = ({ type, data, id, info = {} }) => {
default:
break
}
}
}
const watchFlag = ref(1)
const showModelComfirm = ref(false)
const reconcatNum = ref(0)
const answerText = ref('')
const touchBtnCallBack = ref(null)
const stopAnswerCallBack = ref(false)
let isLeave = false
const initsocketTask = () => {
const watchFlag = ref(1)
const showModelComfirm = ref(false)
const reconcatNum = ref(0)
const answerText = ref('')
const touchBtnCallBack = ref(null)
const stopAnswerCallBack = ref(false)
let isLeave = false
const initsocketTask = () => {
let _src = isPreview.value ? '/trapractice/previewsocket/open' : '/trapractice/partnersocket/open'
socketStore.creatSocket(_src + '?summary=')
// unref(SocketObj).on('open', (res)=>{
@@ -324,7 +437,8 @@ const initsocketTask = () => {
reconcatNum.value += 1
// common.redirectTo(`/pages/index/dialog`);
socketStore?.closeSocket()
common.redirectTo('/pages/sparring/result?isOver=1&traId=' + traId.value + '&execId=' + execId.value + '&type=' + talkingType.value + '&isPreview=' + (isPreview.value ? '1' : ''))
common.redirectTo('/pages/sparring/result?isOver=1&traId=' + traId.value + '&execId=' + execId
.value + '&type=' + talkingType.value + '&isPreview=' + (isPreview.value ? '1' : ''))
})
})
.finally(() => {
@@ -332,7 +446,11 @@ const initsocketTask = () => {
})
})
unref(SocketObj).on('message', res => {
const { rtnCode, body, commond } = JSON.parse(res.data)
const {
rtnCode,
body,
commond
} = JSON.parse(res.data)
let _id = new Date().getTime() + 'id'
if (rtnCode === '0000') {
if (commond === 'ASK-OPEN') {
@@ -451,7 +569,8 @@ const initsocketTask = () => {
console.log(body)
console.log('陪练已结束,去结果页面!')
socketStore?.closeSocket()
common.redirectTo('/pages/sparring/result?isOver=1&traId=' + traId.value + '&execId=' + execId.value + '&type=' + talkingType.value + '&isPreview=' + (isPreview.value ? '1' : ''))
common.redirectTo('/pages/sparring/result?isOver=1&traId=' + traId.value + '&execId=' + execId.value +
'&type=' + talkingType.value + '&isPreview=' + (isPreview.value ? '1' : ''))
return
}
if (commond === 'ASK-PONG') {
@@ -473,20 +592,21 @@ const initsocketTask = () => {
}
})
watchFlag.value += 1
}
const goBack = () => {
console.log(222,detailInfo.value.traInterTyp === '01')
}
const goBack = () => {
console.log(222, detailInfo.value.traInterTyp === '01')
if (detailInfo.value.traInterTyp === '01') {
overTalking()
} else {
common.navigateBack()
}
}
const overTalking = () => {
}
const overTalking = () => {
if (!execId.value) {
common.show('提示', '网络连接失败,请重新加载', false).then(res => {
if (res) {
common.redirectTo('/pages/sparring/tip?traId=' + traId.value + '&chaId=' + chaId.value + '&type=' + talkingType.value + '&isPreview=' + (isPreview.value ? '1' : ''))
common.redirectTo('/pages/sparring/tip?traId=' + traId.value + '&chaId=' + chaId.value + '&type=' +
talkingType.value + '&isPreview=' + (isPreview.value ? '1' : ''))
}
})
return
@@ -496,8 +616,8 @@ const overTalking = () => {
overNow()
}
})
}
const overNow = (cb = () => {}) => {
}
const overNow = (cb = () => {}) => {
watchFlag.value = 1
sendMessage({
commond: 'ASK-STOP',
@@ -507,7 +627,8 @@ const overNow = (cb = () => {}) => {
})
socketStore?.closeSocket()
changePlayItemId('')
common.redirectTo('/pages/sparring/result?isOver=1&traId=' + traId.value + '&execId=' + execId.value + '&type=' + talkingType.value + '&isPreview=' + (isPreview.value ? '1' : ''))
common.redirectTo('/pages/sparring/result?isOver=1&traId=' + traId.value + '&execId=' + execId.value + '&type=' +
talkingType.value + '&isPreview=' + (isPreview.value ? '1' : ''))
// partnerChatReportTrigger({
// execId: execId.value,
@@ -529,16 +650,16 @@ const overNow = (cb = () => {}) => {
// .catch(() => {
// cb()
// })
}
const sendMessage = data => {
}
const sendMessage = data => {
unref(SocketObj).send(data)
if (data.commond == 'ASK-PING') {
console.log('PING')
}
}
// let timer = null
//#ifdef APP-PLUS
onShow(() => {
}
// let timer = null
//#ifdef APP-PLUS
onShow(() => {
isLeave = false
// timer = setInterval(() => {
// sendMessage({
@@ -548,14 +669,14 @@ onShow(() => {
// }
// }, 1000)
// })
})
onHide(() => {
})
onHide(() => {
isLeave = true
// clearInterval(timer)
// timer = null
})
// #endif
onLoad(params => {
})
// #endif
onLoad(params => {
execId.value = ''
traId.value = params.traId
chaId.value = params.chaId
@@ -566,8 +687,8 @@ onLoad(params => {
//#ifdef APP-PLUS
plus.screen.lockOrientation('portrait-primary')
// #endif
})
onUnload(() => {
})
onUnload(() => {
console.log('onUnload')
watchFlag.value = 1
sendMessage({
@@ -580,24 +701,24 @@ onUnload(() => {
socketStore?.closeSocket()
}
execId.value = ''
})
onLaunch(() => {
})
onLaunch(() => {
console.log('onLaunch')
})
onMounted(() => {
})
onMounted(() => {
// getDetailInfo()
})
onBackPress(res => {
})
onBackPress(res => {
console.log(1111)
if (res.from === 'backbutton') {
goBack()
return true
}
})
})
</script>
<style lang="scss" scoped>
.sparring-detail {
.sparring-detail {
position: relative;
overflow-x: hidden;
overflow-y: auto;
@@ -764,6 +885,7 @@ onBackPress(res => {
display: flex;
flex-direction: column;
justify-content: space-evenly;
.role-name {
width: 100%;
@@ -887,6 +1009,7 @@ onBackPress(res => {
text-align: center;
}
}
.talking-desc {
// padding-top: 24rpx;
padding: 24rpx 20rpx 0;
@@ -894,8 +1017,9 @@ onBackPress(res => {
font-size: 24rpx;
// text-align: center;
color: #999;
&.second{
padding-top:0;
&.second {
padding-top: 0;
}
}
@@ -933,7 +1057,7 @@ onBackPress(res => {
.body-bottom {
height: 180rpx;
background-color: #fff;
padding: 36rpx 23rpx 0;
padding: 36rpx 10rpx 0;
position: fixed;
width: 100vw;
bottom: 0;
@@ -969,5 +1093,27 @@ onBackPress(res => {
}
}
}
}
}
.body-bottom{
.center-text {
height: 35rpx;
line-height: 35rpx;
width: 100%;
position: absolute;
top: 50%;
transform: translateY(-50%);
display: flex;
justify-content: center;
color:#fff;
}
.type-icon {
width: 35rpx;
height: 35rpx;
margin-right: 10rpx;
}
}
</style>