1d73dc48
wuxw
继续晚上巡检功能
|
1
|
<template>
|
03f63ab4
wuxw
优化到商户信息
|
2
3
4
5
|
<div class="view-image-container">
<el-dialog
:visible.sync="visible"
:fullscreen="true"
|
1d73dc48
wuxw
继续晚上巡检功能
|
6
|
:show-close="false"
|
03f63ab4
wuxw
优化到商户信息
|
7
8
9
10
11
12
13
14
15
16
17
18
|
custom-class="image-viewer-dialog"
>
<div class="image-wrapper">
<img
:src="imageInfo.url"
:style="{
width: imageInfo.width + 'px',
height: imageInfo.height + 'px'
}"
@error="handleImageError"
/>
<i class="el-icon-close close-icon" @click="close"></i>
|
1d73dc48
wuxw
继续晚上巡检功能
|
19
20
21
22
23
24
25
26
27
28
|
</div>
</el-dialog>
</div>
</template>
<script>
export default {
name: 'ViewImage',
data() {
return {
|
03f63ab4
wuxw
优化到商户信息
|
29
30
31
32
33
34
|
visible: false,
imageInfo: {
url: '',
width: 800,
height: 800
}
|
1d73dc48
wuxw
继续晚上巡检功能
|
35
36
37
|
}
},
methods: {
|
03f63ab4
wuxw
优化到商户信息
|
38
39
40
|
open(params) {
this.imageInfo.url = params.url
this.visible = true
|
1d73dc48
wuxw
继续晚上巡检功能
|
41
|
|
03f63ab4
wuxw
优化到商户信息
|
42
|
// 动态计算图片尺寸
|
1d73dc48
wuxw
继续晚上巡检功能
|
43
|
const img = new Image()
|
03f63ab4
wuxw
优化到商户信息
|
44
|
img.src = params.url
|
1d73dc48
wuxw
继续晚上巡检功能
|
45
|
img.onload = () => {
|
03f63ab4
wuxw
优化到商户信息
|
46
47
48
49
50
51
52
53
54
55
56
|
const imgScale = img.width / img.height
this.imageInfo.width = 800
this.imageInfo.height = 800 / imgScale
}
},
close() {
this.visible = false
this.imageInfo = {
url: '',
width: 800,
height: 800
|
1d73dc48
wuxw
继续晚上巡检功能
|
57
58
|
}
},
|
03f63ab4
wuxw
优化到商户信息
|
59
60
|
handleImageError(e) {
e.target.src = '/img/noPhoto.jpg'
|
1d73dc48
wuxw
继续晚上巡检功能
|
61
62
63
64
65
66
|
}
}
}
</script>
<style lang="scss" scoped>
|
03f63ab4
wuxw
优化到商户信息
|
67
68
69
|
.view-image-container {
.image-viewer-dialog {
background-color: rgba(0, 0, 0, 0.8);
|
1d73dc48
wuxw
继续晚上巡检功能
|
70
|
|
03f63ab4
wuxw
优化到商户信息
|
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
.image-wrapper {
position: relative;
display: flex;
justify-content: center;
align-items: center;
height: 100%;
img {
max-width: 90%;
max-height: 90%;
object-fit: contain;
}
.close-icon {
position: absolute;
top: 20px;
right: 20px;
font-size: 24px;
color: #fff;
cursor: pointer;
z-index: 2001;
&:hover {
color: #f56c6c;
}
}
|
1d73dc48
wuxw
继续晚上巡检功能
|
97
98
99
100
|
}
}
}
</style>
|