Merge branch 'develop' of http://25.13.9.101:9000/K17_AITS/tra-app into develop
This commit is contained in:
+2
-9
@@ -2,19 +2,12 @@
|
||||
ENV = 'development'
|
||||
# 'development'
|
||||
|
||||
#VITE_APP_BASE_API_Url = 'https://aits.jlbank.com.cn:7001'
|
||||
|
||||
|
||||
# VITE_APP_BASE_API_Url = 'https://aits.jlbank.com.cn:7001'
|
||||
VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7001'
|
||||
|
||||
|
||||
#VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7001'
|
||||
|
||||
VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7002'
|
||||
# VITE_APP_BASE_API_Url = 'http://192.168.247.200'
|
||||
# VITE_APP_BASE_API_Url = 'http://aitscdn.jlbank.com.cn:7001'
|
||||
# VITE_APP_BASE_API_Url = 'http://192.168.108.129'
|
||||
# dev
|
||||
|
||||
# DEV
|
||||
#VITE_APP_BASE_API_Url = 'http://25.18.122.65:7001'
|
||||
|
||||
|
||||
@@ -335,17 +335,17 @@ export function setupKeyboardHeightListener(updateCallback) {
|
||||
const handleKeyboardHeightChange = (res) => {
|
||||
// 获取系统信息
|
||||
const systemInfo = uni.getSystemInfoSync();
|
||||
console.log('systemInfo', systemInfo);
|
||||
// console.log('systemInfo', systemInfo);
|
||||
// 计算安全区域底部高度
|
||||
const safeAreaBottomHeight = systemInfo.screenHeight - systemInfo.safeArea.bottom;
|
||||
console.log('计算安全区域底部高度', safeAreaBottomHeight);
|
||||
// console.log('计算安全区域底部高度', safeAreaBottomHeight);
|
||||
let keyboardHeight = res.height;
|
||||
console.log('软键盘高度', keyboardHeight);
|
||||
// console.log('软键盘高度', keyboardHeight);
|
||||
// 仅在iOS端补偿安全区域高度
|
||||
if (systemInfo.platform === 'ios') {
|
||||
keyboardHeight = Math.max(0, keyboardHeight); // 避免负数
|
||||
}
|
||||
console.log('keyboardHeight', keyboardHeight);
|
||||
// console.log('keyboardHeight', keyboardHeight);
|
||||
// 通过回调函数更新外部的响应式变量
|
||||
updateCallback(keyboardHeight);
|
||||
};
|
||||
|
||||
@@ -169,7 +169,7 @@
|
||||
setTimeout(() => {
|
||||
textShow.value = true;
|
||||
textLoading.value = false;
|
||||
}, 500);
|
||||
}, 400);
|
||||
} else {
|
||||
textShow.value = false;
|
||||
}
|
||||
@@ -222,7 +222,7 @@
|
||||
console.log('加载声音', props.dataInfo);
|
||||
if (newVal === '' && props.dataInfo.ossKey) {
|
||||
// 去下载oss内容
|
||||
console.log('真下载oss内容');
|
||||
console.log('真下载oss内容', props.dataInfo.ossKey);
|
||||
downloadFile(props.dataInfo.ossKey).then((res) => {
|
||||
voiceTime.value = '';
|
||||
innerAudio.setAudioSrc(res.tempFilePath);
|
||||
@@ -236,6 +236,22 @@
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
watch(
|
||||
() => props.dataInfo.ossKey,
|
||||
(newVal) => {
|
||||
if (props.dataInfo.voicePath === undefined && props.dataInfo.ossKey) {
|
||||
console.log('真下载oss内容', props.dataInfo.ossKey);
|
||||
downloadFile(props.dataInfo.ossKey).then((res) => {
|
||||
voiceTime.value = '';
|
||||
props.dataInfo.voicePath = res.tempFilePath;
|
||||
innerAudio.setAudioSrc(res.tempFilePath);
|
||||
});
|
||||
} else if (newVal === undefined) {
|
||||
innerAudio.stopAudio();
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
});
|
||||
onUnload(() => {
|
||||
// 1. 停止当前播放(优先处理,避免音频继续播放)
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
bottom: 0;
|
||||
&.voice_to_text {
|
||||
&.voice_to_text,&.send_over {
|
||||
.btn-box-1 {
|
||||
animation: moveLeftOut 0.3s ease-out forwards;
|
||||
}
|
||||
@@ -61,6 +61,7 @@
|
||||
.circle-bg-box {
|
||||
animation: moveBottomOut 0.3s ease-out forwards;
|
||||
}
|
||||
|
||||
}
|
||||
// 仅语音
|
||||
&.voice-only {
|
||||
@@ -138,11 +139,15 @@
|
||||
bottom: 0;
|
||||
opacity: 0;
|
||||
visibility: hidden; // 初始不可见且不占交互位置
|
||||
&.voice_to_text {
|
||||
&.voice_to_text,&.send_over {
|
||||
display: flex !important;
|
||||
visibility: visible; // 激活后可见
|
||||
animation: fadeIn 0.4s ease-out 0.1s forwards;
|
||||
}
|
||||
// 仅文字模式,隐藏发送原语音按钮
|
||||
&.text-only>.trans-btn{
|
||||
visibility: hidden;
|
||||
}
|
||||
.transVoiceIng {
|
||||
width: 154rpx;
|
||||
height: 154rpx;
|
||||
@@ -189,15 +194,19 @@
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
&.init > .send-btn > .send-btn-loading {
|
||||
display: block !important;
|
||||
&.init > .send-btn {
|
||||
pointer-events: none;
|
||||
cursor: not-allowed;
|
||||
.send-btn-loading {
|
||||
display: block !important;
|
||||
pointer-events: none;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
&.success > .send-btn > .send-btn-text {
|
||||
display: block !important;
|
||||
}
|
||||
&.failed .send-btn {
|
||||
&.failed .send-btn,&.networkError .send-btn {
|
||||
pointer-events: none;
|
||||
cursor: not-allowed;
|
||||
background-color: rgb(80, 80, 80);
|
||||
@@ -254,7 +263,7 @@
|
||||
left: 78% !important;
|
||||
}
|
||||
|
||||
&.failed {
|
||||
&.failed,&.networkError {
|
||||
width: 506rpx;
|
||||
height: 114rpx;
|
||||
min-height: 114rpx;
|
||||
@@ -269,7 +278,11 @@
|
||||
// animation: fadeIn 0.4s ease-out 0.1s forwards;
|
||||
}
|
||||
.textarea {
|
||||
// display: none;
|
||||
visibility: hidden; // 初始不可见且不占交互位置
|
||||
}
|
||||
}
|
||||
&.init{
|
||||
.textarea {
|
||||
visibility: hidden; // 初始不可见且不占交互位置
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ export const icKeyboardSvg = () : string => {
|
||||
};
|
||||
export const iconMicSvg = () : string => {
|
||||
const svgXml = `
|
||||
<svg t="1772357429950" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1775" width="200" height="200"><path d="M513.788813 938.289925c-113.566274 0-220.223734-44.167967-300.444149-124.388381-80.220415-80.220415-124.388382-186.877876-124.388382-300.44415s44.167967-220.227983 124.388382-300.448398c165.543834-165.548083 435.348714-165.548083 600.892548 0 165.548083 165.548083 165.548083 435.348714 0 600.892548-80.220415 80.220415-186.877876 124.388382-300.44415 124.388381z m0-785.973112c-92.538158 0-185.072066 35.453344-255.379651 105.756681-68.2001 68.204349-105.75668 158.63927-105.756681 255.3839s37.556581 187.175303 105.756681 255.379652c68.204349 68.2001 158.936697 106.054108 255.379651 105.75668 96.74888 0 187.179552-37.556581 255.379652-105.75668 140.912598-140.912598 140.912598-369.850954 0-510.759303-70.303336-70.307585-162.841494-105.75668-255.379652-105.756681z" fill="#515151" p-id="1776"></path><path d="M318.672199 341.705826h46.313693c11.047303 0 19.545228 8.497925 19.545228 19.120332v46.313693c0 10.622407-8.497925 19.120332-19.120332 19.120332h-46.738589c-10.622407 0.424896-19.120332-8.073029-19.120332-18.695436v-46.738589c0-10.622407 8.497925-19.120332 19.120332-19.120332zM488.630705 341.705826h46.313693c11.047303 0 19.545228 8.497925 19.545229 19.120332v46.313693c0 10.622407-8.497925 19.120332-19.120332 19.120332h-46.73859c-10.622407 0.424896-19.120332-8.073029-19.120332-18.695436v-46.738589c0-10.622407 8.497925-19.120332 19.120332-19.120332zM658.589212 341.705826h46.313693c11.047303 0 19.545228 8.497925 19.545228 19.120332v46.313693c0 10.622407-8.497925 19.120332-19.120332 19.120332h-46.738589c-10.622407 0.424896-19.120332-8.073029-19.120332-18.695436v-46.738589c0-10.622407 8.497925-19.120332 19.120332-19.120332zM318.672199 469.174705h46.313693c10.622407 0 19.120332 8.497925 19.120332 19.120332v46.313693c0 10.622407-8.497925 19.120332-19.120332 19.120332H318.672199c-10.622407 0.424896-19.120332-8.073029-19.120332-18.695435v-46.73859c0-10.622407 8.497925-19.120332 19.120332-19.120332zM488.630705 469.174705h46.313693c10.622407 0 19.120332 8.497925 19.120332 19.120332v46.313693c0 10.622407-8.497925 19.120332-19.120332 19.120332h-46.313693c-10.622407 0.424896-19.120332-8.073029-19.120332-18.695435v-46.73859c0-10.622407 8.497925-19.120332 19.120332-19.120332zM658.589212 469.174705h46.313693c10.622407 0 19.120332 8.497925 19.120332 19.120332v46.313693c0 10.622407-8.497925 19.120332-19.120332 19.120332h-46.313693c-10.622407 0.424896-19.120332-8.073029-19.120332-18.695435v-46.73859c0-10.622407 8.497925-19.120332 19.120332-19.120332zM458.887967 660.378025h106.224066c17.420747 0 31.86722 14.446473 31.86722 31.86722s-14.446473 31.86722-31.86722 31.86722h-106.224066c-17.420747 0-31.86722-14.446473-31.86722-31.86722s14.446473-31.86722 31.86722-31.86722z" fill="#515151" p-id="1777"></path></svg>
|
||||
<svg t="1772603482440" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5657" width="256" height="256"><path d="M512 64c247.424 0 448 200.576 448 448S759.424 960 512 960 64 759.424 64 512 264.576 64 512 64z m0 68c-209.868 0-380 170.132-380 380s170.132 380 380 380 380-170.132 380-380-170.132-380-380-380z m52.766 130.24c12.33-12.32 32.298-12.32 44.625-0.005l0.018 0.019 4.026 4.133c131.545 137.211 131.4 354.035-0.317 491.07l-4.073 4.17-0.342 0.348c-5.74 5.758-13.6 9.025-21.802 9.025a30.85 30.85 0 0 1-22.19-9.419c-11.208-11.926-11.208-30.444-0.044-42.324l0.097-0.1 3.343-3.404c109.19-113.003 109.2-292.426 0.033-405.442l-3.376-3.438-0.365-0.372c-11.943-12.356-11.821-32.055 0.367-44.261z m-115.333 89.643c11.818-10.51 29.644-10.51 41.463-0.003l0.462 0.418 0.096 0.1 2.53 2.652c82.68 88.053 82.688 225.361 0.026 313.424l-2.672 2.799-0.124 0.11-0.358 0.316c-11.864 10.301-29.51 10.302-41.376 0.003l-0.533-0.472-0.157-0.171-0.325-0.36c-10.61-11.942-10.502-30.015 0.325-41.832l0.132-0.138 1.892-1.933c61.805-64.168 61.812-165.846 0.019-230.022l-1.998-2.04-0.083-0.092-0.318-0.361c-10.4-11.99-10.294-29.879 0.318-41.747l0.154-0.172 0.17-0.157z m-128.057 125.89c13.666-13.46 34.104-17.488 51.906-10.157C391.264 475.02 403 492.549 403 512c0 19.452-11.736 36.98-29.718 44.385a47.973 47.973 0 0 1-51.93-10.182l-0.413-0.412-0.425-0.427A47.64 47.64 0 0 1 306.889 512a47.658 47.658 0 0 1 13.675-33.413l0.4-0.403z" fill="#515151" p-id="5658"></path></svg>
|
||||
`;
|
||||
return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svgXml)}`;
|
||||
};
|
||||
|
||||
@@ -5,8 +5,9 @@
|
||||
* - 'voice_recording' : 录音中状态(语音录制面板展开,正在录音)
|
||||
* - 'text_input' : 文字输入中状态(文字输入面板展开,用户正在输入)
|
||||
* - 'voice_to_text' : 语音转文字状态(独立的语音转文字页面/面板展开)
|
||||
* - 'send_over' : 发送完成
|
||||
*/
|
||||
export type StatusType = 'default' | 'voice_recording' | 'text_input' | 'voice_to_text' | 'voice_send_ing';
|
||||
export type StatusType = 'default' | 'voice_recording' | 'text_input' | 'voice_to_text' | 'voice_send_ing' | 'send_over';
|
||||
|
||||
/**
|
||||
* 语音转文字的子状态(仅当主状态为 voice_to_text 时生效)
|
||||
@@ -16,7 +17,8 @@ export type VoiceToTextSubStatus =
|
||||
| 'init' // 初始化(刚进入语音转文字页面)
|
||||
// | 'loading' // 转换中(正在处理语音→文字)
|
||||
| 'success' // 转换完成(成功得到文字结果)
|
||||
| 'failed'; // 转换失败(网络/识别错误等)
|
||||
| 'failed' // 转换失败(网络/识别错误等)
|
||||
| 'networkError'; // 转换失败(网络错误等)
|
||||
|
||||
|
||||
/** 错误码枚举 - 直接映射提示文本 */
|
||||
@@ -33,6 +35,7 @@ export interface ShowErrorTipOptions {
|
||||
delayTime?: number;
|
||||
}
|
||||
|
||||
type ChangeBtnCallback = () => void;
|
||||
|
||||
/**
|
||||
* 触摸按钮组件的自定义事件类型定义
|
||||
@@ -44,13 +47,13 @@ export type TouchBtnEmits = {
|
||||
* @param voiceData - 语音相关数据(包含ossKey、识别文本等核心字段)
|
||||
* @param duration - 录音时长(单位:毫秒),用于校验最短录音时长
|
||||
*/
|
||||
submitVoice: [params: { ossKey: string; text: string }];
|
||||
submitVoice: [params: { ossKey: string; text: string, recordId:string }];
|
||||
/**
|
||||
* 提交文字答案(用户确认识别结果/手动编辑后触发)
|
||||
* @param answerText - 最终提交的文字答案内容
|
||||
* @param isManualEdit - 是否手动编辑过识别结果(true=手动修改,false=纯语音识别)
|
||||
* @param changeBtn - 按钮状态变更的回调函数
|
||||
*/
|
||||
submitAnswer: [answerText: string, isManualEdit: boolean];
|
||||
submitAnswer: [answerText: string, changeBtn: ChangeBtnCallback];
|
||||
/**
|
||||
* 开始录音(用户点击录音按钮时触发)
|
||||
* @param recordParams - 录音初始化参数(可选,默认使用组件内置配置)
|
||||
|
||||
@@ -1,52 +1,85 @@
|
||||
<template>
|
||||
<view>
|
||||
<view class="talk-btns-components" :class="{action:isRecording, inputMode:!isInputVisible}">
|
||||
<view class="talk-btns-components" :class="{ action: isRecording, inputMode: !isInputVisible }">
|
||||
<view class="touch-btn" @click="disabled_click">
|
||||
<button v-if="!isTextOnlyMode && isInputVisible" class="voice-btn" @touchstart="startRecord"
|
||||
@touchend="stopRecord()" @touchmove="handleMove" @touchcancel="stopRecord()" :plain="true">
|
||||
<button
|
||||
v-if="isInputVisible"
|
||||
class="voice-btn"
|
||||
@touchstart="startRecord"
|
||||
@touchend="stopRecord()"
|
||||
@touchmove="handleMove"
|
||||
@touchcancel="stopRecord()"
|
||||
:plain="true"
|
||||
>
|
||||
<text class="voice-text">{{ isRecording ? '松开发送' : '按住说话' }}</text>
|
||||
</button>
|
||||
<input v-if="!isVoiceOnlyMode && !isInputVisible" class="input-box" ref="inputRef" v-model="inputText"
|
||||
:maxlength="props.maxlength" :adjustPosition="true"
|
||||
placeholderStyle="color:#999999;font-size:26rpx" placeholder="请输入文字"
|
||||
:disabled="props.isDisabled" @click="disabled_click"></input>
|
||||
<input
|
||||
v-if="!isVoiceOnlyMode && !isInputVisible"
|
||||
class="input-box"
|
||||
ref="inputRef"
|
||||
v-model="inputText"
|
||||
:maxlength="props.maxlength"
|
||||
:adjustPosition="false"
|
||||
placeholderStyle="color:#999999;font-size:26rpx"
|
||||
placeholder="请输入文字"
|
||||
:disabled="props.isDisabled"
|
||||
@click="disabled_click"
|
||||
/>
|
||||
</view>
|
||||
<view class="talk-right-icon-div" v-if="!isTextOnlyMode && !isVoiceOnlyMode">
|
||||
<image class="talk-right-icon" :src="talkRightIcon" mode="widthFix" @click="changeBtn"></image>
|
||||
<view class="talk-right-icon-div" v-if="!isVoiceOnlyMode">
|
||||
<image class="talk-right-icon" :src="talkRightIcon" mode="widthFix" @click="iconClick()"></image>
|
||||
</view>
|
||||
</view>
|
||||
<uni-popup ref="popupRef" class="popup" @touchmove.stop.prevent="false">
|
||||
<view class="overlay-box" >
|
||||
<view class="overlay-box">
|
||||
<view class="fl1"></view>
|
||||
<view class="talk-dialog-box">
|
||||
<view class="talk-dialog-div" :class="dialogDynamicClasses">
|
||||
<view class="talk-dialog" >
|
||||
<image :src="voiceWhiteBtn" mode="" class="gif-box"></image>
|
||||
<uv-textarea class="textarea" ref="inputRef" v-model="textAreaText" :maxlength="255" @click.stop
|
||||
<view class="talk-dialog">
|
||||
<image :src="TouchBtnImages.voiceWhiteBtn" mode="" class="gif-box"></image>
|
||||
<uv-textarea
|
||||
class="textarea"
|
||||
ref="inputRef"
|
||||
v-model="textAreaText"
|
||||
:maxlength="255"
|
||||
@click.stop
|
||||
customStyle="background: #ffffff00; padding-bottom: 50rpx; color: #fff; caret-color: #fff"
|
||||
text-style="color: #fff" border="none" placeholderStyle="color:#999999;font-size:26rpx;"
|
||||
placeholder=""></uv-textarea>
|
||||
text-style="color: #fff"
|
||||
border="none"
|
||||
placeholderStyle="color:#999999;font-size:26rpx;"
|
||||
placeholder=""
|
||||
></uv-textarea>
|
||||
<view class="error-tip-div">
|
||||
<image :src="iconRecognizeErrorSvg()" mode="aspectFill" class="img"></image>
|
||||
<view class="">
|
||||
未识别到文字
|
||||
</view>
|
||||
<image :src="TouchBtnImages.iconRecognizeErrorSvg()" mode="aspectFill" class="img"></image>
|
||||
<view class="" v-if="voice_to_text_status === 'failed'">未识别到文字</view>
|
||||
<view class="" v-if="voice_to_text_status === 'networkError'">网络识别超时</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 第一形态两侧按钮 -->
|
||||
<view class="page-box" :style="{marginBottom:pageBoxMarginBottom}">
|
||||
<view class="page-box" :style="{ marginBottom: pageBoxMarginBottom }">
|
||||
<view class="page-1" :class="[status, props.mode]">
|
||||
<view class="btns-box">
|
||||
<!-- 左侧取消按钮 -->
|
||||
<image class="btn-box btn-box-1" :src="isOutStatus == '02' ? cancelActiveBtn : cancelBtn"
|
||||
mode="heightFix" @click="closePopup()"></image>
|
||||
<image
|
||||
class="btn-box btn-box-1"
|
||||
:src="isOutStatus == '02' ? TouchBtnImages.cancelActiveBtn : TouchBtnImages.cancelBtn"
|
||||
mode="heightFix"
|
||||
@click="closePopup()"
|
||||
></image>
|
||||
<!-- 右侧转文字按钮 -->
|
||||
<image class="btn-box btn-box-2" :src="isOutStatus == '03' ? translateActiveBtn : translateBtn"
|
||||
mode="heightFix"></image>
|
||||
<image class="btn-box-3" :src="isOutStatus == '02'? closeActiveBtn : closeBtn"
|
||||
mode="heightFix" @click="closePopup()"></image>
|
||||
<image
|
||||
class="btn-box btn-box-2"
|
||||
:src="isOutStatus == '03' ? TouchBtnImages.translateActiveBtn : TouchBtnImages.translateBtn"
|
||||
mode="heightFix"
|
||||
></image>
|
||||
<image
|
||||
class="btn-box-3"
|
||||
:src="isOutStatus == '02' ? TouchBtnImages.closeActiveBtn : TouchBtnImages.closeBtn"
|
||||
mode="heightFix"
|
||||
@click="closePopup()"
|
||||
></image>
|
||||
</view>
|
||||
<!-- 下方按钮 -->
|
||||
<view class="circle-bg-box">
|
||||
@@ -54,15 +87,19 @@
|
||||
</view>
|
||||
</view>
|
||||
<!-- 第二形态 -->
|
||||
<view class="page-2" :class="[ status, voice_to_text_status]" >
|
||||
<view class="page-2" :class="[status, voice_to_text_status, props.mode]">
|
||||
<!-- 左侧XX -->
|
||||
<view class="transVoiceIng cancel-btn" @click="closePopup()"><text class="btn-text">取消</text></view>
|
||||
<view class="transVoiceIng cancel-btn" @click="closePopup()">
|
||||
<text class="btn-text">取消</text>
|
||||
</view>
|
||||
<!-- 中间发送原语音 -->
|
||||
<view class="transVoiceIng trans-btn" @click="testFun()"><text class="btn-text">发送原语音</text></view>
|
||||
<view class="transVoiceIng trans-btn" @click="testFun()">
|
||||
<text class="btn-text">发送原语音</text>
|
||||
</view>
|
||||
<!-- 右侧发送按钮(椭圆) -->
|
||||
<view class="send-btn" @click="send_msg()">
|
||||
<view class="send-btn-text">发送</view>
|
||||
<CommonLoading class="send-btn-loading" color="#444"/>
|
||||
<CommonLoading class="send-btn-loading" color="#444" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -72,16 +109,13 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
// 导出图片
|
||||
import { cancelBtn, cancelActiveBtn, translateBtn, translateActiveBtn, voiceWhiteBtn,closeBtn,closeActiveBtn, icKeyboardSvg, iconMicSvg, iconSendSvg, iconRecognizeErrorSvg } from './touch-btn.images';
|
||||
import { StatusType, VoiceToTextSubStatus,ErrorCode } from './touch-btn.types';
|
||||
import type {TouchBtnEmits } from './touch-btn.types';
|
||||
import * as TouchBtnImages from './touch-btn.images'; // 导出图片
|
||||
import { StatusType, VoiceToTextSubStatus, ErrorCode } from './touch-btn.types';
|
||||
import type { TouchBtnEmits } from './touch-btn.types';
|
||||
import { wsUrl, bottomAreaTopBoundary, horizontalSplitX, initWebSocket, showErrorTip, vibrateLight } from './touch-btn';
|
||||
|
||||
import { ref, computed, onMounted, nextTick, watch, reactive } from 'vue';
|
||||
import { onHide, onLaunch } from '@dcloudio/uni-app';
|
||||
import common from '@/common/common';
|
||||
import {setupKeyboardHeightListener} from '@/common/common';
|
||||
import common, { setupKeyboardHeightListener } from '@/common/common';
|
||||
import { startAudioRecord, stopAudioRecord, preRequestRecordPermission } from '@/uni_modules/ty-recording';
|
||||
import { ProtocolCodec, MessageType, ControlCommand, ControlCode, ControlBody } from '@/common/protocolCodec';
|
||||
import permissionApi from '@/common/permission';
|
||||
@@ -92,13 +126,12 @@
|
||||
const status = ref<StatusType>('default');
|
||||
const voice_to_text_status = ref<VoiceToTextSubStatus>('init');
|
||||
const popupRef = ref(null);
|
||||
|
||||
const props = defineProps({
|
||||
// mode控制功能模式
|
||||
mode: {
|
||||
type: String,
|
||||
default: 'voice-only',
|
||||
validator: (value : string) => {
|
||||
default: 'text-only',
|
||||
validator: (value: string) => {
|
||||
return ['voice-only', 'text-only', 'both'].includes(value);
|
||||
}
|
||||
},
|
||||
@@ -147,10 +180,12 @@
|
||||
});
|
||||
const dialogDynamicClasses = computed(() => {
|
||||
const classes = [];
|
||||
isOutStatus.value === '02' && classes.push('is-out')
|
||||
isOutStatus.value === '03' && classes.push('is-translate')
|
||||
voice_to_text_status.value !== '' && classes.push(voice_to_text_status.value)
|
||||
|
||||
isOutStatus.value === '02' && classes.push('is-out');
|
||||
(isOutStatus.value === '03' || status.value === 'voice_to_text' || status.value === 'send_over') &&
|
||||
classes.push('is-translate');
|
||||
// 仅语音模式,01松手后要和03操作一样
|
||||
// isOutStatus.value === '01' && props.mode === 'text-only' && status.value == 'voice_to_text' && classes.push('is-translate');
|
||||
voice_to_text_status.value !== '' && classes.push(voice_to_text_status.value);
|
||||
return classes;
|
||||
});
|
||||
const recordId = ref('');
|
||||
@@ -161,24 +196,25 @@
|
||||
const touchPos = reactive({ x: 0, y: 0 });
|
||||
// 是否录音中
|
||||
const isRecording = ref(false);
|
||||
let voiceTimer = null; // 兜底关闭的定时器全局唯一
|
||||
// 键盘还是语音
|
||||
const isInputVisible = ref(props.mode !== 'text-only'); // true=显示录音按钮,false=显示输入框
|
||||
const isInputVisible = ref(true); // true=显示录音按钮,false=显示输入框
|
||||
const recordStartTime = ref(0); // 录音开始时间戳
|
||||
const pressTimer = ref<number | null>(null);
|
||||
// 计算属性:判断是否仅语音/仅文字模式(简化模板逻辑)
|
||||
const isVoiceOnlyMode = computed(() => props.mode === 'voice-only');
|
||||
const isTextOnlyMode = computed(() => props.mode === 'text-only');
|
||||
const talkRightIcon = computed(() => {
|
||||
if (isInputVisible.value) return icKeyboardSvg();
|
||||
if (inputText.value) return iconSendSvg();
|
||||
return iconMicSvg();
|
||||
if (isInputVisible.value) return TouchBtnImages.icKeyboardSvg();
|
||||
if (inputText.value) return TouchBtnImages.iconSendSvg();
|
||||
return TouchBtnImages.iconMicSvg();
|
||||
});
|
||||
// 计算是否超出按下盒子位置01代表下方盒子,02代表左上03代表右上
|
||||
const isOutStatus = computed(() => {
|
||||
const { y: touchY, x: touchX } = touchPos;
|
||||
if (touchY >= bottomAreaTopBoundary) return '01';
|
||||
// 仅语音模式只能返回02,就是取消
|
||||
if(props.mode === 'voice-only') return '02';
|
||||
// 仅语音模式只能返回取消(02)
|
||||
if (props.mode === 'voice-only') return '02';
|
||||
return touchX < horizontalSplitX ? '02' : '03';
|
||||
});
|
||||
// 监听按下移动
|
||||
@@ -188,15 +224,16 @@
|
||||
touchPos.y = pageY;
|
||||
};
|
||||
const testFun = () => {
|
||||
voice_to_text_status.value = 'failed'
|
||||
}
|
||||
voice_to_text_status.value = 'failed';
|
||||
};
|
||||
// 开启语音
|
||||
const startRecord = async (obj : { touches : any[]; }) => {
|
||||
if(props.isDisabled) return;
|
||||
const startRecord = async (obj: { touches: any[] }) => {
|
||||
if (props.isDisabled) return;
|
||||
try {
|
||||
const state = await permissionApi.judgeIosPermission('record');
|
||||
if (state === 'not determined') { // 苹果专用
|
||||
preRequestRecordPermission(() => {})
|
||||
if (state === 'not determined') {
|
||||
// 苹果专用
|
||||
preRequestRecordPermission(() => {});
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -205,51 +242,66 @@
|
||||
}
|
||||
// 标记录音开始
|
||||
isRecording.value = true;
|
||||
status.value = 'voice_recording'
|
||||
voice_to_text_status.value = ''
|
||||
status.value = 'voice_recording';
|
||||
voice_to_text_status.value = '';
|
||||
tempText.value = '';
|
||||
allText.value = '';
|
||||
initWebSocket(wsUrl).then(socketTask => {
|
||||
ws.value = socketTask
|
||||
wsStatus.value = true;
|
||||
console.log('WS连接成功');
|
||||
ws.value.onMessage((res : { data : Uint8Array | ArrayBuffer; }) => {
|
||||
try {
|
||||
const { msgType, body } = ProtocolCodec.unpack(res.data);
|
||||
console.log('msgType', msgType, body);
|
||||
if (msgType === MessageType.TEXT_MESSAGE) {
|
||||
tempText.value = '';
|
||||
allText.value = allText.value + body;
|
||||
|
||||
} else if (msgType === MessageType.TIP_MESSAGE) {
|
||||
tempText.value = body as string;
|
||||
} else if (msgType === MessageType.CONTROL_CMD) { // 返回结束消息
|
||||
const controlBody = body as ControlBody;
|
||||
if(controlBody.type === ControlCode.SERVER_TO_FRONT_OVER) {
|
||||
if(controlBody?.txt === '') { //说明没有识别到文字
|
||||
voice_to_text_status.value = 'failed'
|
||||
// todo
|
||||
} else { // 识别成功
|
||||
voice_to_text_status.value = 'success'
|
||||
const ossKey = controlBody?.ossKey;
|
||||
const text = controlBody?.txt;
|
||||
// todo
|
||||
console.log('ossKey', ossKey);
|
||||
emit('submitVoice', {ossKey,text})
|
||||
initWebSocket(wsUrl)
|
||||
.then((socketTask) => {
|
||||
ws.value = socketTask;
|
||||
wsStatus.value = true;
|
||||
console.log('WS连接成功');
|
||||
ws.value.onMessage((res: { data: Uint8Array | ArrayBuffer }) => {
|
||||
try {
|
||||
const { msgType, body } = ProtocolCodec.unpack(res.data);
|
||||
console.log('msgType', msgType, body);
|
||||
if (msgType === MessageType.TEXT_MESSAGE) {
|
||||
tempText.value = '';
|
||||
allText.value = allText.value + body;
|
||||
} else if (msgType === MessageType.TIP_MESSAGE) {
|
||||
tempText.value = body as string;
|
||||
} else if (msgType === MessageType.CONTROL_CMD) {
|
||||
// 返回结束消息
|
||||
const controlBody = body as ControlBody;
|
||||
if (controlBody.type === ControlCode.SERVER_TO_FRONT_OVER) {
|
||||
console.log('识别结束', controlBody, voice_to_text_status.value);
|
||||
// 如果不等于init说明已经超时,被超时函数处理完了,这里即使返回也不做处理
|
||||
if (status.value === 'voice_to_text' && voice_to_text_status.value !== 'init') return;
|
||||
if (status.value === 'send_over') return;
|
||||
if (voiceTimer) clearTimeout(voiceTimer);
|
||||
// 设置识别结果
|
||||
if (controlBody?.txt === '') {
|
||||
//说明没有识别到文字
|
||||
voice_to_text_status.value = 'failed';
|
||||
} else {
|
||||
voice_to_text_status.value = 'success';
|
||||
}
|
||||
// status.value = 'send_over'; // 设置成发送完成
|
||||
// 取值出来
|
||||
const ossKey = controlBody?.ossKey || '';
|
||||
let text = '';
|
||||
if (typeof controlBody?.txt === 'string') {
|
||||
text = controlBody.txt.trim();
|
||||
}
|
||||
const _isOutStatus =
|
||||
props.mode === 'text-only' && isOutStatus.value === '01' ? '03' : isOutStatus.value;
|
||||
// 只有模式为01的时候才发送出去
|
||||
if (_isOutStatus === '01') {
|
||||
emit('submitVoice', { ossKey, text, recordId: recordId.value });
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('后端发来的信息有问题', e);
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('后端发来的信息有问题');
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
// stopRecord('networkError');
|
||||
console.log('网络出现问题');
|
||||
});
|
||||
}).catch(() => {
|
||||
stopRecord('networkError')
|
||||
console.log('网络出现问题');
|
||||
})
|
||||
pressTimer.value = setTimeout(() => {
|
||||
vibrateLight() // 触感震动
|
||||
vibrateLight(); // 触感震动
|
||||
// 重设按下位置
|
||||
const changedTouche = obj.touches[0];
|
||||
touchPos.x = changedTouche.clientX;
|
||||
@@ -259,14 +311,14 @@
|
||||
// 弹出录音界面
|
||||
popupRef.value.open();
|
||||
startAudioRecord({
|
||||
onFrame: (pcmData : any) => {
|
||||
onFrame: (pcmData: any) => {
|
||||
if (wsStatus.value && ws.value) {
|
||||
ws.value.send({ data: ProtocolCodec.pack(MessageType.AUDIO_DATA, pcmData)});
|
||||
ws.value.send({ data: ProtocolCodec.pack(MessageType.AUDIO_DATA, pcmData) });
|
||||
}
|
||||
},
|
||||
onStart: (res : any) => {
|
||||
onStart: (res: any) => {
|
||||
console.log('启动', res);
|
||||
recordId.value = res.recordId ?? ''
|
||||
recordId.value = res.recordId ?? '';
|
||||
},
|
||||
onStop: () => {
|
||||
console.log('关闭');
|
||||
@@ -278,63 +330,91 @@
|
||||
}
|
||||
}
|
||||
});
|
||||
}, 120)
|
||||
}, 120);
|
||||
};
|
||||
|
||||
// 结束录音
|
||||
const closePopup = () => {
|
||||
popupRef.value.close();
|
||||
}
|
||||
const stopRecord = async (errrStatus='') => {
|
||||
};
|
||||
|
||||
const stopRecord = async (errrStatus = '') => {
|
||||
clearTimeout(pressTimer.value);
|
||||
if (!isRecording.value) return; // 未处于录音状态
|
||||
if (isOutStatus.value === '03') {
|
||||
status.value = 'voice_to_text' //主状态设置为转文字
|
||||
voice_to_text_status.value = 'init'
|
||||
} else if(isOutStatus.value === '01') {
|
||||
status.value = 'voice_send_ing' //主状态设置为语音发送中
|
||||
const _isOutStatus = props.mode === 'text-only' && isOutStatus.value === '01' ? '03' : isOutStatus.value;
|
||||
console.log('_isOutStatus', _isOutStatus);
|
||||
// 拖动到转文字按钮上抬手或者仅文字模式的发送也强行算他转文字
|
||||
if (_isOutStatus === '03') {
|
||||
status.value = 'voice_to_text'; //主状态设置为转文字
|
||||
voice_to_text_status.value = 'init';
|
||||
if (voiceTimer) clearTimeout(voiceTimer);
|
||||
voiceTimer = setTimeout(() => {
|
||||
voiceTimer = null;
|
||||
if (voice_to_text_status.value !== 'init') return;
|
||||
voice_to_text_status.value = 'networkError';
|
||||
emit('submitVoice', { ossKey: '', text: '', recordId: recordId.value });
|
||||
}, 5000);
|
||||
} else if (_isOutStatus === '01') {
|
||||
status.value = 'voice_send_ing'; //主状态设置为语音发送中
|
||||
}
|
||||
if(['01', '03'].includes(isOutStatus.value)) { // 向后端发送抬手动作
|
||||
ws.value && ws.value.send({ data: ProtocolCodec.pack(MessageType.CONTROL_CMD, { type: ControlCode.FRONT_TO_SERVER_OVER})});
|
||||
if (['01', '03'].includes(_isOutStatus)) {
|
||||
// 向后端发送抬手动作
|
||||
ws.value &&
|
||||
ws.value.send({
|
||||
data: ProtocolCodec.pack(MessageType.CONTROL_CMD, { type: ControlCode.FRONT_TO_SERVER_OVER })
|
||||
});
|
||||
}
|
||||
const recordDurationMs = Date.now() - recordStartTime.value;
|
||||
if (isOutStatus.value !== '02') { // 取消的时候,不校验最低时间
|
||||
if (_isOutStatus !== '02') {
|
||||
// 取消的时候,不校验最低时间
|
||||
// 核心:计算录音总时长(毫秒转秒,保留1位小数)
|
||||
if (recordDurationMs < 600) {
|
||||
await new Promise<void>((resolve) => {
|
||||
setTimeout(() => {
|
||||
resolve()
|
||||
}, 600 - recordDurationMs)
|
||||
})
|
||||
resolve();
|
||||
}, 600 - recordDurationMs);
|
||||
});
|
||||
}
|
||||
}
|
||||
isRecording.value = false;
|
||||
if (isOutStatus.value === '02' || errrStatus === 'networkError') { // 取消的时候自己主动关闭websocket,其他的时候需要等待后端的消息关闭
|
||||
ws.value && ws.value.close({
|
||||
code: 1000,
|
||||
reason: '挂断',
|
||||
complete: () => {
|
||||
console.log('挂断Ws');
|
||||
wsStatus.value = false;
|
||||
}
|
||||
});
|
||||
if (_isOutStatus === '02' || errrStatus === 'networkError') {
|
||||
// 取消的时候自己主动关闭websocket,其他的时候需要等待后端的消息关闭
|
||||
ws.value &&
|
||||
ws.value.close({
|
||||
code: 1000,
|
||||
reason: '挂断',
|
||||
complete: () => {
|
||||
console.log('挂断Ws');
|
||||
wsStatus.value = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
stopAudioRecord(); // 关掉录音
|
||||
|
||||
if (isOutStatus.value !== '03' || errrStatus === 'networkError') { // 转文字时候不关遮罩层,网络错误必须关遮罩层
|
||||
if (_isOutStatus !== '03' || errrStatus === 'networkError') {
|
||||
// 转文字时候不关遮罩层,网络错误必须关遮罩层
|
||||
popupRef.value.close();
|
||||
// 关掉弹窗后的提示
|
||||
if(errrStatus === 'networkError') {
|
||||
return showErrorTip(ErrorCode.NetworkError)
|
||||
} else if (isOutStatus.value !== '02' && recordDurationMs <= 1200) { // 取消的时候,不校验最低时间
|
||||
return showErrorTip(ErrorCode.ShortRecord)
|
||||
if (errrStatus === 'networkError') {
|
||||
return showErrorTip(ErrorCode.NetworkError);
|
||||
} else if (_isOutStatus !== '02' && recordDurationMs <= 1200) {
|
||||
// 取消的时候,不校验最低时间
|
||||
return showErrorTip(ErrorCode.ShortRecord);
|
||||
}
|
||||
}
|
||||
if(isOutStatus.value === '01' && status.value == 'voice_send_ing') {
|
||||
emit('sendLoading', {recordId:recordId.value})
|
||||
if (_isOutStatus === '01' && status.value == 'voice_send_ing') {
|
||||
emit('sendLoading', { recordId: recordId.value });
|
||||
// 如果socket长时间没有返回,这里兜底一下
|
||||
if (voiceTimer) clearTimeout(voiceTimer);
|
||||
voiceTimer = setTimeout(() => {
|
||||
voiceTimer = null;
|
||||
if (props.mode === 'voice-only') {
|
||||
if (status.value === 'send_over') return;
|
||||
status.value = 'send_over'; // 恢复成默认状态
|
||||
emit('submitVoice', { ossKey: '', text: '', recordId: recordId.value });
|
||||
}
|
||||
}, 5000);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// 发送文本
|
||||
const showKeyboard = () => {
|
||||
@@ -349,14 +429,26 @@
|
||||
isInputVisible.value = !isInputVisible.value;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// 切换键盘语音
|
||||
const changeBtn = () => {
|
||||
if (props.isDisabled) return;
|
||||
isInputVisible.value = !isInputVisible.value;
|
||||
inputText.value = '';
|
||||
};
|
||||
|
||||
// 按钮右侧图标(三个功能)
|
||||
const iconClick = () => {
|
||||
if (props.isDisabled) return;
|
||||
// 当是输入框且输入框的内容不为空时候,是发送文本,否则就是切换
|
||||
if (!isInputVisible.value && inputText.value !== '') {
|
||||
console.log('send_msg');
|
||||
send_msg();
|
||||
} else {
|
||||
isInputVisible.value = !isInputVisible.value;
|
||||
}
|
||||
|
||||
inputText.value = '';
|
||||
};
|
||||
// 禁用时点击给的提示
|
||||
const disabled_click = () => {
|
||||
console.log('禁用时点击给的提示');
|
||||
@@ -364,14 +456,19 @@
|
||||
};
|
||||
|
||||
const send_msg = () => {
|
||||
console.log('点击发送');
|
||||
}
|
||||
|
||||
setupKeyboardHeightListener((height:number) => {
|
||||
const _height = Math.max(height - 100, 0)
|
||||
pageBoxMarginBottom.value = `${_height}px`;
|
||||
if (!isInputVisible.value) {
|
||||
emit('submitAnswer', inputText.value, changeBtn);
|
||||
} else {
|
||||
emit('submitAnswer', textAreaText.value, changeBtn);
|
||||
closePopup();
|
||||
}
|
||||
};
|
||||
|
||||
setupKeyboardHeightListener((height: number) => {
|
||||
const _height = Math.max(height - 100, 0);
|
||||
pageBoxMarginBottom.value = `${_height}px`;
|
||||
});
|
||||
|
||||
|
||||
// 外面调用放弃这次
|
||||
const give_up = () => {
|
||||
console.log('调用结束语音回答');
|
||||
@@ -379,19 +476,17 @@
|
||||
};
|
||||
|
||||
// 外部调用,清理输入框数据
|
||||
const clearinputText = (text = '') => {
|
||||
const clearInputText = (text = '') => {
|
||||
const old_text = inputText.value;
|
||||
inputText.value = text;
|
||||
return old_text;
|
||||
};
|
||||
defineExpose({ clearinputText, give_up });
|
||||
defineExpose({ clearInputText, give_up });
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import "./style/index.scss";
|
||||
@import "./style/popup.scss";
|
||||
|
||||
|
||||
@import './style/index.scss';
|
||||
@import './style/popup.scss';
|
||||
|
||||
.white-bg-box {
|
||||
height: 365rpx;
|
||||
@@ -420,8 +515,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
::v-deep .uv-input__content__field-wrapper__field {
|
||||
padding-right: 60rpx;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
+92
-108
@@ -3,17 +3,31 @@
|
||||
<!-- <MarkdownPreview/> -->
|
||||
<view class="top-bg"></view>
|
||||
<view class="bot-bg"></view>
|
||||
<scroll-view class="index-dialog-body" :scroll-y="true" upper-threshold="0" refresher-enabled="true"
|
||||
refresher-default-style="none" @refresherrefresh="scrolltolower">
|
||||
<scroll-view
|
||||
class="index-dialog-body"
|
||||
:scroll-y="true"
|
||||
upper-threshold="0"
|
||||
refresher-enabled="true"
|
||||
refresher-default-style="none"
|
||||
@refresherrefresh="scrolltolower"
|
||||
>
|
||||
<view class="body-title">
|
||||
<!-- <uv-icon class="arrow-icon" name="arrow-left" @click="common.navigateBack()"/> -->
|
||||
AI问答
|
||||
<view class="top-desc">内容由AI生成</view>
|
||||
<view class="seek-setting">
|
||||
<image src="@/static/images/dialog/new-dialog.png" alt="" class="image-icon-new" @click="createNewDialog">
|
||||
</image>
|
||||
<image src="@/static/images/dialog/history.png" alt="" class="image-icon"
|
||||
@click="showMenuList = !showMenuList"></image>
|
||||
<image
|
||||
src="@/static/images/dialog/new-dialog.png"
|
||||
alt=""
|
||||
class="image-icon-new"
|
||||
@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-item" @click.stop="showHistory">历史</view>
|
||||
<view class="more-item" @click.stop="toMessage">消息</view>
|
||||
@@ -65,18 +79,28 @@
|
||||
</scroll-view>
|
||||
</view> -->
|
||||
<view class="talking-list" v-show="talkingList.length > 0">
|
||||
<scroll-view class="talking-scroll-list" :scroll-y="true" :scroll-top="scrollTop" :show-scrollbar="false"
|
||||
: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
|
||||
class="talking-scroll-list"
|
||||
:scroll-y="true"
|
||||
:scroll-top="scrollTop"
|
||||
:show-scrollbar="false"
|
||||
: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>
|
||||
|
||||
<view class="question-item-box mt-16" v-for="item in talkQnsList">
|
||||
<view class="question-item" @click="sendText(item)">
|
||||
{{ item }}
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</scroll-view>
|
||||
</view>
|
||||
<view class="router-list">
|
||||
@@ -111,18 +135,25 @@
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
<!-- <TouchBtn class="talk-btns" @uploadVoice="uploadRecordNow" @submitAnswer="submitAnswerNow"
|
||||
<TouchBtn
|
||||
class="talk-btns"
|
||||
@uploadVoice="uploadRecordNow"
|
||||
@submitAnswer="submitAnswerNow"
|
||||
@startRecord="startRecordCallback"
|
||||
:loadingText="sendLoadingText"
|
||||
:isLoading="!answerIsOver"
|
||||
:adjustPosition="true"
|
||||
:isDisabled="isHistory"
|
||||
/>
|
||||
<!-- <touch-btn @uploadVoice="uploadRecordNow" @submitAnswer="submitAnswerNow"
|
||||
@startRecord="startRecordCallback" :loadingText="sendLoadingText" :isLoading="!answerIsOver"
|
||||
:adjustPosition="true" :isDisabled="isHistory" /> -->
|
||||
<touch-btn @uploadVoice="uploadRecordNow" @submitAnswer="submitAnswerNow"
|
||||
@startRecord="startRecordCallback" :loadingText="sendLoadingText" :isLoading="!answerIsOver"
|
||||
:adjustPosition="true" :isDisabled="isHistory" />
|
||||
|
||||
|
||||
<History ref="historyRef" @showDetail="showHistoryDetail"></History>
|
||||
<PreviewVue ref="previewRef" />
|
||||
</scroll-view>
|
||||
</view>
|
||||
|
||||
|
||||
<badge ref="badgeRef"></badge>
|
||||
<points ref="pointsRef"></points>
|
||||
<!-- 反馈组件 -->
|
||||
@@ -133,51 +164,20 @@
|
||||
</template>
|
||||
|
||||
<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 {
|
||||
setupKeyboardHeightListener
|
||||
} from '@/common/common';
|
||||
// import TouchBtn from '@/pages/course/components/touchBtn.vue';
|
||||
import { setupKeyboardHeightListener } from '@/common/common';
|
||||
import TouchBtn from '@/pages/course/components/touchBtn.vue';
|
||||
import TalkingItem from './components/talking-item.vue';
|
||||
import PreviewVue from './components/preview.vue';
|
||||
import {
|
||||
useSocketStore
|
||||
} from '@/store/socket.js';
|
||||
import {
|
||||
useStorageStore
|
||||
} from '@/store/storage.js';
|
||||
import {
|
||||
storeToRefs
|
||||
} from 'pinia';
|
||||
import {
|
||||
onLoad,
|
||||
onShow,
|
||||
onUnload,
|
||||
onHide,
|
||||
onBackPress,
|
||||
onLaunch
|
||||
} 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 { useSocketStore } from '@/store/socket.js';
|
||||
import { useStorageStore } from '@/store/storage.js';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { onLoad, onShow, onUnload, onHide, onBackPress, onLaunch } 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 {
|
||||
queryHotQuestionApi,
|
||||
insertTraAskFeedback,
|
||||
@@ -190,28 +190,20 @@
|
||||
import badge from '@/components/points-and-badge/badge';
|
||||
import points from '@/components/points-and-badge/points';
|
||||
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 socketStore = useSocketStore();
|
||||
const {
|
||||
SocketObj
|
||||
} = storeToRefs(socketStore);
|
||||
const { SocketObj } = storeToRefs(socketStore);
|
||||
|
||||
const feedbackRef = ref();
|
||||
const watermarkRef = ref();
|
||||
const userInfo = ref(getUserInfo());
|
||||
const luimgAddr = computed(() => unref(userInfo)?.mascotInfo?.imgAddr || '')
|
||||
const userParams = '/' + (unref(userInfo)?.loginName ?? '')
|
||||
const luimgAddr = computed(() => unref(userInfo)?.mascotInfo?.imgAddr || '');
|
||||
const userParams = '/' + (unref(userInfo)?.loginName ?? '');
|
||||
const questionList = ref([
|
||||
// '对公小程序开户流程?',
|
||||
// '厅堂服务经理2025年管理办法?',
|
||||
@@ -257,8 +249,8 @@
|
||||
};
|
||||
const showModelComfirm = ref(false);
|
||||
const reconcatNum = ref(1);
|
||||
const askTime = ref(0)
|
||||
const talkQnsList = ref([])
|
||||
const askTime = ref(0);
|
||||
const talkQnsList = ref([]);
|
||||
const initsocketTask = () => {
|
||||
isHistory.value = false;
|
||||
socketStore.creatSocket('/traask/asksocket/open?summary=');
|
||||
@@ -292,11 +284,7 @@
|
||||
});
|
||||
});
|
||||
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';
|
||||
if (rtnCode === '0000') {
|
||||
if (commond === 'ASK-OPEN') {
|
||||
@@ -364,8 +352,8 @@
|
||||
if (body.event === 'start') {
|
||||
console.log('开始回答!');
|
||||
if (askTime.value === 0) {
|
||||
pointAndBadgesRun('06')
|
||||
askTime.value = 1
|
||||
pointAndBadgesRun('06');
|
||||
askTime.value = 1;
|
||||
}
|
||||
answerIsOver.value = false;
|
||||
answerText.value = '';
|
||||
@@ -388,7 +376,7 @@
|
||||
} else if (body.event === 'end') {
|
||||
console.log('完成回答!');
|
||||
answerIsOver.value = true;
|
||||
console.log(answerText.value)
|
||||
console.log(answerText.value);
|
||||
} else if (body.event === 'sourceDocuments') {
|
||||
console.log('回答返回文件列表!');
|
||||
console.log('body: ', body);
|
||||
@@ -399,7 +387,7 @@
|
||||
} else if (body.event === 'recommend') {
|
||||
console.log('回答返回问题列表!');
|
||||
if (talkingList.value.length === 0) return;
|
||||
talkQnsList.value = body.data || []//questionList.value.splice(0, 3);
|
||||
talkQnsList.value = body.data || []; //questionList.value.splice(0, 3);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -438,7 +426,7 @@
|
||||
};
|
||||
const sendMessage = (data) => {
|
||||
if (data.commond === 'ASK') {
|
||||
talkQnsList.value = []
|
||||
talkQnsList.value = [];
|
||||
}
|
||||
unref(SocketObj).send(data);
|
||||
};
|
||||
@@ -457,14 +445,9 @@
|
||||
talkingList.value[talkingList.value.length - 1].talkingText = answerText.value;
|
||||
};
|
||||
|
||||
const isDownloading = ref(false)
|
||||
const isDownloading = ref(false);
|
||||
const stopAnswerCallBack = ref(null);
|
||||
const talkItemEvents = ({
|
||||
type,
|
||||
data,
|
||||
id,
|
||||
info = {}
|
||||
}) => {
|
||||
const talkItemEvents = ({ type, data, id, info = {} }) => {
|
||||
switch (type) {
|
||||
case 'reAnswer':
|
||||
console.log('重新提问回答');
|
||||
@@ -577,7 +560,8 @@
|
||||
return new Promise((resolve, reject) => {
|
||||
console.log('开始下载:', fileUrl);
|
||||
const dtask = plus.downloader.createDownload(
|
||||
fileUrl, {
|
||||
fileUrl,
|
||||
{
|
||||
filename: localFilePath
|
||||
},
|
||||
(d, status) => {
|
||||
@@ -707,7 +691,7 @@
|
||||
const sendText = (item) => {
|
||||
submitAnswerNow(item);
|
||||
};
|
||||
|
||||
|
||||
// 发送语音
|
||||
const uploadRecordNow = (voicePath, voiceTime) => {
|
||||
// /traask/traAskchat/voiceTrans
|
||||
@@ -775,7 +759,7 @@
|
||||
});
|
||||
setHeight({
|
||||
height: 0
|
||||
})
|
||||
});
|
||||
};
|
||||
const startRecordCallback = () => {
|
||||
// 开始录音回调
|
||||
@@ -841,7 +825,7 @@
|
||||
};
|
||||
onLoad(() => {
|
||||
//#ifdef APP-PLUS
|
||||
plus.screen.lockOrientation('portrait-primary')
|
||||
plus.screen.lockOrientation('portrait-primary');
|
||||
// #endif
|
||||
changeAppHeightBottom();
|
||||
if (!common.isLogin()) {
|
||||
@@ -873,20 +857,21 @@
|
||||
const setHeight = (res) => {
|
||||
keyboardHeight.value = (res.height || 0) + 'px';
|
||||
setTimeout(() => {
|
||||
console.log(totalBotHeight.value)
|
||||
}, 1000)
|
||||
console.log(totalBotHeight.value);
|
||||
}, 1000);
|
||||
};
|
||||
const keyBoardIsHide = computed(() => {
|
||||
return parseInt(keyboardHeight.value) == 0;
|
||||
});
|
||||
const bottomHeight = ref('0px');
|
||||
const totalBotHeight = computed(() => {
|
||||
let isIos
|
||||
let isIos;
|
||||
// #ifdef APP-PLUS
|
||||
isIos = (plus.os.name == "iOS")
|
||||
isIos = plus.os.name == 'iOS';
|
||||
// #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) => {
|
||||
//#ifdef APP-PLUS
|
||||
@@ -894,16 +879,16 @@
|
||||
const systemInfo = uni.getSystemInfoSync();
|
||||
// 计算安全区域底部高度
|
||||
bottomHeight.value = systemInfo.screenHeight - systemInfo.safeArea.bottom + 'px';
|
||||
console.log(systemInfo)
|
||||
console.log(systemInfo.screenHeight, systemInfo.safeArea.bottom)
|
||||
console.log(systemInfo);
|
||||
console.log(systemInfo.screenHeight, systemInfo.safeArea.bottom);
|
||||
// #endif
|
||||
};
|
||||
|
||||
const deleteFolder = () => {
|
||||
//#ifdef APP-PLUS
|
||||
plus.io.resolveLocalFileSystemURL('_doc/pdf_view', function(entry) {
|
||||
plus.io.resolveLocalFileSystemURL('_doc/pdf_view', function (entry) {
|
||||
console.log('entry', entry);
|
||||
entry.removeRecursively(function(res) {
|
||||
entry.removeRecursively(function (res) {
|
||||
console.log('删除成功');
|
||||
});
|
||||
});
|
||||
@@ -920,7 +905,6 @@
|
||||
nextTick(() => {
|
||||
watermarkRef.value?.updateWatermarkText();
|
||||
});
|
||||
|
||||
});
|
||||
// #endif
|
||||
onUnload(() => {
|
||||
@@ -1257,4 +1241,4 @@
|
||||
// height: 100%;
|
||||
// }
|
||||
// }
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
:onlyVoice="true"
|
||||
:answerMethod="answerMethod"
|
||||
/>
|
||||
<!-- <TouchBtn
|
||||
<TouchBtn
|
||||
v-else
|
||||
class="talk-btns"
|
||||
ref="touchBtnRef"
|
||||
@@ -91,17 +91,19 @@
|
||||
:adjustPosition="false"
|
||||
:isDisabled="false"
|
||||
:answerMethod="answerMethod"
|
||||
/> -->
|
||||
<touch-btn
|
||||
v-else
|
||||
/>
|
||||
|
||||
<!-- <touch-btn
|
||||
class="talk-btns"
|
||||
ref="touchBtnRef"
|
||||
@sendLoading="sendLoading"
|
||||
@submitVoice="submitVoice"
|
||||
@uploadVoice="touchBtnSubmit('voice', $event)"
|
||||
@submitAnswer="touchBtnSubmit('text', $event)"
|
||||
:isLoading="touchIsDisabled"
|
||||
loadingText="只能进行一条回答"
|
||||
:answerMethod="answerMethod"
|
||||
/>
|
||||
/> -->
|
||||
|
||||
</view>
|
||||
</view>
|
||||
@@ -121,7 +123,7 @@
|
||||
import Subject from '@/components/examination/subject.vue';
|
||||
import CharactersSubject from '@/components/examination/characters-subject.vue';
|
||||
// import TouchBtn from '@/components/examination/touchBtn.vue';
|
||||
// import TouchBtn from '@/pages/course/components/touchBtn.vue';
|
||||
import TouchBtn from '@/pages/course/components/touchBtn.vue';
|
||||
import TouchBtnOnlyVoice from '@/pages/course/components/touchBtnOnlyVoice.vue';
|
||||
import common from '@/common/common';
|
||||
import { setPageCache, formatSeconds, getPageCache, setupKeyboardHeightListener } from '@/common/common';
|
||||
@@ -331,7 +333,32 @@
|
||||
return Promise.reject(error);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
// 录音组件提交中转圈
|
||||
const sendLoading = () => {
|
||||
const topic = topicList[questionNumber.value];
|
||||
console.log('录音组件提交中转圈', topic.es_status);
|
||||
if (topic.es_status === '00') return;
|
||||
topic.es_status = '00'; // 00转圈
|
||||
}
|
||||
// 新录音组件语音提交
|
||||
const submitVoice = (voiceObj) => {
|
||||
console.log('新录音组件语音提交');
|
||||
const topic = topicList[questionNumber.value];
|
||||
touchBtnRef.value?.clearInputText(); // 清除发送框数据
|
||||
const _content = voiceObj.text;
|
||||
if (_content === '') {
|
||||
topic.es_status = ''; // 取消转圈
|
||||
return common.msg('未识别到文字');
|
||||
} else {
|
||||
topic.es_status = '02';
|
||||
topic.my_answer = {
|
||||
anserResult: _content,
|
||||
ossKey: voiceObj.ossKey
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
// 录音组件提交
|
||||
const touchBtnSubmit = (type, submitObj) => {
|
||||
const topic = topicList[questionNumber.value];
|
||||
|
||||
Reference in New Issue
Block a user