Commit b19a45dc authored by caicaicai's avatar caicaicai

修改

parent e69a32f1
......@@ -173,8 +173,8 @@ export default {
let array1 = [];
res.data.line.forEach((item,index)=>{
let array2 = [];
array2.push(item.lat);
array2.push(item.lon);
array2.push(item.lat);
array2.push(1000);
array1.push(array2);
})
......
......@@ -171,7 +171,8 @@
<slot name="bottom"></slot>
</div>
<audio controls currentTime autoplay :src='srcUrl' style="display:none;"></audio>
<audio controls currentTime autoplay :src='srcUrl' style="display:none;"></audio>
<!-- 语音发起dialog -->
<el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="30%">
......@@ -678,6 +679,7 @@ export default {
})
carNumberString = carNumberString + 'pcBigScreen';
this.carAllNumberString = carNumberString;
var This=this;
if(!this.recLogLast){
this.reclog("请先录音,然后停止后再上传",1);
......@@ -690,38 +692,14 @@ export default {
};
var blob=this.recLogLast.res.blob;
//本例子假设使用原始XMLHttpRequest请求方式,实际使用中自行调整为自己的请求方式
//录音结束时拿到了blob文件对象,可以用FileReader读取出内容,或者用FormData上传
var api="https://xx.xx/test_request";
var onreadystatechange=function(title){
return function(){
if(xhr.readyState==4){
if(xhr.status==200){
This.reclog(title+"上传成功",2);
}else{
This.reclog(title+"没有完成上传,演示上传地址无需关注上传结果,只要浏览器控制台内Network面板内看到的请求数据结构是预期的就ok了。", "#d8c1a0");
console.error(title+"上传失败",xhr.status,xhr.responseText);
};
};
};
};
This.reclog("开始上传到"+api+",请求稍后...","#f60");
/***方式一:将blob文件转成base64纯文本编码,使用普通application/x-www-form-urlencoded表单上传***/
/***方式一:将blob文件转成base64纯文本编码 ***/
var reader=new FileReader();
reader.onloadend=function(){
var postData="";
postData+="mime="+encodeURIComponent(blob.type);//告诉后端,这个录音是什么格式的,可能前后端都固定的mp3可以不用写
postData+="&upfile_b64="+encodeURIComponent((/.+;\s*base64\s*,\s*(.+)$/i.exec(reader.result)||[])[1]) //录音文件内容,后端进行base64解码成二进制
//...其他表单参数
// var xhr=new XMLHttpRequest();
// xhr.open("POST", api);
// xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
// xhr.onreadystatechange=onreadystatechange("上传方式一【Base64】");
// xhr.send(postData);
//发送语音数据
if (This.websocket.readyState == 1) { // that.websock.readyState = 1 表示连接成功,可以立即发送信息
This.websocketsend(`{"toUserId":"${This.carAllNumberString}","contentText":"${postData}","fromUserId":"${This.dialogTitle1}"}`);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment