preview.vue
1.94 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
<template>
<view class="popup-box">
<view class="nav-bar">
<view class="back" @click="back">
<uni-icons type="left" :size="24" color="#fff"></uni-icons>
</view>
<view class="title">{{ title }}</view>
</view>
<view class="popup-body">
<video
ref="videoPlayer"
:src="detailUrl"
controls
v-if="sourceType == 2"
></video>
<view class="img-detail" v-else
><image :src="detailUrl" :style="{ width: width + 'px' }"
/></view>
</view>
</view>
</template>
<script type="text/ecmascript-6">
export default {
data () {
return {
width:0,
title: '11',
sourceType: '',
detailUrl: ''
}
},
onLoad (options) {
const {tabName,sourceType,detailUrl} = options
this.title = tabName
this.sourceType = sourceType
this.detailUrl = detailUrl
const img = new Image()
img.onload = ()=> {
this.width = document.querySelector('.img-detail').offsetHeight*img.height/img.width
console.log(this.width)
}
img.src = detailUrl
},
methods: {
back() {
uni.navigateBack()
}
}
}
</script>
<style scoped lang="scss">
.popup-box {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background: #000;
padding: 100rpx 0rpx;
z-index: 100;
.nav-bar {
width: 100%;
height: 96rpx;
margin-bottom: 50rpx;
display: flex;
align-items: center;
.back {
height: 100%;
aspect-ratio: 1/1;
display: flex;
align-items: center;
justify-content: center;
}
.title {
color: #fff;
flex: 1;
font-size: 32rpx;
text-align: center;
}
}
.popup-body {
width: 100%;
height: calc(100% - 200rpx);
video {
width: 100%;
height: 100%;
}
.img-detail {
height: 100%;
text-align: center;
image {
height: 100%;
width: auto;
}
}
}
}
</style>