h5
Mr.Shi
2023-08-25 50b0f1787720062df58bf9be64b0aa8403955765
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<template>
  <div v-if="show" class="image-main">
    <!-- @click="cancel" -->
    <div class="preview_close" @click="cancel">
      <i class="el-icon-close" />
    </div>
    <el-carousel
      :height="windowHeight"
      :autoplay="false"
      indicator-position="none"
      :initial-index="index"
      @change="onSlideChange"
    >
      <el-carousel-item v-for="(item, i) in multiFilesList" :key="i">
        <img v-if="item.type === 0" :src="resourcePath + item.fileurl" alt="" />
        <video ref="video" v-else-if="item.type === 1" :src="resourcePath + item.fileurl" controls="controls"></video>
      </el-carousel-item>
    </el-carousel>
  
  </div>
</template>
 
<script>
 
export default {
  name: 'ShowImage',
  
  data () {
    return {
      show: false,
      multiFilesList: [],
      temp: {},
      resourcePath: '',
      index: 0,
      windowHeight: document.documentElement.clientHeight + 'px',
    }
  },
  mounted() {
    const that = this;
    window.addEventListener('resize', () => {
      that.windowHeight = document.documentElement.clientHeight + 'px'
    })
  },
  methods: {
    open (multiFilesList, resourcePath, index) {
      this.show = true
      this.multiFilesList = multiFilesList
      this.temp = multiFilesList[index]
      this.resourcePath = resourcePath
      this.index = index
    },
    cancel () {
      this.show = false
    },
    onSlideChange () {
      let video = this.$refs.video
      if (!video.length) return
      video.forEach((item) => {
          item.pause()
      })
    }
  }
}
</script>
 
<style scoped lang="scss">
.image-main {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba($color: #000000, $alpha: 0.4);
  z-index: 9999;
  .preview_close {
      position: fixed;
      right: 50px;
      top: 50px;
      width: 70px;
      height: 70px;
      // border-radius: 50%;
      // background: #B2B2B2;
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 99999;
      .el-icon-close {
        font-size: 50px;
        color: #fff;
      }
  }
  img {
    max-width: 100%;
    max-height: 100%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }
  video {
    max-width: 100%;
    max-height: 100%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }
  .preview_content {
        height: 100%;
        position: relative;
        top: 50%;
        left: 0;
        transform: translate(0, -50%);
        .swiper {
            width: 100%;
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
            .swiper-slide {
                width: 100%;
                height: 100%;
                position: relative;
                .preview_content_box {
                    width: 100%;
                    position: absolute;
                    top: 50%;
                    left: 50%;
                    transform: translate(-50%, -50%);
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    
                }
            }
        }
    }
  // .image-item-style {
  //   position: relative;
  //   width: 120px;
  //   height: 120px;
  //   overflow: hidden;
  //   margin-right: 10px;
  //   margin-bottom: 10px;
  //   .video-inner-style {
  //     max-width: 100%;
  //     height: 100%;
  //     cursor: pointer;
  //   }
  //   .el-icon-caret-right {
        // position: absolute;
        // top: 50%;
        // left: 50%;
        // transform: translate(-50%, -50%);
  //       // height: 10%;
  //       // width: 10%;
  //       font-size: 30px;
  //       color: rgba($color: #fff, $alpha: 0.6);
  //     }
  //   // video:hover {
  //   // }
  //   .image-inner-style {
  //     max-width: 100%;
  //     height: 100%;
  //     cursor: pointer;
  //   }
  // }
}
</style>