layui.use(["layer", "form", "upload"], function(){
    $ = layui.$;
    form = layui.form;
    layer = layui.layer;
    upload = layui.upload;

    registerUser();
    getPrivateOrder();//数据渲染
    getData();
    translationVal(parent.type);//翻译

    //上传pdf
    upload.render({
        elem: '#traffic' //绑定元素
        ,url: 'https://www.tuyatrip.com/api/upload/uploadFile' //上传接口
        ,method: 'post'  //可选项。HTTP类型，默认post
        ,accept: 'file'
        ,acceptMime: 'file/pdf'
        ,exts: "pdf"
        ,headers: {token: token},
        before: function (res){
            layer.load(2);
        }
        ,done: function(res){
            delOosFile();//删除之前上传的文件
            $(".upload_traffic").find(".upload-btn").remove();
            $("#pdf").show();
            let myPDF = new PDFObject({ url: res.data }).embed("pdf");
            fileTraffic = res.data;
            layer.closeAll("loading");
        }
        ,error: function(){
            //请求异常回调
        }
    });

    //上传pdf
    upload.render({
        elem: '.upload_btn_taffic' //绑定元素
        ,url: 'https://www.tuyatrip.com/api/upload/uploadFile' //上传接口
        ,method: 'post'  //可选项。HTTP类型，默认post
        ,accept: 'file'
        ,acceptMime: 'file/pdf'
        ,exts: "pdf"
        ,headers: {token: token},
        before: function (res){
            layer.load(2);
        }
        ,done: function(res){
            delOosFile();//删除之前上传的文件
            $(".upload_traffic").find(".upload-btn").remove();
            $("#pdf").show();
            let myPDF = new PDFObject({ url: res.data }).embed("pdf");
            fileTraffic = res.data;
            layer.closeAll("loading");
        }
        ,error: function(){
            //请求异常回调
        }
    });
    //确定上传
    $(".ok_btn_taffic").on("click", () => {
        updateTraffic();
    });
})