layui.use(["layer", "form", "laydate", "upload"], function(){
    $ = layui.$;
    form = layui.form;
    layer = layui.layer;
    laydate = layui.laydate;
    upload = layui.upload;
    //视频
    upload.render({
        elem: '.file_videos' //绑定元素
        ,url: 'https://www.tuyatrip.com/api/upload/uploadFile' //上传接口
        ,method: 'post'  //可选项。HTTP类型，默认post
        ,accept: 'video'
        ,acceptMime: 'video/*'
        ,headers: {token: token}
        ,before: function (){
            layer.load(2);
        }
        ,done: function(res){
            $(this.item[0]).parent().next().append("<video src="+ res.data +" onclick='clickVideo(this)' controls=\"\" data-v-400c2eb9=\"\"></video>");
            layer.closeAll("loading");
        }
        ,error: function(){
            //请求异常回调
        }
    });

    //图片上传
    upload.render({
        elem: '.file_img' //绑定元素
        ,url: 'https://www.tuyatrip.com/api/upload/uploadFile' //上传接口
        ,method: 'post'  //可选项。HTTP类型，默认post
        ,accept: 'images'
        ,acceptMime: 'image/*'
        ,headers: {token: token}
        ,before: function (){
            layer.load(2);
        }
        ,done: function(res){
            $(this.item[0]).parent().next().append("<div class=\"editor-assets-content-info\" data-v-400c2eb9=\"\">\n" +
                "                                    <div class=\"el-image\" data-v-400c2eb9=\"\"><img style='width: 100px;height: 100px;' onclick='clickImg(this)' alt=\"upload-assets\"\n" +
                "                                                                                  src="+ res.data +"\n" +
                "                                                                                  class=\"el-image__inner el-image__preview\"\n" +
                "                                                                                  style=\"object-fit: cover;\"><!--v-if-->\n" +
                "                                    </div>\n" +
                "                                    <svg viewBox=\"0 0 1024 1024\" xmlns=\"http://www.w3.org/2000/svg\" onclick=\"closeSvg(this)\" data-v-400c2eb9=\"\">\n" +
                "                                        <path fill=\"currentColor\"\n" +
                "                                              d=\"M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896zm0 393.664L407.936 353.6a38.4 38.4 0 1 0-54.336 54.336L457.664 512 353.6 616.064a38.4 38.4 0 1 0 54.336 54.336L512 566.336 616.064 670.4a38.4 38.4 0 1 0 54.336-54.336L566.336 512 670.4 407.936a38.4 38.4 0 1 0-54.336-54.336L512 457.664z\"></path>\n" +
                "                                    </svg>\n" +
                "                                </div>");
            layer.closeAll("loading");
        }
        ,error: function(){
            //请求异常回调
        }
    });

    //封面上传
    upload.render({
        elem: '.cover_img' //绑定元素
        ,url: 'https://www.tuyatrip.com/api/upload/uploadFile' //上传接口
        ,method: 'post'  //可选项。HTTP类型，默认post
        ,accept: 'file'
        // ,acceptMime: 'file/pdf'
        ,headers: {token: token}
        ,before: function (){
            layer.load(2);
        }
        ,done: function(res){
            layer.msg("上传成功", {icon: 1});
            titleImg = res.data;
            layer.closeAll("loading");
        }
        ,error: function(){
            //请求异常回调
        }
    });

    $(".list_div").scroll(function(e){
        $(".day_column").scrollTop($(".list_div").scrollTop());
    });

    laydate.render({
        elem: '.select_date_input'
        ,format: 'yyyy-MM-dd'
    });
    laydate.render({
        elem: '.date_hours_content_input'
        ,type: 'time'
        ,format: 'HH:mm'
    });

    //日期范围
    laydate.render({
        elem: '#test6'
        //设置开始日期、日期日期的 input 选择器
        //数组格式为 2.6.6 开始新增，之前版本直接配置 true 或任意分割字符即可
        ,range: ['#test-startDate-1', '#test-endDate-1']
    });

    getData();//元素渲染
    translationVal(parent.type);//翻译
});