DialogBox.vue
4.41 KB
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
240
241
242
243
244
245
<template>
<div
class="mask"
v-if="isShowDialog"
>
<div class="dialog-wrap">
<div
class="close"
@click="closeHandle"
>
<img src="@/assets/images/icon-close.png" />
</div>
<div class="dialog">
<div
:class="['dialog-content',modeName]"
:style="{'background-image': `url(${backgroundImageList[currentIndex]})`}"
>
<div class="dialog-title">
{{titleList[currentIndex]}}
</div>
</div>
</div>
<div class="left_arrow">
<div
class="arrow_inner"
@click="changeHandle(-1)"
>
<img
src="@/assets/images/arrow_left.png"
class="img"
/>
<img
src="@/assets/images/arrow_circle.png"
class="circle"
/>
</div>
</div>
<div class="right_arrow">
<div
class="arrow_inner"
@click="changeHandle(1)"
>
<img
src="@/assets/images/arrow_right.png"
class="img"
/>
<img
src="@/assets/images/arrow_circle.png"
class="circle"
/>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
name: 'MyDialog',
props: {
isShowDialog: Boolean,
titleList: {
type: Array,
default: () => []
},
currentIndex: {
type: Number,
default: 0
},
backgroundImageList: {
type: Array,
default: () => []
}
},
data () {
return {
modeName: ''
}
},
methods: {
closeHandle () {
this.$emit('update:isShowDialog', false)
},
changeHandle (val) {
const { currentIndex, backgroundImageList } = this
if ((currentIndex == 0 && val == -1) || (currentIndex == backgroundImageList.length - 1 && val == 1)) return alert('无更多内容')
this.modeName = val == -1 ? 'to-left' : 'to-right'
this.$emit('update:currentIndex', currentIndex + val)
setTimeout(()=>{
this.modeName = ''
},300)
}
}
}
</script>
<style lang="scss" scoped>
.mask {
position: fixed;
z-index: 99;
left: 50%;
top: 50%;
background: rgba(0, 0, 0, 0.8);
animation: show-mask 0.2s forwards;
transform: translate(-50%, -50%);
}
@keyframes show-mask {
0% {
width: 0;
height: 0;
opacity: 0;
}
100% {
width: 100%;
height: 100%;
opacity: 1;
}
}
.dialog-wrap {
width: 67.31%;
height: 90.38%;
position: absolute;
z-index: 1;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
.close {
width: 60px;
height: 60px;
position: absolute;
right: -103px;
top: 0.96vh;
cursor: pointer;
z-index: 3;
}
.dialog {
width: 100%;
height: 100%;
overflow: hidden;
&-content {
width: 100%;
height: 100%;
background-repeat: no-repeat;
background-size: 100% 100%;
}
.dialog-title {
width: 13.19vw;
font-weight: 900;
font-size: 30px;
color: #19ecff;
text-align: center;
margin: 0 auto;
position: relative;
line-height: 8.39vh;
}
}
.to-left {
animation: to-left 0.25s forwards;
}
.to-right {
animation: to-right 0.25s forwards;
}
@keyframes to-left {
0% {
transform: translateX(-100%);
}
100% {
transform: translateX(0);
}
}
@keyframes to-right {
0% {
transform: translateX(100%);
}
100% {
transform: translateX(0);
}
}
}
.left_arrow,
.right_arrow {
position: absolute;
top: 0;
bottom: 0;
z-index: 2;
width: 100px;
.arrow_inner {
position: absolute;
width: 100px;
height: 50vh;
top: 50%;
transform: translateY(-50%);
z-index: 99;
cursor: pointer;
}
.img {
width: 48px;
height: 48px;
cursor: pointer;
position: absolute;
top: 50%;
transform: translateY(-50%);
}
.circle {
width: 84px;
height: 84px;
position: absolute;
top: 50%;
// transform: translateY(-50%);
margin-top: -42px;
z-index: 98;
}
}
.left_arrow {
left: -162px;
.img {
left: 18px;
}
.circle {
left: 0;
}
}
.right_arrow {
right: -162px;
.img {
right: 18px;
}
.circle {
right: 0;
}
}
.left_arrow:hover,
.right_arrow:hover {
.circle {
animation: rotate360 1.2s ease-out 0s;
}
}
@keyframes rotate360 {
100% {
transform: rotate(360deg);
}
}
</style>