var layer; var userInfo; var openCog = { openIdx: null } layui.use(['layer'], function() { layer = layui.layer; }); $(function() { userInfo = false; //mystorage.get("userInfo"); buildMenu(); }); function buildMenu() { if (typeof(_initParam) == "undefined") { return; } var permission = userInfo.permission; $(".layui-nav-tree").html(""); var _layNavTree = ""; for (var i = 0; i < menuList.length; i++) { var maxId = menuList[i].id.substr(0, 2); if (permission && permission.indexOf("," + maxId) > -1) { var subMenuData = menuList[i].submenu; var layuiNavItem = ""; if (menuList[i].id == _initParam.parentId) { layuiNavItem = "layui-nav-itemed"; } _layNavTree += '
  • '; _layNavTree += ' '; _layNavTree += ' '; _layNavTree += ' ' + menuList[i].name + ''; _layNavTree += ' '; _layNavTree += ' '; _layNavTree += '
    '; for (var j = 0; j < subMenuData.length; j++) { var id = subMenuData[j].id; var classStyle = ""; if (id == _initParam.id) { classStyle = "layui-this"; } var iCss = ''; if (subMenuData[j].icon) { iCss = ''; } if (permission && permission.indexOf("," + id + ",") > -1) { _layNavTree += '
    ' + iCss + '' + subMenuData[j].name + '
    '; } else if (!permission) { _layNavTree += '
    ' + iCss + '' + subMenuData[j].name + '
    '; } } _layNavTree += '
    '; } else if (!permission) { var subMenuData = menuList[i].submenu; var layuiNavItem = ""; if (menuList[i].id == _initParam.parentId) { layuiNavItem = "layui-nav-itemed"; } _layNavTree += '
  • '; _layNavTree += ' '; _layNavTree += ' '; _layNavTree += ' ' + menuList[i].name + ''; _layNavTree += ' '; _layNavTree += ' '; _layNavTree += '
    '; for (var j = 0; j < subMenuData.length; j++) { var id = subMenuData[j].id; var classStyle = ""; if (id == _initParam.id) { classStyle = "layui-this"; } var iCss = ''; if (subMenuData[j].icon) { iCss = ''; } _layNavTree += '
    ' + iCss + '' + subMenuData[j].name + '
    '; } _layNavTree += '
    '; } } $(".layui-nav-tree").html(_layNavTree); layui.use('element', function() { var element = layui.element; }); mainFunHandler(); } function appSuccessMsg(param, msg) { layui.use(['layer'], function() { layer = layui.layer; layer.open({ title: '消息提示', btn: ['我知道了'], content: msg, success: function(layero, index) { setTimeout(function() { this.enterEsc = function(event) { if (event.keyCode === 13) { layer.close(index); return false; //阻止系统默认回车事件 } }; $(document).on('keydown', this.enterEsc); //监听键盘事件,关闭层 }, 500); }, end: function() { appErrorMsgCallBack(); } }); }); } function appErrorMsg(param, msg, postType) { _getRows = null; layui.use(['layer'], function() { layer = layui.layer; //layer.msg(msg, { time: 5000, icon: 5 }); layer.open({ title: '消息提示', btn: ['我知道了'], offset: '100px', content: msg //显示遮罩 , success: function(layero, index) { if (postType) { $("#" + postType).blur(); } setTimeout(function() { this.enterEsc = function(event) { if (event.keyCode === 13) { layer.close(index); return false; //阻止系统默认回车事件 } }; $(document).on('keydown', this.enterEsc); //监听键盘事件,关闭层 }, 500); }, end: function() { appErrorMsgCallBack(postType); } }); }); } function appErrorMsgCallBack(postType) { } function appVerifyMsg(param) { layui.use(['layer'], function() { layer = layui.layer; layer.open({ title: '消息提示', btn: ['我知道了'], offset: '100px', content: param.msg //显示遮罩 , success: function(layero, index) { $("#" + param.id).focus(); }, end: function() { } }); }); } function tokenVerifyMsg(param) { layui.use(['layer'], function() { layer = layui.layer; layer.open({ title: '消息提示', btn: ['我知道了'], offset: '100px', content: param.msg, //显示遮罩 success: function(layero, index) { }, end: function() { logOut(); } }); }); } function showLoad() { return layer.msg('拼命执行中...', { icon: 16, shade: [0.5, '#f5f5f5'], scrollbar: false, offset: 'auto', time: 100000 }); } function closeLoad(index) { layer.close(index); } function logOut() { mystorage.remove("userInfo"); var url = "../views/login.html"; window.location = url; } var updateLayer; function update() { layui.use(['layer'], function() { layer = layui.layer; updateLayer = layer.open({ type: 1, shade: false, title: "修改密码", content: $(".update-pwd"), //捕获的元素 area: ['360px', '300px'], shade: 0.5, //显示遮罩 cancel: function(index) { layer.close(updateLayer); } }); }); } function saveRestOperPwd() { var arr = [ { "id": "oldpwd", "name": "原密码" }, { "id": "newpwd", "name": "新密码" }, { "id": "okpwd", "name": "确认密码" } ]; var record = {}; for (var i in arr) { record[arr[i].id] = $("#" + arr[i].id).val(); if (record[arr[i].id].length == 0) { return alert(arr[i].name + "不能为空!"); } } if (record.newpwd != record.okpwd) { return alert("新密码和确认密码不一致!"); } var param = {}; param.account = userInfo.account; param.old_pwd = record.oldpwd; param.new_pwd = record.newpwd; var url = serverAppUrl + "operator/changePwd"; $.ajax({ type: "post", url: url, data: param, timeout: mytimeout, //超时时间:10秒 headers: { 'Authorization': userInfo.tokenHead + " " + userInfo.token }, dataType: "json", error: function(XMLHttpRequest, textStatus, errorThrown) { alert('连接异常,数据返回有误!'); }, success: function(data) { if (data.status == "0") { tokenVerifyMsg({ "msg": data.message }); } else { alert(data.message); } } }); } function closeRestPwdWin() { layer.close(updateLayer); }