chengkun
2025-09-09 1ff9e27b020822168a95edd83be567e7153837f3
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
let uploaderMixin = {
    data() {
        return {
            prevPlayer: "",
        };
    },
    methods: {
        uploadFile(file, file_floder_fix = "default") {
            file.status = "uploading";
            file.message = "上传中...";
            // console.log(file);
            let formData = new FormData();
            formData.append("file", file.file);
            let file_floder = file_floder_fix;
            formData.append("file_floder", file_floder);
            formData.append("show_json", 1);
            return axios.post("/supplier/upload/exec", formData);
        },
        uploadVideo(file) {
            let that = this;
            const getSignature = function getSignature() {
                return axios.post("/member/upload/getuploadsign").then(function (res) {
                    return res.data.data.signature;
                });
            };
            const tcVod = new TcVod.default({
                getSignature: getSignature,
            });
            const uploader = tcVod.upload({
                mediaFile: file.file,
            });
            // 视频上传完成时
            uploader.on("media_upload", function (info) {
                that.uploaderInfo.isVideoUploadSuccess = true;
            });
            // 视频上传进度
            uploader.on("media_progress", function (info) {
                that.uploaderInfo.progress = parseInt(info.percent * 100);
                // console.log(info.percent);
            });
 
            return new Promise((resolve, reject) => {
                uploader
                    .done()
                    .then((doneResult) => {
                        axios.post(
                            "/member/upload/transcode",
                            Qs.stringify({
                                videoifleid: doneResult.fileId
                            })
                        );
                        resolve(doneResult);
                    })
                    .catch((err) => {
                        reject(err);
                    });
            });
        },
 
        getTodayDateString() {
            let today = new Date();
            let today_date_string =
                today.getFullYear() + "_" + today.getMonth() + "_" + today.getDay();
            return today_date_string;
        },
        initVideoInfo(
            videoFieldId,
            qcloudSubappid,
            width = 320,
            height = 450,
            player_id = "player-container-id"
        ) {
            setTimeout(() => {
                if (this.prevPlayer != "") {
                    this.prevPlayer.loadVideoByID({
                        fileID: videoFieldId,
                        appID: qcloudSubappid,
                        width: width,
                        height: height,
                    });
                } else {
                    this.prevPlayer = TCPlayer(player_id, {
                        fileID: videoFieldId,
                        appID: qcloudSubappid,
                        width: width,
                        height: height,
                    });
                }
            }, 500);
        },
    },
};