ZhangXianQiang
2024-03-07 b50dfd566774dea66153f97fe300b46de0baed1c
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
<!-- 交通宣传 -->
 
 
<template>
  <RightTitle title="交通宣传">
    <template #top>
      <div class="select-container flex">
        <div class="item whitespace-no-wrap cursor-pointer" :class="{ 'select-active': item.isActive }"
          v-for="item in selectItems" :key="item.itemIndex" @click="changeSelect(item)">
          {{ item.name }}
        </div>
      </div>
    </template>
    <template #content>
      <div class="content-container flex flex-wrap justify-between content-between">
        <div class="content-item" v-for="item in contentList" :key="item.itemIndex" @click="openVideo(item)">
          <div class="content-wrapper">
            <div class="content-video-info">
              <img :src="item.image" class="video-cover">
              <div class="video-icon">
                <el-icon>
                  <VideoPlay />
                </el-icon>
              </div>
            </div>
            <div class="content-video-name">
              {{ item.unit }}
            </div>
          </div>
        </div>
      </div>
    </template>
  </RightTitle>
 
  <div class="video-container" v-show="isShowVideo">
    <div class="video-wrapper">
      <video :src="testVideo" ref="videoDom" class="video-player" controls></video>
      <div class="close-btn flex justify-center items-center" @click="closeVideo">X</div>
    </div>
  </div>
</template>
 
<script setup>
import { require } from '@/utils/require.js';
 
import Test1 from '@/assets/img/test_img/t4.jpg';
import Test2 from '@/assets/img/test_img/t5.jpg';
import Test3 from '@/assets/img/test_img/t6.jpg';
import Test4 from '@/assets/img/test_img/t7.jpg';
 
import video1 from '@/assets/video/video1.mp4';
import video2 from '@/assets/video/video2.mp4';
 
 
import RightTitle from "@/components/right-title";
import { ref } from 'vue';
 
// 测试视频
const testVideo = ref('');
const isShowVideo = ref(false);
const videoDom = ref(null);
const selectItems = ref([
  { itemIndex: 1, name: '交通宣传', isActive: true },
  { itemIndex: 2, name: '交通事故', isActive: false },
]);
 
const contentList = ref([
  {
    itemIndex: 1,
    time: '2023 12-12',
    type: '道路隐患',
    unit: '全国交通安全日',
    rectTime: '2023-13-23',
    state: '抢修中',
    image: Test1,
    video: video1
  },
  {
    itemIndex: 2,
    time: '2023 12-12',
    type: '道路隐患',
    unit: '冬季交安宣传忙 营造文明出行好氛围',
    rectTime: '2023-13-23',
    state: '抢修中',
    image: Test2,
    video: video2
  },
  {
    itemIndex: 3,
    time: '2023 12-12',
    type: '道路隐患',
    unit: '高速交警强化宣传提示 确保春运交通安全',
    rectTime: '2023-13-23',
    state: '抢修中',
    image: Test3,
    video: video1
  },
  {
    itemIndex: 4,
    time: '2023 12-12',
    type: '道路隐患',
    unit: '云哨警示风险自纠',
    rectTime: '2023-13-23',
    state: '抢修中',
    image: Test4,
    video: video2
  },
]);
 
const changeSelect = (selectItem) => {
  selectItems.value.map(item => item.isActive = false);
  selectItem.isActive = true;
}
 
const openVideo = (item) => {
  isShowVideo.value = true;
  testVideo.value = item.video;
  setTimeout(() => {
    videoDom.value.play();
  },500);
}
 
const closeVideo = () => {
  isShowVideo.value = false;
  videoDom.value.pause();
}
 
 
</script>
 
<style scoped lang="scss">
.select-container {
  flex-shrink: 0;
}
 
.item {
  margin: 0 8px;
  padding: 10px 14px;
  font-size: 14px;
  background: rgba(67, 102, 155, 0.4);
  border: 1px solid rgba(47, 91, 157, 0.8);
  flex-shrink: 0;
  color: #5B83BD;
  font-family: 'PingFang SC';
}
 
.select-active {
  color: #fff;
}
 
.item:last-child {
  margin-right: 0;
}
 
.content-container {
  width: 100%;
  height: 510px;
  overflow-y: hidden;
  background-color: rgba(17, 34, 58, 0.6);
  border: 1px solid rgba(47, 91, 157, 0.8);
  padding: 22px 20px;
 
}
 
.content-item {
  width: 279px;
  flex-shrink: 0;
  cursor: pointer;
  font-family: 'PingFang SC';
  // margin-bottom: 24px;
}
 
.content-video-info {
  width: 100%;
  height: 180px;
  position: relative;
}
 
.video-icon {
  width: 45px;
  height: 45px;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 45px;
  opacity: 0.7;
}
 
.video-cover {
  width: 100%;
  height: 100%;
  object-fit: fill;
}
 
.content-video-name {
  text-align: center;
  margin-top: 16px;
  font-size: 14px;
  color: rgba(91, 131, 189, 1);
}
 
.video-container {
  position: fixed;
  z-index: 99999;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
 
  .video-wrapper {
    position: absolute;
    width: 70%;
    height: 80%;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.9);
 
  }
 
  .video-player {
    width: 100%;
    height: 100%;
  }
}
 
.close-btn {
  position: absolute;
  right: -80px;
  top: -10px;
  width: 40px;
  height: 40px;
  border: 2px solid #fff;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
}
</style>