
$(function () {
    setTimeout(vedioUpload,1000);
    function vedioUpload() {
        var $vedioUpload = $("#vedioUpload"),
            $uploaderFiles = $("#uploaderFiles");
        $vedioUpload.on("change",function (e) {
            files = e.target.files;
            // 如果没有选中文件，直接返回
            if (files.length === 0) {
                return;
            }
            for (var i = 0, len = files.length; i < len; ++i) {
                var file = files[i];
                var reader = new FileReader();
                var fileType = file.type;
                var base64;
                reader.onload = function (e) {
                    $.showLoading("上传中");
                    var FormDatas = new FormData();
                    FormDatas.append("file", file);
                    //这里实现上传
                    $.ajax({
                        url: uploadUrl,
                        type: 'POST',
                        data: FormDatas,
                        contentType: false,
                        processData: false,
                        success: function (res) {
                            if (res.code === "200"){
                                var str =`
                            <div class="video_a" style="position: relative;" file-Url="${res.data.fullURL}">
                                <a href="javascript:;" class="weui-btn weui-btn_mini weui-btn_primary delete_video">删除</a>
                                <video controls="controls" style="width: 100%;height: 200px;" file-Name="${res.data.fileName}">
                                   <source src="${res.data.fullURL}">
                                        当浏览器不支持时，此处给出提示
                                </video>
                            </div>`;
                                $('.vedio_text .title_style').after(str);
                                $('.videoFlie').hide();
                                $(".loadModel").remove();
                                $.toast('上传成功');
                                $.hideLoading();
                            }else {
                                $.toast('上传失败，请检查网络','forbidden');
                                $.hideLoading();
                            }
                        },
                        error:function () {
                            $.toast("上传失败,请检查网络！",'forbidden')
                            $.hideLoading();
                        }
                    })

                };
                reader.readAsDataURL(file);
            }
        });
    }
});