JLBA202505130001_关于吉林银行新建AI智能培训系统的需求_sit前检查功能

This commit is contained in:
田岩
2026-02-28 19:26:00 +08:00
27 changed files with 909 additions and 339 deletions
+62 -50
View File
@@ -96,12 +96,13 @@
import { wsUrl, bottomAreaTopBoundary, horizontalSplitX } from './touch-btn';
import { ref, computed, onMounted, nextTick, watch, reactive } from 'vue';
import common from '@/common/common';
import { onHide } from '@dcloudio/uni-app';
import { onHide, onLaunch } from '@dcloudio/uni-app';
import { getPhoneEnvBool, getToken } from '@/common/common.js';
import { startAudioRecord, stopAudioRecord } from '@/uni_modules/ty-recording';
import { startAudioRecord, stopAudioRecord,preRequestRecordPermission } from '@/uni_modules/ty-recording';
import { ProtocolCodec, MessageType, ControlCommand, ControlCode } from '@/pages/sparring/js/ProtocolCodec';
import permissionApi from '@/common/permission';
const emit = defineEmits(['submit']);
const ws = ref(null);
const status = ref<StatusType>('voice');
@@ -164,9 +165,13 @@
const inputText = ref('');
let startTime = 0;
// 开启语音
const startRecord = async (obj) => {
const startRecord = async (obj: { touches: any[]; }) => {
try {
await permissionApi.judgeIosPermission('record');
const state = await permissionApi.judgeIosPermission('record');
if(state === 'not determined') { // 苹果专用
preRequestRecordPermission(() => {})
return;
}
} catch (e) {
console.error('麦克风权限申请失败:', e);
return;
@@ -174,54 +179,61 @@
const changedTouche = obj.touches[0];
touchPos.x = changedTouche.clientX;
touchPos.y = changedTouche.clientY;
ws.value = uni.connectSocket({
url: wsUrl + '?summary=' + getToken(),
fail: () => {},
success: () => {}
});
ws.value.onOpen((res) => {
console.log('ws已连接');
popupRef.value.open();
startAudioRecord({
onFrame: (pcmData) => {
console.log(pcmData.length);
ws.value.send({
data: ProtocolCodec.pack(MessageType.AUDIO_DATA, pcmData)
});
},
onStart: ({ startTime }) => {
console.log('开始', startTime);
},
onStop: () => {
console.log('关闭');
},
onError: ({ errCode, errMsg }) => {
if (errCode === 9010001) {
console.log(errMsg);
}
popupRef.value.open();
startAudioRecord({
onFrame: (pcmData: any) => {
console.log('pcmData', pcmData);
// console.log('pcmData', pcmData.length);
// ws.value.send({
// data: ProtocolCodec.pack(MessageType.AUDIO_DATA, pcmData)
// });
},
onStart: (res: any) => {
console.log('启动', res);
},
onStop: () => {
console.log('关闭');
},
onError: ({ errCode, errMsg }) => {
console.log('onError',errMsg);
if (errCode === 9010001) {
console.log(errMsg);
}
});
});
ws.value.onError((err) => {
console.log('err', err);
});
ws.value.onClose((err) => {
console.log('onClose', err);
});
ws.value.onMessage((res) => {
try {
const { msgType, body } = ProtocolCodec.unpack(res.data);
console.log('来消息了', msgType, body);
if (msgType === MessageType.TEXT_MESSAGE) {
tempText.value = '';
allText.value = allText.value + body;
} else if (msgType === MessageType.TIP_MESSAGE) {
tempText.value = body;
}
} catch (e) {
console.log('后端发来的信息有问题');
}
});
// ws.value = uni.connectSocket({
// url: wsUrl + '?summary=' + getToken(),
// fail: () => {},
// success: () => {}
// });
// ws.value.onOpen((res) => {
// console.log('ws已连接');
// popupRef.value.open();
// });
// ws.value.onError((err) => {
// console.log('err', err);
// });
// ws.value.onClose((err) => {
// console.log('onClose', err);
// });
// ws.value.onMessage((res) => {
// try {
// const { msgType, body } = ProtocolCodec.unpack(res.data);
// console.log('来消息了', msgType, body);
// if (msgType === MessageType.TEXT_MESSAGE) {
// tempText.value = '';
// allText.value = allText.value + body;
// } else if (msgType === MessageType.TIP_MESSAGE) {
// // tempText.value = body;
// }
// } catch (e) {
// console.log('后端发来的信息有问题');
// }
// });
};
// 关掉遮罩层
const closePopup = () => {