Merge branch 'dev-0120' of http://25.13.9.101:9000/K17_AITS/tra-app into dev-0120

This commit is contained in:
田岩
2026-01-12 17:30:22 +08:00
2 changed files with 139 additions and 114 deletions
+2 -1
View File
@@ -267,7 +267,7 @@
transLoading.value = false transLoading.value = false
closeModel() closeModel()
uni.showToast({ uni.showToast({
title: '系统异常,请联系管理员', title: err.message || '系统异常,请联系管理员',
icon: 'none', icon: 'none',
duration: 1000 duration: 1000
}); });
@@ -515,6 +515,7 @@
// } // }
isMoving.value = true; isMoving.value = true;
isTalking.value = true; isTalking.value = true;
answerValue.value = ''
emit('startRecord'); emit('startRecord');
recNum.value += 1; recNum.value += 1;
let _recnum = recNum.value let _recnum = recNum.value
+133 -109
View File
@@ -3,31 +3,17 @@
<!-- <MarkdownPreview/> --> <!-- <MarkdownPreview/> -->
<view class="top-bg"></view> <view class="top-bg"></view>
<view class="bot-bg"></view> <view class="bot-bg"></view>
<scroll-view <scroll-view class="index-dialog-body" :scroll-y="true" upper-threshold="0" refresher-enabled="true"
class="index-dialog-body" refresher-default-style="none" @refresherrefresh="scrolltolower">
:scroll-y="true"
upper-threshold="0"
refresher-enabled="true"
refresher-default-style="none"
@refresherrefresh="scrolltolower"
>
<view class="body-title"> <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问答 AI问答
<view class="top-desc">内容由AI生成</view> <view class="top-desc">内容由AI生成</view>
<view class="seek-setting"> <view class="seek-setting">
<image <image src="@/static/images/dialog/new-dialog.png" alt="" class="image-icon-new" @click="createNewDialog">
src="@/static/images/dialog/new-dialog.png" </image>
alt="" <image src="@/static/images/dialog/history.png" alt="" class="image-icon"
class="image-icon-new" @click="showMenuList = !showMenuList"></image>
@click="createNewDialog"
></image>
<image
src="@/static/images/dialog/history.png"
alt=""
class="image-icon"
@click="showMenuList = !showMenuList"
></image>
<view :class="['more-list', showMenuList ? 'show' : '']"> <view :class="['more-list', showMenuList ? 'show' : '']">
<view class="more-item" @click.stop="showHistory">历史</view> <view class="more-item" @click.stop="showHistory">历史</view>
<view class="more-item" @click.stop="toMessage">消息</view> <view class="more-item" @click.stop="toMessage">消息</view>
@@ -49,42 +35,25 @@
<view class="questions-view"> <view class="questions-view">
<scroll-view :scroll-x="true" :show-scrollbar="false"> <scroll-view :scroll-x="true" :show-scrollbar="false">
<view class="question-row"> <view class="question-row">
<view <view class="question-item" v-for="item in Math.ceil(questionList.length / 2)"
class="question-item" @click="sendText(questionList[item - 1].hotContent)">
v-for="item in Math.ceil(questionList.length / 2)"
@click="sendText(questionList[item - 1].hotContent)"
>
{{ questionList[item - 1].hotContent }} {{ questionList[item - 1].hotContent }}
</view> </view>
</view> </view>
<view class="question-row"> <view class="question-row">
<view <view class="question-item" v-for="item in questionList.length - Math.ceil(questionList.length / 2)"
class="question-item" @click="sendText(questionList[item + Math.ceil(questionList.length / 2) - 1].hotContent)">
v-for="item in questionList.length - Math.ceil(questionList.length / 2)"
@click="sendText(questionList[item + Math.ceil(questionList.length / 2) - 1].hotContent)"
>
{{ questionList[item + Math.ceil(questionList.length / 2) - 1].hotContent }} {{ questionList[item + Math.ceil(questionList.length / 2) - 1].hotContent }}
</view> </view>
</view> </view>
</scroll-view> </scroll-view>
</view> </view>
<view class="talking-list"> <view class="talking-list">
<scroll-view <scroll-view class="talking-scroll-list" :scroll-y="true" :scroll-top="scrollTop" :show-scrollbar="false"
class="talking-scroll-list" :scroll-with-animation="false">
:scroll-y="true" <TalkingItem v-for="(item, index) in talkingList" :talkingType="item.type" :talkingInfo="item"
:scroll-top="scrollTop" :isLast="index + 1 === talkingList.length" :isAnswering="!answerIsOver"
:show-scrollbar="false" :activeVoiceId="activeVoiceTalkingItemId" @handleEvents="talkItemEvents"></TalkingItem>
:scroll-with-animation="false"
>
<TalkingItem
v-for="(item, index) in talkingList"
:talkingType="item.type"
:talkingInfo="item"
:isLast="index + 1 === talkingList.length"
:isAnswering="!answerIsOver"
:activeVoiceId="activeVoiceTalkingItemId"
@handleEvents="talkItemEvents"
></TalkingItem>
</scroll-view> </scroll-view>
</view> </view>
<view class="router-list"> <view class="router-list">
@@ -119,23 +88,16 @@
</view> </view>
</scroll-view> </scroll-view>
</view> </view>
<TouchBtn <TouchBtn class="talk-btns" @uploadVoice="uploadRecordNow" @submitAnswer="submitAnswerNow"
class="talk-btns" @startRecord="startRecordCallback" :loadingText="sendLoadingText" :isLoading="!answerIsOver"
@uploadVoice="uploadRecordNow" :adjustPosition="true" :isDisabled="isHistory" />
@submitAnswer="submitAnswerNow"
@startRecord="startRecordCallback"
:loadingText="sendLoadingText"
:isLoading="!answerIsOver"
:adjustPosition="true"
:isDisabled="isHistory"
/>
<History ref="historyRef" @showDetail="showHistoryDetail"></History> <History ref="historyRef" @showDetail="showHistoryDetail"></History>
<PreviewVue ref="previewRef" /> <PreviewVue ref="previewRef" />
</scroll-view> </scroll-view>
</view> </view>
<badge ref="badgeRef"></badge> <badge ref="badgeRef"></badge>
<points ref="pointsRef"></points> <points ref="pointsRef"></points>
<!-- 反馈组件 --> <!-- 反馈组件 -->
<Feedback ref="feedbackRef" @feedbackAnswer="feedbackAnswer"></Feedback> <Feedback ref="feedbackRef" @feedbackAnswer="feedbackAnswer"></Feedback>
<!-- <file-preview ref="previewFileRef" :file-id="'603058d8-88e0-43d2-8242-3132b85bc91c'" v-model="showPreview" /> --> <!-- <file-preview ref="previewFileRef" :file-id="'603058d8-88e0-43d2-8242-3132b85bc91c'" v-model="showPreview" /> -->
@@ -144,19 +106,49 @@
</template> </template>
<script setup> <script setup>
import { ref, unref, onMounted, watch, nextTick, computed, onActivated } from 'vue'; import {
ref,
unref,
onMounted,
watch,
nextTick,
computed,
onActivated
} from 'vue';
import common from '@/common/common'; import common from '@/common/common';
import { setupKeyboardHeightListener } from '@/common/common'; import {
setupKeyboardHeightListener
} from '@/common/common';
import TouchBtn from '@/pages/course/components/touchBtn.vue'; import TouchBtn from '@/pages/course/components/touchBtn.vue';
import TalkingItem from './components/talking-item.vue'; import TalkingItem from './components/talking-item.vue';
import PreviewVue from './components/preview.vue'; import PreviewVue from './components/preview.vue';
import { useSocketStore } from '@/store/socket.js'; import {
import { useStorageStore } from '@/store/storage.js'; useSocketStore
import { storeToRefs } from 'pinia'; } from '@/store/socket.js';
import { onLoad, onShow, onUnload, onHide, onBackPress } from '@dcloudio/uni-app'; import {
import { get_base_url, goto_login_fun } from '@/api/request'; useStorageStore
import { getUserInfo, getPhoneEnvBool } from '@/common/common'; } from '@/store/storage.js';
import { commonUploadVoiceFile } from '@/api/common.js'; import {
storeToRefs
} from 'pinia';
import {
onLoad,
onShow,
onUnload,
onHide,
onBackPress
} from '@dcloudio/uni-app';
import {
get_base_url,
goto_login_fun
} from '@/api/request';
import {
getUserInfo,
getPhoneEnvBool
} from '@/common/common';
import {
commonUploadVoiceFile
} from '@/api/common.js';
import { import {
queryHotQuestionApi, queryHotQuestionApi,
insertTraAskFeedback, insertTraAskFeedback,
@@ -169,20 +161,28 @@
import badge from '@/components/points-and-badge/badge'; import badge from '@/components/points-and-badge/badge';
import points from '@/components/points-and-badge/points'; import points from '@/components/points-and-badge/points';
import usePointsAndBadge from '@/components/points-and-badge/usePointsAndBadge'; import usePointsAndBadge from '@/components/points-and-badge/usePointsAndBadge';
const { pointAndBadgesRun, badgeRef, pointsRef } = usePointsAndBadge(); const {
pointAndBadgesRun,
badgeRef,
pointsRef
} = usePointsAndBadge();
const { statusBarHeight } = uni.getWindowInfo(); const {
statusBarHeight
} = uni.getWindowInfo();
const pageTopPadding = computed(() => statusBarHeight + 'px'); const pageTopPadding = computed(() => statusBarHeight + 'px');
const socketStore = useSocketStore(); const socketStore = useSocketStore();
const { SocketObj } = storeToRefs(socketStore); const {
SocketObj
} = storeToRefs(socketStore);
const feedbackRef = ref(); const feedbackRef = ref();
const watermarkRef = ref(); const watermarkRef = ref();
const userInfo = ref(getUserInfo()); const userInfo = ref(getUserInfo());
const luimgAddr = computed(()=> unref(userInfo)?.mascotInfo?.imgAddr || '') const luimgAddr = computed(() => unref(userInfo)?.mascotInfo?.imgAddr || '')
const userParams = '/' + (unref(userInfo)?.loginName??'') const userParams = '/' + (unref(userInfo)?.loginName ?? '')
const questionList = ref([ const questionList = ref([
// '对公小程序开户流程?', // '对公小程序开户流程?',
// '厅堂服务经理2025年管理办法?', // '厅堂服务经理2025年管理办法?',
@@ -262,7 +262,11 @@
}); });
}); });
unref(SocketObj).on('message', (res) => { unref(SocketObj).on('message', (res) => {
const { rtnCode, body, commond } = JSON.parse(res.data); const {
rtnCode,
body,
commond
} = JSON.parse(res.data);
let _id = new Date().getTime() + 'id'; let _id = new Date().getTime() + 'id';
if (rtnCode === '0000') { if (rtnCode === '0000') {
if (commond === 'ASK-OPEN') { if (commond === 'ASK-OPEN') {
@@ -296,7 +300,8 @@
if (commond === 'ASK') { if (commond === 'ASK') {
console.log('发送问题成功!'); console.log('发送问题成功!');
if (talkingList.value.length > 0 && talkingList.value[talkingList.value.length - 1].isLoading) { if (talkingList.value.length > 0 && talkingList.value[talkingList.value.length - 1].isLoading) {
talkingList.value.pop(); // talkingList.value.pop();
talkingList.value = talkingList.value.filter(t => !t.isLoading)
} }
seqNo.value = body.seqNo; seqNo.value = body.seqNo;
touchBtnCallBack.value && touchBtnCallBack.value(); touchBtnCallBack.value && touchBtnCallBack.value();
@@ -314,6 +319,7 @@
isLoading: true, isLoading: true,
id: _id + 'loading' id: _id + 'loading'
}); });
answerIsOver.value = false;
scrollToBottomNow(); scrollToBottomNow();
return; return;
} }
@@ -329,13 +335,14 @@
if (commond === 'ASK-ANSWER') { if (commond === 'ASK-ANSWER') {
if (body.event === 'start') { if (body.event === 'start') {
console.log('开始回答!'); console.log('开始回答!');
if (askTime.value === 0){ if (askTime.value === 0) {
pointAndBadgesRun('06') pointAndBadgesRun('06')
askTime.value = 1 askTime.value = 1
} }
answerIsOver.value = false; answerIsOver.value = false;
answerText.value = ''; answerText.value = '';
talkingList.value.pop(); talkingList.value.pop();
talkingList.value = talkingList.value.filter(t => !t.isLoading)
talkingList.value.push({ talkingList.value.push({
type: 'answer', type: 'answer',
talkingText: answerText.value, talkingText: answerText.value,
@@ -380,6 +387,7 @@
if (commond === 'ASK-ERR') { if (commond === 'ASK-ERR') {
console.log('提问失败,系统异常!'); console.log('提问失败,系统异常!');
answerIsOver.value = true;
return; return;
} }
} else { } else {
@@ -417,7 +425,12 @@
const isDownloading = ref(false) const isDownloading = ref(false)
const stopAnswerCallBack = ref(null); const stopAnswerCallBack = ref(null);
const talkItemEvents = ({ type, data, id, info = {} }) => { const talkItemEvents = ({
type,
data,
id,
info = {}
}) => {
switch (type) { switch (type) {
case 'reAnswer': case 'reAnswer':
console.log('重新提问回答'); console.log('重新提问回答');
@@ -530,8 +543,7 @@
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
console.log('开始下载:', fileUrl); console.log('开始下载:', fileUrl);
const dtask = plus.downloader.createDownload( const dtask = plus.downloader.createDownload(
fileUrl, fileUrl, {
{
filename: localFilePath filename: localFilePath
}, },
(d, status) => { (d, status) => {
@@ -676,31 +688,33 @@
scrollToBottomNow(); scrollToBottomNow();
commonUploadVoiceFile(voicePath, '/traask/traAskchat/voiceTrans', {}) commonUploadVoiceFile(voicePath, '/traask/traAskchat/voiceTrans', {})
.then((_res) => { .then((_res) => {
if (!!(_res.body.transContent || '').trim()) { if (!!(_res.body.transContent || '').trim()) {
askData.value = { askData.value = {
reqBatch: reqBatch.value, reqBatch: reqBatch.value,
intrctWay: '02', //01-文本;02-语音;03-图片 intrctWay: '02', //01-文本;02-语音;03-图片
intrctContent: _res.body.transContent, intrctContent: _res.body.transContent,
bucketKey: _res.body.fileId, bucketKey: _res.body.fileId,
ossFileAddr: _res.body.ossFileAddr, ossFileAddr: _res.body.ossFileAddr,
talkingVoice: voicePath, talkingVoice: voicePath,
voiceTime: voiceTime voiceTime: voiceTime
}; };
sendMessage({ sendMessage({
commond: 'ASK', commond: 'ASK',
body: askData.value body: askData.value
}); });
} else { } else {
talkingList.value.pop(); talkingList.value.pop();
uni.showToast({ talkingList.value = talkingList.value.filter(t => !t.isLoading)
title: '未识别到文字', uni.showToast({
icon: 'none', title: '未识别到文字',
duration: 1000 icon: 'none',
}); duration: 1000
} });
}
}) })
.catch((err) => { .catch((err) => {
talkingList.value.pop(); talkingList.value.pop();
talkingList.value = talkingList.value.filter(t => !t.isLoading)
uni.showToast({ uni.showToast({
title: '系统异常,请联系管理员', title: '系统异常,请联系管理员',
icon: 'none', icon: 'none',
@@ -726,7 +740,9 @@
commond: 'ASK', commond: 'ASK',
body: askData.value body: askData.value
}); });
setHeight({height: 0}) setHeight({
height: 0
})
}; };
const startRecordCallback = () => { const startRecordCallback = () => {
// 开始录音回调 // 开始录音回调
@@ -793,7 +809,7 @@
}; };
onLoad(() => { onLoad(() => {
//#ifdef APP-PLUS //#ifdef APP-PLUS
plus.screen.lockOrientation('portrait-primary') plus.screen.lockOrientation('portrait-primary')
// #endif // #endif
changeAppHeightBottom(); changeAppHeightBottom();
if (!common.isLogin()) { if (!common.isLogin()) {
@@ -824,9 +840,9 @@
const keyboardHeight = ref('0px'); const keyboardHeight = ref('0px');
const setHeight = (res) => { const setHeight = (res) => {
keyboardHeight.value = (res.height || 0) + 'px'; keyboardHeight.value = (res.height || 0) + 'px';
setTimeout(()=>{ setTimeout(() => {
console.log(totalBotHeight.value) console.log(totalBotHeight.value)
},1000) }, 1000)
}; };
const keyBoardIsHide = computed(() => { const keyBoardIsHide = computed(() => {
return parseInt(keyboardHeight.value) == 0; return parseInt(keyboardHeight.value) == 0;
@@ -837,7 +853,8 @@
// #ifdef APP-PLUS // #ifdef APP-PLUS
isIos = (plus.os.name == "iOS") isIos = (plus.os.name == "iOS")
// #endif // #endif
return isIos || keyBoardIsHide.value ? 0 + 'px' : parseInt(keyboardHeight.value) + parseInt(bottomHeight.value) + 'px'; return isIos || keyBoardIsHide.value ? 0 + 'px' : parseInt(keyboardHeight.value) + parseInt(bottomHeight.value) +
'px';
}); });
const changeAppHeightBottom = (height) => { const changeAppHeightBottom = (height) => {
//#ifdef APP-PLUS //#ifdef APP-PLUS
@@ -846,15 +863,15 @@
// 计算安全区域底部高度 // 计算安全区域底部高度
bottomHeight.value = systemInfo.screenHeight - systemInfo.safeArea.bottom + 'px'; bottomHeight.value = systemInfo.screenHeight - systemInfo.safeArea.bottom + 'px';
console.log(systemInfo) console.log(systemInfo)
console.log(systemInfo.screenHeight , systemInfo.safeArea.bottom ) console.log(systemInfo.screenHeight, systemInfo.safeArea.bottom)
// #endif // #endif
}; };
const deleteFolder = () => { const deleteFolder = () => {
//#ifdef APP-PLUS //#ifdef APP-PLUS
plus.io.resolveLocalFileSystemURL('_doc/pdf_view', function (entry) { plus.io.resolveLocalFileSystemURL('_doc/pdf_view', function(entry) {
console.log('entry', entry); console.log('entry', entry);
entry.removeRecursively(function (res) { entry.removeRecursively(function(res) {
console.log('删除成功'); console.log('删除成功');
}); });
}); });
@@ -932,7 +949,8 @@
font-weight: 500; font-weight: 500;
color: #000; color: #000;
position: relative; position: relative;
.top-desc{
.top-desc {
position: absolute; position: absolute;
bottom: -10rpx; bottom: -10rpx;
font-size: 18rpx; font-size: 18rpx;
@@ -941,7 +959,7 @@
transform: translateX(-50%); transform: translateX(-50%);
} }
.top-desc{ .top-desc {
position: absolute; position: absolute;
bottom: -10rpx; bottom: -10rpx;
font-size: 18rpx; font-size: 18rpx;
@@ -949,6 +967,7 @@
left: 50%; left: 50%;
transform: translateX(-50%); transform: translateX(-50%);
} }
// margin-bottom: 23rpx; // margin-bottom: 23rpx;
.arrow-icon { .arrow-icon {
position: absolute; position: absolute;
@@ -971,6 +990,7 @@
line-height: 32rpx; line-height: 32rpx;
text-align: right; text-align: right;
padding-right: 48rpx; padding-right: 48rpx;
.more-list { .more-list {
position: absolute; position: absolute;
top: 100%; top: 100%;
@@ -982,9 +1002,11 @@
padding: 16rpx 0; padding: 16rpx 0;
display: none; display: none;
z-index: 21; z-index: 21;
&.show { &.show {
display: block; display: block;
} }
.more-item { .more-item {
line-height: 60rpx; line-height: 60rpx;
font-size: 29rpx; font-size: 29rpx;
@@ -993,6 +1015,7 @@
z-index: 22; z-index: 22;
} }
} }
.image-icon { .image-icon {
width: 30rpx; width: 30rpx;
height: 32rpx; height: 32rpx;
@@ -1150,6 +1173,7 @@
padding: 12rpx 24rpx; padding: 12rpx 24rpx;
box-sizing: border-box; box-sizing: border-box;
min-height: 300rpx; min-height: 300rpx;
.talking-scroll-list { .talking-scroll-list {
height: 100%; height: 100%;
} }