784f3522 by renchao@pashanhoo.com

style:捷宇高拍仪

1 parent 28f8b95d
<!--
* @Description:
* @Autor: renchao
* @LastEditTime: 2023-11-14 13:25:42
* @LastEditTime: 2023-12-13 14:19:09
-->
<template>
<div class="rlPopup">
......@@ -12,7 +12,8 @@
<i class="el-icon-arrow-right"></i>
</div>
<div class="img-list-wrap" v-Loading="loading">
<img src="http://127.0.0.1:38088/video=stream&camidx=0" v-if="isScan" alt="高拍仪">
<img id="photo" src="" v-show="isScan && this.BASE_API.gaopaiyi=='jy'" alt="高拍仪捷宇">
<img src="http://127.0.0.1:38088/video=stream&camidx=0" v-if="isScan && this.BASE_API.gaopaiyi=='lt'" alt="高拍仪">
<div v-for="(img, i) in previewImg.imgList" :key="i" v-else>
<photo-zoom :url="img.fjurl" :bigWidth="165" v-if="i === previewImg.index" :scale="2"
overlayStyle="width: 100%;height:100%">
......@@ -89,6 +90,7 @@
showViewer: false,
initialIndex: 0,
allLi: [],
webSocket: null
}
},
watch: {
......@@ -107,9 +109,36 @@
}
},
created () {
let that = this
this.maxLength = 0;
this.allLi = _.cloneDeep(this.previewImg.imgList).map(item => item.fjurl)
this.thumbnailImages = this.previewImg.imgList
if (this.BASE_API.gaopaiyi == 'jy') {
this.webSocket = new WebSocket('ws://localhost:1818');
this.webSocket.onmessage = function (event) {
let begin_data = "data:image/jpeg;base64,";
document.getElementById('photo').src = begin_data + event.data;
if (event.data.indexOf('BeginsGetBase64') >= 0) {
let blob = that.dataURLtoBlob('data:image/png;base64,' + event.data.replace('BeginsGetBase64', '').replace('EndsGetBase64', ''));
let file = that.blobToFile(blob);
var formData = new FormData();
formData.append('file', file)
formData.append("bsmSj", that.previewImg.bsmSj);
if (that.previewImg.imgList.length > 0) {
formData.append("index", that.previewImg.imgList[that.previewImg.index].sxh);
}
uploadSjClmx(formData).then((res) => {
if (res.code == 200) {
that.$emit('updateList', { children: res.result, bsmSj: that.previewImg.bsmSj })
that.$message({
message: '上传成功!',
type: 'success'
})
}
})
}
}
}
},
computed: {
isFirst () {
......@@ -164,28 +193,32 @@
* @description: 拍照
* @author: renchao
*/
handleViewScan () {
function dataURLtoBlob (base64String) {
const arr = base64String.split(',');
if (arr.length !== 2) {
throw new Error('Invalid Base64 format');
}
const mime = arr[0].match(/:(.*?);/)[1];
if (!mime) {
throw new Error('Cannot retrieve MIME type');
}
const bstr = atob(arr[1]);
const n = bstr.length;
const u8arr = new Uint8Array(n);
for (let i = 0; i < n; i++) {
u8arr[i] = bstr.charCodeAt(i);
}
return new Blob([u8arr], { type: mime });
dataURLtoBlob (base64String) {
const arr = base64String.split(',');
if (arr.length !== 2) {
throw new Error('Invalid Base64 format');
}
const mime = arr[0].match(/:(.*?);/)[1];
if (!mime) {
throw new Error('Cannot retrieve MIME type');
}
const bstr = atob(arr[1]);
const n = bstr.length;
const u8arr = new Uint8Array(n);
for (let i = 0; i < n; i++) {
u8arr[i] = bstr.charCodeAt(i);
}
function blobToFile (blob) {
let name = getUuid(8) + '.jpg'
const file = new File([blob], name);
return file;
return new Blob([u8arr], { type: mime });
},
blobToFile (blob) {
let name = getUuid(8) + '.jpg'
const file = new File([blob], name);
return file;
},
handleViewScan () {
if (this.BASE_API.gaopaiyi == 'jy') {
this.webSocket.send('sGetBase64');
return
}
getAltimeterInfo().then(res => {
let blob = dataURLtoBlob('data:image/png;base64,' + res.data.photoBase64);
......
......@@ -12,8 +12,7 @@
<i class="el-icon-arrow-right"></i>
</div>
<div class="img-list-wrap" v-Loading="loading">
<img src="http://127.0.0.1:38088/video=stream&camidx=0" v-if="isScan" alt="">
<div v-for="(img, i) in previewImg.imgList" :key="i" v-else>
<div v-for="(img, i) in previewImg.imgList" :key="i">
<photo-zoom :url="img.fjurl" :bigWidth="165" v-if="i === previewImg.index" :scale="2"
overlayStyle="width: 100%;height:100%">
</photo-zoom>
......@@ -60,8 +59,6 @@
loading: false,
key: 0,
isScan: false,
// 打开高拍仪
scanTitle: '打开高拍仪',
transform: {
scale: 1,
degree: 0
......