This commit is contained in:
zyy 2020-04-21 14:14:44 +08:00
commit 778c2059df
4 changed files with 44 additions and 14 deletions

View File

@ -85,7 +85,7 @@ export default {
panelShow: true, panelShow: true,
ibpPart: '', ibpPart: '',
showStation: '', showStation: '',
stationList: '', stationList: [],
showSelectStation: false, showSelectStation: false,
mapViewLoadedOver: false mapViewLoadedOver: false
}; };

View File

@ -66,7 +66,7 @@ export default {
} }
}, },
stationList: { stationList: {
type: Object, type: Array,
default() { default() {
return []; return [];
} }

View File

@ -75,7 +75,9 @@ export default {
this.loading = false; this.loading = false;
this.dialogShow = true; this.dialogShow = true;
this.loadInitData(); this.loadInitData();
this.reloadTable(); if (this.mapId) {
this.reloadTable();
}
}, },
doClose() { doClose() {
this.dialogShow = false; this.dialogShow = false;

View File

@ -31,6 +31,7 @@
</div> </div>
</ul> </ul>
<div v-if="recordSending" class="chat_record_tip"> <div v-if="recordSending" class="chat_record_tip">
<div id="record_progress_bar" :style="'width:'+100/60*seconds+'%'" />
<div class="record_icon" /> <div class="record_icon" />
<div class="record_tip_text">正在录音...</div> <div class="record_tip_text">正在录音...</div>
<div class="record_tip_confirm" @click="stopRecording()">确定</div> <div class="record_tip_confirm" @click="stopRecording()">确定</div>
@ -75,6 +76,8 @@ export default {
textList: [], textList: [],
recordSending:false, recordSending:false,
text: '', text: '',
seconds:0,
inter:null,
recorders: null, recorders: null,
sending: false, sending: false,
disabled:true, disabled:true,
@ -147,7 +150,6 @@ export default {
startRecording() { startRecording() {
const that = this; const that = this;
if (!this.recordSending && !this.recorders && !this.microphone) { if (!this.recordSending && !this.recorders && !this.microphone) {
debugger;
navigator.getUserMedia( navigator.getUserMedia(
{ audio: true } // { audio: true } //
, function (stream) { , function (stream) {
@ -158,6 +160,13 @@ export default {
}); });
that.recorders.startRecording(); that.recorders.startRecording();
that.recordSending = true; that.recordSending = true;
that.inter = setInterval(() => {
if (that.seconds < 60) {
that.seconds++;
} else {
clearInterval(that.inter);
}
}, 1000);
}, function (error) { }, function (error) {
switch (error.code || error.name) { switch (error.code || error.name) {
case 'PERMISSION_DENIED': case 'PERMISSION_DENIED':
@ -209,40 +218,42 @@ export default {
this.recorders.stopRecording(function(blobURL) { this.recorders.stopRecording(function(blobURL) {
const data = URL.createObjectURL(that.recorders.getBlob()); const data = URL.createObjectURL(that.recorders.getBlob());
console.log('--------', data); console.log('--------', data);
clearInterval(that.inter);
that.seconds = 0;
const blob = that.recorders.getBlob(); const blob = that.recorders.getBlob();
const fd = new FormData(); const fd = new FormData();
fd.append('file', blob); fd.append('file', blob);
chatWithAudio(fd, that.$route.query.group).then((res)=>{ chatWithAudio(fd, that.$route.query.group).then((res)=>{
this.recordSending = false; this.recordSending = false;
this.$message({ that.$message({
showClose: true, showClose: true,
message: '语音发送成功', message: '语音发送成功',
type: 'success' type: 'success'
}); });
}).catch(error => { }).catch(error => {
// this.sending = false; // this.sending = false;
this.recordSending = false; that.recordSending = false;
const message = JSON.parse(error.message); const message = JSON.parse(error.message);
if (message.err_no == 3301) { if (message.err_no == 3301) {
this.$message({ that.$message({
showClose: true, showClose: true,
message: '音频质量有问题', message: '音频质量有问题',
type: 'error' type: 'error'
}); });
} else if (message.err_no == 3308) { } else if (message.err_no == 3308) {
this.$message({ that.$message({
showClose: true, showClose: true,
message: '音频过长,建议60s以下', message: '音频过长,建议60s以下',
type: 'error' type: 'error'
}); });
} else if (message.err_no == 3314) { } else if (message.err_no == 3314) {
this.$message({ that.$message({
showClose: true, showClose: true,
message: '音频太短,建议重录', message: '音频太短,建议重录',
type: 'error' type: 'error'
}); });
} else { } else {
this.$message({ that.$message({
showClose: true, showClose: true,
message: '网络问题,请重试', message: '网络问题,请重试',
type: 'error' type: 'error'
@ -309,8 +320,14 @@ export default {
// } // }
}, },
cancleRecording() { cancleRecording() {
this.recordSending = false; if (this.microphone) {
this.recorders = null; clearInterval(this.inter);
this.seconds = 0;
this.microphone.stop();
this.microphone = null;
this.recordSending = false;
this.recorders = null;
}
}, },
playAudio(nor) { playAudio(nor) {
this.$refs.audio.src = nor.src; this.$refs.audio.src = nor.src;
@ -435,6 +452,12 @@ export default {
} }
} }
#record_progress_bar{
height: 100%;
position: absolute;
background: #bbe5f5;
}
.chat_record_tip{ .chat_record_tip{
height: 28px; height: 28px;
display: inline-block; display: inline-block;
@ -442,7 +465,6 @@ export default {
width: 100%; width: 100%;
font-size: 13px; font-size: 13px;
border-top: 1px #d8dce5 solid; border-top: 1px #d8dce5 solid;
padding: 6px 0px 6px 4px;
position: absolute; position: absolute;
bottom: 0; bottom: 0;
right: 0; right: 0;
@ -453,15 +475,21 @@ export default {
height: 8px; height: 8px;
background: #25d825; background: #25d825;
border-radius: 10px; border-radius: 10px;
margin-left: 3px; left: 7px;
margin-right: 0px; margin-right: 0px;
box-shadow: -1px 0px 3px #6d6d6d; box-shadow: -1px 0px 3px #6d6d6d;
border: 1px #28d228 solid; border: 1px #28d228 solid;
position: absolute;
top: 10px;
} }
.record_tip_text{ .record_tip_text{
display: inline-block; display: inline-block;
font-size: 12px; font-size: 12px;
margin-left: 3px; margin-left: 3px;
// padding: 8px 0px 6px 0px;
position: absolute;
top: 8px;
left:20px
} }
.record_tip_confirm{ .record_tip_confirm{
position: absolute; position: absolute;