1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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
97
98
99
100
101
102
| <template>
| <div class="image-message no-select">
| <el-image
| fit="cover"
| :src="src1"
| :lazy="true"
| :style="getImgStyle(src1)"
| @click="open"
| v-if="status!=1"
| >
| <div slot="error" class="image-slot">图片加载失败...</div>
| <div slot="placeholder" class="image-slot">图片加载中...</div>
| </el-image>
| <div class="loading" v-if="status==1"></div>
| </div>
| </template>
| <script>
| import { imgZoom } from '@/utils/functions'
| import { openImage} from "@/common/image";
| export default {
| data () {
| return {
| status : 0,
| src1 : "/load.png"
| }
| },
| name: 'ImageMessage',
| props: {
| src: {
| type: String,
| default: '',
| },
| },
| methods: {
| getImgStyle(url) {
| return imgZoom(url, 200)
| },
| open(){
| switch(this.status)
| {
| case 0: //点击加载
|
| this.status = 1;
| setTimeout(()=>{
| this.src1 = this.src;
| this.status = 2;
| },1500);
| break;
| case 2: //打开界面
| openImage(this.src)
| break;
| case 0:
| break;
| }
| }
| },
| }
| </script>
| <style lang="less" scoped>
| .image-message {
| /deep/.el-image {
| border-radius: 5px;
| cursor: pointer;
| background: #f1efef;
|
| .image-slot {
| display: flex;
| justify-content: center;
| align-items: center;
| width: 100%;
| height: 100%;
| font-size: 13px;
| color: #908686;
| background: #efeaea;
| }
| }
| }
| </style>
|
| <style scoped>
| .loading {
| position: relative;
| width: 200px;
| height: 200px;
| border: 2px solid #000;
| border-top-color: rgba(0, 0, 0, 0.2);
| border-right-color: rgba(0, 0, 0, 0.2);
| border-bottom-color: rgba(0, 0, 0, 0.2);
| border-radius: 100%;
|
| animation: circle infinite 0.75s linear;
| }
|
| @keyframes circle {
| 0% {
| transform: rotate(0);
| }
| 100% {
| transform: rotate(360deg);
| }
| }
| </style>
|
|