Merge branch 'develop' into 'sit'

Develop

See merge request K17_AITS/tra-app!44
This commit is contained in:
田岩
2025-07-18 17:44:49 +08:00
7 changed files with 62 additions and 36 deletions
+1
View File
@@ -72,6 +72,7 @@ export const commonUploadVoiceFile = (file, url, data = {}, fileKey='voice') =>
};
if (token)
header['summary'] = token
console.log(`${base_url}${url}`)
return new Promise((resolve, reject) => {
uni.uploadFile({
url: `${base_url}${url}`,
+1 -1
View File
@@ -152,7 +152,7 @@
<view
class="icon text-right-btn"
@click.stop="withdraw"
v-show="isLast"
v-show="showWithdraw"
>撤回
<!-- v-show="showWithdraw" -->
</view>
+11 -12
View File
@@ -15,13 +15,13 @@
<view class="btns-cont">
<view class="play-btn">
<image class="icon"
v-show="!isPlaying"
v-show="!(!voiceLoading&&(props.activeVoiceId === dataInfo.id))"
@click="playVoice"
src="@/static/images/course/play-blue.png"
style="width: 100%;height: 100%;"
></image>
<image class="icon"
v-show="isPlaying"
v-show="!voiceLoading&&(props.activeVoiceId === dataInfo.id)"
@click.stop="pauseVoice"
src="@/static/images/course/stop-blue.png"
style="width: 100%;height: 100%;"
@@ -94,11 +94,10 @@ import { onUnload } from '@dcloudio/uni-app';
}
const playVoice = () =>{
emit('changePlay', unref(dataInfo)?.id)
if(talkVoiceObj.value && talkVoiceObj.value.src && talkVoiceObj.value.src === itemVoice.value) {
if(talkVoiceObj.value && talkVoiceObj.value.src) {
talkVoiceObj.value.play()
return
}else{
initVoice()
talkVoiceObj.value.src = ''
if(unref(dataInfo).talkingVoice){
setTimeout(()=>{
@@ -110,15 +109,15 @@ import { onUnload } from '@dcloudio/uni-app';
}
}
const initVoice = () => {
talkVoiceObj.value = uni.createInnerAudioContext()
talkVoiceObj.value.onEnded(()=>{
emit('changePlay', '')
talkVoiceObj.value.src = ''
})
talkVoiceObj.value.onError(()=>{
talkVoiceObj.value.src = ''
})
if(unref(dataInfo).intrctWay === '02'){
talkVoiceObj.value = uni.createInnerAudioContext()
talkVoiceObj.value.onEnded(()=>{
emit('changePlay', '')
talkVoiceObj.value.src = ''
})
talkVoiceObj.value.onError(()=>{
talkVoiceObj.value.src = ''
})
itemVoice.value = unref(dataInfo).talkingVoice
talkVoiceObj.value.src = itemVoice.value
setTimeout(()=>{
@@ -35,6 +35,7 @@
type: String
}
})
watch(() => props.activeVoiceId, () => {},{deep: true,immediate: true})
watch(() => props.talkingInfo, () => {},{deep: true,immediate: true})
const { talkingType } = toRefs(props)
const handleEvents = (type) => {
+48 -23
View File
@@ -13,9 +13,11 @@
AI问答
</view>
<view class="ai-info">
<image src="@/static/images/dialog/pet-3.png" alt="" class="image-pet-bg"></image>
<view class="ai-info-bg-box">
<view class="hello-text">Hi我是{{'李想'}}</view>
<!-- <image src="@/static/images/dialog/pet-3.png" alt="" class="image-pet-bg"></image> -->
<image src="@/static/images/dialog/pet-bg-base.png" alt="" class="image-pet-bg"></image>
<image :src="userInfo.mascotInfo?.imgAddr ||''" alt="" class="image-pet"></image>
<view class="ai-info-bg-box">
<view class="hello-text">Hi我是{{ userInfo.mascotInfo?.mascotName || ''}}</view>
<view class="info-text">工作学习我都能帮你</view>
<view class="info-btn">试试他的能力</view>
</view>
@@ -102,7 +104,7 @@
</template>
<script setup>
import { ref, unref, onMounted, watch, nextTick } from 'vue'
import { ref, unref, onMounted, watch, nextTick, computed } from 'vue'
import common from '@/common/common';
import TouchBtn from '@/pages/course/components/touchBtn.vue'
import TalkingItem from './components/talking-item.vue';
@@ -111,12 +113,14 @@
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"
import { getUserInfo } from '@/common/common';
import {
commonUploadVoiceFile
} from "@/api/common.js"
const socketStore = useSocketStore()
const { SocketObj } = storeToRefs(socketStore)
const userInfo = computed(() => getUserInfo())
const questionList = ref([
'对公小程序开户流程?',
@@ -146,7 +150,9 @@ import {
const isManualClose = ref(false) // 是否手动关闭
const reqBatch = ref('')
const seqNo = ref('')
const mascotId = ref('Tst00001')
const mascotId = computed(() => {
return unref(userInfo).mascotInfo?.mascotId || 'Tst00001'
})
const answerText = ref('')
const answerIsOver = ref(true)
const talkingList = ref([])
@@ -198,7 +204,8 @@ import {
talkingText: body.intrctContent,
isLoading: false,
id: _id,
...body
...body,
talkingVoice: askData.value.talkingVoice
})
return
}
@@ -352,21 +359,31 @@ import {
isLoading: true
})
scrollToBottomNow()
console.log(voicePath,111111111)
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,
talkingVoice: voicePath
if(!!(_res.body.transContent || '').trim()){
askData.value = {
reqBatch: reqBatch.value,
intrctWay: '02',//01-文本;02-语音;03-图片
intrctContent: _res.body.transContent,
bucketKey: _res.body.fileId,
ossFileAddr: _res.body.ossFileAddr,
talkingVoice: voicePath
}
sendMessage({
"commond" : 'ASK',
"body": askData.value
})
}else{
talkingList.value.pop()
uni.showToast({
title: '语音内容不能为空!',
icon: "none",
duration:1000
});
}
sendMessage({
"commond" : 'ASK',
"body": askData.value
})
}else{}
}).catch(err=>{
talkingList.value.pop()
@@ -528,14 +545,22 @@ import {
margin-bottom: 24rpx;
position: relative;
box-sizing: border-box;
.image-pet{
width: 230rpx;
height: 235rpx;
position: absolute;
right: 24rpx;
top: 15rpx;
z-index: 2;
}
.image-pet-bg{
position: absolute;
padding: 0 24rpx;
box-sizing: border-box;
width: 100%;
height: 100%;
height: 230rpx;
left: 0;
top: 0;
bottom: 0;
z-index: 2;
}
.ai-info-bg-box{
@@ -570,7 +595,7 @@ import {
text-align: center;
border-radius: 15rpx 15rpx 0 0;
position: absolute;
left: 64rpx;
left: 68rpx;
bottom: 0;
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 344 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 KiB