|
@ -83,6 +83,7 @@
|
83
|
83
|
<div>抓拍图片</div>
|
84
|
84
|
<div>
|
85
|
85
|
<img :src="rowdata.pictureInfo.fileUrl" alt="" srcset="" style="width:100%;height:100%">
|
|
86
|
|
86
|
87
|
</div>
|
87
|
88
|
</div>
|
88
|
89
|
<div class="detail_item2">
|
|
@ -90,13 +91,14 @@
|
90
|
91
|
<div>
|
91
|
92
|
<div>
|
92
|
93
|
<!-- 修改-->
|
93
|
|
<!-- <img src="" alt="" srcset="" style="width:120px;height:160px;border-radius: 5px; "> -->
|
94
|
|
<div class="scaleimg">
|
|
94
|
<img :src="newimage" alt="" srcset="" style="width:120px;height:160px;border-radius: 5px; ">
|
|
95
|
|
|
96
|
<!-- <div class="scaleimg">
|
95
|
97
|
<div :style="{backgroundImage:style.bgimg,backgroundPosition:style.bgposition,
|
96
|
98
|
transform:style.scale,
|
97
|
99
|
width:style.width,
|
98
|
100
|
height:style.height}" class="imgcontant"></div>
|
99
|
|
</div>
|
|
101
|
</div> -->
|
100
|
102
|
<div class="bottomimg">抓拍图片</div>
|
101
|
103
|
</div>
|
102
|
104
|
<div>
|
|
@ -174,14 +176,16 @@ export default {
|
174
|
176
|
// 当前页
|
175
|
177
|
page: 1,
|
176
|
178
|
limit: 10,
|
177
|
|
style: {
|
178
|
|
bgimg: '',
|
179
|
|
bgposition: '',
|
180
|
|
scale: '',
|
181
|
|
width: '',
|
182
|
|
height: ''
|
|
179
|
// style: {
|
|
180
|
// bgimg: '',
|
|
181
|
// bgposition: '',
|
|
182
|
// scale: '',
|
|
183
|
// width: '',
|
|
184
|
// height: ''
|
183
|
185
|
|
184
|
|
}
|
|
186
|
// }
|
|
187
|
// 截取后的图片
|
|
188
|
newimage: ''
|
185
|
189
|
|
186
|
190
|
}
|
187
|
191
|
},
|
|
@ -216,25 +220,39 @@ export default {
|
216
|
220
|
if (res.data.success) {
|
217
|
221
|
// this.rowdata = res.data.data
|
218
|
222
|
this.rowdata.pictureInfo = res.data.data.pictureInfo
|
|
223
|
console.log('数据', this.rowdata.pictureInfo)
|
219
|
224
|
this.rowdata.alarmInfo = res.data.data.alarmInfo
|
220
|
|
this.style.width = res.data.data.alarmInfo.face_box[2] - res.data.data.alarmInfo.face_box[0] + 'px'
|
221
|
|
// console.log('width是', this.style.width)
|
222
|
|
this.style.height = res.data.data.alarmInfo.face_box[3] - res.data.data.alarmInfo.face_box[1] + 'px'
|
223
|
|
// console.log('height是', this.style.height)
|
224
|
|
this.style.bgimg = 'url(' + res.data.data.pictureInfo.fileUrl + ')'
|
225
|
|
// console.log('bgimg是', this.style.bgimg)
|
226
|
|
this.style.bgposition = '' + -res.data.data.alarmInfo.face_box[0] + 'px ' + -res.data.data.alarmInfo.face_box[1] + 'px'
|
|
225
|
console.log('数据', this.rowdata.alarmInfo)
|
|
226
|
// this.rowdata.alarmInfo.newImg = this.rowdata.pictureInfo.fileUrl
|
|
227
|
|
|
228
|
this.getImage()
|
|
229
|
// var loadTimer
|
|
230
|
// var imgObject = new Image()
|
|
231
|
// imgObject.setAttribute('crossOrigin', 'anonymous')
|
|
232
|
// imgObject.src = this.rowdata.pictureInfo.fileUrl
|
|
233
|
// console.log(this)
|
|
234
|
// imgObject.onload = this.onImgLoaded(loadTimer, imgObject, this.rowdata.alarmInfo)
|
|
235
|
|
|
236
|
// console.log(this.rowdata.alarmInfo.newImg)
|
|
237
|
|
|
238
|
// this.style.width = res.data.data.alarmInfo.face_box[2] - res.data.data.alarmInfo.face_box[0] + 'px'
|
|
239
|
// // console.log('width是', this.style.width)
|
|
240
|
// this.style.height = res.data.data.alarmInfo.face_box[3] - res.data.data.alarmInfo.face_box[1] + 'px'
|
|
241
|
// // console.log('height是', this.style.height)
|
|
242
|
// this.style.bgimg = 'url(' + res.data.data.pictureInfo.fileUrl + ')'
|
|
243
|
// // console.log('bgimg是', this.style.bgimg)
|
|
244
|
// this.style.bgposition = '' + -res.data.data.alarmInfo.face_box[0] + 'px ' + -res.data.data.alarmInfo.face_box[1] + 'px'
|
227
|
245
|
// console.log('bgposition是', this.style.bgposition)
|
228
|
|
// transform: scale(0.33, 0.33);
|
229
|
|
var width = res.data.data.alarmInfo.face_box[2] - res.data.data.alarmInfo.face_box[0]
|
230
|
|
var height = res.data.data.alarmInfo.face_box[3] - res.data.data.alarmInfo.face_box[1]
|
231
|
|
var scalex = 120 / width
|
232
|
|
var scaley = 160 / height
|
233
|
|
// console.log(scalex)
|
234
|
|
this.style.scale = 'scale(' + scalex + ',' + scaley + ')'
|
235
|
|
// console.log('scale是', this.style.scale)
|
236
|
|
// console.log(res.data.data)
|
237
|
|
// console.log('详情数据是', this.rowdata)
|
|
246
|
// // transform: scale(0.33, 0.33);
|
|
247
|
// var width = res.data.data.alarmInfo.face_box[2] - res.data.data.alarmInfo.face_box[0]
|
|
248
|
// var height = res.data.data.alarmInfo.face_box[3] - res.data.data.alarmInfo.face_box[1]
|
|
249
|
// var scalex = 120 / width
|
|
250
|
// var scaley = 160 / height
|
|
251
|
// // console.log(scalex)
|
|
252
|
// this.style.scale = 'scale(' + scalex + ',' + scaley + ')'
|
|
253
|
// // console.log('scale是', this.style.scale)
|
|
254
|
// // console.log(res.data.data)
|
|
255
|
// console.log('详情数据是', this.rowdata.alarmInfo)
|
238
|
256
|
|
239
|
257
|
this.detail_modal = true
|
240
|
258
|
} else {
|
|
@ -341,7 +359,41 @@ export default {
|
341
|
359
|
} else {
|
342
|
360
|
return true
|
343
|
361
|
}
|
|
362
|
},
|
|
363
|
async getImage () {
|
|
364
|
var loadTimer
|
|
365
|
var imgObject = new Image()
|
|
366
|
imgObject.setAttribute('crossOrigin', 'anonymous')
|
|
367
|
imgObject.src = this.rowdata.pictureInfo.fileUrl
|
|
368
|
var e = this.rowdata.alarmInfo
|
|
369
|
var that = this
|
|
370
|
imgObject.onload = onImgLoaded()
|
|
371
|
// eslint-disable-next-line no-return-assign
|
|
372
|
function onImgLoaded () {
|
|
373
|
if (loadTimer != null) clearTimeout(loadTimer)
|
|
374
|
if (!imgObject.complete) {
|
|
375
|
loadTimer = setTimeout(() => {
|
|
376
|
onImgLoaded()
|
|
377
|
}, 3)
|
|
378
|
} else {
|
|
379
|
that.newimage = getImagePortion(imgObject, e.face_box[2] - e.face_box[0], e.face_box[3] - e.face_box[1], e.face_box[0], e.face_box[1])
|
|
380
|
}
|
|
381
|
}
|
|
382
|
function getImagePortion (imgObj, newWidth, newHeight, startX, startY) {
|
|
383
|
var tnCanvas = document.createElement('canvas')
|
|
384
|
var tnCanvasContext = tnCanvas.getContext('2d')
|
|
385
|
tnCanvas.width = newWidth; tnCanvas.height = newHeight
|
|
386
|
var bufferCanvas = document.createElement('canvas')
|
|
387
|
var bufferContext = bufferCanvas.getContext('2d')
|
|
388
|
bufferCanvas.width = imgObj.width
|
|
389
|
bufferCanvas.height = imgObj.height
|
|
390
|
bufferContext.drawImage(imgObj, 0, 0)
|
|
391
|
tnCanvasContext.drawImage(bufferCanvas, startX, startY, newWidth, newHeight, 0, 0, newWidth, newHeight)
|
|
392
|
// console.log(tnCanvas.toDataURL())
|
|
393
|
return tnCanvas.toDataURL()
|
|
394
|
}
|
344
|
395
|
}
|
|
396
|
|
345
|
397
|
}
|
346
|
398
|
}
|
347
|
399
|
</script>
|
|
@ -400,6 +452,7 @@ export default {
|
400
|
452
|
|
401
|
453
|
border-radius: 5px;
|
402
|
454
|
overflow: hidden;
|
|
455
|
position: relative;
|
403
|
456
|
}
|
404
|
457
|
}
|
405
|
458
|
|