imagePreview.vue
1.52 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
<template>
<div class="imagePreview">
<template v-if="item">
<van-image-preview v-model="show" :images="item" @change="change" :show-index="false" :start-position="index" ref="preview" asyncClose></van-image-preview>
<template v-if="textStyle">
<div class="text" :style="textStyle">
{{ experience }}
</div>
</template>
</template>
</div>
</template>
<script type="text/ecmascript-6">
import { ImagePreview } from 'vant'
export default {
name: 'imagePreview',
components: {
[ImagePreview.Component.name]: ImagePreview.Component
},
data () {
return {
textStyle: '',
experience: '',
item: [],
show: true,
index: 0
}
},
activated () {
let { item, index, experience } = this.getParams()
if (item && item.length) {
this.item = item
this.experience = experience
this.index = index
document.title = `${index + 1}/${item.length}`
setTimeout(() => {
this.textStyle = `z-index:${Number(this.$refs.preview.$el.style.zIndex + 1)}`
}, 1e3)
} else this.to('crowdfunding')
},
mounted () {
},
methods: {
change (e) {
document.title = `${e + 1}/${this.item.length}`
}
}
}
</script>
<style scoped lang="scss">
.imagePreview {
position: relative;
width: 100vw;
height: 100vh;
.text {
position: fixed;
left: 0;
bottom: 0;
width: 100%;
font-size: 14px;
color: #ffffff;
padding: 16px 16px 50px;
box-sizing: border-box;
z-index: 2;
}
}
</style>