JLBA202505130001_关于吉林银行新建AI智能培训系统的需求_开发录音组件,基本功能开发完成

This commit is contained in:
田岩
2026-03-04 16:09:22 +08:00
parent cfd9c5f224
commit 4981aed2df
7 changed files with 190 additions and 240 deletions
-14
View File
@@ -2,25 +2,11 @@
ENV = 'development'
# 'development'
#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://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:7002'
# VITE_APP_BASE_API_Url = 'http://192.168.247.200'
# VITE_APP_BASE_API_Url = 'http://aitscdn.jlbank.com.cn:7001'
# dev
# DEV
#VITE_APP_BASE_API_Url = 'http://25.18.122.65:7001'
+4 -4
View File
@@ -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);
};
+15 -7
View File
@@ -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;
}
@@ -139,7 +139,7 @@
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;
@@ -194,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);
@@ -259,7 +263,7 @@
left: 78% !important;
}
&.failed {
&.failed,&.networkError {
width: 506rpx;
height: 114rpx;
min-height: 114rpx;
@@ -274,7 +278,11 @@
// animation: fadeIn 0.4s ease-out 0.1s forwards;
}
.textarea {
// display: none;
visibility: hidden; // 初始不可见且不占交互位置
}
}
&.init{
.textarea {
visibility: hidden; // 初始不可见且不占交互位置
}
}
+7 -4
View File
@@ -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;
/**
* 触摸按钮组件的自定义事件类型定义
@@ -48,9 +51,9 @@ export type TouchBtnEmits = {
/**
* 提交文字答案(用户确认识别结果/手动编辑后触发)
* @param answerText - 最终提交的文字答案内容
* @param isManualEdit - 是否手动编辑过识别结果(true=手动修改,false=纯语音识别)
* @param changeBtn - 按钮状态变更的回调函数
*/
submitAnswer: [answerText: string, isManualEdit: boolean];
submitAnswer: [answerText: string, changeBtn: ChangeBtnCallback];
/**
* 开始录音(用户点击录音按钮时触发)
* @param recordParams - 录音初始化参数(可选,默认使用组件内置配置)
+65 -96
View File
@@ -19,7 +19,7 @@
ref="inputRef"
v-model="inputText"
:maxlength="props.maxlength"
:adjustPosition="true"
:adjustPosition="false"
placeholderStyle="color:#999999;font-size:26rpx"
placeholder="请输入文字"
:disabled="props.isDisabled"
@@ -27,7 +27,7 @@
/>
</view>
<view class="talk-right-icon-div" v-if="!isVoiceOnlyMode">
<image class="talk-right-icon" :src="talkRightIcon" mode="widthFix" @click="changeBtn"></image>
<image class="talk-right-icon" :src="talkRightIcon" mode="widthFix" @click="iconClick()"></image>
</view>
</view>
<uni-popup ref="popupRef" class="popup" @touchmove.stop.prevent="false">
@@ -51,7 +51,8 @@
></uv-textarea>
<view class="error-tip-div">
<image :src="TouchBtnImages.iconRecognizeErrorSvg()" mode="aspectFill" class="img"></image>
<view class="">未识别到文字</view>
<view class="" v-if="voice_to_text_status === 'failed'">未识别到文字</view>
<view class="" v-if="voice_to_text_status === 'networkError'">网络识别超时</view>
</view>
</view>
</view>
@@ -125,7 +126,6 @@
const status = ref<StatusType>('default');
const voice_to_text_status = ref<VoiceToTextSubStatus>('init');
const popupRef = ref(null);
const props = defineProps({
// mode控制功能模式
mode: {
@@ -181,7 +181,8 @@
const dialogDynamicClasses = computed(() => {
const classes = [];
isOutStatus.value === '02' && classes.push('is-out');
(isOutStatus.value === '03' || status.value === 'voice_to_text') && classes.push('is-translate');
(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);
@@ -195,6 +196,7 @@
const touchPos = reactive({ x: 0, y: 0 });
// 是否录音中
const isRecording = ref(false);
let voiceTimer = null; // 兜底关闭的定时器全局唯一
// 键盘还是语音
const isInputVisible = ref(true); // true=显示录音按钮,false=显示输入框
const recordStartTime = ref(0); // 录音开始时间戳
@@ -262,33 +264,40 @@
// 返回结束消息
const controlBody = body as ControlBody;
if (controlBody.type === ControlCode.SERVER_TO_FRONT_OVER) {
console.log('识别结束', controlBody);
// if(status.value === 'default') return;
// status.value = 'default'; // 恢复成默认状态
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';
emit('submitVoice', { ossKey:'', text:'', recordId: recordId.value });
// todo
} else {
// 识别成功
voice_to_text_status.value = 'success';
const ossKey = controlBody?.ossKey;
let text = '';
if (typeof controlBody?.txt === 'string') {
text = controlBody.txt.trim();
}
}
// 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('后端发来的信息有问题');
console.log('后端发来的信息有问题', e);
}
});
})
.catch(() => {
stopRecord('networkError');
// stopRecord('networkError');
console.log('网络出现问题');
});
pressTimer.value = setTimeout(() => {
@@ -323,86 +332,28 @@
});
}, 120);
};
// 结束录音
const closePopup = () => {
popupRef.value.close();
};
const stopRecord2 = 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'; //主状态设置为语音发送中
}
if (['01', '03'].includes(isOutStatus.value)) {
// 向后端发送抬手动作
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') {
// 取消的时候,不校验最低时间
// 核心:计算录音总时长(毫秒转秒,保留1位小数)
if (recordDurationMs < 600) {
await new Promise<void>((resolve) => {
setTimeout(() => {
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;
}
});
}
stopAudioRecord(); // 关掉录音
if (isOutStatus.value !== '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 (isOutStatus.value === '01' && status.value == 'voice_send_ing') {
emit('sendLoading', { recordId: recordId.value });
// 如果socket长时间没有返回,这里兜底一下
setTimeout(() => {
if(status.value === 'default') return;
status.value = 'default'; // 恢复成默认状态
emit('submitVoice', { ossKey:'', text:'', recordId: recordId.value });
}, 5000)
}
};
const stopRecord = async (errrStatus = '') => {
clearTimeout(pressTimer.value);
if (!isRecording.value) return; // 未处于录音状态
const _isOutStatus = (props.mode === 'text-only' && isOutStatus.value === '01')?"03":isOutStatus.value;
const _isOutStatus = props.mode === 'text-only' && isOutStatus.value === '01' ? '03' : isOutStatus.value;
console.log('_isOutStatus', _isOutStatus);
// 拖动到转文字按钮上抬手或者仅文字模式的发送也强行算他转文字
if (_isOutStatus === '03' ) {
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'; //主状态设置为语音发送中
}
@@ -439,7 +390,6 @@
});
}
stopAudioRecord(); // 关掉录音
if (_isOutStatus !== '03' || errrStatus === 'networkError') {
// 转文字时候不关遮罩层,网络错误必须关遮罩层
popupRef.value.close();
@@ -454,13 +404,16 @@
if (_isOutStatus === '01' && status.value == 'voice_send_ing') {
emit('sendLoading', { recordId: recordId.value });
// 如果socket长时间没有返回,这里兜底一下
setTimeout(() => {
if(status.value === 'default') return;
status.value = 'default'; // 恢复成默认状态
emit('submitVoice', { ossKey:'', text:'', recordId: recordId.value });
}, 5000)
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);
}
};
// 发送文本
@@ -483,16 +436,32 @@
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('禁用时点击给的提示');
if (props.isDisabled) common.msg(props.disabledText);
};
const send_msg = () => {
console.log('点击发送');
if (!isInputVisible.value) {
emit('submitAnswer', inputText.value, changeBtn);
} else {
emit('submitAnswer', textAreaText.value, changeBtn);
closePopup();
}
};
setupKeyboardHeightListener((height: number) => {
+92 -108
View File
@@ -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>
+7 -7
View File
@@ -67,7 +67,7 @@
<view class="fixed-box font_pf" :style="{ marginBottom: popup_input_bottom }">
<view class="touch-btn-div" :class="{ show: showTouchBtn }">
<!-- <TouchBtnOnlyVoice
<TouchBtnOnlyVoice
v-if="answerMethod === '03'"
class="talk-btns"
ref="touchBtnRef"
@@ -79,8 +79,8 @@
:isDisabled="false"
:onlyVoice="true"
:answerMethod="answerMethod"
/> -->
<!-- <TouchBtn
/>
<TouchBtn
v-else
class="talk-btns"
ref="touchBtnRef"
@@ -91,9 +91,9 @@
:adjustPosition="false"
:isDisabled="false"
:answerMethod="answerMethod"
/> -->
/>
<touch-btn
<!-- <touch-btn
class="talk-btns"
ref="touchBtnRef"
@sendLoading="sendLoading"
@@ -103,7 +103,7 @@
:isLoading="touchIsDisabled"
loadingText="只能进行一条回答"
:answerMethod="answerMethod"
/>
/> -->
</view>
</view>
@@ -123,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';