diff --git a/.env.development b/.env.development index bc2a8d2a..f8c85ebb 100644 --- a/.env.development +++ b/.env.development @@ -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:7002' +VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7001' # DEV #VITE_APP_BASE_API_Url = 'http://25.18.122.65:7001' diff --git a/src/components/comment-input/comment-input.vue b/src/components/comment-input/comment-input.vue index a8a8c051..75b6f280 100644 --- a/src/components/comment-input/comment-input.vue +++ b/src/components/comment-input/comment-input.vue @@ -24,7 +24,7 @@ - + @@ -70,11 +70,14 @@ - + + + - 发送 + 发送 @@ -113,7 +116,7 @@ import commentInput2 from '@/static/images/courseDetail/comment-input-2.png' import commentInput3 from '@/static/images/courseDetail/comment-input-3.png' import commentInput4 from '@/static/images/courseDetail/comment-input-4.png' - import { reactive, ref, watch, nextTick, computed } from 'vue'; + import { reactive, ref, watch, nextTick, computed, onBeforeUnmount } from 'vue'; import { emojiList } from '@/emoji'; import { publishCrsEvaluation, queryTraMemeInfoList } from '@/api/courseDetail.js' import common from '@/common/common.js'; @@ -144,7 +147,6 @@ // '/src/static/images/test/e7dd89a71493fcc6281700a4864e24cb.jpg' ]) const isShow = ref(false); - const popHeight = ref('0px') const value = ref(''); const click_input = () => { if(!isShow.value) isShow.value = true @@ -161,9 +163,14 @@ isFocus.value = true cursorLength.value = resStart.value || value.value.length } + const showEmoji = ref(false) + const showEmojiNow = () => { + showEmoji.value = !showEmoji.value + } + const popHeight = ref('0px') const focus = (event) => { - popHeight.value = 'calc(270px + 120rpx)' isShow.value = true + isFocus.value = true console.log('focusevent'); if(!isReply.value){ getMemList() @@ -263,15 +270,14 @@ }) } const setMemValue = (item) => { - console.log(item) if(!isImg.value || fileList.value.length == 0){ - fileList.value = [item.ossAddr] + fileList.value = [item.ossKey] isImg.value = false return } common.show('','是否清空当前图片并重新添加?').then((res) => { if (res) { - fileList.value = [item.ossAddr] + fileList.value = [item.ossKey] isImg.value = false } }); @@ -314,9 +320,6 @@ value.value = '' fileList.value = [] emit('submitOver') - if (from.value === 'study') { - } else { - } }, 500); }, delayTime); }).catch(err=>{ @@ -335,6 +338,24 @@ isImg.value = true } }) + const keyboardHeight = ref(0) + const maxKeyboardHeight = ref(0) + uni.onKeyboardHeightChange((res)=>{ + maxKeyboardHeight.value = res.height > keyboardHeight.value?res.height : keyboardHeight.value + keyboardHeight.value = res.height + }) + onBeforeUnmount(()=>{ + + }) + watch(()=> showEmoji.value,(val)=>{ + popHeight.value = val ? `${maxKeyboardHeight.value}px` : (keyboardHeight.value+'px') + }) + watch(()=> keyboardHeight.value,(val)=>{ + console.log(val,showEmoji.value) + console.log(maxKeyboardHeight.value) + popHeight.value = showEmoji.value ? `${maxKeyboardHeight.value}px` : keyboardHeight.value+'px' + console.log(popHeight.value) + }) defineExpose({hideAll, resetVal}) @@ -455,6 +476,10 @@ font-size: 30rpx; color: #fff; margin-right: 20rpx; + &.is-disabled{ + background-color: #ccc; + // pointer-events: none; + } } } .main-div { diff --git a/src/components/touch-btn/style/index.scss b/src/components/touch-btn/style/index.scss index f2d405dc..98734ee8 100644 --- a/src/components/touch-btn/style/index.scss +++ b/src/components/touch-btn/style/index.scss @@ -8,7 +8,6 @@ background-color: #fff; box-shadow: 0 4rpx 14rpx rgba(100, 100, 100, 0.3); padding: 0 10rpx; - display: flex; align-items: center; border: 2rpx solid rgba(0, 0, 0, 0); @@ -47,39 +46,4 @@ height: 50rpx; } } - // .touch-btn { - // height: 92rpx; - // box-shadow: 0 8rpx 20rpx 0 rgba(0, 0, 0, 0.06); - // text-align: center; - // line-height: 92rpx; - // color: #000; - // font-weight: 400; - // position: relative; - - // .input-box { - // width: 100%; - // height: 92rpx; - // line-height: 92rpx; - // text-align: left; - // box-sizing: border-box; - // padding: 0 40rpx 0 40rpx; - // } - // } - - // .talk-btn-box { - // position: absolute; - // height: 100%; - // width: 120rpx; - // right: 0; - // top: 0; - - // .talk-btn-icon { - // width: 40rpx; - // height: 40rpx; - // position: absolute; - // right: 60rpx; - // top: 50%; - // margin-top: -20rpx; - // } - // } } diff --git a/src/components/touch-btn/style/popup.scss b/src/components/touch-btn/style/popup.scss index 3b8e2314..759b10ec 100644 --- a/src/components/touch-btn/style/popup.scss +++ b/src/components/touch-btn/style/popup.scss @@ -206,13 +206,25 @@ &.success > .send-btn > .send-btn-text { display: block !important; } - &.failed .send-btn,&.networkError .send-btn { - pointer-events: none; - cursor: not-allowed; - background-color: rgb(80, 80, 80); - color: rgb(106, 106, 106); - .send-btn-text { - display: block !important; + &.failed,&.networkError { + // 发送按钮置灰 + .send-btn { + pointer-events: none; + cursor: not-allowed; + background-color: rgb(80, 80, 80); + color: rgb(106, 106, 106); + .send-btn-text { + display: block !important; + } + } + // 发送原语音按钮置灰 + .trans-btn{ + pointer-events: none; + cursor: not-allowed; + .btn-text{ + color: rgb(106, 106, 106); + } + } } } diff --git a/src/components/touch-btn/touch-btn.ts b/src/components/touch-btn/touch-btn.ts index 3f1a2911..4344bf47 100644 --- a/src/components/touch-btn/touch-btn.ts +++ b/src/components/touch-btn/touch-btn.ts @@ -26,7 +26,6 @@ export const horizontalSplitX = safeArea.right / 2; * @returns {Promise} 成功时返回WS实例,失败时reject错误信息 */ export const initWebSocket = (wsUrl : string) : Promise => { - console.log('wsUrl', wsUrl); return new Promise((resolve, reject) => { // 1. 创建WS连接 const ws = uni.connectSocket({ diff --git a/src/components/touch-btn/touch-btn.vue b/src/components/touch-btn/touch-btn.vue index bc2e08cc..b5998e9f 100644 --- a/src/components/touch-btn/touch-btn.vue +++ b/src/components/touch-btn/touch-btn.vue @@ -41,7 +41,7 @@ class="textarea" ref="inputRef" v-model="textAreaText" - :maxlength="255" + :maxlength="props.maxlength" @click.stop customStyle="background: #ffffff00; padding-bottom: 50rpx; color: #fff; caret-color: #fff" text-style="color: #fff" @@ -74,6 +74,7 @@ :src="isOutStatus == '03' ? TouchBtnImages.translateActiveBtn : TouchBtnImages.translateBtn" mode="heightFix" > + - 松开发送 + {{ workMode === 'text-only' ? '松开转文字' : '松开发送' }} @@ -93,11 +94,11 @@ 取消 - + 发送原语音 - + 发送 @@ -110,7 +111,7 @@ \ No newline at end of file + diff --git a/src/pages/index/dialog.vue b/src/pages/index/dialog.vue index 71667c38..909e1978 100644 --- a/src/pages/index/dialog.vue +++ b/src/pages/index/dialog.vue @@ -145,7 +145,7 @@ :adjustPosition="true" :isDisabled="isHistory" /> --> - @@ -690,20 +690,53 @@ const sendText = (item) => { submitAnswerNow(item); }; - - // 发送语音 - const uploadRecordNow = (voicePath, voiceTime) => { - // /traask/traAskchat/voiceTrans - //#ifndef APP-PLUS - // h5 假数据 - // #endif - //#ifdef APP-PLUS + // 新发送语音前loading动画 + const sendLoading = () => { talkingList.value.push({ type: 'question', talkingText: '', isLoading: true }); scrollToBottomNow(); + } + + // 新发送语音 + const submitVoice = ({ossKey,text}) => { + console.log('新发送语音',ossKey,text); + if(!ossKey) { + talkingList.value.pop(); + uni.showToast({ + title: '系统异常,请联系管理员', + icon: 'none', + duration: 1000 + }); + }else if(text) { + askData.value = { + reqBatch: reqBatch.value, + intrctWay: '02', //01-文本;02-语音;03-图片 + intrctContent: text, + bucketKey: ossKey, + // ossFileAddr: _res.body.ossFileAddr, + // talkingVoice: voicePath, + // voiceTime: voiceTime + }; + sendMessage({ + commond: 'ASK', + body: askData.value + }); + } else { + talkingList.value.pop(); + uni.showToast({ + title: '未识别到文字', + icon: 'none', + duration: 1000 + }); + } + } + // 发送语音 + const uploadRecordNow = (voicePath, voiceTime) => { + //#ifdef APP-PLUS + commonUploadVoiceFile(voicePath, '/traask/traAskchat/voiceTrans', {}) .then((_res) => { if (!!(_res.body.transContent || '').trim()) { diff --git a/src/pages/practice/index.vue b/src/pages/practice/index.vue index b2ab1c49..16e98d25 100644 --- a/src/pages/practice/index.vue +++ b/src/pages/practice/index.vue @@ -98,8 +98,7 @@ ref="touchBtnRef" @sendLoading="sendLoading" @submitVoice="submitVoice" - @uploadVoice="touchBtnSubmit('voice', $event)" - @submitAnswer="touchBtnSubmit('text', $event)" + @submitAnswer="submitAnswer" :isLoading="touchIsDisabled" loadingText="只能进行一条回答" :answerMethod="answerMethod" @@ -342,27 +341,39 @@ topic.es_status = '00'; // 00转圈 } // 新录音组件语音提交 - const submitVoice = (voiceObj) => { - console.log('新录音组件语音提交'); + const submitVoice = ({ossKey,text}) => { + console.log('新录音组件语音提交', ossKey,text); const topic = topicList[questionNumber.value]; - touchBtnRef.value?.clearInputText(); // 清除发送框数据 - const _content = voiceObj.text; - if (_content === '') { + if(!ossKey) { + topic.es_status = ''; // 取消转圈 + common.msg('系统异常,请联系管理员'); + } else if (text === '') { topic.es_status = ''; // 取消转圈 return common.msg('未识别到文字'); } else { topic.es_status = '02'; topic.my_answer = { - anserResult: _content, - ossKey: voiceObj.ossKey + anserResult: text, + ossKey: ossKey }; } } + // 新录音组件文本提交 + const submitAnswer = (answerText) => { + const topic = topicList[questionNumber.value]; + touchBtnRef.value?.clearInputText(); // 清除发送框数据 + topic.es_status = '01'; + topic.my_answer = { + anserResult: answerText // 正确答案文字内容 + }; + } + // 录音组件提交 const touchBtnSubmit = (type, submitObj) => { const topic = topicList[questionNumber.value]; touchBtnRef.value?.clearInputText(); // 清除发送框数据 + if (type === 'voice') { if (topic.es_status === '00') return; topic.es_status = '00'; // 00转圈 diff --git a/src/uni_modules/ty-recording/utssdk/app-android/index.uts b/src/uni_modules/ty-recording/utssdk/app-android/index.uts index a4d3fe1e..ebf3c09a 100644 --- a/src/uni_modules/ty-recording/utssdk/app-android/index.uts +++ b/src/uni_modules/ty-recording/utssdk/app-android/index.uts @@ -14,7 +14,7 @@ import AtomicBoolean from "java.util.concurrent.atomic.AtomicBoolean"; const isRecording = new AtomicBoolean(false); // 原子布尔值,保证线程安全 // 1. 音频采集参数(极简配置,适配大部分设备) -const sampleRate : Int = 16000; // 采样率 +const sampleRate : Int = 48000; // 采样率 const channelConfig = AudioFormat.CHANNEL_IN_MONO; // 单声道 const audioFormat = AudioFormat.ENCODING_PCM_16BIT; // 16位PCM const minBufferSize = AudioRecord.getMinBufferSize(sampleRate, channelConfig, audioFormat);