fix: bug 问答语音联调20%
This commit is contained in:
+2
-2
@@ -3,13 +3,13 @@ ENV = 'development'
|
||||
# 'development'
|
||||
|
||||
# 苗扬
|
||||
VITE_APP_BASE_API_Url = 'http://25.64.16.133:9786'
|
||||
# VITE_APP_BASE_API_Url = 'http://25.64.16.133:9786'
|
||||
|
||||
# UAT
|
||||
# VITE_APP_BASE_API_Url = 'http://25.18.122.78:9786'
|
||||
|
||||
# DEV
|
||||
# VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7001'
|
||||
VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7001'
|
||||
|
||||
|
||||
# app入口
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@ export default class WebSocketUtil {
|
||||
this.socketTask.onMessage((res) => {
|
||||
if(res.data){
|
||||
const { rtnCode } = JSON.parse(res.data)
|
||||
console.log('收到WebSocket消息', JSON.parse(res.data) );
|
||||
// console.log('收到WebSocket消息', JSON.parse(res.data) );
|
||||
if(['0005', 'QQ0005'].includes(rtnCode)) {
|
||||
clearInterval(this.reconnectTimer);
|
||||
this.reconnectTimer = null
|
||||
|
||||
@@ -53,6 +53,10 @@ const props = defineProps({
|
||||
default: false,
|
||||
type: Boolean
|
||||
},
|
||||
loadingText:{
|
||||
default: '发送回答中,请稍后再试!',
|
||||
type: String
|
||||
},
|
||||
onlyVoice:{
|
||||
default: false,
|
||||
type: Boolean
|
||||
@@ -168,7 +172,7 @@ const getRecordPermission = async (obj) => {
|
||||
const showOverlayTalking = (obj) => {
|
||||
if(isLoadingState.value){
|
||||
uni.showToast({
|
||||
title: '发送回答中,请稍后再试!',
|
||||
title: props.loadingText,
|
||||
icon: "none",
|
||||
duration:1000
|
||||
})
|
||||
@@ -224,6 +228,14 @@ const handleMove = (obj) => {
|
||||
}
|
||||
// 发送文本
|
||||
const showKeyboard = () => {
|
||||
if(isLoadingState.value){
|
||||
uni.showToast({
|
||||
title: props.loadingText,
|
||||
icon: "none",
|
||||
duration:1000
|
||||
})
|
||||
return
|
||||
}
|
||||
if(!isDisabled.value){
|
||||
if(keyboardIsShow.value){
|
||||
if(answerValue.value){
|
||||
|
||||
@@ -182,8 +182,8 @@ const getData = async (flag) => {
|
||||
// return
|
||||
// }
|
||||
try{
|
||||
await initsocketTask()
|
||||
const { body } = await getCourseStudyInfoApi({crsId: crsId.value})
|
||||
initsocketTask()
|
||||
teacherList.value = body.teacheList.map(t=>({
|
||||
...t,
|
||||
voicePath: '',
|
||||
@@ -193,7 +193,6 @@ const getData = async (flag) => {
|
||||
step.value = 1
|
||||
}else{
|
||||
if(startPgrphId.value){
|
||||
scrollToBottomNow()
|
||||
choiceTeacher.value = body.choiceTeacher
|
||||
sendMessage({
|
||||
"commond" : 'STDY',
|
||||
@@ -375,6 +374,7 @@ const getGraphInfoUnStudy = (flag = 0) => {
|
||||
if(!_body.chatBody) {
|
||||
return
|
||||
}
|
||||
console.log('prgh', _body)
|
||||
if(Number(_body.bodyTyp) === 7){
|
||||
common.show('恭喜你已学完全部知识点', '有什么心得跟我们分享吗?',true, '取消','去评论').then((res) => {
|
||||
if(res) {
|
||||
@@ -425,6 +425,18 @@ const getQuestionInfoUnStudy = (pgrphId) => {
|
||||
let _id = new Date().getTime() + 'id'
|
||||
let _body = res.body || {}
|
||||
console.log(_body)
|
||||
if(Number(_body.bodyTyp) === 7){
|
||||
common.show('恭喜你已学完全部知识点', '有什么心得跟我们分享吗?',true, '取消','去评论').then((res) => {
|
||||
if(res) {
|
||||
// 去评论
|
||||
common.redirectTo(`/pages/courseDetail/submit?crsId=${crsId.value}&crsNum=${crsNum.value}&from=study&imgId=${imageId.value}`)
|
||||
}else{
|
||||
// 取消
|
||||
common.redirectTo(`/pages/courseDetail/index?crsId=${crsId.value}&crsNum=${crsNum.value}&from=study`)
|
||||
}
|
||||
}).finally(() => {})
|
||||
return
|
||||
}
|
||||
if(_body.chatBody && _body.chatBody?.stdyStat !== 'N'){
|
||||
let _id = new Date().getTime() + 'id'
|
||||
lastTalkingInfo.value = {
|
||||
@@ -485,7 +497,7 @@ const nextQuestionSuccess = (info, type='next') => {
|
||||
talkingList.value.push({
|
||||
crsId: info.crsId,
|
||||
pgrphId: info.pgrphId,
|
||||
talkingContent: '重新学',
|
||||
talkingContent: '重新答',
|
||||
type: 0,
|
||||
id: _id
|
||||
})
|
||||
@@ -575,8 +587,8 @@ const stdyId = ref('')
|
||||
const stdyBatch = ref('')
|
||||
const logId = ref('')
|
||||
// ws 初始化逻辑
|
||||
const initsocketTask = () => {
|
||||
socketStore.creatSocket()
|
||||
const initsocketTask = async () => {
|
||||
await socketStore.creatSocket()
|
||||
unref(SocketObj).on('message', (res)=>{
|
||||
const { rtnCode, body, commond } = JSON.parse(res.data)
|
||||
if(rtnCode === '0000'){
|
||||
|
||||
@@ -70,6 +70,7 @@
|
||||
border-radius: 15rpx;
|
||||
padding-bottom: 10rpx;
|
||||
position: relative;
|
||||
float: left;
|
||||
.talking-cont{
|
||||
padding-bottom: 20rpx;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<view class="talking-info">
|
||||
<view class="talking-info" v-if="dataInfo.intrctWay === '02'">
|
||||
<view :class="['talking-gif', !voiceLoading ? 'is-play' : '']">
|
||||
<CommonLoading color="#fff" v-show="voiceLoading"/>
|
||||
</view>
|
||||
@@ -22,6 +22,20 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="talking-info talking-info-text" v-else-if="dataInfo.intrctWay === '01'">
|
||||
<view class="talking-cont">
|
||||
<text :class="['talking-text translate-text loading']">
|
||||
{{ showContent }}
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="talking-info talking-info-text" v-else>
|
||||
<view class="talking-cont">
|
||||
<view class="talking-text translate-text" v-if="translateLoading">
|
||||
<CommonLoading color="#fff"/>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@@ -55,6 +69,8 @@
|
||||
padding-bottom: 30rpx;
|
||||
position: relative;
|
||||
color: #fff;
|
||||
width: 100%;
|
||||
float: right;
|
||||
.talking-gif{
|
||||
width: 200rpx;
|
||||
height: 38rpx;
|
||||
@@ -74,6 +90,15 @@
|
||||
height: 38rpx;
|
||||
line-height: 38rpx;
|
||||
}
|
||||
&.talking-info-text{
|
||||
padding-bottom: 20rpx;
|
||||
width: auto;
|
||||
float: right;
|
||||
.talking-cont{
|
||||
margin-top: 0rpx;
|
||||
}
|
||||
|
||||
}
|
||||
.talking-cont{
|
||||
margin-top: 16rpx;
|
||||
overflow: hidden;
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
|
||||
<style >
|
||||
.talking-item{
|
||||
overflow: hidden;
|
||||
&+.talking-item{
|
||||
margin-top: 30rpx;
|
||||
}
|
||||
|
||||
+53
-22
@@ -9,7 +9,7 @@
|
||||
<image src="@/static/images/dialog/history.png" alt="" class="image-icon"></image>
|
||||
</view>
|
||||
<view class="body-title">
|
||||
<uv-icon class="arrow-icon" name="arrow-left" @click="common.navigateBack()"/>
|
||||
<!-- <uv-icon class="arrow-icon" name="arrow-left" @click="common.navigateBack()"/> -->
|
||||
AI问答
|
||||
</view>
|
||||
<view class="ai-info">
|
||||
@@ -44,7 +44,7 @@
|
||||
:scroll-y="true"
|
||||
:scroll-top="scrollTop"
|
||||
:show-scrollbar="false"
|
||||
:scroll-with-animation="true"
|
||||
:scroll-with-animation="false"
|
||||
>
|
||||
<TalkingItem
|
||||
v-for="item in talkingList"
|
||||
@@ -92,6 +92,8 @@
|
||||
@uploadVoice="uploadRecordNow"
|
||||
@submitAnswer="submitAnswerNow"
|
||||
@startRecord="startRecordCallback"
|
||||
:loadingText="sendLoadingText"
|
||||
:isLoading="!answerIsOver"
|
||||
:isDisabled="false"
|
||||
/>
|
||||
</scroll-view>
|
||||
@@ -108,6 +110,9 @@
|
||||
import { storeToRefs } from 'pinia'
|
||||
import { onLoad, onShow, onUnload, onHide } from '@dcloudio/uni-app';
|
||||
import { get_base_url, goto_login_fun } from '@/api/request'
|
||||
import {
|
||||
commonUploadVoiceFile
|
||||
} from "@/api/common.js"
|
||||
|
||||
const socketStore = useSocketStore()
|
||||
const { SocketObj } = storeToRefs(socketStore)
|
||||
@@ -129,15 +134,8 @@
|
||||
const scrollToBottomNow = (time = 100) => {
|
||||
nextTick(()=>{
|
||||
setTimeout(() => {
|
||||
scrollTop.value += 1
|
||||
// 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
|
||||
// })
|
||||
// }
|
||||
scrollTop.value += 100
|
||||
scrollTop.value += 100
|
||||
},time)
|
||||
})
|
||||
}
|
||||
@@ -168,10 +166,9 @@
|
||||
})
|
||||
unref(SocketObj).on('message', (res)=>{
|
||||
const { rtnCode, body, commond } = JSON.parse(res.data)
|
||||
console.log(rtnCode, body, commond)
|
||||
if(rtnCode === '0000'){
|
||||
if(commond === 'ASK-OPEN'){
|
||||
console.log('链接成功!')
|
||||
// console.log('链接成功!')
|
||||
sendMessage({
|
||||
"commond" : 'ASK-START',
|
||||
"body" : {
|
||||
@@ -182,12 +179,12 @@
|
||||
return
|
||||
}
|
||||
if(commond === 'ASK-START'){
|
||||
console.log('开启对话!')
|
||||
// console.log('开启对话!')
|
||||
reqBatch.value = body.reqBatch
|
||||
return
|
||||
}
|
||||
if(commond === 'ASK'){
|
||||
console.log('body')
|
||||
console.log('发送问题成功!')
|
||||
seqNo.value = body.seqNo
|
||||
touchBtnCallBack.value && touchBtnCallBack.value()
|
||||
touchBtnCallBack.value = null
|
||||
@@ -199,7 +196,7 @@
|
||||
return
|
||||
}
|
||||
if(commond === 'ASK-STOP'){
|
||||
console.log('停止回答标记!')
|
||||
// console.log('停止回答标记!')
|
||||
stopAnswerCallBack.value && stopAnswerCallBack.value(askData.value)
|
||||
setTimeout(()=>{
|
||||
stopAnswerCallBack.value = null
|
||||
@@ -225,7 +222,7 @@
|
||||
return
|
||||
}
|
||||
if(commond === 'ASK-RE-ANSWER'){
|
||||
console.log('开始继续回答!')
|
||||
// console.log('开始继续回答!')
|
||||
if(body.event === 'start'){
|
||||
answerIsOver.value = false
|
||||
answerText.value = ''
|
||||
@@ -240,7 +237,6 @@
|
||||
|
||||
if(commond === 'ASK-ERR'){
|
||||
console.log('操作异常!')
|
||||
console.log(body)
|
||||
return
|
||||
}
|
||||
}else{
|
||||
@@ -251,7 +247,7 @@
|
||||
})
|
||||
watchFlag.value += 1
|
||||
}
|
||||
|
||||
const sendLoadingText = ref('问题回答中,请在问题回答结束后重试!')
|
||||
const reconnect = ()=> {
|
||||
if(reconnectTimer || isManualClose.value) return
|
||||
reconnectTimer = setTimeout(()=>{
|
||||
@@ -323,14 +319,49 @@
|
||||
const scrolltolower = () => {
|
||||
common.switchTab('/pages/index/index')
|
||||
}
|
||||
const uploadRecordNow = (voicePath) => {
|
||||
// /traask/traAskchat/voiceTrans
|
||||
}
|
||||
const touchBtnCallBack = ref(null)
|
||||
const askData = ref({})
|
||||
const sendText = (item) => {
|
||||
submitAnswerNow(item)
|
||||
}
|
||||
// 发送语音
|
||||
const uploadRecordNow = (voicePath) => {
|
||||
// /traask/traAskchat/voiceTrans
|
||||
//#ifndef APP-PLUS
|
||||
// h5 假数据
|
||||
// #endif
|
||||
//#ifdef APP-PLUS
|
||||
talkingList.value.push({
|
||||
type: 'question',
|
||||
talkingText: ''
|
||||
})
|
||||
scrollToBottomNow()
|
||||
commonUploadVoiceFile(voicePath, '/traask/traAskchat/voiceTrans', {}).then(res=>{
|
||||
let _res = JSON.parse(res.data)
|
||||
if(_res.rtnCode === '0000'){
|
||||
askData.value = {
|
||||
reqBatch: reqBatch.value,
|
||||
intrctWay: '02',//01-文本;02-语音;03-图片
|
||||
intrctContent: _res.body.transContent,
|
||||
bucketKey: _res.body.fileId,
|
||||
ossFileAddr: _res.body.ossFileAddr,
|
||||
voicePath: voicePath
|
||||
}
|
||||
sendMessage({
|
||||
"commond" : 'ASK',
|
||||
"body": askData.value
|
||||
})
|
||||
}else{}
|
||||
}).catch(err=>{
|
||||
talkingList.value.pop()
|
||||
uni.showToast({
|
||||
title: '系统异常,请联系管理员',
|
||||
icon: "none",
|
||||
duration:1000
|
||||
});
|
||||
})
|
||||
// #endif
|
||||
}
|
||||
// 发送文本
|
||||
const submitAnswerNow = (val, cb = null) => {
|
||||
if(!answerIsOver.value){
|
||||
|
||||
Reference in New Issue
Block a user