cuiqian2004
2025-07-10 2db331628bbf94deee446d6e172e98f4db474a33
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
<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>