//公共配置文件 var fun_pub; var pub_fun; var pub; var this_hash = window.location.href; var www = document.location.protocol + "//" + window.location.host; var ctx = www; var set_editor = [ [ "undo", "redo", "insertcode", "bold", "italic", "underline", "strikethrough", "forecolor", "fontsize", "attachment", "simpleupload", "insertvideo", "link", "unlink", "justifyleft", "justifycenter", "justifyright", "justifyjustify", "forecolor", "backcolor", "insertorderedlist", "insertunorderedlist", "source", "preview", ], ]; jQuery.support.cors = true; //IE跨域处理 兼容调试 var msg_time = 60; pub = { close_element: function () { $(".registerModal").addClass("none"); }, open_element: function () { $(".registerModal").removeClass("none"); }, inputChange: function (_this) { if (pub.isText(_this) == "") { $(_this).addClass("error"); } else { $(_this).removeClass("error"); } }, banner_scope: function (rType) { var data = [ { id: "1", name: "首页" }, { id: "2", name: "产品服务" }, { id: "3", name: "行业案例" }, { id: "4", name: "8455新葡萄官网版" }, ]; return data; }, news_status: function ($leixing) { if ($leixing == 1) { return "已发布"; } else if ($leixing == 2) { return "未发布"; } else { return "--"; } }, productType: function ($leixing) { if ($leixing == 1) { return "排程规划"; } else if ($leixing == 2) { return "品质管理"; } else if ($leixing == 3) { return "物流自动化"; } else if ($leixing == 4) { return "经营管理"; } else if ($leixing == 5) { return "设备自动化"; } else if ($leixing == 6) { return "生产管理"; } else if ($leixing == 7) { return "通用工具"; } else { return "--"; } }, json_quchong: function (arr) { for (var i = 0; i < arr.length - 1; i++) { var old = arr[i]; for (var j = i + 1; j < arr.length; j++) { if (old.id == arr[j].id) { arr.splice(j, 1); j--; } } } return arr; }, toggleLanguage: function (el, index, type) { console.log(index) $(el).find('a').removeClass('active'); $(el).find('a').eq(index).addClass('active') sessionStorage.web_language = type; localStorage.web_language = [el, index] pub.ajax( ctx + "/public/api/cn_en.php", "post", { type: index == 1 ? 'en' : 'cn' }, function (data) { console.log(data) let https = document.location.protocol + '//' let stra = this_hash.split(https); let strb = stra[1].indexOf("/"); let strc = stra[1].substring(strb) if (index == 0) { strc = strc.replace('/en', '/cn'); } else { strc = strc.replace('/cn', '/en'); } if (sessionStorage.web_language != 1) { window.location.href = strc; } else { if (sessionStorage.reload_language != 1) { sessionStorage.reload_language = 1; location.reload(); } } }, function (data) { layer.msg(data.msg); return false; } ); }, productType_list: function (rType) { var data = [ { id: "1", name: "生产排程规划" }, { id: "2", name: "生产品质管理" }, { id: "3", name: "生产物流自动化" }, { id: "4", name: "经营管理" }, { id: "5", name: "设备自动化&数据收集" }, { id: "6", name: "制造执行管理" }, { id: "7", name: "通用工具&中间件" } ]; return data; }, news_status_list: function (rType) { var data = [ { id: "1", name: "已发布" }, { id: "2", name: "未发布" }, ]; return data; }, is_top_list: function (rType) { var data = [ { id: "1", name: "是" }, { id: "2", name: "否" }, ]; return data; }, is_top: function ($leixing) { if ($leixing == "denglujiangli") { return "是"; } else if ($leixing == "sharejiangli") { return "否"; } else { return "--"; } }, isMoblie: function () { //返回true是移动端 var devices = ["iPhone", "iPad", "Android", "Windows Phone"]; var ua = window.navigator.userAgent; for (var i = 0; i < devices.length; i++) { if (ua.indexOf(devices[i]) != -1) { return true; } } // ipad pro检测 if (ua.indexOf("Macintosh") > -1) { try { document.createEvent("TouchEvent"); return true; } catch (e) { return false; } } else { return false; } }, delData: function (obj_data, callback) { if (pub.isText(obj_data.title) == "") { title = '您确认要【删除】这条数据吗?'; } else { title = obj_data.title; } layer.confirm( title, { icon: 3, skin: "layui-layer-admin", shade: 0.1, }, function (i) { var loadIndex = layer.load(2); pub.ajax( ctx + "/public/" + obj_data.url, obj_data.method, obj_data, function (data) { layer.close(loadIndex); callback(data); }, function (data) { layer.close(loadIndex); layer.msg(data.msg); return false; } ); } ); return false; }, setCookie: function (name, value, days) { if (days) { var date = new Date(); date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000); var expires = "; expires=" + date.toGMTString(); } else { var expires = ""; } document.cookie = name + "=" + value + expires + "; path=/"; }, refresh_btn: function () { setTimeout(function () { window.location.reload(true); }, 1000); }, parseJSON: function (_Obj) { var result = _Obj; if (!$.isArray(_Obj) && !$.isPlainObject(_Obj)) { result = $.parseJSON(_Obj); } return result; }, getNowTime: function () { //当前系统时间 var d = new Date(), str = ""; var td = d.getDay(); var _month = d.getMonth() + 1; if (_month < 10) { _month = "0" + _month; } var _gDate = d.getDate(); if (_gDate < 10) { _gDate = "0" + _gDate; } var _hours = d.getHours(); if (_hours < 10) { _hours = "0" + _hours; } var _minutes = d.getMinutes(); if (_minutes < 10) { _minutes = "0" + _minutes; } var _seconds = d.getSeconds(); if (_seconds < 10) { _seconds = "0" + _seconds; } str += d.getFullYear() + "-"; str += _month + "-"; str += _gDate + " "; str += _hours + ":"; str += _minutes + ":"; str += _seconds + " "; return str; }, ajax: function (url, _type, obj_ajax, callback, callbackb) { //请求地址,类型,参数,正确回调,错误回调 var load_cover = layer.load(0, { shade: [0.1, "#fff"] }); $.ajax({ type: _type, url: url, async: false, data: obj_ajax, dataType: "json", success: function (data) { if (data.code == 200) { //正确回调 layer.close(load_cover); callback(data); } else if (data.code == 201) { layer.close(load_cover); callbackb(data); //错误回调 } else { pub.setCookie("web_username", "", -1); pub.setCookie("web_id", "", -1); pub.setCookie("nicheng", "", -1); localStorage.removeItem("web_user_token"); localStorage.removeItem("web_user_info"); setTimeout(function () { location.href = document.location.protocol + "//" + window.location.host + "/adminstyle/login.html"; //后台主页 }, 100); } }, error: function () { layer.close(load_cover); layer.msg("服务器连接失败"); }, }); }, isMail: function (msg) { //验证邮箱 var reg = new RegExp( "^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$" ); //正则表达式 if (msg == "null" || msg == null || msg == "" || msg == "undefined") { return "请输入您的邮箱"; } else if (!reg.test(msg)) { return "请输入的邮箱格式错误"; } else { return 1; } }, open_close_nav: function (type) { if (type == 1) { $(".menus.open").addClass("none"); $(".menus.close").removeClass("none"); $(".modal").show(); $(".menuTabs").show(); } else { $(".menus.open").removeClass("none"); $(".menus.close").addClass("none"); $(".modal").hide(); $(".menuTabs").hide(); } }, headerNav: function () { let availWidth = window.screen.availWidth; $(".sub_nav").css({ width: availWidth, "margin-left": -availWidth / 2, "padding-left": availWidth / 2 - 40, }); }, font_dd: function (msg, num) { //大于多少字用... //console.log(msg); if (msg == "null" || msg == null || msg == "" || msg == "undefined") { return ""; } else { var s = msg; //要展示的字符串 if (msg.length > num) { s = msg.substring(0, num) + "..."; } return s; } }, isNull: function (_value) { //如果是空就是真,否则是假 if (_value == null || _value == "" || _value == "undefined") { return true; } return false; }, isText: function (_value) { //字符串是空就输出空,防止undefined _value = "" + _value; if ( _value == "null" || _value == null || _value == "" || _value == "undefined" ) { return ""; } return _value; }, getUrlName: function (name) { //获取浏览器参数 var result = location.search.match( new RegExp("[?&]" + name + "=([^&]+)", "i") ); if (result == null || result.length < 1) { return ""; } return result[1]; }, url_this: function ( str //判断浏览包含某个字符 ) { var url = window.location.href; if (url.indexOf(str) >= 0) { return str; } else { return ""; } }, filterHTMLTag: function (msg, num) { //过滤html标签 if (msg == "null" || msg == null || msg == "" || msg == "undefined") { return ""; } else { var msgx = msg.replace(/<\/?[^>]*>/g, ""); //去除HTML Tag msgx = msgx.replace(/[|]*\n/, ""); //去除行尾空格 msgx = msgx.replace(/ /gi, ""); //去掉nbsp if (pub.isText(num) != "") { var s = msg; //要展示的字符串 if (msgx.length > num) { s = msgx.substring(0, num) + "..."; } return s; } else { return msgx; } } }, dataTimestamp: function (datetime, type) { //时间戳转换时间 if (datetime == null || datetime == "" || datetime == "undefined") { return ""; } else if (datetime.indexOf("-") > -1 || datetime.indexOf("/") > -1) { return datetime; } else { var date = new Date(datetime * 1000); var year = date.getFullYear(), month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1, day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate(), hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours(), min = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes(), sec = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds(); if (type == 1 || type == "1") { return year + "-" + month + "-" + day; } else if (type == 2 || type == "2") { return hour + ":" + min; } else { return ( year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec ); } } }, sweetTitles: { x: 10, y: 20, tipElements: "a,span,img,div,input,button", noTitle: false, init: function () { var b = this.noTitle; $(this.tipElements).each(function () { $(this) .mouseover(function (e) { if (b) { isTitle = true; } else { isTitle = $.trim(this.title) != ""; } if (isTitle) { this.myTitle = this.title; this.title = ""; var a = "