long
2023-03-03 9860e221460a0a4ac1903dad2c97160d0eed0e63
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
<template>
  <div class="pop-box">
    <!-- 已加载 -->
    <div v-if="data.fileUrl">
      <el-image :src="data.fileUrl" class="img" fit="contain" :preview-src-list="[data.fileUrl]" />
    </div>
    <!-- 加载失败 -->
    <div v-else class="com_chat_notx">[图片]</div>
    <!-- <div v-else class="no-box" @click="tapNoReal">
      <i class="el-icon-picture img-icon" />
      <div class="download-btn" :class="{'show':loading}">
        <i :class="loading?'el-icon-loading':'el-icon-download'" />
      </div>
    </div> -->
  </div>
</template>
 
<script>
export default {
  name: 'ImagePop',
  props: {
    // 数据
    data: {
      type: Object,
      default: null
    },
    // 方向
    direction: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      loading: false
    }
  },
  // watch: {
  //   data(value) {
  //     if (value && value.fileUrl) this.loading = false
  //   }
  // },
  mounted() {
  },
  methods: {
    // 点击获取真实数据
    tapNoReal() {
      if (this.loading) return
      this.loading = true
      this.$emit('tapNoReal')
    }
  }
}
</script>
 
<style scoped>
.pop-box .img {
  width: 150px;
  min-height: 150px;
  border-radius: 4px;
  display: block;
}
 
.pop-box .no-box {
  position: relative;
  width: 60px;
  height: 60px;
  cursor: pointer;
  border-radius: 4px;
  overflow: hidden;
}
 
.pop-box .no-box .img-icon {
  font-size: 60px;
  text-align: center;
}
 
.pop-box .no-box:hover .download-btn {
  opacity: 1;
  transition: opacity .2s;
}
 
.pop-box .no-box .download-btn.show {
  opacity: 1;
}
 
.pop-box .no-box .download-btn {
  opacity: 0;
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  text-align: center;
  font-size: 30px;
  line-height: 60px;
  color: #fff;
  background: rgba(0, 0, 0, 0.5);
}
 
</style>