修改语音掉线
This commit is contained in:
+6
-4
@@ -86,22 +86,24 @@ export const commonUploadVoiceFile = (file, url, data = {}, fileKey = 'voice') =
|
||||
filePath: file,
|
||||
name: fileKey,
|
||||
formData: data,
|
||||
timeout: 6000,
|
||||
success(result) {
|
||||
try {
|
||||
const res = JSON.parse(result.data);
|
||||
if (res.rtnCode === '0000') {
|
||||
resolve(result);
|
||||
return resolve(result);
|
||||
} else if (REQUES_ERROR_CODES['NO_LOGIN'].includes(res.rtnCode)) {
|
||||
goto_login_fun()
|
||||
} else {
|
||||
reject(new Error(res.message));
|
||||
return reject('NO_LOGIN');
|
||||
}
|
||||
return reject('Other');
|
||||
} catch (error) {
|
||||
reject(new Error('Failed to parse response'));
|
||||
}
|
||||
},
|
||||
fail(error) {
|
||||
reject(new Error('Upload failed'));
|
||||
console.log('err', error);
|
||||
return reject('Other');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -206,7 +206,6 @@
|
||||
// 赋值显示
|
||||
console.log('displayTime', displayTime);
|
||||
voiceTime.value = displayTime + 's';
|
||||
console.log('displayTime', voiceTime.value);
|
||||
});
|
||||
watch(
|
||||
() => props.dataInfo.voicePath,
|
||||
|
||||
@@ -148,6 +148,7 @@
|
||||
};
|
||||
// 结束录音
|
||||
const stopRecord = (status = false) => {
|
||||
console.log('结束录音stopRecord', status);
|
||||
if (props.isDisabled) return;
|
||||
if (startTimer.value) {
|
||||
clearTimeout(startTimer.value);
|
||||
@@ -162,10 +163,12 @@
|
||||
const times = Math.max(500 - endTime + startTime, 0);
|
||||
setTimeout(() => {
|
||||
console.log('延迟数据', times);
|
||||
nextTick(() => {
|
||||
popupRef.value.close();
|
||||
recorderManager.stop();
|
||||
});
|
||||
// nextTick(() => {
|
||||
|
||||
// });
|
||||
popupRef.value.close();
|
||||
console.log('停止录音');
|
||||
recorderManager.stop();
|
||||
}, times);
|
||||
}
|
||||
nextTick(() => (recordingStatus.value = 'not_started'));
|
||||
@@ -181,13 +184,18 @@
|
||||
console.log('说话时长', recordDuration);
|
||||
if (props.minRecordDuration > recordDuration) {
|
||||
nextTick(() => common.msg('说话时间太短,没有听清!'));
|
||||
// console.log('说话时间太短,没有听清');
|
||||
return;
|
||||
}
|
||||
|
||||
stopRecord(true); // 在去主动执行一次关闭
|
||||
popupRef.value?.close();
|
||||
recordingStatus.value = 'not_started'
|
||||
// stopRecord(true); // 在去主动执行一次关闭
|
||||
console.log('录音结束,时长:', recordDuration, '秒');
|
||||
emit('submit', 'voice', res.tempFilePath);
|
||||
});
|
||||
recorderManager.onError(function (err) {
|
||||
console.log('录音错误', err);
|
||||
});
|
||||
recorderManager.onStart(function (res) {
|
||||
// 检测是否已经抬手结束了
|
||||
console.log('检测是否已经抬手结束了', recordingStatus.value);
|
||||
|
||||
@@ -190,10 +190,9 @@
|
||||
papersId: '', // 试卷ID
|
||||
limitTm: 0, // 考试限制时间
|
||||
papersName: '', // 试卷名称
|
||||
isCacheExam: '' ,// 是否是缓存试卷(继续答题试卷)
|
||||
flagQuery: '' ,
|
||||
flagQueryDetail: '' ,
|
||||
|
||||
isCacheExam: '', // 是否是缓存试卷(继续答题试卷)
|
||||
flagQuery: '',
|
||||
flagQueryDetail: ''
|
||||
}); // 试卷信息
|
||||
const topicList = reactive([]); // 问题列表
|
||||
const popup_input_bottom = ref('0px');
|
||||
@@ -304,6 +303,7 @@
|
||||
const topic = topicList[questionNumber.value];
|
||||
touchBtnRef.value?.clearinputText(); // 清除发送框数据
|
||||
if (type === 'voice') {
|
||||
if(topic.es_status == '00') return;
|
||||
topic.es_status = '00'; // 00转圈
|
||||
const voicePath = submitObj;
|
||||
commonUploadVoiceFile(voicePath, '/traask/traAskchat/voiceTrans', {})
|
||||
@@ -326,9 +326,11 @@
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
.catch((error) => {
|
||||
topic.es_status = ''; // 取消转圈
|
||||
common.msg('系统异常,请联系管理员');
|
||||
if (error === 'Other') {
|
||||
common.msg('系统异常,请联系管理员');
|
||||
}
|
||||
});
|
||||
} else if (type === 'text') {
|
||||
topic.es_status = '01';
|
||||
@@ -339,14 +341,13 @@
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const answerCacheList = ref({});
|
||||
const setAnswerCacheList = (value) => {
|
||||
console.log('触发变化', value);
|
||||
answerCacheList.value = value;
|
||||
common.setValue(examinationAnswerCacheKey, value);
|
||||
};
|
||||
|
||||
|
||||
// 添加试题答案缓存
|
||||
const addTopicAnswerCache = () => {
|
||||
const my_answer = topic.value.my_answer;
|
||||
|
||||
@@ -306,6 +306,7 @@
|
||||
const topic = topicList[questionNumber.value]
|
||||
touchBtnRef.value?.clearinputText(); // 清除发送框数据
|
||||
if (type === 'voice') {
|
||||
if(topic.es_status == '00') return;
|
||||
topic.es_status = '00'; // 00转圈
|
||||
const voicePath = submitObj;
|
||||
commonUploadVoiceFile(voicePath, '/traask/traAskchat/voiceTrans', {})
|
||||
@@ -327,9 +328,11 @@
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
.catch((error) => {
|
||||
topic.es_status = ''; // 取消转圈
|
||||
common.msg('系统异常,请联系管理员');
|
||||
if (error === 'Other') {
|
||||
common.msg('系统异常,请联系管理员');
|
||||
}
|
||||
});
|
||||
} else if (type === 'text') {
|
||||
topic.es_status = '01';
|
||||
|
||||
@@ -287,18 +287,24 @@
|
||||
const touchBtnSubmit = (type, submitObj) => {
|
||||
const topic = topicList[questionNumber.value];
|
||||
touchBtnRef.value?.clearinputText(); // 清除发送框数据
|
||||
console.log('录音组件提交');
|
||||
if (type === 'voice') {
|
||||
if(topic.es_status == '00') return;
|
||||
topic.es_status = '00'; // 00转圈
|
||||
const voicePath = submitObj;
|
||||
commonUploadVoiceFile(voicePath, '/traask/traAskchat/voiceTrans', {})
|
||||
.then((res) => {
|
||||
console.log('_contentsssss', res);
|
||||
let _res = JSON.parse(res.data);
|
||||
if (_res.rtnCode === '0000') {
|
||||
const _content = _res.body.transContent.trim();
|
||||
console.log('_content', _content);
|
||||
if (_content === '') {
|
||||
topic.es_status = ''; // 取消转圈
|
||||
console.log('未识别到文字');
|
||||
return common.msg('未识别到文字');
|
||||
} else {
|
||||
console.log('识别到了文字', _content);
|
||||
topic.es_status = '02';
|
||||
topic.my_answer = {
|
||||
anserResult: _res.body.transContent,
|
||||
@@ -309,9 +315,11 @@
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
.catch((error) => {
|
||||
topic.es_status = ''; // 取消转圈
|
||||
common.msg('系统异常,请联系管理员');
|
||||
if (error === 'Other') {
|
||||
common.msg('系统异常,请联系管理员');
|
||||
}
|
||||
});
|
||||
} else if (type === 'text') {
|
||||
topic.es_status = '01';
|
||||
|
||||
Reference in New Issue
Block a user