216 lines
7.3 KiB
JavaScript
216 lines
7.3 KiB
JavaScript
layui.config({
|
||
base: "lib/okPlugins/"
|
||
}).extend({
|
||
okTab: "okTab",
|
||
okUtils: "okUtils",
|
||
okMenu: "okMenu"
|
||
}).use(["element", "layer", "okTab", "okUtils", "okMenu"], function () {
|
||
var element = layui.element;
|
||
var layer = layui.layer;
|
||
var $ = layui.jquery;
|
||
var okTab = layui.okTab;
|
||
var okUtils = layui.okUtils;
|
||
var okMenu = layui.okMenu;
|
||
|
||
/**
|
||
* localhost运行提示
|
||
*/
|
||
var href = location.href;
|
||
if (href.substring(0, 4) != "http") {
|
||
layer.msg("请先部署到localhost环境下再访问!", {icon: 7, time: 3000, anim: 1});
|
||
}
|
||
|
||
/**
|
||
* 左边菜单显示/隐藏功能
|
||
* @type {boolean}
|
||
*/
|
||
$(".menu-switch").click(function () {
|
||
if ($(".layui-layout-admin .layui-side").css("left") == '0px') {
|
||
$(".layui-layout-admin .layui-side").animate({left: "-200px"});
|
||
$(".layui-layout-admin .content-body").animate({left: "0px"});
|
||
$(".layui-layout-admin .layui-footer").animate({left: "0px"});
|
||
} else {
|
||
$(".layui-layout-admin .layui-side").animate({left: "0px"});
|
||
$(".layui-layout-admin .content-body").animate({left: "200px"});
|
||
$(".layui-layout-admin .layui-footer").animate({left: "200px"});
|
||
}
|
||
});
|
||
|
||
/**
|
||
* 生成左侧菜单树
|
||
*/
|
||
okMenu.generatorMenu("data/menu.json", "get");
|
||
|
||
// okUtils.ajax("data/menu.json", "get").done(function (response) {
|
||
// var html = "";
|
||
// for (var i = 0; i < response.length; i++) {
|
||
// var d = response[i];
|
||
// html += liHtml(d);
|
||
// html += "<a href='javascript:;'>"
|
||
// html += iconHtml(d) + " " + response[i].title;
|
||
// html += "</a>"
|
||
// // var children = d.children;
|
||
// // if (children != undefined && children.length > 0) {
|
||
// // html += "<dl class='layui-nav-child'>"
|
||
// // for (var j = 0; j < children.length; j++) {
|
||
// // html += "<dd>";
|
||
// // html += "<a href='javascript:;' path='" + children[j].path + "'>" + iconHtml(children[j]) + " " + children[j].title + "</a>";
|
||
// // html += "</dd>";
|
||
// // }
|
||
// // html += "</dl>"
|
||
// // }
|
||
// var temp = createMenu(d.children);
|
||
// html += temp;
|
||
// html += "</li>";
|
||
// }
|
||
// $(".layui-nav-tree").html(html);
|
||
// element.render("nav");
|
||
// }).fail(function (error) {
|
||
// console.log(error)
|
||
// });
|
||
|
||
// function liHtml(obj) {
|
||
// var html = "";
|
||
// if (obj.spread) {
|
||
// html += "<li class='layui-nav-item layui-nav-itemed'>";
|
||
// } else {
|
||
// html += "<li class='layui-nav-item'>";
|
||
// }
|
||
// return html;
|
||
// }
|
||
|
||
// function iconHtml(obj) {
|
||
// var html = "";
|
||
// if (obj.icon) {
|
||
// if (obj.font == "iconfont") {
|
||
// html += "<i class='iconfont'>" + obj.icon + "</i>";
|
||
// } else if (obj.font == "layui-icon") {
|
||
// html += "<i class='layui-icon'> " + obj.icon + "</i>";
|
||
// } else {
|
||
// html += "<i class='iconfont'>" + obj.icon + "</i>";
|
||
// }
|
||
// } else {
|
||
// console.warn(obj.title, "icon未定义");
|
||
// }
|
||
// return html;
|
||
// }
|
||
|
||
// function createMenu(obj) {
|
||
// var html = "";
|
||
// if (obj != undefined && obj.length > 0) {
|
||
// html += "<dl class='layui-nav-child'>"
|
||
// for (var i = 0; i < obj.length; i++) {
|
||
// html += "<dd>";
|
||
// html += "<a href='javascript:;' path='" + obj[i].path + "'>" + iconHtml(obj[i]) + " " + obj[i].title + "</a>";
|
||
// var children = obj[i].children;
|
||
// if (children != undefined && children.length > 0) {
|
||
// html += createMenu(children);
|
||
// }
|
||
// html += "</dd>";
|
||
// }
|
||
// html += "</dl>"
|
||
// }
|
||
// return html;
|
||
// }
|
||
|
||
/**
|
||
* 监听导航菜单的点击
|
||
*/
|
||
element.on("nav(navFilter)", function (elem) {
|
||
var path = elem.context.attributes.path;
|
||
if (path && path.textContent != "") {
|
||
// var title = elem.context.innerHTML;
|
||
var title = elem.context.innerText;
|
||
title = title.substring(title.indexOf(" "), title.length);
|
||
var path = path.textContent;
|
||
okTab.add(title, path)
|
||
}
|
||
});
|
||
|
||
// 停用
|
||
// $(".layui-nav-child").find("dd").click(function () {
|
||
// var title = $(this).text();
|
||
// var path = $(this).children("a").attr("path");
|
||
// okTab.add(title, path)
|
||
// });
|
||
|
||
/**
|
||
* 修改copyright结束时间
|
||
*/
|
||
var data = new Date();
|
||
var year = data.getFullYear();
|
||
$("#endYear").text(year);
|
||
|
||
/**
|
||
* 捐赠作者
|
||
*/
|
||
$(".layui-footer button.donate").click(function () {
|
||
layer.tab({
|
||
area: ["330px", "350px"],
|
||
tab: [{
|
||
title: "支付宝",
|
||
content: "<img src='imgs/zfb.jpg' width='200' height='300' style='margin-left: 60px'>"
|
||
}, {
|
||
title: "微信",
|
||
content: "<img src='imgs/wx.jpg' width='200' height='300' style='margin-left: 60px'>"
|
||
}]
|
||
});
|
||
});
|
||
|
||
/**
|
||
* QQ群交流
|
||
*/
|
||
$(".layui-footer button.communication").click(function () {
|
||
layer.tab({
|
||
area: ["330px", "350px"],
|
||
tab: [{
|
||
title: "QQ群",
|
||
content: "<img src='imgs/qq.jpeg' width='200' height='300' style='margin-left: 60px'>"
|
||
}]
|
||
});
|
||
});
|
||
|
||
/**
|
||
* 退出操作
|
||
*/
|
||
$("#logout").click(function () {
|
||
layer.confirm("确定要退出吗?", {skin: 'layui-layer-lan', icon: 3, title: '提示', anim: 6}, function () {
|
||
window.location = "pages/user/login.html";
|
||
});
|
||
});
|
||
|
||
/**
|
||
* 锁定账户
|
||
*/
|
||
$("#lock").click(function () {
|
||
layer.confirm("确定要锁定账户吗?", {skin: 'layui-layer-lan', icon: 4, title: '提示', anim: 1}, function (index) {
|
||
layer.close(index);
|
||
$(".yy").show();
|
||
layer.prompt({
|
||
btn: ['确定'],
|
||
title: '输入密码解锁(123456)',
|
||
closeBtn: 0,
|
||
formType: 1
|
||
}, function (value, index, elem) {
|
||
if (value == "123456") {
|
||
layer.close(index);
|
||
$(".yy").hide();
|
||
} else {
|
||
layer.msg('密码错误', {anim: 6});
|
||
}
|
||
});
|
||
});
|
||
});
|
||
|
||
console.log(" __ .___ .__ \n" +
|
||
" ____ | | __ _____ __| _/_____ |__| ____ \n" +
|
||
" / _ \\| |/ / ______ \\__ \\ / __ |/ \\| |/ \\ \n" +
|
||
"( <_> ) < /_____/ / __ \\_/ /_/ | Y Y \\ | | \\\n" +
|
||
" \\____/|__|_ \\ (____ /\\____ |__|_| /__|___| /\n" +
|
||
" \\/ \\/ \\/ \\/ \\/ \n" +
|
||
"版本:v1.0\n" +
|
||
"作者:bobi\n" +
|
||
"邮箱:bobi1234@foxmail.com\n" +
|
||
"描述:一个很赞的,扁平化风格的,响应式布局的后台管理模版,旨为后端程序员减压!")
|
||
});
|