easyui1

登录

容器居中
body { background: #038bf6 url(/Content/images/bg.jpg) no-repeat fixed center; background-size:cover; }
<div class="login_bginner" style="position: absolute;background: url(/Content/images/mb.png); top: 50%; left: 50%; margin: -362px 0 0 -600px; width: 1200px; height: 724px; "></div>
密码隐藏显示
<img src="~/Content/images/yan1.png" id="yan" style="vertical-align:-5px;cursor: pointer;" onclick="mimaOpen()" />
function mimaOpen(){
    if($("#login_password").attr("type") == 'password'){
        $("#login_password").attr("type", "text");
        $("#yan").attr('src','/Content/images/yan2.png');
    }else{
        $("#login_password").attr("type", "password");
        $("#yan").attr('src','/Content/images/yan1.png');
    }
}
发送短信验证码
<button id="fsyzm" style="width: 100%; height: 48px; background: #0076fe; color: #fff; font-size: 17px;border:none;border-radius: 24px;cursor: pointer;" onclick="fdxFn()">发送短信验证码</button>
function fdxFn(){
    var name = $("#login_uesrname").val();
    var $fsyzm = $("#fsyzm");
    var flag = regMobilephone(name)
    //console.log(name)
    if (name == "" || name.length<5) {
        $.messager.alert("提示", "请输入账号为5-25个字符", "", function () {});
        return
    }else{
        var tempT = 60;
        $fsyzm.prop({
            disabled: true
        });//.css({"background":"#0076fe"});
        var timer = setInterval(function() {
            --tempT;
            $fsyzm.html(tempT+"S");
            if (!tempT) {
                clearInterval(timer);
                timer = null;
                $fsyzm.html("发送短信验证码");
                $fsyzm.removeProp("disabled");
                //$fsyzm.css({"background":"#0076fe"});
            }
        }, 1000)
        $.ajax({
            type: 'post',
            dataType: "json",
            url: "/Home/GetSms?t=" + Math.random(),
            data: {
                AdminName: name
            },
            cache: false,
            async: false,
            success: function (msg) {
                console.log(msg)
                if (msg.status.code == 1) {
                    //console.log('ok')
                    dxdl = 1;
                    $("#smsID").val(msg.data);
                    $("#AdminID").val(msg.status.sub_msg);

                } else if(msg.status.code == -1000){
                    $.messager.alert("提示", msg.status.msg, "", function () {
                        top.location.href = '/Home/SystemLogin';
                    });
                } else {
                    $fsyzm.removeProp("disabled");
                    $.messager.alert("提示", msg.status.msg, "", function () {});
                }
            },
        });
    }
}
登录按钮
function login() {
发请求之前:
$("#dengluWZ").html('登录中...');
$("#DLAN_bbnn").removeAttr('onclick');
请求回应后:
$("#dengluWZ").html('登录');
$("#DLAN_bbnn").on('click',login);
}

监听回车按钮登录
document.onkeydown = function (e) {
if (e.keyCode == 13) {
login();
}
}
所有的请求都要加-1000判断:
 else if(msg.status.code == -1000){
      $.messager.alert("提示", msg.status.msg, "", function () {
        top.location.href = '/Home/SystemLogin';
      });
}
登录成功后将信息记录到localStorage:
var obj = {};
obj["AdminName"] = res.AdminName;
obj["AdminType"] = res.AdminType;
obj["AdminPwd"] = res.AdminPwd;
obj["Token"] = res.Token;
window.localStorage.setItem("userInfo",JSON.stringify(obj));

然后页面跳转:
if(res.AdminType == 1 || res.AdminType == 2){
      top.location.href = "/Management/Index";
}else{
      top.location.href = "/Management/IndexEnterprise";
}

 

index.js


if (window.localStorage["userInfo"] != undefined) {
    var userInfo = JSON.parse(window.localStorage.getItem("userInfo"));
    var UserToken = userInfo.Token;
    var AdminName = userInfo.AdminName;
    var AdminType = userInfo.AdminType;// 1,平台管理员  2,地区管理员  3,企业用户(自行注册)
    var userCityID = userInfo.CityID;
    var userAreaID = userInfo.AreaID;
    var userRoleID = userInfo.RoleID;
    var userPhone = userInfo.Phone;
    var userEPID = userInfo.EPID;
    var userLanmu = userInfo.Lanmu;
    var AdminPwd = userInfo.AdminPwd;
}
    //AdminType 1,平台管理员  2,地区管理员  3,企业用户(自行注册)

$(function () {
    //console.log(userInfo,UserToken,AdminName)
    //获取到了用户名
    $("#username").text(AdminName);
    if(AdminType == 3){
        StaffOrVehicleLicenseExpireRemind()
    }

    //这句可能影响显示灰色背景
    $.messager.defaults = { ok: "确定", cancel: "取消", width: 300, height: 200 };
    $("#maintab").tabs({
        onContextMenu: function (e, title) {
            e.preventDefault();
            $('#tabsMenu').menu('show', {
                left: e.pageX,
                top: e.pageY
            }).data("tabTitle", title);
        },
        onSelect: function (title, index) {
            //点击标签卡触发
            if (title == '现场培训') {
                //console.log('点击页卡',aaa)
                //赋值时间
            }
        },
        onBeforeClose: function (title, index) {
            //
            if (title == '现场培训') {
                //console.log('关闭页卡')
                //发请求存储时间
            }
        },
        onUnselect: function (title, index) {
            //离开页卡
            if (title == '现场培训') {
                console.log('离开页卡')
                var winAry = Object.keys(parent.window).filter(function (item) { return !isNaN(item) })
                if (winAry.length == 0) {
                    winAry = Object.keys(parent.window.document).filter(function (item) { return item.substring(0, 10) == 'openIframe' })
                }
                $(winAry).each(function (index, item) {
                    if (typeof parent.window[item]["TrainingRecordScene_TrainContinue"] == "function") {
                        parent.window[item].$("#TrainTimeOut").click()
                    }
                })
                //发请求存储时间
            }
        },
    });

    $("#tabsMenu").menu({
        onClick: function (item) {
            CloseTab(this, item.name);
        }
    });

    function CloseTab(menu, type) {
        var curTabTitle = $(menu).data("tabTitle");
        var tabs = $("#maintab");

        if (type === "close") {
            tabs.tabs("close", curTabTitle);
            return;
        }

        var allTabs = tabs.tabs("tabs");
        var closeTabsTitle = [];

        $.each(allTabs, function () {
            var opt = $(this).panel("options");
            if (opt.closable && opt.title != curTabTitle && type === "Other") {
                closeTabsTitle.push(opt.title);
            } else if (opt.closable && type === "All") {
                closeTabsTitle.push(opt.title);
            }
        });

        for (var i = 0; i < closeTabsTitle.length; i++) {
            tabs.tabs("close", closeTabsTitle[i]);
        }
    }

    PNotify.prototype.options.styling = "bootstrap2";
    //禁用下拉的输入功能
    $('.easyui-combobox').combobox({editable:false})
    // $(".panel-icon").each(function(index,item){
    //     console.log(item)
    // })
    if(AdminPwd == ''){
        // console.log(addTab)
        setTimeout(function(){
            changepass()
            // addTab('修改密码', '/Management/ChangePassword');
        },200)

        // $("#maintab").tabs('add',{
        //     title:'修改密码',
        //     closable:true,
        //     content:'<iframe frameborder="0" scrolling="true" src="' + url + '" style="width:100%;height:100%;position:relative;"></iframe>',
        // });
    }
});

//企业是否需要提醒及提醒即将到期的车牌和员工
function StaffOrVehicleLicenseExpireRemind() {
    $.ajax({
        type: 'get',
        dataType: "json",
        url: "/Management/StaffOrVehicleLicenseExpireRemind?t=" + Math.random(),
        data: {
            UserToken: UserToken
        },
        cache: false,
        async: false,
        success: function (msg) {
            // console.log(msg.status.sub_msg != null);
            if (msg.status.code == 1) {

                if(msg.status.sub_msg != null){
                    var cljjdq = msg.status.sub_msg.split(',');
                    var cljjdqJG = '';
                    if(cljjdq.length > 0){
                        $("#cheliang").show();
                        $(cljjdq).each(function(index,item){
                            cljjdqJG += '<span class="ffllff">' + item + '</span>';
                        })
                    }
                    $("#cljjdq").html(cljjdqJG);
                }

                if(msg.data != null){
                    var jszjjdq = msg.data.split(',');
                    var jszjjdqJG = '';
                    if(jszjjdq.length > 0){
                        $("#jiashizheng").show();
                        $(jszjjdq).each(function(index,item){
                            jszjjdqJG += '<span class="ffllff">' + item + '</span>';
                        })
                    }
                    $("#jszjjdq").html(jszjjdqJG);
                }

            } else if(msg.status.code == -1000){
                $.messager.alert("提示", msg.status.msg, "", function () {
                    top.location.href = '/Home/SystemLogin';
                });
            } else {

            }
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
        }
    });
}

//退出系统
function userout() {
    $.messager.confirm({
        title: '提示:',
        msg: '您确定退出系统吗?',
        width: 250,
        height: 170,
        modal: true,//开启灰色背景
        fn: function (r) {
            if (r) {
                $.ajax({
                    type: 'post',
                    dataType: "json",
                    url: "/Home/Logout",
                    data: {},
                    cache: false,
                    async: false,
                    success: function (msg) {
                        console.log(msg)
                        if (msg.status.code == 1) {
                            // window.localStorage.removeItem("user");
                            // window.localStorage.removeItem("AdminType");
                            top.location.href = "/Home/SystemLogin";
                        } else {
                            $.messager.alert("提示", msg.status.msg, "", function () { });
                        }
                    },
                    error: function () {

                    }
                })
            }
        }
    });
}

//修改密码
function changepass() {
    addTab("修改密码", '/Management/ChangePassword?t=1');
}

//初始化
$('#mb').menubutton({
    menu: '#mm2'
});

var _CallSearch;
var _CallBack;
//跳转页面
function addTab(title, href, icon) {
    //点击左侧列表触发
    var tt = $('#maintab');
    if (title == "数据控制字段") {
        if (tt.tabs('exists', title)) {
            tt.tabs('close', title);
        }
        if (href) {
            var content = '<iframe scrolling-x="no" frameborder="0"  src="' + href + '" style="width:100%;height:100%;"></iframe>';
        } else {
            var content = 'content is undfine';
        }
        tt.tabs('add', {
            title: title,
            closable: true,
            tools: [{
                iconCls: 'icon-mini-refresh',
                title: '刷新',
                handler: function () {
                    refreshTab(href, title);
                }
            }],
            content: content
        });
    }
    if (tt.tabs('exists', title)) {
        tt.tabs('select', title);
    }
    else {
        if (href) {
            var content = '<iframe scrolling-x="no" frameborder="0"  src="' + href + '" style="width:100%;height:100%;"></iframe>';
        } else {
            var content = 'content is undfine';
        }
        tt.tabs('add', {
            title: title,
            closable: true,
            tools: [{
                iconCls: 'icon-mini-refresh',
                title: '刷新',
                handler: function () {
                    refreshTab(href, title);
                }
            }],
            content: content
        });
    }
}

function removeTabs() {
    $.messager.confirm('提示:', '您确定关闭所有窗口吗?', function (r) {
        if (r) {
            while ($('#maintab').tabs("getTab", 1) != null) {
                $('#maintab').tabs('close', 1);
            }
        }
    });
}

function refreshTab(href, title) {
    //刷新
    //console.log(title)
    //存储时间
    var refresh_tab = title ? $('#maintab').tabs('getTab', title) : $('#maintab').tabs('getSelected');
    if (refresh_tab && refresh_tab.find('iframe').length > 0) {
        var _refresh_ifram = refresh_tab.find('iframe')[0];
        var refresh_url = href ? href : _refresh_ifram.src;
        _refresh_ifram.contentWindow.location.href = refresh_url;
    }
}

function openWindow(t, url, w, h) {
    if (w > 1400)
        w = 1400;
    if (h > 800)
        h = 800;

    var mleft = ((document.documentElement.clientWidth || document.body.clientWidth) - w) / 2 + 'px';
    var mtop = ((document.documentElement.clientHeight || document.body.clientHieght) - h) / 2 + 'px';
    $('#openIframe')[0].src = url;
    $('#openDialog').dialog({
        title: t,
        width: w,
        height: h,
        left: mleft,
        top: mtop,
        border: false,
    });
    //$('#openDialog').window({
    //    inline: false,
    //});
    $('#openDialog').window('open');
}
function openWindow1(t, url, w, h) {
    if (w > 1400)
        w = 1400;
    if (h > 800)
        h = 800;
    var mleft = ((document.documentElement.clientWidth || document.body.clientWidth) - w) / 2 + 'px';
    var mtop = ((document.documentElement.clientHeight || document.body.clientHieght) - h) / 2 + 'px';
    $('#openIframe1')[0].src = url;
    $('#openDialog1').dialog({
        title: t,
        width: w,
        height: h,
        left: mleft,
        top: mtop,
        border: false
    });
    //$('#openDialog').window({
    //    inline: false,
    //});
    $('#openDialog1').window('open');
}
function openWindow2(t, url, w, h) {
    if (w > 1400)
        w = 1400;
    if (h > 800)
        h = 800;
    var mleft = ((document.documentElement.clientWidth || document.body.clientWidth) - w) / 2 + 'px';
    var mtop = ((document.documentElement.clientHeight || document.body.clientHieght) - h) / 2 + 'px';
    $('#openIframe2')[0].src = url;
    $('#openDialog2').dialog({
        title: t,
        width: w,
        height: h,
        left: mleft,
        top: mtop,
        border: false
    });
    //$('#openDialog').window({
    //    inline: false,
    //});
    $('#openDialog2').window('open');
}

function openWindow3(t, url, w, h) {
    if (w > 1400)
        w = 1400;

    if (h > 800)
        h = 800;
    var mleft = ((document.documentElement.clientWidth || document.body.clientWidth) - w) / 2 + 'px';
    var mtop = ((document.documentElement.clientHeight || document.body.clientHieght) - h) / 2 + 'px';
    $('#openIframe3')[0].src = url;
    $('#openDialog3').dialog({
        title: t,
        width: w,
        height: h,
        left: mleft,
        top: mtop,
        border: false
    });
    //$('#openDialog').window({
    //    inline: false,
    //});
    $('#openDialog3').window('open');
}
function openWindowNOC(t, url, w, h) {
    if (w > 1400)
        w = 1400;

    if (h > 800)
        h = 800;

    var mleft = ((document.documentElement.clientWidth || document.body.clientWidth) - w) / 2 + 'px';
    var mtop = ((document.documentElement.clientHeight || document.body.clientHieght) - h) / 2 + 'px';
    $('#openIframeNOC')[0].src = url;
    $('#openDialogNOC').dialog({
        title: t,
        width: w,
        height: h,
        left: mleft,
        top: mtop,
        border: false,
        closable: false
    });
    $('#openDialogNOC').window('open');
}

function aaopenWindow(t, url, w, h) {
    if (w > 1400)
        w = 1400;

    if (h > 800)
        h = 800;
    var mleft = ((document.documentElement.clientWidth || document.body.clientWidth) - w) / 2 + 'px';
    var mtop = ((document.documentElement.clientHeight || document.body.clientHieght) - h) / 2 + 'px';
    $('#openIframe')[0].src = url;
    $('#openDialog').dialog({
        title: t,
        width: w,
        height: h,
        left: mleft,
        top: mtop,
        border: false
    });
    $('#openDialog').window('open');

    _CallBack = function (msg) {
        console.log('11', msg)
    }
}


function openWindowTarget(t, form, w, h) {
    if (w > 1400)
        w = 1400;

    if (h > 800)
        h = 800;
    var mleft = ((document.documentElement.clientWidth || document.body.clientWidth) - w) / 2 + 'px';
    var mtop = ((document.documentElement.clientHeight || document.body.clientHieght) - h) / 2 + 'px';
    form.id = "openSubmitFrom";
    $("#openDailogsubmitFrom").html('');
    $("#openDailogsubmitFrom").append(form);
    $("#openSubmitFrom").submit();
    $('#openDialog').dialog({
        title: t,
        width: w,
        height: h,
        left: mleft,
        top: mtop,
        border: false
    });
    $('#openDialog').window('open');
}
function onlyOpenWindow(t, form, w, h) {
    $('#openDialog').window('open');
}
function closeWindow() {
    clearWindow();
    $('#openDialog').window('close');

    //window.location.href = window.location.href;
    if (_CallSearch != null)
        _CallSearch();
}
function closeWindow1() {
    clearWindow1();
    $('#openDialog1').window('close');

    //window.location.href = window.location.href;
    if (_CallSearch != null)
        _CallSearch();
}
function closeWindow2() {
    clearWindow2();
    $('#openDialog2').window('close');

    //window.location.href = window.location.href;
    if (_CallSearch != null)
        _CallSearch();
}
function closeWindow3() {
    clearWindow3();
    $('#openDialog3').window('close');

    //window.location.href = window.location.href;
    if (_CallSearch != null)
        _CallSearch();
}
function closeWindowNOC() {
    clearWindowNOC();
    $('#openDialogNOC').window('close');

    //window.location.href = window.location.href;
    if (_CallSearch != null)
        _CallSearch();
}
function aacloseWindow() {
    clearWindow();
    $('#openDialog').window('close');

    if (_CallSearch != null)
        _CallSearch();

    //回调函数,可以把其他函数当参数传进来执行
    _CallBack = function (fn) {
        console.log('22')
        fn();
        //var childWindow = $("#openIframe")[0].contentWindow;
        //console.log(childWindow)
        //childWindow.getlist();
    }
}

function closeCurTab() {
    var tab = $('#maintab').tabs('getSelected');
    var index = $('#maintab').tabs('getTabIndex', tab);
    $('#maintab').tabs('close', index);
}

function clearWindow() {
    $('#openIframe')[0].src = "";
    //window.parent.location.reload(true);
}
function clearWindow1() {
    $('#openIframe1')[0].src = "";
    //window.parent.location.reload(true);
}
function clearWindow2() {
    $('#openIframe2')[0].src = "";
    //window.parent.location.reload(true);
}
function clearWindow3() {
    $('#openIframe3')[0].src = "";
    //window.parent.location.reload(true);
}
function clearWindowNOC() {
    $('#openIframeNOC')[0].src = "";
    //window.parent.location.reload(true);
}

function dialogOnClose() {
    clearWindow();
}
function dialogOnClose1() {
    clearWindow1();
}
function dialogOnClose2() {
    clearWindow2();
}
function dialogOnClose3() {
    clearWindow3();
}
function dialogOnCloseNOC() {
    clearWindowNOC();
}

function showMessage(message) {
    $.messager.show({
        msg: message,
        showType: 'slide',
        width: 350,
        height: 50,
        timeout: 5000,
        style: {
            right: '',
            top: document.body.scrollTop + document.documentElement.scrollTop - 10,
            bottom: ''
        }
    });
}

function CallBack(chanList) {
    clearWindow();
    $('#openDialog').window('close');
    _CallBack(chanList);
}

function clearCache() {
    $.post("/WebAdmin/p/cache/cacheAjax.ashx", function (result) {
        if (result.success) {
            alert('清除成功');
        }
        else {
            alert('清除失败');
        }
    });
}

function logout() {
    $.messager.confirm('提示:', '您确定退出系统吗?', function (r) {
        if (r) {
            $.post("/WebAdmin/p/share/LoginAjax.ashx?t=logout", function (result) {
                if (result.success) {
                    top.location.href = "/WebAdmin/Login.aspx";
                }
                else {
                    alert('退出失败');
                }
            });
        }
    });
}
function showNotify() {
    var stack_custom2 = { "dir1": "left", "dir2": "up", "push": "top" };
    new PNotify({
        text: '您已删除了一个用户您已删除了',
        type: 'error',

        addclass: "stack-custom",
        stack: stack_custom2
    });
}

var dataMenu = [];
var mentEvent = null;

if (AdminType != 3) {

    //侧边栏导航
    dataMenu = userLanmu;

    //页面链接
    mentEvent = function (item) {
        if (item.text == '地区管理') {
            addTab(item.text, '/CityArea/CityAreaList');
        } else if (item.text == '基础设置') {
            addTab(item.text, '/BasicCategory/BasicCategoryList');
        } else if (item.text == '账号管理') {
            addTab(item.text, '/AdminTable/AdminTableList');
        } else if (item.text == '功能权限') {
            addTab(item.text, '/Jurisdiction/JurisdictionList');
        } else if (item.text == '登录日志') {
            addTab(item.text, '/Management/LoginList');
        } else if (item.text == '公文管理') {
            addTab(item.text, '/News/NewsList');
        } else if (item.text == '通知管理') {
            addTab(item.text, '/News/NewsNoticeList');
        } else if (item.text == '课程管理') {
            addTab(item.text, '/Classes/ClassesList');
        } else if (item.text == '培训计划') {
            addTab(item.text, '/TrainingPlan/TrainingPlanList');
        } else if (item.text == '指派计划') {
            addTab(item.text, '/TrainingPlan/TrainingPlanAssignList');
        } else if (item.text == '订单管理') {
            addTab(item.text, '/Orders/OrdersList');
        } else if (item.text == '发票管理') {
            addTab(item.text, '/Invoice/InvoiceList');
        } else if (item.text == '培训劵设置') {
            addTab(item.text, '/TicketCategory/TicketCategoryList');
        } else if (item.text == '企业信息') {
            addTab(item.text, '/Enterprise/EnterpriseList');
        } else if (item.text == '车辆信息') {
            addTab(item.text, '/Vehicle/VehicleList');
        } else if (item.text == '学员信息') {
            addTab(item.text, '/Staff/StaffList');
        } else if (item.text == '月培训人数汇总') {
            addTab(item.text, '/Statistics/StatisticsList');
        } else if (item.text == '消息中心') {
            addTab(item.text, '/Management/MessageList');
        } else if (item.text == '清除缓存') {
            addTab(item.text, '/Management/ClearList');
        }
    }
} else {

    //侧边栏导航
    dataMenu = [{
        text: '基础信息',
        iconCls: 'icon-jcxx',
        children: [
            { text: '企业信息' },
            { text: '车辆管理' },
            { text: '员工管理' }
        ]
    }, {
        text: '订单中心',
        iconCls: 'icon-ddzx',
        children: [
            { text: '订单管理' },
            { text: '发票管理' },
            { text: '开票信息' },
            { text: '培训劵' }
        ]
    }, {
        text: '培训中心',
        iconCls: 'icon-pxzx',
        children: [
            { text: '现场培训' },
            { text: '培训计划' }
        ]
    }, {
        text: '消息中心',
        iconCls: 'icon-xxzx',
        children: [
            { text: '消息中心' }
        ]
    }, {
        text: '安全中心',
        iconCls: 'icon-aqzx',
        children: [
            { text: '修改密码' },
            { text: '重置密码' },
            // { text: '密保手机' },
            // { text: '登录日志' },
            // { text: '常用设备' },
            // { text: '清除缓存' }
        ]
    }];


    //页面链接
    mentEvent = function (item) {
        if (item.text == '企业信息') {
            addTab(item.text, '/Enterprise/EnterpriseModify?CurID=' + userEPID);
        } else if (item.text == '车辆管理') {
            addTab(item.text, '/Vehicle/VehicleList');
        } else if (item.text == '员工管理') {
            addTab(item.text, '/Staff/StaffList');
        } else if (item.text == '订单管理') {
            addTab(item.text, '/Orders/OrdersList');
        } else if (item.text == '发票管理') {
            addTab(item.text, '/Invoice/InvoiceList');
        } else if (item.text == '开票信息') {
            addTab(item.text, '/InvoiceMess/InvoiceMessList');
        } else if (item.text == '培训劵') {
            addTab(item.text, '/EPTicket/EPTicketList');
        } else if (item.text == '现场培训') {
            addTab(item.text, '/TrainingRecord/TrainingRecordScene');
        } else if (item.text == '培训计划') {
            addTab(item.text, '/TrainingPlan/TrainingPlanList');
        } else if (item.text == '消息中心') {
            addTab(item.text, '/Management/MessageList');
        } else if (item.text == '修改密码') {
            addTab(item.text, '/Management/ChangePassword?t=1');
        } else if (item.text == '重置密码') {
            addTab(item.text, '/Management/SetUpPassword');
        } else if (item.text == '密保手机') {
            addTab(item.text, '/');
        } else if (item.text == '登录日志') {
            addTab(item.text, '/Management/LoginList');
        } else if (item.text == '常用设备') {
            addTab(item.text, '/UsersEquipment/UsersEquipmentList');
        } else if (item.text == '清除缓存') {
            addTab(item.text, '/Management/ClearList');
        }
    }

}

function toggle() {
    var opts = $('#sm').sidemenu('options');
    $('#sm').sidemenu(opts.collapsed ? 'expand' : 'collapse');
    opts = $('#sm').sidemenu('options');
    $('#sm').sidemenu('resize', {
        width: opts.collapsed ? 60 : 200
    })

}

//详情弹页在提交发请求成功后自动关闭前可用此方法刷新父级列表更新数据,name传父级方法名字符串,arg父级方法中传参
function shuaxin(name,arg) { var winAry = Object.keys(parent.window).filter(function (item) { return !isNaN(item) }) if (winAry.length == 0) { winAry = Object.keys(parent.window.document).filter(function (item) { return item.substring(0, 10) == 'openIframe' }) } $(winAry).each(function (index, item) { if (typeof parent.window[item][name] == "function") { if(typeof arg != 'undefined'){ parent.window[item].eval(name)(arg); }else{ parent.window[item].eval(name)(); } } }) } //取百分比方法 function getWidth(percent) { return document.body.clientWidth * percent; } function close_btn() { parent.closeWindow(); //关闭该弹层页面的方法,从父级关闭 } function delblack(text) { var str = $.trim(text); str = str.replace(/[ | ]*\n/g, '\n'); //去除行尾空白 str = str.replace(/\n[\s| | ]*\r/g, '\n'); //去除多余空行 str = str.replace(/^[\s ]+|[\s ]+$/g, "");//去掉全角半角空格 str = str.replace(/[\r\n]/g, "");//去掉回车换行 return str } //补全数字 function buquan(num, length) { var numstr = num.toString(); var l = numstr.length; if (numstr.length >= length) { return numstr; } for (var i = 0 ; i < length - l; i++) { numstr = "0" + numstr; } return numstr; } //时间格式化(带时分秒) function FormatallDate(strTime) { if (strTime == "" || strTime == "null" || strTime == null) { return ""; } else { strTime = strTime.replace("T", " "); var _data = strTime.split(' ')[0]; var _time = strTime.split(' ')[1]; var date = new Date(_data); var time = _time.split(':'); return date.getFullYear() + "-" + buquan((date.getMonth() + 1), 2) + "-" + buquan(date.getDate(), 2) + " " + buquan(time[0], 2) + ":" + buquan(time[1], 2) + ":" + buquan(time[2].split('.')[0], 2); } } //当天 function Present_Time() { var now = new Date(); var year = now.getFullYear(); //得到年份 var month = now.getMonth();//得到月份 var date = now.getDate();//得到日期 var day = now.getDay();//得到周几 var hour = now.getHours();//得到小时 var minu = now.getMinutes();//得到分钟 var sec = now.getSeconds();//得到秒 var MS = now.getMilliseconds();//获取毫秒 var week; month = month + 1; if (month < 10) month = "0" + month; if (date < 10) date = "0" + date; if (hour < 10) hour = "0" + hour; if (minu < 10) minu = "0" + minu; if (sec < 10) sec = "0" + sec; if (MS < 100) { MS = "0" + MS }; var arr_week = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"); week = arr_week[day]; var time = ""; time = month + "/" + date + "/" + year + " " + hour + ":" + minu + ":" + sec; //当前日期赋值给当前日期输入框中(jQuery easyUI) return time; //设置得到当前日期的函数的执行间隔时间,每1000毫秒刷新一次。 // var timer = setTimeout("writeCurrentDate()", 1000); } //七天后 function sevenDay(){ var now = new Date(); now.setDate(now.getDate() + 7);//获取3天前的日期 var year = now.getFullYear(); var month = now.getMonth(); var date = now.getDate();//得到日期 var day = now.getDay();//得到周几 var hour = now.getHours();//得到小时 var minu = now.getMinutes();//得到分钟 var sec = now.getSeconds();//得到秒 var MS = now.getMilliseconds();//获取毫秒 var week; month = month + 1; if (month < 10) month = "0" + month; if (date < 10) date = "0" + date; if (hour < 10) hour = "0" + hour; if (minu < 10) minu = "0" + minu; if (sec < 10) sec = "0" + sec; if (MS < 100) { MS = "0" + MS }; var arr_week = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"); week = arr_week[day]; var time = ""; time = month + "/" + date + "/" + year + " " + hour + ":" + minu + ":" + sec; //当前日期赋值给当前日期输入框中(jQuery easyUI) return time; //设置得到当前日期的函数的执行间隔时间,每1000毫秒刷新一次。 // var timer = setTimeout("writeCurrentDate()", 1000); return time; } //一年后的今天的前一天 function oneYearPast() { var now = new Date(); var year = now.getFullYear() + 1; //得到年份 var month = now.getMonth();//得到月份 var date = now.getDate();//得到日期 var day = now.getDay();//得到周几 var hour = now.getHours();//得到小时 var minu = now.getMinutes();//得到分钟 var sec = now.getSeconds();//得到秒 var MS = now.getMilliseconds();//获取毫秒 var week; month = month + 1; if (month < 10) month = "0" + month; if (date < 10) date = "0" + date; if (hour < 10) hour = "0" + hour; if (minu < 10) minu = "0" + minu; if (sec < 10) sec = "0" + sec; if (MS < 100) { MS = "0" + MS }; var arr_week = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"); week = arr_week[day]; var time = ""; time = month + "/" + date + "/" + year + " " + hour + ":" + minu + ":" + sec; //当前日期赋值给当前日期输入框中(jQuery easyUI) return time; //设置得到当前日期的函数的执行间隔时间,每1000毫秒刷新一次。 // var timer = setTimeout("writeCurrentDate()", 1000); } //月末 function writeCurrentDate() { var nowDate = new Date(); var fullYear = nowDate.getFullYear(); var month = nowDate.getMonth() + 1; // getMonth 方法返回 0-11,代表1-12月 var endOfMonth = new Date(fullYear, month, 0).getDate(); // 获取本月最后一天 var time = fullYear + "-" + month + "-" + endOfMonth + " 23:59:59"; //当前日期赋值给当前日期输入框中(jQuery easyUI) return time; } //日期 function Present_Date() { var now = new Date(); var year = now.getFullYear(); //得到年份 var month = now.getMonth();//得到月份 var date = now.getDate();//得到日期 var day = now.getDay();//得到周几 var hour = now.getHours();//得到小时 var minu = now.getMinutes();//得到分钟 var sec = now.getSeconds();//得到秒 var MS = now.getMilliseconds();//获取毫秒 var week; month = month + 1; if (month < 10) month = "0" + month; if (date < 10) date = "0" + date; if (hour < 10) hour = "0" + hour; if (minu < 10) minu = "0" + minu; if (sec < 10) sec = "0" + sec; if (MS < 100) { MS = "0" + MS }; var arr_week = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"); week = arr_week[day]; var time = ""; time = month + "/" + date + "/" + year; //当前日期赋值给当前日期输入框中(jQuery easyUI) return time; //设置得到当前日期的函数的执行间隔时间,每1000毫秒刷新一次。 // var timer = setTimeout("writeCurrentDate()", 1000); } //时间格式化 function FormatallDate1(strTime) { if (strTime == "" || strTime == "null" || strTime == null) { return ""; } else { strTime = strTime.replace("T", " "); var _data = strTime.split(' ')[0]; var date = new Date(_data); return date.getFullYear() + "-" + buquan((date.getMonth() + 1), 2) + "-" + buquan(date.getDate(), 2); } } //数组深度克隆 function deepClone(obj) { var newObj = Array.isArray(obj) ? [] : {} if (obj && typeof obj === "object") { for (var key in obj) { if (obj.hasOwnProperty(key)) { newObj[key] = (obj && typeof obj[key] === 'object') ? deepClone(obj[key]) : obj[key]; } } } return newObj } function GetQueryValue(queryName) { var reg = new RegExp("(^|&)" + queryName + "=([^&]*)(&|$)", "i"); var r = window.location.search.substr(1).match(reg); if (r != null) { return decodeURI(r[2]); } else { return null; } } //车牌号验证方法 function isVehicleNumber(vehicleNumber) { var xreg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}(([0-9]{5}[DF]$)|([DF][A-HJ-NP-Z0-9][0-9]{4}$))/; var creg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳]{1}$/; if (vehicleNumber.length == 7) { return creg.test(vehicleNumber); } else if (vehicleNumber.length == 8) { return xreg.test(vehicleNumber); } else { return false; } } // function timeFF(str) { //var val = str.substring(0,str.length-7); var val = str.split(' ')[0] return val } function xiaoSTime(s) { // return ('0' + Math.floor(s) % 24).slice(-2) + ':' + ((s % 1)*60*10 + '0').slice(0, 2); var t; if (s > -1) { var hour = Math.floor(s / 3600); var min = Math.floor(s / 60) % 60; var sec = s % 60; sec = String(sec).split('.')[0]; if (hour < 10) { t = '0' + hour + ":"; } else { t = hour + ":"; } if (min < 10) { t += "0"; } t += min + ":"; if (sec < 10) { t += "0"; } t += Number(sec); } return t; } //将秒数转换为时分秒格式 function sec_to_time(s) { var t; if (s > -1) { var hour = Math.floor(s / 3600); var min = Math.floor(s / 60) % 60; var sec = s % 60; sec = String(sec).split('.')[0]; if (hour < 10) { t = '0' + hour + ":"; } else { t = hour + ":"; } if (min < 10) { t += "0"; } t += min + ":"; if (sec < 10) { t += "0"; } t += Number(sec); } return t; } function s_to_hs(s){ //计算分钟 //算法:将秒数除以60,然后下舍入,既得到分钟数 var h; h = Math.floor(s/60); console.log(h) //计算秒 //算法:取得秒%60的余数,既得到秒数 s = s%60; //将变量转换为字符串 h += ''; s += ''; //如果只有一位数,前面增加一个0 h = (h.length==1)?'0'+h:h; s = (s.length==1)?'0'+s:s; return h+':'+s; } //正数小数得到分秒格式00:00 function ssss(num){ num = Number(num) var minutes = Math.floor(num / 60); var seconds = Math.floor(num % 60); minutes<10 ? minutes = '0' + minutes : null; seconds<10 ? seconds = '0' + seconds : null; var msg = minutes + ":" + seconds; return msg } function ww3(date) { var y = date.getFullYear(); var m = date.getMonth() + 1; var d = date.getDate(); var h = date.getHours(); var min = date.getMinutes(); var sec = date.getSeconds(); var str = y + '-' + (m < 10 ? ('0' + m) : m) + '-' + (d < 10 ? ('0' + d) : d); return str; } function w3(s) { if (s) { var ss = FormatallDate1(s); var y = ss.substring(0, 4); var m = ss.substring(5, 7); var d = ss.substring(8, 10); var h = ss.substring(11, 14); var min = ss.substring(15, 17); var sec = ss.substring(18, 20); return new Date(y, m - 1, d, h, min, sec); } else { return new Date(); } } function ww4(date) { var y = date.getFullYear(); var m = date.getMonth() + 1; var d = date.getDate(); var h = date.getHours(); var min = date.getMinutes(); var sec = date.getSeconds(); var str = y + '-' + (m < 10 ? ('0' + m) : m) + '-' + (d < 10 ? ('0' + d) : d) + ' ' + (h < 10 ? ('0' + h) : h) + ':' + (min < 10 ? ('0' + min) : min) + ':' + (sec < 10 ? ('0' + sec) : sec); return str; } function w4(s) { if (s) { var ss = FormatallDate(s); //console.log(ss); var y = ss.substring(0, 4); var m = ss.substring(5, 7); var d = ss.substring(8, 10); var h = ss.substring(11, 13); var min = ss.substring(14, 16); var sec = ss.substring(17, 20); console.log(y, m, d, h, min, sec); return new Date(y, m - 1, d, h, min, sec); } else { return new Date(); } }
给父级元素赋值
     var winAry = Object.keys(parent.window).filter(function(item){return !isNaN(item)})
        if(winAry.length == 0){
            winAry = Object.keys(parent.window.document).filter(function(item){return item.substring(0,10) == 'openIframe'})
        }
        if(curTr.length > 0){
            //点击操作的
            var curName = "已选择" + curTr.length + "个员工";
            //var idss = items[0].StaffID;
            //在所有的window中找到有NewsIDFn方法的那个window下给元素赋值,值为点击的那项
            $(winAry).each(function(index,item){
                if(typeof parent.window[item]["TPStaffIDFn"] == "function"){
                    parent.window[item].$("#TrainingPlanModify_StaffID").val(curName);
                    parent.window[item].$("#TrainingPlanModify_StaffIDid").val(ids);
                }
            })
            parent.closeWindow1();
            return
        }

 

登录成功后跳转页面之前,拿到权限码筛选自己的权限
var Lanmu = [{
    text: '基础信息',
    iconCls: 'icon-jcxx',
    numm:'0101',
    children: [
        { text: '地区管理',numm:'01'},
        { text: '基础设置',numm:'02'},
        { text: '清除缓存',numm:'03' }
    ]
}, {
    text: '账号管理',
    iconCls: 'icon-zhgl',
    numm:'0102',
    children: [
        { text: '账号管理',numm:'01'},
        { text: '功能权限',numm:'02'},
        { text: '登录日志',numm:'03'}
    ]
}, {
    text: '公文管理',
    iconCls: 'icon-gwgl',
    numm:'0103',
    children: [
        { text: '公文管理',numm:'01'}
    ]
}, {
    text: '通知管理',
    iconCls: 'icon-tzgl',
    numm:'0104',
    children: [
        { text: '通知管理',numm:'01' }
    ]
}, {
    text: '课程中心',
    iconCls: 'icon-kczx',
    numm:'0105',
    children: [
        { text: '课程管理',numm:'01' },
        { text: '培训计划',numm:'02' },
        { text: '指派计划',numm:'03' }
    ]
}, {
    text: '订单中心',
    iconCls: 'icon-ddzx',
    numm:'0106',
    children: [
        { text: '订单管理',numm:'01' },
        { text: '发票管理',numm:'02' },
        { text: '培训劵设置',numm:'03' }
    ]
}, {
    text: '企业中心',
    iconCls: 'icon-qyzx',
    numm:'0107',
    children: [
        { text: '企业信息',numm:'01' },
        { text: '车辆信息',numm:'02' },
        { text: '学员信息',numm:'03' }
    ]
}, {
    text: '统计信息',
    iconCls: 'icon-tjxx',
    numm:'0108',
    children: [
        { text: '月培训人数汇总',numm:'01' }
    ]
}, {
    text: '消息中心',
    iconCls: 'icon-xxzx',
    numm:'',
    children: [
        { text: '消息中心',numm:'' }
    ]
}];
var dataMenuTemp = [];
                        $(Lanmu).each(function(index,item){
                            $(res.User_Auth).each(function(i,t){
                                if(item.numm == t){
                                    var ary = [];
                                    $(item.children).each(function(a,b){
                                        $(res.User_Auth).each(function(c,d){
                                            if(b.numm == d){
                                                ary.push(b)
                                            }
                                        })
                                    })
                                    item.children = ary;
                                    dataMenuTemp.push(item);
                                }
                            })
                        })
                        obj["Lanmu"] = dataMenuTemp;
window.localStorage.setItem("userInfo",JSON.stringify(obj));

index.js中通过获取window.localStorage["userInfo"]中的userInfo.Lanmu赋值
登录成功跳转页面:
top.location.href = "/Management/Index";

此页面为:
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

转到_Layout这个页面:
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>管理</title>
    <meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE">
    <link href="~/Content/easyuicss/bootstrap/css/bootstrap.css" rel="stylesheet" />
    <link href="~/Content/easyuicss/themes/default/easyui.css" rel="stylesheet" />
    <link href="~/Content/easyuicss/themes/icon.css" rel="stylesheet" />
    <link href="~/Scripts/pnotify-1.2.0/pnotify.custom.min.css" rel="stylesheet" />
    <link href="~/Content/css/main.css" rel="stylesheet" />
    <script src="~/Scripts/jquery-1.10.2.min.js"></script>
    <script src="~/Scripts/urlconfig.js"></script>
    <script src="~/Scripts/pnotify-1.2.0/pnotify.custom.min.js"></script>
 
    <script src="~/Scripts/jquery.easyui.min.js"></script>
    <script src="~/Scripts/easyui-lang-zh_CN.js"></script>
    <script src="~/Scripts/jquery.showLoading.min.js"></script>
    <script src="~/Scripts/localResizeIMG.js"></script>
    <script src="~/Scripts/mobileBUGFix.mini.js"></script>
    <script src="~/Scripts/index.js"></script>
    <script src="~/Scripts/web.base.js"></script>

</head>
<body class="easyui-layout">
    <div data-options="region:'north',split:false,border:false" style="height: 58px; padding: 0px; overflow: hidden; background: #cddef7; ">

        <div id="nav"><!-- background-image: linear-gradient(to bottom left, #cddef7, #a4c2ec,#7fa7de,#4e92f1);-->
            <div class="logo" style="text-align: center; height: 58px; line-height: 58px; font-size: 26px; font-weight: bold; color: rgba(255, 255, 255, 0.9); background: #1eb4ff url(/Content/images/top2.jpg) no-repeat left; letter-spacing: 5px; ">
                <span>管理</span>
            </div>

        </div>
        <div class="topinfo">
            <div id="rigPan" class="easyui-panel" style="position: absolute; border-radius: 15px; right: 30px; top: 15px; width: auto; border-width: 0; border-style: none; background-color: #ffffff; ">
                <a href="javascript:void(0)" id="mb" class="easyui-menubutton" data-options="menu:'#mm2'" style="width:auto;margin: auto 10px;">
                    <img src="~/Content/images/username.png" style="vertical-align: -2px; height: 14px; width: 14px;" />
                    <span id="username" class="fc5 f16" style="letter-spacing: 2px;"></span>
                </a>
            </div>
            <div id="mm2" style="width:auto;">
                <div onclick="changepass()">修改密码</div>
                <div onclick="userout()">退出系统</div>
            </div>
        </div>
    </div>
    <div data-options="region:'west',split:false" title="管理中心" style="width: 190px; position: relative;">
        <div class="accordion" id="leftmenu" style="border-top: 0px; border: none;">
            <div id="sm" class="easyui-sidemenu" data-options="data:dataMenu, onSelect:mentEvent" style="width:100%;"></div>
        </div>
    </div>

    <div data-options="region:'center'" style="overflow: hidden;">

        <div class="easyui-tabs" id="maintab" data-options="fit:true,border:false,tools:'#tab-tools'">
            <div title="管理中心" style="padding: 20px; overflow: hidden;">
                <table class="order">
                    <tr>
                        <td valign="top"></td>
                        <td valign="top" style="padding-left: 10px;"></td>
                    </tr>
                    <tr>
                        <td colspan="2" valign="top"></td>

                    </tr>
                </table>

            </div>
        </div>
        <div id="tab-tools">
        </div>
    </div>
    <div id="openDialog" class="easyui-window" data-options="modal:true, resizable:true, closed:true,minimizable:false, maximizable:false,collapsible:false,onClose:function(){dialogOnClose();}"
         style="width: 700px; height: 450px; overflow: hidden;">
        <iframe scrolling-x="no" id='openIframe' name="openIframe" frameborder="0" src="" style="width: 100%; height: 100%;"></iframe>
    </div>
    <div id="openDialog1" class="easyui-window" data-options="modal:true, resizable:true, closed:true,minimizable:false, maximizable:false,collapsible:false,onClose:function(){dialogOnClose1();}"
         style="width: 700px; height: 450px; overflow: hidden;">
        <iframe scrolling-x="no" id='openIframe1' name="openIframe1" frameborder="0" src="" style="width: 100%; height: 100%;"></iframe>
    </div>
    <div id="openDialog2" class="easyui-window" data-options="modal:true, resizable:true, closed:true,minimizable:false, maximizable:false,collapsible:false,onClose:function(){dialogOnClose2();}"
         style="width: 700px; height: 450px; overflow: hidden;">
        <iframe scrolling-x="no" id='openIframe2' name="openIframe2" frameborder="0" src="" style="width: 100%; height: 100%;"></iframe>
    </div>
    <div id="openDialog3" class="easyui-window" data-options="modal:true, resizable:true, closed:true,minimizable:false, maximizable:false,collapsible:false,onClose:function(){dialogOnClose3();}"
         style="width: 700px; height: 450px; overflow: hidden;">
        <iframe scrolling-x="no" id='openIframe3' name="openIframe3" frameborder="0" src="" style="width: 100%; height: 100%;"></iframe>
    </div>
    <div id="openDialogNOC" class="easyui-window" data-options="modal:true, resizable:true, closed:true,minimizable:false, maximizable:false,collapsible:false,onClose:function(){dialogOnCloseNOC();}"
         style="width: 700px; height: 450px; overflow: hidden;">
        <iframe scrolling-x="no" id='openIframeNOC' name="openIframeNOC" frameborder="0" src="" style="width: 100%; height: 100%;"></iframe>
    </div>
        @RenderBody()
    <script type="text/javascript">
        //var rigPanWid = $("#username")[0].offsetWidth;
        var rigPanWid = parseInt($("#username").css('width'));
        //console.log(rigPanWid);

        if(rigPanWid < 160){
            $("#rigPan").css({'width':'220'});
            $("#mb").css({'width':'200'});

        }else{
            $("#rigPan").css({'width':(rigPanWid+70)+'px'});
        }
    </script>
</body>
</html>
页面有五个弹页分别对应index.js里的函数空值

 

posted @ 2021-11-01 11:20  石头记1  阅读(9)  评论(0)    收藏  举报