diff --git a/src/api/study.js b/src/api/study.js index df818e4e..ef123a57 100644 --- a/src/api/study.js +++ b/src/api/study.js @@ -156,4 +156,14 @@ export const textChartApi = (data) => { toastErrors: true, data }); +}; + +// 设置学习顾问音色/traStdyTeacher/setStudyTeacher +export const setStudyTeacherApi = (data) => { + return request({ + url: base_url + '/traStdyTeacher/setStudyTeacher', + method: 'post', + toastErrors: true, + data + }); }; \ No newline at end of file diff --git a/src/pages/course/components/talkingItem.vue b/src/pages/course/components/talkingItem.vue index 43b5ec4e..b2d61564 100644 --- a/src/pages/course/components/talkingItem.vue +++ b/src/pages/course/components/talkingItem.vue @@ -3,11 +3,11 @@ - + - {{ dataInfo?.userInfo?.teacherName }} - {{dataInfo?.userInfo?.teacherDesc}} + {{ teacherInfo?.teacherName }} + {{teacherInfo?.teacherDesc}} @@ -88,11 +88,11 @@ @@ -205,6 +205,10 @@ const audioCacheObj = computed(() => storageStore.audioObj) default: () => ({}), type: Object }, + teacherInfo: { + default: () => ({}), + type: Object + }, activeVoiceId:{ default:'', type: String @@ -239,12 +243,13 @@ const audioCacheObj = computed(() => storageStore.audioObj) } }) - const { type, dataInfo, activeVoiceId, isPlaying, isLast, lastQuestionInfo} = toRefs(props) + const { type, dataInfo, activeVoiceId, isPlaying, isLast, lastQuestionInfo, teacherInfo} = toRefs(props) const emit = defineEmits(['changePlay', 'nextQuestion', 'withdraw', 'finishQuestion']) // 声音播放初始化 const talkVoiceObj = ref(uni.createInnerAudioContext()) talkVoiceObj.value.playbackRate = Number(props.voiceRate) const userInfo = computed(() => getUserInfo()) + const itemVoice = ref('') const showWithdraw = computed(()=>{ let _isMe = unref(lastQuestionInfo).qnsLogId === unref(dataInfo).qnsLogId @@ -253,6 +258,13 @@ const audioCacheObj = computed(() => storageStore.audioObj) }) const voiceLoading = ref(false) + watch(() => props.teacherInfo,(val) => { + itemVoice.value = '' + talkVoiceObj.value.src = '' + },{ + deep: true, + immediate: true + }) watch(() => props.isPlaying,(val) => { if(!val){ talkVoiceObj.value?.pause() @@ -311,7 +323,6 @@ const audioCacheObj = computed(() => storageStore.audioObj) talkVoiceObj.value.src = '' }) talkVoiceObj.value.onError(()=>{ - emit('changePlay', '') talkVoiceObj.value.src = '' }) const pauseVoice = () => { @@ -333,19 +344,20 @@ const audioCacheObj = computed(() => storageStore.audioObj) playVoice() } } - const itemVoice = ref('') const playVoice = (readType = 'pgth') =>{ let _content = showContent.value if(!_content){ common.msg('没有可以播放的文字信息!') return } + emit('changePlay', unref(dataInfo)?.id) // readType 阅读内容类型pgrh段落/qns问题 - emit('changePlay', unref(dataInfo)?.id) if(talkVoiceObj.value.src && talkVoiceObj.value.src === itemVoice.value) { + emit('changePlay', unref(dataInfo)?.id) talkVoiceObj.value.play() return } + talkVoiceObj.value.src = '' if(itemVoice.value){ setTimeout(()=>{ talkVoiceObj.value.src = itemVoice.value @@ -358,14 +370,14 @@ const audioCacheObj = computed(() => storageStore.audioObj) pgrphId: unref(dataInfo)?.pgrphId || '', qnsId: unref(dataInfo)?.qnsId || '', readType: readType, - teachNo: unref(dataInfo)?.userInfo?.teacherNo, // 必填 + teachNo: unref(teacherInfo)?.teacherNo, // 必填 content: _content } let _url = '/trastudy/traStdyInfo/readContent?' + Object.keys(_params).map(t=>{ return encodeURIComponent(t) + '=' + encodeURIComponent(_params[t]) }).join('&') - storageStore.getStorageById('audio', _url, (url)=>{ + storageStore.getStorageById('audio', _url + _params.teachNo, (url)=>{ if(url){ voiceLoading.value = false itemVoice.value = url @@ -381,7 +393,7 @@ const audioCacheObj = computed(() => storageStore.audioObj) itemVoice.value = res.tempFilePath talkVoiceObj.value.src = res.tempFilePath talkVoiceObj.value.play() - storageStore.setStorage('audio', _url, itemVoice.value) + storageStore.setStorage('audio', _url + _params.teachNo, itemVoice.value) }).catch((err)=>{ voiceLoading.value = false }) diff --git a/src/pages/course/components/touchBtn.vue b/src/pages/course/components/touchBtn.vue index 2aa9db6b..6e957d9d 100644 --- a/src/pages/course/components/touchBtn.vue +++ b/src/pages/course/components/touchBtn.vue @@ -13,7 +13,7 @@ placeholderStyle='color:#999999;font-size:26rpx' placeholder="请输入答案"> - + @@ -46,19 +46,26 @@ const proxy = getCurrentInstance() const emit = defineEmits(['uploadVoice', 'submitAnswer','startRecord']) const props = defineProps({ isDisabled:{ - default: Boolean, - type: true + default: true, + type: Boolean }, isLoading:{ + default: false, + type: Boolean + }, + onlyVoice:{ default: false, type: Boolean - } + }, }) -const { isDisabled } = toRefs(props) +const { isDisabled, onlyVoice } = toRefs(props) const isLoadingState = computed(() => props.isLoading) watch(()=>props.isLoading,()=>{},{ deep:true,immediate:true }) +watch(()=>props.onlyVoice,()=>{},{ + deep:true,immediate:true +}) const showTalkingModel = ref(false) const keyboardIsShow = ref(false) const answerValue = ref('') @@ -235,7 +242,7 @@ const showKeyboard = () => { } }else{ uni.showToast({ - title: '请先获取问题信息!', + title: '暂无问题需要回答!', icon: "none", duration:1000 }) diff --git a/src/pages/course/study.vue b/src/pages/course/study.vue index c9c8a447..5c19da10 100644 --- a/src/pages/course/study.vue +++ b/src/pages/course/study.vue @@ -5,7 +5,7 @@ {{chooseRate}}倍 - + @@ -67,6 +67,7 @@ :isPlaying="activeVoiceTalkingItemId === item.id" :voiceRate="chooseRate" :lastQuestionInfo="lastTalkingInfo" + :teacherInfo="choiceTeacherInfo" @changePlay="changePlayItemId" @nextQuestion="nextQuestionSuccess" @withdraw="withdrawNow" @@ -83,6 +84,7 @@ @submitAnswer="submitAnswerNow" @startRecord="changePlayItemId('')" :isLoading="isUploadingVoice" + :onlyVoice="answerOnlyVoice" :isDisabled="((lastTalkingInfo.type||0) !== 4)" /> @@ -103,15 +105,22 @@ - + 设置 - - {{item}} + + + 音色 + + + + + + {{item.teacherName}} + + + + @@ -135,7 +144,8 @@ import { getCourseStudyInfoApi, afreshStudyCourseApi, queryQuestionEvalateApi, - textChartApi + textChartApi, + setStudyTeacherApi } from "@/api/study.js" import common from '@/common/common'; import TalkingItem from '@/pages/course/components/talkingItem.vue' @@ -244,20 +254,38 @@ const showChangeSeekModelNow = () => { } const showBgModel = ref(false) const showChangeBgModelNow = () => { + changePlayItemId() showBgModel.value = true } // 关闭播放状态 const changePlayItemId = (id = '') => { - if(activeVoiceTalkingItemId.value === id){ - activeVoiceTalkingItemId.value = '' - }else{ - activeVoiceTalkingItemId.value = id - } + activeVoiceTalkingItemId.value = id + // if(activeVoiceTalkingItemId.value === id){ + // activeVoiceTalkingItemId.value = '' + // }else{ + // activeVoiceTalkingItemId.value = id + // } } // 选择的教师对象信息 const choiceTeacherInfo = computed(()=>{ return teacherList.value.find(t=> t.teacherNo === choiceTeacher.value) }) + +const changeTeacherVoiceNow = async (item) => { + if(item.teacherNo === choiceTeacher.value) return + try{ + const res = await setStudyTeacherApi({ + stdyId: stdyId.value, + teacherNo: item.teacherNo + }) + console.log(res) + if(res.rtnCode === '0000'){ + choiceTeacher.value = item.teacherNo + showBgModel.value = false + } + }catch{} finally{} +} + // 选择教师语音对象 const activeVoiceTeachNo = ref('') let teacherVoiceObj = uni.createInnerAudioContext() @@ -322,6 +350,11 @@ const isLastPgrph = ref(false) const backRouter = ()=>{ common.redirectTo(`/pages/courseDetail/index?crsId=${crsId.value}&crsNum=${crsNum.value}&from=study`) } + +const answerOnlyVoice = computed(()=>{ + return lastTalkingInfo.value.answerWay === 'V' +}) + // 获取段落 const getGraphInfoUnStudy = (flag = 0) => { console.log(isLastPgrph.value) @@ -1162,6 +1195,10 @@ const chooseRateNow = (item) => { overflow: hidden; border-radius: 32rpx 32rpx 0 0; padding: 58rpx 36rpx; + &.white-bg-box-setting{ + height: auto; + min-height: 400rpx; + } .box-title{ font-size: 32rpx; font-weight: bold; @@ -1178,6 +1215,55 @@ const chooseRateNow = (item) => { color: #06f; } } + .box-items{ + .box-item{ + margin-bottom: 20rpx; + overflow: hidden; + .box-item-title{ + width: 86rpx; + height: 100%; + float: left; + overflow: hidden; + color: #666; + font-size: 28rpx; + } + .box-item-cont{ + display: block; + float: left; + width: calc(100% - 86rpx); + overflow: hidden; + .overlay-voice-item{ + width: 123rpx; + float: left; + position: relative; + margin-bottom: 30rpx; + &:not(:nth-child(3n)){ + margin-right: 100rpx; + } + .overlay-avatar-box{ + width: 123rpx; + height: 123rpx; + border-radius: 50%; + overflow: hidden; + box-shadow: 1rpx 0rpx 5rpx #ccc; + } + .overlay-teacher-name{ + width: 123rpx; + text-align: center; + height: 58rpx; + line-height: 58rpx; + font-size: 28rpx; + } + .overlay-radio-box{ + position: absolute; + left: 100rpx; + top: 5rpx; + pointer-events: none; + } + } + } + } + } } }