diff --git a/.env.development b/.env.development index 0ca35a60..23e0e4f5 100644 --- a/.env.development +++ b/.env.development @@ -2,7 +2,7 @@ ENV = 'development' # 'development' -VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7002' +VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7001' # UAT # VITE_APP_BASE_API_Url = 'http://25.18.122.78:9786' @@ -11,14 +11,15 @@ VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7002' # app入口 -#VITE_APP_BASE_API_Url = 'http://25.16.122.65:7001' +# VITE_APP_BASE_API_Url = 'http://25.18.122.65:7001' # VITE_APP_BASE_API_Url = 'http://25.16.122.92:9786' # VITE_APP_BASE_API_Url = 'http://25.18.122.66:9786' # h5专用地址x2 # VITE_APP_BASE_H5_API_Url = 'http://25.18.122.65:7001' -# VITE_APP_BASE_H5_API_Url = 'http://25.18.122.21:9786' +# VITE_APP_BASE_H5_API_Url = 'http://25.18.122.78:9786' +# VITE_APP_BASE_H5_API_Url_TRAASK = 'http://25.64.16.144:9605' diff --git a/src/api/common.js b/src/api/common.js index cb7c54b9..79105795 100644 --- a/src/api/common.js +++ b/src/api/common.js @@ -91,11 +91,11 @@ export const commonUploadVoiceFile = (file, url, data = {}, fileKey = 'voice') = try { const res = JSON.parse(result.data); if (res.rtnCode === '0000') { - return resolve(result); + return resolve(res); } else if (REQUES_ERROR_CODES['NO_LOGIN'].includes(res.rtnCode)) { goto_login_fun() return reject('NO_LOGIN'); - }else if(res.rtnCode === '0004') { + } else if (res.rtnCode === '0004') { return reject('N'); } return reject('Other'); diff --git a/src/components/examination/question.vue b/src/components/examination/question.vue index 678d4a7a..14332801 100644 --- a/src/components/examination/question.vue +++ b/src/components/examination/question.vue @@ -80,8 +80,6 @@ diff --git a/src/composables/useUpdateAvatar.js b/src/composables/useUpdateAvatar.js new file mode 100644 index 00000000..d1f55e48 --- /dev/null +++ b/src/composables/useUpdateAvatar.js @@ -0,0 +1,83 @@ +import { + reactive, + ref, + computed, + nextTick +} from 'vue'; +import { + uploadFile +} from '@/api/common'; +import { + queryCurrentUser +} from '@/api/login.js'; +import common from '@/common/common'; +import { + updateDfSysUserExtandInfoImageAddr +} from '@/api/user.js'; + +export default function useUpdateAvatar({ + success = () => {} +}) { + const avatarCropperUrl = ref(''); + const avatarCropperStatus = ref(true); + // 点击修改头像 + const click_update_avatar = () => { + uni.chooseImage({ + count: 1, + sizeType: ['compressed'], + success: (resPicture) => { + uni.getFileInfo({ + filePath: resPicture.tempFilePaths[0], + success: function(resSize) { + if (resSize.size > 10 * 1024 * 1024) return common.msg( + '图片过大,请重新选择'); + avatarCropperUrl.value = resPicture.tempFilePaths[0]; + avatarCropperStatus.value = true; + }, + fail: function(err) { + common.msg('获取图片失败,请选择其他图片'); + } + }); + } + }); + }; + // 选择头像取消 + const avatarOnCancel = (value) => { + avatarCropperStatus.value = false; + }; + // 选择头像确定 + const avatarOnConfirm = (file) => { + avatarCropperStatus.value = false; + nextTick(async () => { + common.loading('更新头像中'); + try { + const data = { + bizScen: 'S3007', + thumbnailFlag: true, + thumbImgSize: 100 + }; + // 上传图片 + const res = await uploadFile(file.tempFilePath, data); + // 更新个人信息 + await updateDfSysUserExtandInfoImageAddr({ + imageAddr: res.thumbFileId + }); + // 更新个人信息 + const userData = await queryCurrentUser(); + common.msg('修改成功'); + success(userData) + + } catch { + common.msg('修改失败'); + } + common.hideLoading(); + }); + }; + return { + avatarCropperUrl, + avatarCropperStatus, + click_update_avatar, + avatarOnCancel, + avatarOnConfirm, + }; +} \ No newline at end of file diff --git a/src/pages/course/components/talkingItem.vue b/src/pages/course/components/talkingItem.vue index 6a3805ee..2ff31718 100644 --- a/src/pages/course/components/talkingItem.vue +++ b/src/pages/course/components/talkingItem.vue @@ -416,28 +416,36 @@ pauseVoice(); }); let prevTime = -1; + let pauseTime = -1; talkVoiceObj.value.onEnded(() => { console.log('onEnded'); - emit('changePlay', ''); + if(props.activeVoiceId){ + emit('changePlay', ''); + } prevTime = -1; + pauseTime = prevTime talkVoiceObj.value.src = ''; }); talkVoiceObj.value.onStop(() => { console.log('onStop'); - emit('changePlay', ''); + if(props.activeVoiceId){ + emit('changePlay', ''); + } prevTime = -1; + pauseTime = prevTime talkVoiceObj.value.src = ''; }); talkVoiceObj.value.onPause(() => { - console.log('onPause'); prevTime = talkVoiceObj.value.currentTime; - emit('changePlay', ''); + pauseTime = prevTime }); talkVoiceObj.value.onPlay(() => { console.log('onPlay'); prevTime = talkVoiceObj.value.currentTime; + pauseTime = prevTime emit('changePlay', unref(dataInfo)?.id); }); + talkVoiceObj.value.onTimeUpdate(() => { if (activeVoiceId.value === unref(dataInfo)?.id) { setTimeout(() => { @@ -446,18 +454,23 @@ prevTime = talkVoiceObj.value.currentTime; } } else { - emit('changePlay', ''); + if (props.isPlaying && (talkVoiceObj.value.currentTime > 0) && props.activeVoiceId) { + console.log(pauseTime , prevTime) + emit('changePlay', ''); + } } - }, 500); + }, 100); } }); talkVoiceObj.value.onError(() => { - if(!talkVoiceObj.value.src) return - talkVoiceObj.value.src = ''; - emit('changePlay', ''); + // console.log('onError'); + // if(!talkVoiceObj.value.src) return + // talkVoiceObj.value.src = ''; + // emit('changePlay', ''); }); const pauseVoice = () => { + console.log('手动') if (!talkVoiceObj.value) return; talkVoiceObj.value.pause(); emit('changePlay', ''); @@ -478,92 +491,95 @@ }; const playVoice = (readType = 'pgth') => { let _content = showContent.value; - console.log(_content); if (!_content) { common.msg('没有可以播放的文字信息!'); return; } - emit('changePlay', unref(dataInfo)?.id); - // readType 阅读内容类型pgrh段落/qns问题 - if (talkVoiceObj.value.src && talkVoiceObj.value.src === itemVoice.value) { - talkVoiceObj.value.play(); - return; - } - talkVoiceObj.value.src = ''; - if (itemVoice.value) { - setTimeout(() => { - talkVoiceObj.value.src = itemVoice.value; + setTimeout(() => { + emit('changePlay', unref(dataInfo)?.id); + console.log(1) + // readType 阅读内容类型pgrh段落/qns问题 + if (talkVoiceObj.value.src && talkVoiceObj.value.src === itemVoice.value) { talkVoiceObj.value.play(); - }, 100); - } else { - voiceLoading.value = true; - let _type = - props.type == 2 ? - 'ans' : - props.type == 3 ? - 'pgrh' : - props.type == 4 ? - 'qns' : - props.type == 5 ? - 'analysis' : - props.type == 8 ? - 'stemAnalysis' : - ''; - let _readId = - props.type == 2 ? - unref(dataInfo)?.intrctId : - props.type == 3 ? - unref(dataInfo)?.pgrphId : - props.type == 4 ? - unref(dataInfo)?.qnsId : - props.type == 5 ? - unref(dataInfo)?.qnsId : - props.type == 8 ? - unref(dataInfo)?.qnsId : - ''; - let _params = { - crsId: unref(dataInfo)?.crsId || '', - pgrphId: unref(dataInfo)?.pgrphId || '', - qnsId: unref(dataInfo)?.qnsId || '', - readType: _type, // 2 文本回答 3, 段落信息 4 问题信息 - teachNo: unref(teacherInfo)?.teacherNo, // 必填 - readId: _readId - // content: _content - }; - - let _url = - '/trastudy/traStdyInfo/readContent?' + - Object.keys(_params) - .map((t) => { - return encodeURIComponent(t) + '=' + encodeURIComponent(_params[t]); - }) - .join('&'); - - storageStore.getStorageById('audio', _url + _params.teachNo, (url) => { - if (url) { - voiceLoading.value = false; - itemVoice.value = url; - talkVoiceObj.value.src = url; + return; + } + talkVoiceObj.value.src = ''; + if (itemVoice.value) { + setTimeout(() => { + talkVoiceObj.value.src = itemVoice.value; talkVoiceObj.value.play(); - } else { - downloadVoiceFile(_url) - .then((res) => { - if (res?.data) { - common.msg(res.data.message); - return; - } - voiceLoading.value = false; - itemVoice.value = res.tempFilePath; - talkVoiceObj.value.src = res.tempFilePath; - talkVoiceObj.value.play(); - storageStore.setStorage('audio', _url + _params.teachNo, itemVoice.value); - }) - .catch((err) => { - voiceLoading.value = false; - }); - } - }); - } + }, 100); + } else { + voiceLoading.value = true; + let _type = + props.type == 2 ? + 'ans' : + props.type == 3 ? + 'pgrh' : + props.type == 4 ? + 'qns' : + props.type == 5 ? + 'analysis' : + props.type == 8 ? + 'stemAnalysis' : + ''; + let _readId = + props.type == 2 ? + unref(dataInfo)?.intrctId : + props.type == 3 ? + unref(dataInfo)?.pgrphId : + props.type == 4 ? + unref(dataInfo)?.qnsId : + props.type == 5 ? + unref(dataInfo)?.qnsId : + props.type == 8 ? + unref(dataInfo)?.qnsId : + ''; + let _params = { + crsId: unref(dataInfo)?.crsId || '', + pgrphId: unref(dataInfo)?.pgrphId || '', + qnsId: unref(dataInfo)?.qnsId || '', + readType: _type, // 2 文本回答 3, 段落信息 4 问题信息 + teachNo: unref(teacherInfo)?.teacherNo, // 必填 + readId: _readId + // content: _content + }; + + let _url = + '/trastudy/traStdyInfo/readContent?' + + Object.keys(_params) + .map((t) => { + return encodeURIComponent(t) + '=' + encodeURIComponent(_params[t]); + }) + .join('&'); + + storageStore.getStorageById('audio', _url + _params.teachNo, (url) => { + if (url) { + voiceLoading.value = false; + itemVoice.value = url; + talkVoiceObj.value.src = url; + talkVoiceObj.value.play(); + } else { + downloadVoiceFile(_url) + .then((res) => { + if (res?.data) { + common.msg(res.data.message); + return; + } + voiceLoading.value = false; + itemVoice.value = res.tempFilePath; + talkVoiceObj.value.src = res.tempFilePath; + talkVoiceObj.value.play(); + storageStore.setStorage('audio', _url + _params.teachNo, itemVoice.value); + }) + .catch((err) => { + voiceLoading.value = false; + }); + } + }); + + } + }, 100); }; const saveFile = (buffer, filePath, cb = () => {}) => { let fileManager = uni.getFileSystemManager(); diff --git a/src/pages/course/study.vue b/src/pages/course/study.vue index 6c5eca81..b09db19c 100644 --- a/src/pages/course/study.vue +++ b/src/pages/course/study.vue @@ -8,32 +8,38 @@ - + 语言选择,开启学习之旅 - + - + {{ item.teacherName }} 描述:{{ item.voiceDesc || '--' }} - - + + - - + + - + - 开启学习之旅 + 开启学习之旅 @@ -43,46 +49,48 @@ - + 课程学习 - {{ showOrder }} / {{ pgrphNum }} + {{ showOrder }} + / {{ pgrphNum }} - + + 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" + @changePlay="changePlayItemId" + @nextQuestion="nextQuestionSuccess" + @withdraw="withdrawNow" + @answerQuestion="answerQuestionNow" + @finishQuestion="finishQuestionNow" + :id="'item' + item.id" + :isLast="talkingList.length === index + 1"> + class="talk-btns" + @uploadVoice="uploadRecordNow" + @submitAnswer="submitAnswerNow" + @startRecord="changePlayItemId('')" + :isLoading="isUploadingVoice" + :onlyVoice="answerOnlyVoice" + :canAnswer="testAnswer" + :adjustPosition="true" + :canAnswerText="canAnswerText" + :isDisabled="(lastTalkingInfo.type || 0) !== 4 || ['SN', 'MU', 'JD'].includes(lastTalkingInfo.qnsTyp)"/> @@ -99,17 +107,19 @@ - 设置 + 设置 音色 - + - + {{ item.teacherName }} - + @@ -121,37 +131,37 @@ diff --git a/src/pages/setting/index.vue b/src/pages/setting/index.vue index f3292b30..0b5bfb55 100644 --- a/src/pages/setting/index.vue +++ b/src/pages/setting/index.vue @@ -20,37 +20,8 @@ - - - @@ -69,26 +40,31 @@