<template>
|
<view class="container">
|
<video id="myVideo" :src="videoData.url" autoplay style="width:750rpx;height:100vh" @error="videoErrorCallback"
|
controls></video>
|
</view>
|
</template>
|
|
<script>
|
export default {
|
data() {
|
return {
|
videoData: {},
|
}
|
},
|
onLoad(option) {
|
// #ifdef MP-DINGTALK
|
|
my.setNavigationBar({
|
backgroundColor: "#007AFF",
|
frontColor: "#ffffff"
|
})
|
// #endif
|
uni.setNavigationBarTitle({
|
title: option.name || "视频"
|
})
|
let app = getApp()
|
let urlVideo = decodeURIComponent(option.url)
|
urlVideo = option.url|| ""
|
this.videoContext = uni.createVideoContext('myVideo')
|
let item = {
|
fileId: option.fileId|| "",
|
name: option.name|| "",
|
fileServer: option.fileServer || "",
|
url: urlVideo
|
}
|
this.setData({
|
videoData: item
|
})
|
},
|
methods: {
|
setData: function(obj) {
|
let that = this;
|
let keys = [];
|
let val, data;
|
|
Object.keys(obj).forEach(function(key) {
|
keys = key.split(".");
|
val = obj[key];
|
data = that.$data;
|
keys.forEach(function(key2, index) {
|
if (index + 1 == keys.length) {
|
that.$set(data, key2, val);
|
} else {
|
if (!data[key2]) {
|
that.$set(data, key2, {});
|
}
|
}
|
data = data[key2];
|
});
|
});
|
},
|
|
videoErrorCallback: function(e) {
|
uni.showModal({
|
content: e.target.errMsg,
|
showCancel: false
|
})
|
}
|
}
|
}
|
</script>
|
<style>
|
.container {
|
display: flex;
|
width: 750rpx;
|
height: 100vh;
|
position: relative;
|
background-color: #f7f7f7;
|
}
|
</style>
|