发送文字替换发送语音
This commit is contained in:
parent
2f5444e27f
commit
d73bc4d577
@ -907,6 +907,10 @@ export const menuOperate = {
|
|||||||
Chat: {
|
Chat: {
|
||||||
operation: OperationEvent.Conversation.Chat.menu.operation,
|
operation: OperationEvent.Conversation.Chat.menu.operation,
|
||||||
cmdType: CMD.Conversation.CMD_Conversation_Chat_Text
|
cmdType: CMD.Conversation.CMD_Conversation_Chat_Text
|
||||||
|
},
|
||||||
|
Record: {
|
||||||
|
operation: OperationEvent.Conversation.Chat.record.operation,
|
||||||
|
cmdType: CMD.Conversation.CMD_Conversation_Chat_Audio_Base64
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4189,6 +4189,10 @@ export const OperationEvent = {
|
|||||||
sideButton: {
|
sideButton: {
|
||||||
operation: '1402',
|
operation: '1402',
|
||||||
domId: '_Tips-Conversation-Chat-sideButton'
|
domId: '_Tips-Conversation-Chat-sideButton'
|
||||||
|
},
|
||||||
|
record: {
|
||||||
|
operation: '1403',
|
||||||
|
domId: '_Tips-Conversation-Chat-record'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -2,7 +2,9 @@ import ValidateHandler from './newValidateHandler';
|
|||||||
import store from '@/store/index';
|
import store from '@/store/index';
|
||||||
import { sendCommandNew, endTrainingStep } from '@/api/jmap/training';
|
import { sendCommandNew, endTrainingStep } from '@/api/jmap/training';
|
||||||
import router from '@/router/index';
|
import router from '@/router/index';
|
||||||
|
import { OperationEvent } from '@/scripts/cmdPlugin/OperationHandler';
|
||||||
|
import {UserOperationType} from '@/scripts/ConstDic';
|
||||||
|
import CMD from '@/scripts/cmdPlugin/CommandEnum';
|
||||||
class Handler {
|
class Handler {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.operations = [];
|
this.operations = [];
|
||||||
@ -95,6 +97,10 @@ class Handler {
|
|||||||
const operateOrder = store.state.trainingNew.operateOrder;
|
const operateOrder = store.state.trainingNew.operateOrder;
|
||||||
return stepInfo.operations.length <= operateOrder + 1;
|
return stepInfo.operations.length <= operateOrder + 1;
|
||||||
}
|
}
|
||||||
|
// 是否未特殊语音执行步骤列表的最后一步
|
||||||
|
isLastVoiceStep() {
|
||||||
|
return store.state.trainingNew.voiceStepList.length <= store.state.trainingNew.voiceStepIndex + 1;
|
||||||
|
}
|
||||||
// 计算当前步骤得分
|
// 计算当前步骤得分
|
||||||
computedScoring() {
|
computedScoring() {
|
||||||
const stepInfo = store.state.trainingNew.stepInfo;
|
const stepInfo = store.state.trainingNew.stepInfo;
|
||||||
@ -116,5 +122,61 @@ class Handler {
|
|||||||
console.error('进入下一步失败!', e);
|
console.error('进入下一步失败!', e);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// 判定是否转换特殊语音消息步骤列表 如果是跳过当前操作 进入特殊语音执行序列
|
||||||
|
judgeIsTextSendOperation() {
|
||||||
|
const stepInfo = store.state.trainingNew.stepInfo;
|
||||||
|
const operateOrder = store.state.trainingNew.operateOrder;
|
||||||
|
const operation = stepInfo.operations[operateOrder];
|
||||||
|
if (operation.domId === OperationEvent.Conversation.Chat.menu.operation) {
|
||||||
|
this.handleVoiceStepList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 处理特殊语音消息步骤列表
|
||||||
|
handleVoiceStepList() {
|
||||||
|
const stepInfo = store.state.trainingNew.stepInfo;
|
||||||
|
const operateOrder = store.state.trainingNew.operateOrder;
|
||||||
|
const operation = stepInfo.operations[operateOrder];
|
||||||
|
const operation1 = {
|
||||||
|
userOperationType: UserOperationType.LEFTCLICK,
|
||||||
|
domId: OperationEvent.Conversation.Chat.sideButton.operation,
|
||||||
|
params: { chatBoxMin: true }
|
||||||
|
};
|
||||||
|
const step1 = {
|
||||||
|
description: '点击打开聊天室',
|
||||||
|
memberId: stepInfo.memberId,
|
||||||
|
operations: [operation1],
|
||||||
|
tipPosition: { deviceCode: '', domId: operation1.domId, operateIndex: 0 }
|
||||||
|
};
|
||||||
|
const operation2 = {
|
||||||
|
userOperationType: UserOperationType.LEFTCLICK,
|
||||||
|
domId: OperationEvent.Conversation.Chat.record.operation,
|
||||||
|
params: {}
|
||||||
|
};
|
||||||
|
const step2 = {
|
||||||
|
description: '点击录制语音',
|
||||||
|
memberId: stepInfo.memberId,
|
||||||
|
operations: [operation2],
|
||||||
|
tipPosition: { deviceCode: '', domId: operation2.domId, operateIndex: 0 }
|
||||||
|
};
|
||||||
|
const operation3 = {
|
||||||
|
userOperationType: UserOperationType.LEFTCLICK,
|
||||||
|
domId: OperationEvent.Conversation.Chat.record.operation,
|
||||||
|
operationType: CMD.Conversation.CMD_Conversation_Chat_Audio_Base64.value,
|
||||||
|
params: {
|
||||||
|
fileBase64Str: 'no'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const step3 = {
|
||||||
|
description: `请说出“${operation.params.content}”后,再次点击发送语音!`,
|
||||||
|
memberId: stepInfo.memberId,
|
||||||
|
operations: [operation3],
|
||||||
|
tipPosition: { deviceCode: '', domId: operation3.domId, operateIndex: 0 }
|
||||||
|
};
|
||||||
|
if (store.state.training.chatBoxMin) {
|
||||||
|
store.dispatch('trainingNew/setVoiceStepList', [step1, step2, step3]);
|
||||||
|
} else {
|
||||||
|
store.dispatch('trainingNew/setVoiceStepList', [step2, step3]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
export default new Handler();
|
export default new Handler();
|
||||||
|
@ -23,8 +23,12 @@ class ValidateHandler {
|
|||||||
}
|
}
|
||||||
// 判断实训操作正确性
|
// 判断实训操作正确性
|
||||||
judgeTraining(operate) {
|
judgeTraining(operate) {
|
||||||
const stepOperation = Handler.getTrainingOperation();
|
let stepOperation = {};
|
||||||
console.log(operate, stepOperation, 'judgeTraining');
|
if (store.state.trainingNew.voiceStepIndex > -1) {
|
||||||
|
stepOperation = store.state.trainingNew.voiceStepList[store.state.trainingNew.voiceStepIndex].operations[0];
|
||||||
|
} else {
|
||||||
|
stepOperation = Handler.getTrainingOperation();
|
||||||
|
}
|
||||||
let valid = true;
|
let valid = true;
|
||||||
if (operate.cmdType || stepOperation.operationType) {
|
if (operate.cmdType || stepOperation.operationType) {
|
||||||
const cmd = operate.cmdType ? operate.cmdType.value : '';
|
const cmd = operate.cmdType ? operate.cmdType.value : '';
|
||||||
@ -40,14 +44,17 @@ class ValidateHandler {
|
|||||||
valid = (operate.userOperationType === stepOperation.userOperationType) && valid;
|
valid = (operate.userOperationType === stepOperation.userOperationType) && valid;
|
||||||
}
|
}
|
||||||
const opParam = operate.param === undefined ? {} : operate.param;
|
const opParam = operate.param === undefined ? {} : operate.param;
|
||||||
if (opParam || stepOperation.params) {
|
if ((opParam || stepOperation.params) && !opParam.hasOwnProperty('fileBase64Str')) {
|
||||||
valid = objectIsEqual(opParam, stepOperation.params) && valid;
|
valid = objectIsEqual(opParam, stepOperation.params) && valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (valid && Handler.isLastOperation()) {
|
if (valid && store.state.trainingNew.voiceStepIndex > -1) {
|
||||||
|
!Handler.isLastVoiceStep() && store.dispatch('trainingNew/voiceStepIndexIncrease');
|
||||||
|
} else if (valid && Handler.isLastOperation()) {
|
||||||
Handler.nextStep();
|
Handler.nextStep();
|
||||||
} else if (valid) {
|
} else if (valid) {
|
||||||
store.dispatch('trainingNew/operateOrderIncrease');
|
store.dispatch('trainingNew/operateOrderIncrease');
|
||||||
|
Handler.judgeIsTextSendOperation();
|
||||||
} else {
|
} else {
|
||||||
console.error('校验失败;');
|
console.error('校验失败;');
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,8 @@ const training = {
|
|||||||
runPathList:[], // 运行线 (宁波三号线)
|
runPathList:[], // 运行线 (宁波三号线)
|
||||||
domConfig: {}, // 线路功能前端配置项
|
domConfig: {}, // 线路功能前端配置项
|
||||||
simulationUserType: '', // 仿真用户角色
|
simulationUserType: '', // 仿真用户角色
|
||||||
simulationCreator: false
|
simulationCreator: false,
|
||||||
|
chatBoxMin: true // 聊天框最小化
|
||||||
},
|
},
|
||||||
|
|
||||||
getters: {
|
getters: {
|
||||||
@ -324,6 +325,9 @@ const training = {
|
|||||||
},
|
},
|
||||||
setDomConfig: (state, domConfig) => {
|
setDomConfig: (state, domConfig) => {
|
||||||
state.domConfig = domConfig;
|
state.domConfig = domConfig;
|
||||||
|
},
|
||||||
|
setChatBoxMin: (state, chatBoxMin) => {
|
||||||
|
state.chatBoxMin = chatBoxMin;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -661,6 +665,9 @@ const training = {
|
|||||||
},
|
},
|
||||||
setOperate: ({ commit }, operate) => {
|
setOperate: ({ commit }, operate) => {
|
||||||
commit('setOperate', operate);
|
commit('setOperate', operate);
|
||||||
|
},
|
||||||
|
setChatBoxMin: ({ commit }, chatBoxMin) => {
|
||||||
|
commit('setChatBoxMin', chatBoxMin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import NewHandler from '@/scripts/cmdPlugin/newHandler';
|
import Handler from '@/scripts/cmdPlugin/newHandler';
|
||||||
import store from '@/store/index';
|
import store from '@/store/index';
|
||||||
const training = {
|
const training = {
|
||||||
namespaced: true,
|
namespaced: true,
|
||||||
@ -15,7 +15,9 @@ const training = {
|
|||||||
operateOrder: 0, // 操作order
|
operateOrder: 0, // 操作order
|
||||||
operateErrMsg: '',
|
operateErrMsg: '',
|
||||||
scoreList: [], // 实训得分
|
scoreList: [], // 实训得分
|
||||||
draftStepList: null // 显示的步骤列表
|
draftStepList: null, // 显示的步骤列表
|
||||||
|
voiceStepList: [], // 实训特殊语音步骤列表
|
||||||
|
voiceStepIndex: -1
|
||||||
},
|
},
|
||||||
getters: {
|
getters: {
|
||||||
teachMode: (state) => {
|
teachMode: (state) => {
|
||||||
@ -71,7 +73,7 @@ const training = {
|
|||||||
},
|
},
|
||||||
setStepInfo: (state, stepInfo) => {
|
setStepInfo: (state, stepInfo) => {
|
||||||
state.stepInfo = state.stepList.find(step => step.id === stepInfo.stepId);
|
state.stepInfo = state.stepList.find(step => step.id === stepInfo.stepId);
|
||||||
console.log(state.stepInfo, stepInfo, state.stepList, 'dsdf');
|
Handler.judgeIsTextSendOperation();
|
||||||
},
|
},
|
||||||
clearTrainingData: (state) => {
|
clearTrainingData: (state) => {
|
||||||
state.teachMode = '';
|
state.teachMode = '';
|
||||||
@ -89,6 +91,18 @@ const training = {
|
|||||||
},
|
},
|
||||||
editDraftStepList: (state, draftStepList) => {
|
editDraftStepList: (state, draftStepList) => {
|
||||||
state.draftStepList = draftStepList;
|
state.draftStepList = draftStepList;
|
||||||
|
},
|
||||||
|
setVoiceStepList: (state, voiceStepList) => {
|
||||||
|
state.voiceStepIndex = 0;
|
||||||
|
state.voiceStepList = voiceStepList;
|
||||||
|
console.log(voiceStepList, state.voiceStepIndex);
|
||||||
|
},
|
||||||
|
voiceStepIndexIncrease: (state) => {
|
||||||
|
state.voiceStepIndex++;
|
||||||
|
},
|
||||||
|
clearVoiceStepList: (state) => {
|
||||||
|
state.voiceStepIndex = -1;
|
||||||
|
state.voiceStepList = [];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
@ -129,7 +143,7 @@ const training = {
|
|||||||
if (!store.state.training.roles) {
|
if (!store.state.training.roles) {
|
||||||
reject({message: '您目前无仿真成员角色!'});
|
reject({message: '您目前无仿真成员角色!'});
|
||||||
} else {
|
} else {
|
||||||
NewHandler.handle(operate).then(rtn => {
|
Handler.handle(operate).then(rtn => {
|
||||||
resolve(rtn);
|
resolve(rtn);
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
reject(e);
|
reject(e);
|
||||||
@ -152,6 +166,30 @@ const training = {
|
|||||||
},
|
},
|
||||||
editDraftStepList: ({ commit }, draftStepList) => {
|
editDraftStepList: ({ commit }, draftStepList) => {
|
||||||
commit('editDraftStepList', draftStepList);
|
commit('editDraftStepList', draftStepList);
|
||||||
|
},
|
||||||
|
setVoiceStepList: ({ commit }, voiceStepList) => {
|
||||||
|
commit('setVoiceStepList', voiceStepList);
|
||||||
|
},
|
||||||
|
voiceStepIndexIncrease: ({ commit }) => {
|
||||||
|
commit('voiceStepIndexIncrease');
|
||||||
|
},
|
||||||
|
clearVoiceStepList: ({ commit }) => {
|
||||||
|
commit('clearVoiceStepList');
|
||||||
|
},
|
||||||
|
handleMatchVoice: ({ commit }, info) => {
|
||||||
|
console.log(info);
|
||||||
|
if (info && info.content === 'true') {
|
||||||
|
if (Handler.isLastOperation()) {
|
||||||
|
Handler.nextStep();
|
||||||
|
commit('clearVoiceStepList');
|
||||||
|
} else {
|
||||||
|
commit('clearVoiceStepList');
|
||||||
|
commit('operateOrderIncrease');
|
||||||
|
Handler.judgeIsTextSendOperation();
|
||||||
|
}
|
||||||
|
} else if (info && info.content === 'false') {
|
||||||
|
Handler.handleVoiceStepList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -180,6 +180,9 @@ function handle(data) {
|
|||||||
case 'Simulation_Training_Step_Tip':
|
case 'Simulation_Training_Step_Tip':
|
||||||
store.dispatch('trainingNew/setStepInfo', msg);
|
store.dispatch('trainingNew/setStepInfo', msg);
|
||||||
break;
|
break;
|
||||||
|
case 'Simulation_Training_Audio_MATCH_RESULT':
|
||||||
|
store.dispatch('trainingNew/handleMatchVoice', msg);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 仿真内部聊天
|
// 仿真内部聊天
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-quickMenuDrag class="voice-chat-box">
|
<div v-quickMenuDrag class="voice-chat-box">
|
||||||
<div v-if="min" :id="sideButtonDom.domId" @click="clickBtn">
|
<div v-if="chatBoxMin" :id="sideButtonDom.domId" @click="clickBtn">
|
||||||
<el-button circle style="color: #0C161A;" icon="el-icon-mic" />
|
<el-button circle style="color: #0C161A;" icon="el-icon-mic" />
|
||||||
</div>
|
</div>
|
||||||
<div v-show="!min" class="chat-box-main">
|
<div v-show="!chatBoxMin" class="chat-box-main">
|
||||||
<div class="chat-box-header">
|
<div class="chat-box-header">
|
||||||
<div style="margin-right: 10px;cursor: pointer;">
|
<div style="margin-right: 10px;cursor: pointer;">
|
||||||
<i class="el-icon-minus" style="color: #000;" @click="minimize" />
|
<i class="el-icon-minus" style="color: #000;" @click="minimize" />
|
||||||
@ -36,7 +36,7 @@
|
|||||||
<div class="chat-box-footer">
|
<div class="chat-box-footer">
|
||||||
<el-input v-model="textContent" size="small" placeholder="请输入会话文字,点击T发送" style="flex: 1; margin-left: 5px;" :rows="1" />
|
<el-input v-model="textContent" size="small" placeholder="请输入会话文字,点击T发送" style="flex: 1; margin-left: 5px;" :rows="1" />
|
||||||
<el-button :id="sendTextId" size="mini" class="chat-box-footer-create" :disabled="contentSend" @click="sendText">T</el-button>
|
<el-button :id="sendTextId" size="mini" class="chat-box-footer-create" :disabled="contentSend" @click="sendText">T</el-button>
|
||||||
<el-button class="chat-box-footer-create chat-box-footer-send" :class="{'active': recordSending}" :disabled="audioPlay" size="mini" type="primary" @click="startRecording()">
|
<el-button :id="recordVoice" class="chat-box-footer-create chat-box-footer-send" :class="{'active': recordSending}" :disabled="audioPlay || (trainingDesign && !trainingSwitch)" size="mini" type="primary" @click="startRecording()">
|
||||||
<el-progress id="voice_progress_bar" type="circle" :show-text="false" :percentage="100/60*seconds" :width="40" :stroke-width="2" status="success" />
|
<el-progress id="voice_progress_bar" type="circle" :show-text="false" :percentage="100/60*seconds" :width="40" :stroke-width="2" status="success" />
|
||||||
<i v-if="recordSending" class="el-icon-close close_icon" @click.stop="cancelRecording()" />
|
<i v-if="recordSending" class="el-icon-close close_icon" @click.stop="cancelRecording()" />
|
||||||
<span class="iconfont icon-yuyin"></span>
|
<span class="iconfont icon-yuyin"></span>
|
||||||
@ -49,10 +49,11 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import RecordRTC from 'recordrtc';
|
import RecordRTC from 'recordrtc';
|
||||||
import {sendChatAudioBase64, getAllConversition} from '@/api/chat';
|
import {getAllConversition} from '@/api/chat';
|
||||||
import { OperationEvent } from '@/scripts/cmdPlugin/OperationHandler';
|
import { OperationEvent } from '@/scripts/cmdPlugin/OperationHandler';
|
||||||
import {menuOperate, commitOperate} from '@/jmapNew/theme/components/utils/menuOperate';
|
import {menuOperate, commitOperate} from '@/jmapNew/theme/components/utils/menuOperate';
|
||||||
import {UserOperationType} from '@/scripts/ConstDic';
|
import {UserOperationType} from '@/scripts/ConstDic';
|
||||||
|
import CMD from '@/scripts/cmdPlugin/CommandEnum';
|
||||||
export default {
|
export default {
|
||||||
name: 'ChatBox',
|
name: 'ChatBox',
|
||||||
data() {
|
data() {
|
||||||
@ -64,16 +65,19 @@ export default {
|
|||||||
microphone:null,
|
microphone:null,
|
||||||
audioPlay:false,
|
audioPlay:false,
|
||||||
textContent: '',
|
textContent: '',
|
||||||
min: true,
|
|
||||||
messageList: [], // 消息列表
|
messageList: [], // 消息列表
|
||||||
currentAudioList:[],
|
currentAudioList:[],
|
||||||
currentMessage: {}
|
currentMessage: {},
|
||||||
|
trainingDesign: false
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed:{
|
computed:{
|
||||||
group() {
|
group() {
|
||||||
return this.$route.query.group;
|
return this.$route.query.group;
|
||||||
},
|
},
|
||||||
|
chatBoxMin() {
|
||||||
|
return this.$store.state.training.chatBoxMin;
|
||||||
|
},
|
||||||
contentSend() {
|
contentSend() {
|
||||||
return !this.textContent;
|
return !this.textContent;
|
||||||
},
|
},
|
||||||
@ -86,18 +90,26 @@ export default {
|
|||||||
sendTextId() {
|
sendTextId() {
|
||||||
return OperationEvent.Conversation.Chat.menu.domId;
|
return OperationEvent.Conversation.Chat.menu.domId;
|
||||||
},
|
},
|
||||||
|
recordVoice() {
|
||||||
|
return OperationEvent.Conversation.Chat.record.domId;
|
||||||
|
},
|
||||||
sideButtonDom() {
|
sideButtonDom() {
|
||||||
return OperationEvent.Conversation.Chat.sideButton;
|
return OperationEvent.Conversation.Chat.sideButton;
|
||||||
|
},
|
||||||
|
trainingSwitch() {
|
||||||
|
return this.$store.state.trainingNew.trainingSwitch;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
'$store.state.socket.simulationReset': function () { // 仿真重置
|
'$store.state.socket.simulationReset': function () { // 仿真重置
|
||||||
this.messageList = [];
|
this.messageList = [];
|
||||||
},
|
},
|
||||||
|
'$store.state.training.domConfig': function(val) {
|
||||||
|
this.trainingDesign = val.trainingDesign;
|
||||||
|
},
|
||||||
'$store.state.socket.conversationMessage':function (val) { // 仿真聊天
|
'$store.state.socket.conversationMessage':function (val) { // 仿真聊天
|
||||||
const message = {...val};
|
const message = {...val};
|
||||||
this.messageList.push(message);
|
this.messageList.push(message);
|
||||||
console.log(val, '----------');
|
|
||||||
if (val.memberId != this.myMemberId) {
|
if (val.memberId != this.myMemberId) {
|
||||||
this.currentAudioList.push(message);
|
this.currentAudioList.push(message);
|
||||||
if (!this.isPlay) {
|
if (!this.isPlay) {
|
||||||
@ -105,21 +117,25 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.scrollTop();
|
this.scrollTop();
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
this.trainingDesign = this.$store.state.training.domConfig ? this.$store.state.training.domConfig.trainingDesign : false;
|
||||||
this.initConversationData();
|
this.initConversationData();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
scrollTop() {
|
scrollTop() {
|
||||||
|
this.$nextTick(() => {
|
||||||
|
const scrollTop = this.messageList.length * 65 - 250;
|
||||||
|
document.querySelector('.chat-box-content').scrollTop = scrollTop;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
initConversationData() {
|
initConversationData() {
|
||||||
getAllConversition(this.group).then(resp => {
|
getAllConversition(this.group).then(resp => {
|
||||||
if (resp.data && resp.data.length) {
|
if (resp.data && resp.data.length) {
|
||||||
const conversation = resp.data.find(con => con.id === 'chat_room_key');
|
const conversation = resp.data.find(con => con.id === 'chat_room_key');
|
||||||
this.messageList = conversation ? conversation.messageList : [];
|
this.messageList = conversation ? conversation.messageList : [];
|
||||||
|
this.scrollTop();
|
||||||
} else {
|
} else {
|
||||||
this.messageList = [];
|
this.messageList = [];
|
||||||
}
|
}
|
||||||
@ -166,14 +182,18 @@ export default {
|
|||||||
clickBtn() {
|
clickBtn() {
|
||||||
const operate = {
|
const operate = {
|
||||||
operation: this.sideButtonDom.operation,
|
operation: this.sideButtonDom.operation,
|
||||||
param: { min: this.min },
|
param: { chatBoxMin: this.chatBoxMin },
|
||||||
userOperationType: UserOperationType.LEFTCLICK
|
userOperationType: UserOperationType.LEFTCLICK
|
||||||
};
|
};
|
||||||
this.min = false;
|
this.$store.dispatch('training/setChatBoxMin', false);
|
||||||
this.$store.dispatch('trainingNew/next', operate);
|
if (this.$store.state.trainingNew.trainingSwitch) {
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$store.dispatch('trainingNew/next', operate);
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
minimize() {
|
minimize() {
|
||||||
this.min = true;
|
this.$store.dispatch('training/setChatBoxMin', true);
|
||||||
},
|
},
|
||||||
sendText() {
|
sendText() {
|
||||||
commitOperate(menuOperate.Conversation.Chat, {content: this.textContent}, 3).then(({valid})=>{
|
commitOperate(menuOperate.Conversation.Chat, {content: this.textContent}, 3).then(({valid})=>{
|
||||||
@ -202,16 +222,24 @@ export default {
|
|||||||
const that = this;
|
const that = this;
|
||||||
this.recorders.stopRecording(function(blobURL) {
|
this.recorders.stopRecording(function(blobURL) {
|
||||||
that.recorders.getDataURL(function(BaseURL) {
|
that.recorders.getDataURL(function(BaseURL) {
|
||||||
sendChatAudioBase64(that.group, {fileBase64Str: BaseURL})
|
const operate = {
|
||||||
.then((data) => {
|
over: true,
|
||||||
|
cmdType: CMD.Conversation.CMD_Conversation_Chat_Audio_Base64,
|
||||||
|
operation: OperationEvent.Conversation.Chat.record.operation,
|
||||||
|
userOperationType: UserOperationType.LEFTCLICK,
|
||||||
|
param: {
|
||||||
|
fileBase64Str: BaseURL
|
||||||
|
}
|
||||||
|
};
|
||||||
|
that.$store.dispatch('trainingNew/next', operate).then(({ valid }) => {
|
||||||
|
if (valid) {
|
||||||
that.textContent = '';
|
that.textContent = '';
|
||||||
that.audioPlay = false;
|
that.audioPlay = false;
|
||||||
})
|
}
|
||||||
.catch(error => {
|
}).catch(error => {
|
||||||
console.log(error);
|
that.$message.error('发送会话语音失败:' + error.message);
|
||||||
that.$message.error('语音发送失败: ' + error.message);
|
that.audioPlay = false;
|
||||||
that.audioPlay = false;
|
});
|
||||||
});
|
|
||||||
if (that.microphone) {
|
if (that.microphone) {
|
||||||
that.microphone.stop();
|
that.microphone.stop();
|
||||||
that.microphone = null;
|
that.microphone = null;
|
||||||
@ -221,73 +249,87 @@ export default {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
tipErrorMessage(error) {
|
||||||
|
switch (error.code || error.name) {
|
||||||
|
case 'PERMISSION_DENIED':
|
||||||
|
case 'PermissionDeniedError':
|
||||||
|
this.$message({
|
||||||
|
showClose: true,
|
||||||
|
message: '用户拒绝提供信息',
|
||||||
|
type: 'error'
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 'NOT_SUPPORTED_ERROR':
|
||||||
|
case 'NotSupportedError':
|
||||||
|
this.$message({
|
||||||
|
showClose: true,
|
||||||
|
message: '浏览器不支持硬件设备',
|
||||||
|
type: 'error'
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 'MANDATORY_UNSATISFIED_ERROR':
|
||||||
|
case 'MandatoryUnsatisfiedError':
|
||||||
|
this.$message({
|
||||||
|
showClose: true,
|
||||||
|
message: '无法发现指定的硬件设备',
|
||||||
|
type: 'error'
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
this.$message({
|
||||||
|
showClose: true,
|
||||||
|
message: '无法打开麦克风',
|
||||||
|
type: 'error'
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mediaSuccessCallback(stream) {
|
||||||
|
const StereoAudioRecorder = RecordRTC.StereoAudioRecorder;
|
||||||
|
this.microphone = stream;
|
||||||
|
this.recorders = new RecordRTC(this.microphone, {
|
||||||
|
type: 'audio',
|
||||||
|
recorderType: StereoAudioRecorder,
|
||||||
|
numberOfAudioChannels: 1,
|
||||||
|
bitsPerSecond:256000,
|
||||||
|
desiredSampRate: 16000
|
||||||
|
});
|
||||||
|
this.recorders.startRecording();
|
||||||
|
this.recordSending = true;
|
||||||
|
this.audioPlay = false;
|
||||||
|
this.inter = setInterval(() => {
|
||||||
|
if (this.seconds < 60) {
|
||||||
|
this.seconds++;
|
||||||
|
} else {
|
||||||
|
clearInterval(this.inter);
|
||||||
|
this.stopRecording();
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
|
},
|
||||||
// 语音录制开始
|
// 语音录制开始
|
||||||
startRecording() {
|
startRecording() {
|
||||||
this.audioPlay = true;
|
|
||||||
const that = this;
|
|
||||||
if (!this.recordSending) {
|
if (!this.recordSending) {
|
||||||
if (!this.recordSending && !this.recorders && !this.microphone) {
|
const operate = {
|
||||||
const StereoAudioRecorder = RecordRTC.StereoAudioRecorder;
|
operation: OperationEvent.Conversation.Chat.record.operation,
|
||||||
navigator.getUserMedia(
|
userOperationType: UserOperationType.LEFTCLICK
|
||||||
{ audio: true } // 只启用音频
|
};
|
||||||
, function (stream) {
|
this.$store.dispatch('trainingNew/next', operate).then(({ valid }) => {
|
||||||
that.microphone = stream;
|
if (valid) {
|
||||||
that.recorders = new RecordRTC(that.microphone, {
|
this.audioPlay = true;
|
||||||
type: 'audio',
|
const that = this;
|
||||||
recorderType: StereoAudioRecorder,
|
if (!this.recordSending && !this.recorders && !this.microphone) {
|
||||||
numberOfAudioChannels: 1,
|
navigator.getUserMedia(
|
||||||
bitsPerSecond:256000,
|
{ audio: true } // 只启用音频
|
||||||
desiredSampRate: 16000
|
, function (stream) {
|
||||||
});
|
that.mediaSuccessCallback(stream);
|
||||||
that.recorders.startRecording();
|
}, function (error) {
|
||||||
that.recordSending = true;
|
that.audioPlay = false;
|
||||||
that.audioPlay = false;
|
that.tipErrorMessage(error);
|
||||||
that.inter = setInterval(() => {
|
|
||||||
if (that.seconds < 60) {
|
|
||||||
that.seconds++;
|
|
||||||
} else {
|
|
||||||
clearInterval(that.inter);
|
|
||||||
that.stopRecording();
|
|
||||||
}
|
}
|
||||||
}, 1000);
|
);
|
||||||
}, function (error) {
|
|
||||||
that.audioPlay = false;
|
|
||||||
switch (error.code || error.name) {
|
|
||||||
case 'PERMISSION_DENIED':
|
|
||||||
case 'PermissionDeniedError':
|
|
||||||
that.$message({
|
|
||||||
showClose: true,
|
|
||||||
message: '用户拒绝提供信息',
|
|
||||||
type: 'error'
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
case 'NOT_SUPPORTED_ERROR':
|
|
||||||
case 'NotSupportedError':
|
|
||||||
that.$message({
|
|
||||||
showClose: true,
|
|
||||||
message: '浏览器不支持硬件设备',
|
|
||||||
type: 'error'
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
case 'MANDATORY_UNSATISFIED_ERROR':
|
|
||||||
case 'MandatoryUnsatisfiedError':
|
|
||||||
that.$message({
|
|
||||||
showClose: true,
|
|
||||||
message: '无法发现指定的硬件设备',
|
|
||||||
type: 'error'
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
that.$message({
|
|
||||||
showClose: true,
|
|
||||||
message: '无法打开麦克风',
|
|
||||||
type: 'error'
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
);
|
}
|
||||||
}
|
}).catch(() => { console.error('操作失败!'); });
|
||||||
} else {
|
} else {
|
||||||
this.stopRecording(); // 发送语音
|
this.stopRecording(); // 发送语音
|
||||||
}
|
}
|
||||||
@ -445,6 +487,7 @@ export default {
|
|||||||
}
|
}
|
||||||
.userMessage{
|
.userMessage{
|
||||||
position: relative;
|
position: relative;
|
||||||
|
text-align: left;
|
||||||
}
|
}
|
||||||
.messageText{
|
.messageText{
|
||||||
line-height: 20px;
|
line-height: 20px;
|
@ -9,7 +9,7 @@
|
|||||||
<training-position-tip ref="trainingPositionTip" />
|
<training-position-tip ref="trainingPositionTip" />
|
||||||
<training-menu v-if="hasTraining" ref="trainingMenu" :offset-bottom="offsetBottom" />
|
<training-menu v-if="hasTraining" ref="trainingMenu" :offset-bottom="offsetBottom" />
|
||||||
<training-design v-if="trainingDesign" ref="trainingDesign" />
|
<training-design v-if="trainingDesign" ref="trainingDesign" />
|
||||||
<voice-chat-box v-if="hasVoice" :group="group" />
|
<chat-box v-if="hasVoice" ref="chatBox" :group="group" />
|
||||||
<design-training-menu v-if="trainingDesign && trainingDetail" ref="trainingMenu" :offset-bottom="offsetBottom" />
|
<design-training-menu v-if="trainingDesign && trainingDetail" ref="trainingMenu" :offset-bottom="offsetBottom" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -27,7 +27,7 @@ import TrainingTip from './trainingList/trainingTip';
|
|||||||
import TrainingPositionTip from './trainingList/trainingPositionTip.vue';
|
import TrainingPositionTip from './trainingList/trainingPositionTip.vue';
|
||||||
import TrainingMenu from './trainingList/trainingMenu';
|
import TrainingMenu from './trainingList/trainingMenu';
|
||||||
import TrainingDesign from './trainingDesign/designPane.vue';
|
import TrainingDesign from './trainingDesign/designPane.vue';
|
||||||
import VoiceChatBox from './voiceChatBox/chatBox';
|
import ChatBox from './chatBox';
|
||||||
import DesignTrainingMenu from './trainingList/designTrainingMenu';
|
import DesignTrainingMenu from './trainingList/designTrainingMenu';
|
||||||
export default {
|
export default {
|
||||||
name: 'DisplayDraft',
|
name: 'DisplayDraft',
|
||||||
@ -39,7 +39,7 @@ export default {
|
|||||||
TrainingPositionTip,
|
TrainingPositionTip,
|
||||||
TrainingMenu,
|
TrainingMenu,
|
||||||
TrainingDesign,
|
TrainingDesign,
|
||||||
VoiceChatBox,
|
ChatBox,
|
||||||
DesignTrainingMenu
|
DesignTrainingMenu
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
@ -50,6 +50,15 @@ export default {
|
|||||||
this.tipShow = false;
|
this.tipShow = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
'$store.state.trainingNew.voiceStepIndex': function(val) {
|
||||||
|
if (val > -1 && this.trainingDetail && this.trainingDetail.type === 'SINGLE') {
|
||||||
|
this.tipInit();
|
||||||
|
} else {
|
||||||
|
this.tip = '';
|
||||||
|
this.popShow = false;
|
||||||
|
this.tipShow = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
'$store.state.socket.trainingOverCount': function(val) {
|
'$store.state.socket.trainingOverCount': function(val) {
|
||||||
this.tip = '';
|
this.tip = '';
|
||||||
this.popShow = false;
|
this.popShow = false;
|
||||||
@ -73,9 +82,16 @@ export default {
|
|||||||
if (this.teachMode === ScriptMode.TEACH) {
|
if (this.teachMode === ScriptMode.TEACH) {
|
||||||
this.tipShow = true;
|
this.tipShow = true;
|
||||||
const offset = this.$store.state.config.canvasOffset;
|
const offset = this.$store.state.config.canvasOffset;
|
||||||
const stepInfo = this.$store.state.trainingNew.stepInfo;
|
let stepInfo = {};
|
||||||
|
if (this.$store.state.trainingNew.voiceStepIndex > -1) {
|
||||||
|
stepInfo = this.$store.state.trainingNew.voiceStepList[this.$store.state.trainingNew.voiceStepIndex];
|
||||||
|
if (!stepInfo) { return; }
|
||||||
|
} else {
|
||||||
|
stepInfo = this.$store.state.trainingNew.stepInfo;
|
||||||
|
}
|
||||||
const distance = 5;
|
const distance = 5;
|
||||||
this.tip = stepInfo ? stepInfo.description : '';
|
this.tip = stepInfo ? stepInfo.description : '';
|
||||||
|
console.log(stepInfo, this.tip, '***');
|
||||||
if (stepInfo.tipPosition && stepInfo.tipPosition.deviceCode) {
|
if (stepInfo.tipPosition && stepInfo.tipPosition.deviceCode) {
|
||||||
const position = this.getShapeTipPoint(stepInfo.tipPosition);
|
const position = this.getShapeTipPoint(stepInfo.tipPosition);
|
||||||
if (position) {
|
if (position) {
|
||||||
@ -92,6 +108,7 @@ export default {
|
|||||||
this.position.y -= distance;
|
this.position.y -= distance;
|
||||||
this.popTipShow();
|
this.popTipShow();
|
||||||
}
|
}
|
||||||
|
console.log(this.popShow, this.position, this.tip, '-----');
|
||||||
} else {
|
} else {
|
||||||
this.popTipHide();
|
this.popTipHide();
|
||||||
}
|
}
|
||||||
@ -145,7 +162,6 @@ export default {
|
|||||||
// 获取地图菜单按钮和对话框按钮提示显示位置
|
// 获取地图菜单按钮和对话框按钮提示显示位置
|
||||||
getOtherTipPoint(tipPosition) {
|
getOtherTipPoint(tipPosition) {
|
||||||
const domId = OperationHandler.getDomIdByOperation(tipPosition.domId);
|
const domId = OperationHandler.getDomIdByOperation(tipPosition.domId);
|
||||||
console.log(domId, '-------------');
|
|
||||||
if (!domId) { return null; }
|
if (!domId) { return null; }
|
||||||
return new Promise(async(resolve, reject) => {
|
return new Promise(async(resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
@ -172,6 +188,7 @@ export default {
|
|||||||
y: offset.y
|
y: offset.y
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
console.log('235s');
|
||||||
resolve(null);
|
resolve(null);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
@ -31,6 +31,14 @@ export default {
|
|||||||
this.trainingTipMessage = '';
|
this.trainingTipMessage = '';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
'$store.state.trainingNew.voiceStepIndex': function(val) {
|
||||||
|
if (val > -1 && this.trainingDetail.type === 'SCENE' && (this.teachMode === ScriptMode.TEACH || this.teachMode === ScriptMode.PRACTICE)) {
|
||||||
|
const stepInfo = this.$store.state.trainingNew.voiceStepList[this.$store.state.trainingNew.voiceStepIndex];
|
||||||
|
this.trainingTipMessage = stepInfo ? stepInfo.description : this.$store.state.trainingNew.stepInfo.description;
|
||||||
|
} else {
|
||||||
|
this.trainingTipMessage = '';
|
||||||
|
}
|
||||||
|
},
|
||||||
'$store.state.trainingNew.trainingSwitch': function(val) {
|
'$store.state.trainingNew.trainingSwitch': function(val) {
|
||||||
if (!val) {
|
if (!val) {
|
||||||
this.trainingTipMessage = '';
|
this.trainingTipMessage = '';
|
||||||
|
Loading…
Reference in New Issue
Block a user