Blame view

uniapp_jiju/pages/new/zlgl/video-preview.vue 2.22 KB
d56bd957   “wangming”   修复问题,组建AI
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
  <template>
  	<view class="video-preview-container">
  		<view class="video-header">
  			<view class="header-left" @click="goBack">
  				<u-icon name="arrow-left" color="#fff" size="20"></u-icon>
  			</view>
  			<view class="header-title">{{ videoName }}</view>
  			<view class="header-right"></view>
  		</view>
  		<view class="video-wrapper">
  			<video 
  				:src="videoUrl" 
  				controls 
  				:show-center-play-btn="true"
  				:enable-play-gesture="true"
  				:show-fullscreen-btn="true"
  				class="video-player"
  				@error="onVideoError"
  			></video>
  		</view>
  	</view>
  </template>
  
  <script>
  	export default {
  		data() {
  			return {
  				videoUrl: '',
  				videoName: '视频'
  			}
  		},
  		onLoad() {
  			const url = uni.getStorageSync('videoUrl');
  			const name = uni.getStorageSync('videoName');
  			
  			if (!url) {
  				uni.showToast({
  					title: '视频地址不存在',
  					icon: 'none'
  				});
  				setTimeout(() => {
  					this.goBack();
  				}, 1500);
  				return;
  			}
  			
  			this.videoUrl = url;
  			this.videoName = name || '视频';
  		},
  		methods: {
  			goBack() {
  				uni.navigateBack({
  					delta: 1
  				});
  			},
  			onVideoError(e) {
  				console.error('视频加载失败:', e);
  				uni.showToast({
  					title: '视频加载失败',
  					icon: 'none',
  					duration: 2000
  				});
  			}
  		}
  	}
  </script>
  
  <style scoped lang="scss">
  	.video-preview-container {
  		width: 100%;
  		height: 100vh;
  		background-color: #000;
  		display: flex;
  		flex-direction: column;
  	}
  	
  	.video-header {
  		position: fixed;
  		top: 0;
  		left: 0;
  		right: 0;
  		height: 80px;
  		background-color: rgba(0, 0, 0, 0.7);
  		display: flex;
  		align-items: center;
  		justify-content: space-between;
  		padding: 0 15px;
  		z-index: 100;
  		padding-top: 20px;
  		
  		.header-left {
  			width: 40px;
  			height: 40px;
  			display: flex;
  			align-items: center;
  			justify-content: center;
  		}
  		
  		.header-title {
  			flex: 1;
  			text-align: center;
  			color: #fff;
  			font-size: 16px;
  			overflow: hidden;
  			text-overflow: ellipsis;
  			white-space: nowrap;
  			padding: 0 20px;
  		}
  		
  		.header-right {
  			width: 40px;
  		}
  	}
  	
  	.video-wrapper {
  		flex: 1;
  		width: 100%;
  		display: flex;
  		align-items: center;
  		justify-content: center;
  		padding-top: 80px;
  		
  		.video-player {
  			width: 100%;
  			height: 100%;
  		}
  	}
  </style>