var dom_str_new = ` <div id="info-warning-new" class="modal fade">
                                <div class="modal-dialog custom" style="margin-left: calc((100% - 400px)/2);margin-top: 200px;margin-left: calc((100% - 400px)/2);margin-top: 200px;">
                                    <div class="modal-content" style="width: 400px; background: #78899B;">
                                            <div class="modal-header" style="color: white;padding: 0px;text-align: center;background: #78899B;border-bottom: none;box-shadow: 0 0 5px #1d1616;">
                                                <h5>提示</h5>
                                            </div>
                                            <div class="modal-body" style="font-size: 22px;color: white;text-align: center;">
                                                <p>` + `</p>
                                            </div>
                                    </div>
                                </div>
                            </div>`;

var dom_objx_new = function (arg) {
    var objE1 = document.createElement("div");
    objE1.innerHTML = arg;
    return objE1.childNodes[1];
}(dom_str_new);
document.body.appendChild(dom_objx_new);
//提醒窗口新增
function info_new(text) {
    $(dom_objx_new).find("p").html(text);
    $(dom_objx_new).modal();
};

//获取当前系统时间
function getTime() {
    var now_today = new Date();
    var year_today = now_today.getFullYear();
    var month_today = now_today.getMonth() + 1;
    var date_today = now_today.getDate();
    var newMonth_today = (month_today < 10) ? "0" + month_today : month_today;
    var newDate_today = (date_today < 10) ? "0" + date_today : date_today;
    var kssj = year_today + '-' + newMonth_today + '-' + newDate_today + ' ' + '00:00:00';
    var kssj_ym = year_today + '-' + newMonth_today;
    var jssj = year_today + '-' + newMonth_today + '-' + newDate_today + ' ' + '23:59:59';
    var jssj_big = year_today + '-' + newMonth_today + '-' + newDate_today;
    return {kssj, kssj_ym, jssj, jssj_big};
};
//获取前几日的日期
function getTime_extent(n) {
    var now = new Date();
    var preDate = now.getTime() - (n * 24 * 60 * 60 * 1000);
    var preDay = new Date(preDate);
    var pre_year = preDay.getFullYear();
    var pre_month = preDay.getMonth() + 1;
    var pre_date = preDay.getDate();
    var pre_newMonth = (pre_month < 10) ? "0" + pre_month : pre_month;
    var pre_newDate = (pre_date < 10) ? "0" + pre_date : pre_date;
    var now_rq_end = this.getTime().jssj;
    var pre_rq_month = pre_year + '-' + pre_newMonth
    var pre_rq = pre_year + '-' + pre_newMonth + '-' + pre_newDate;
    var pre_rq_start = pre_year + '-' + pre_newMonth + '-' + pre_newDate + ' ' + '00:00:00';
    var pre_rq_end = pre_year + '-' + pre_newMonth + '-' + pre_newDate + ' ' + '23:59:59';
    return {pre_rq_month,pre_rq, pre_rq_start, pre_rq_end, now_rq_end}
};
function getCookie(cname) {
    var name = cname + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') {
            c = c.substring(1);
        }
        if (c.indexOf(name) == 0) {
            return c.substring(name.length, c.length);
        }
    }
    return "";
}
function getByAjax(url, callback) {
    fetch(url, {
        method: "GET",
        credentials: 'include',
        headers: new Headers({
            'x-requested-with': 'XMLHttpRequest'
        })
    }).then(res => {
        if (res.status == 200) {
            return res.text();
        } else {
            return '{"resultStatusPO":{"code":404,"msg":"未找到相关资源"}}';
        }
    }).then(res => {
        var model = JSON.parse(res);
        if (model.code == 0) {
            callback(model.data);
        } else {
            console.log(model.msg);
        }
    });
};
function postByAjax(url, data, callback, cus_header) {
    var base_headers = {
        'Content-Type': 'application/json', // 指定提交方式为表单提交
        'x-requested-with': 'XMLHttpRequest'
    };
    cus_header && (base_headers = Object.assign(base_headers, cus_header));
    fetch(url, {
        method: "POST",
        body: JSON.stringify(data),
        credentials: 'include',
        headers: new Headers(base_headers)
    }).then(res => {
        if (res.status == 200) {
            return res.text();
        } else {
            return '{"resultStatusPO":{"code":404,"msg":"未找到相关资源"}}';
        }
    }).then(res => {
        var model = JSON.parse(res);
        if (model.code == 0) {
            callback(model.data);
        } else {
            console.log(model.msg);
        }
    });
};
Date.prototype.Format = function (fmt) { // author: meizz
    var o = {
        "M+": this.getMonth() + 1, // 月份
        "d+": this.getDate(), // 日
        "h+": this.getHours(), // 小时
        "m+": this.getMinutes(), // 分
        "s+": this.getSeconds(), // 秒
        "q+": Math.floor((this.getMonth() + 3) / 3), // 季度
        "S": this.getMilliseconds() // 毫秒
    };
    if (/(y+)/.test(fmt))
        fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
}
//全屏
function launchIntoFullscreen(element) {
    if(element.requestFullscreen){
        element.requestFullscreen();
    }
    else if(element.mozRequestFullScreen) {
        element.mozRequestFullScreen();
    }
    else if(element.webkitRequestFullscreen) {
        element.webkitRequestFullscreen();
    }
    else if(element.msRequestFullscreen) {
        element.msRequestFullscreen();
    }
}
//退出全屏
function exitFullscreen() {
    if(document.exitFullscreen) {
        document.exitFullscreen();
    } else if(document.mozCancelFullScreen) {
        document.mozCancelFullScreen();
    } else if(document.webkitExitFullscreen) {
        document.webkitExitFullscreen();
    }
}
$.ajaxSetup({
    contentType : "application/x-www-form-urlencoded;charset=utf-8",
    complete : function(XMLHttpRequest, textStatus) {
        if(XMLHttpRequest.responseJSON!=undefined){
            if(XMLHttpRequest.responseJSON.code!=undefined){
                if(XMLHttpRequest.responseJSON.code==401){
                    location.href = '/login';
                }
            }
        }
    }
});