style:捷宇高拍仪
Showing
2 changed files
with
57 additions
and
27 deletions
1 | <!-- | 1 | <!-- |
2 | * @Description: | 2 | * @Description: |
3 | * @Autor: renchao | 3 | * @Autor: renchao |
4 | * @LastEditTime: 2023-11-14 13:25:42 | 4 | * @LastEditTime: 2023-12-13 14:19:09 |
5 | --> | 5 | --> |
6 | <template> | 6 | <template> |
7 | <div class="rlPopup"> | 7 | <div class="rlPopup"> |
... | @@ -12,7 +12,8 @@ | ... | @@ -12,7 +12,8 @@ |
12 | <i class="el-icon-arrow-right"></i> | 12 | <i class="el-icon-arrow-right"></i> |
13 | </div> | 13 | </div> |
14 | <div class="img-list-wrap" v-Loading="loading"> | 14 | <div class="img-list-wrap" v-Loading="loading"> |
15 | <img src="http://127.0.0.1:38088/video=stream&camidx=0" v-if="isScan" alt="高拍仪"> | 15 | <img id="photo" src="" v-show="isScan && this.BASE_API.gaopaiyi=='jy'" alt="高拍仪捷宇"> |
16 | <img src="http://127.0.0.1:38088/video=stream&camidx=0" v-if="isScan && this.BASE_API.gaopaiyi=='lt'" alt="高拍仪"> | ||
16 | <div v-for="(img, i) in previewImg.imgList" :key="i" v-else> | 17 | <div v-for="(img, i) in previewImg.imgList" :key="i" v-else> |
17 | <photo-zoom :url="img.fjurl" :bigWidth="165" v-if="i === previewImg.index" :scale="2" | 18 | <photo-zoom :url="img.fjurl" :bigWidth="165" v-if="i === previewImg.index" :scale="2" |
18 | overlayStyle="width: 100%;height:100%"> | 19 | overlayStyle="width: 100%;height:100%"> |
... | @@ -89,6 +90,7 @@ | ... | @@ -89,6 +90,7 @@ |
89 | showViewer: false, | 90 | showViewer: false, |
90 | initialIndex: 0, | 91 | initialIndex: 0, |
91 | allLi: [], | 92 | allLi: [], |
93 | webSocket: null | ||
92 | } | 94 | } |
93 | }, | 95 | }, |
94 | watch: { | 96 | watch: { |
... | @@ -107,9 +109,36 @@ | ... | @@ -107,9 +109,36 @@ |
107 | } | 109 | } |
108 | }, | 110 | }, |
109 | created () { | 111 | created () { |
112 | let that = this | ||
110 | this.maxLength = 0; | 113 | this.maxLength = 0; |
111 | this.allLi = _.cloneDeep(this.previewImg.imgList).map(item => item.fjurl) | 114 | this.allLi = _.cloneDeep(this.previewImg.imgList).map(item => item.fjurl) |
112 | this.thumbnailImages = this.previewImg.imgList | 115 | this.thumbnailImages = this.previewImg.imgList |
116 | if (this.BASE_API.gaopaiyi == 'jy') { | ||
117 | this.webSocket = new WebSocket('ws://localhost:1818'); | ||
118 | this.webSocket.onmessage = function (event) { | ||
119 | let begin_data = "data:image/jpeg;base64,"; | ||
120 | document.getElementById('photo').src = begin_data + event.data; | ||
121 | if (event.data.indexOf('BeginsGetBase64') >= 0) { | ||
122 | let blob = that.dataURLtoBlob('data:image/png;base64,' + event.data.replace('BeginsGetBase64', '').replace('EndsGetBase64', '')); | ||
123 | let file = that.blobToFile(blob); | ||
124 | var formData = new FormData(); | ||
125 | formData.append('file', file) | ||
126 | formData.append("bsmSj", that.previewImg.bsmSj); | ||
127 | if (that.previewImg.imgList.length > 0) { | ||
128 | formData.append("index", that.previewImg.imgList[that.previewImg.index].sxh); | ||
129 | } | ||
130 | uploadSjClmx(formData).then((res) => { | ||
131 | if (res.code == 200) { | ||
132 | that.$emit('updateList', { children: res.result, bsmSj: that.previewImg.bsmSj }) | ||
133 | that.$message({ | ||
134 | message: '上传成功!', | ||
135 | type: 'success' | ||
136 | }) | ||
137 | } | ||
138 | }) | ||
139 | } | ||
140 | } | ||
141 | } | ||
113 | }, | 142 | }, |
114 | computed: { | 143 | computed: { |
115 | isFirst () { | 144 | isFirst () { |
... | @@ -164,28 +193,32 @@ | ... | @@ -164,28 +193,32 @@ |
164 | * @description: 拍照 | 193 | * @description: 拍照 |
165 | * @author: renchao | 194 | * @author: renchao |
166 | */ | 195 | */ |
167 | handleViewScan () { | 196 | dataURLtoBlob (base64String) { |
168 | function dataURLtoBlob (base64String) { | 197 | const arr = base64String.split(','); |
169 | const arr = base64String.split(','); | 198 | if (arr.length !== 2) { |
170 | if (arr.length !== 2) { | 199 | throw new Error('Invalid Base64 format'); |
171 | throw new Error('Invalid Base64 format'); | 200 | } |
172 | } | 201 | const mime = arr[0].match(/:(.*?);/)[1]; |
173 | const mime = arr[0].match(/:(.*?);/)[1]; | 202 | if (!mime) { |
174 | if (!mime) { | 203 | throw new Error('Cannot retrieve MIME type'); |
175 | throw new Error('Cannot retrieve MIME type'); | 204 | } |
176 | } | 205 | const bstr = atob(arr[1]); |
177 | const bstr = atob(arr[1]); | 206 | const n = bstr.length; |
178 | const n = bstr.length; | 207 | const u8arr = new Uint8Array(n); |
179 | const u8arr = new Uint8Array(n); | 208 | for (let i = 0; i < n; i++) { |
180 | for (let i = 0; i < n; i++) { | 209 | u8arr[i] = bstr.charCodeAt(i); |
181 | u8arr[i] = bstr.charCodeAt(i); | ||
182 | } | ||
183 | return new Blob([u8arr], { type: mime }); | ||
184 | } | 210 | } |
185 | function blobToFile (blob) { | 211 | return new Blob([u8arr], { type: mime }); |
186 | let name = getUuid(8) + '.jpg' | 212 | }, |
187 | const file = new File([blob], name); | 213 | blobToFile (blob) { |
188 | return file; | 214 | let name = getUuid(8) + '.jpg' |
215 | const file = new File([blob], name); | ||
216 | return file; | ||
217 | }, | ||
218 | handleViewScan () { | ||
219 | if (this.BASE_API.gaopaiyi == 'jy') { | ||
220 | this.webSocket.send('sGetBase64'); | ||
221 | return | ||
189 | } | 222 | } |
190 | getAltimeterInfo().then(res => { | 223 | getAltimeterInfo().then(res => { |
191 | let blob = dataURLtoBlob('data:image/png;base64,' + res.data.photoBase64); | 224 | let blob = dataURLtoBlob('data:image/png;base64,' + res.data.photoBase64); | ... | ... |
... | @@ -12,8 +12,7 @@ | ... | @@ -12,8 +12,7 @@ |
12 | <i class="el-icon-arrow-right"></i> | 12 | <i class="el-icon-arrow-right"></i> |
13 | </div> | 13 | </div> |
14 | <div class="img-list-wrap" v-Loading="loading"> | 14 | <div class="img-list-wrap" v-Loading="loading"> |
15 | <img src="http://127.0.0.1:38088/video=stream&camidx=0" v-if="isScan" alt=""> | 15 | <div v-for="(img, i) in previewImg.imgList" :key="i"> |
16 | <div v-for="(img, i) in previewImg.imgList" :key="i" v-else> | ||
17 | <photo-zoom :url="img.fjurl" :bigWidth="165" v-if="i === previewImg.index" :scale="2" | 16 | <photo-zoom :url="img.fjurl" :bigWidth="165" v-if="i === previewImg.index" :scale="2" |
18 | overlayStyle="width: 100%;height:100%"> | 17 | overlayStyle="width: 100%;height:100%"> |
19 | </photo-zoom> | 18 | </photo-zoom> |
... | @@ -60,8 +59,6 @@ | ... | @@ -60,8 +59,6 @@ |
60 | loading: false, | 59 | loading: false, |
61 | key: 0, | 60 | key: 0, |
62 | isScan: false, | 61 | isScan: false, |
63 | // 打开高拍仪 | ||
64 | scanTitle: '打开高拍仪', | ||
65 | transform: { | 62 | transform: { |
66 | scale: 1, | 63 | scale: 1, |
67 | degree: 0 | 64 | degree: 0 | ... | ... |
-
Please register or sign in to post a comment