diff --git a/lib/layui_plugins/okLayer/okLayer.js b/lib/layui_plugins/okLayer/okLayer.js index b475fd0..2e91544 100644 --- a/lib/layui_plugins/okLayer/okLayer.js +++ b/lib/layui_plugins/okLayer/okLayer.js @@ -1,8 +1,15 @@ layui.define(["layer"], function (exports) { var $ = layui.jquery; var okLayer = { - skinStyle: 2, + // 控制了msg() confirm() open()方法的弹窗皮肤 + skinStyle: 3, + // 控制了msg() confirm() open()方法的弹窗动画 animStyle: 2, + /** + * 主要用于针对表格批量操作操作之前的检查 + * @param table + * @returns {string} + */ tableCheck: function (table) { var checkStatus = table.checkStatus("tableId"); var rows = checkStatus.data.length; @@ -16,15 +23,33 @@ layui.define(["layer"], function (exports) { layer.msg("未选择有效数据", {offset: "t", anim: 6}); } }, - tableOperationMsg: function (content) { + /** + * 在表格页面操作成功后弹窗提示 + * @param content + */ + tableOperationSuccessMsg: function (content) { layer.msg(content, {icon: 1, time: 1000}, function () { + // 刷新当前table数据 $(".layui-laypage-btn")[0].click(); }); }, + /** + * confirm()函数二次封装 + * @param content + * @param yesFunction + */ confirm: function (content, yesFunction) { var options = {skin: okLayer.skinChoose(), icon: 2, title: "提示", anim: okLayer.animChoose()}; layer.confirm(content, options, yesFunction); }, + /** + * open()函数二次封装,支持在table页面和普通页面打开 + * @param title + * @param content + * @param width + * @param height + * @param isRefreshTable + */ open: function (title, content, width, height, isRefreshTable) { layer.open({ title: title, @@ -38,23 +63,83 @@ layui.define(["layer"], function (exports) { zIndex: layer.zIndex, skin: okLayer.skinChoose(), end: function () { - if (isRefreshTable) { - $(".layui-laypage-btn")[0].click(); - } + if (isRefreshTable) { + $(".layui-laypage-btn")[0].click(); + } } }); }, - skinChoose: function () { - if (okLayer.skinStyle == 1) { - return "layui-layer-lan"; - } else if (okLayer.skinStyle == 2) { - return "layui-layer-molv"; + /** + * msg()函数二次封装 + */ + msg: { + // msg弹窗默认消失时间 + time: 1000, + // 绿色勾 + greenTick: function (content, time, callbackFunction) { + var options = {icon: 1, time: okLayer.msg.timeCompute(time), anim: okLayer.animChoose()}; + layer.msg(content, options, callbackFunction); + }, + // 红色叉 + redCross: function (content, callbackFunction) { + var options = {icon: 2, time: okLayer.msg.timeCompute(time), anim: okLayer.animChoose()}; + layer.msg(content, options, callbackFunction); + }, + // 黄色问号 + yellowQuestion: function (content, callbackFunction) { + var options = {icon: 3, time: okLayer.msg.timeCompute(time), anim: okLayer.animChoose()}; + layer.msg(content, options, callbackFunction); + }, + // 灰色锁 + grayLock: function (content, callbackFunction) { + var options = {icon: 4, time: okLayer.msg.timeCompute(time), anim: okLayer.animChoose()}; + layer.msg(content, options, callbackFunction); + }, + // 红色哭脸 + redCry: function (content, callbackFunction) { + var options = {icon: 5, time: okLayer.msg.timeCompute(time), anim: okLayer.animChoose()}; + layer.msg(content, options, callbackFunction); + }, + // 绿色笑脸 + greenLaugh: function (content, callbackFunction) { + var options = {icon: 6, time: okLayer.msg.timeCompute(time), anim: okLayer.animChoose()}; + layer.msg(content, options, callbackFunction); + }, + // 黄色感叹号 + yellowSigh: function (content, callbackFunction) { + var options = {icon: 7, time: okLayer.msg.timeCompute(time), anim: okLayer.animChoose()}; + layer.msg(content, options, callbackFunction); + }, + timeCompute: function (time) { + return time ? time : okLayer.msg.time; } }, + /** + * 皮肤选择 + * @returns {string} + */ + skinChoose: function () { + if (okLayer.skinStyle == 1) { + // 默认皮肤 + return ""; + } else if (okLayer.skinStyle == 2) { + // 墨绿色 + return "layui-layer-molv"; + } else if (okLayer.skinStyle == 3) { + // 蓝色 + return "layui-layer-lan"; + } + }, + /** + * 动画选择 + * @returns {number} + */ animChoose: function () { if (okLayer.animStyle == 1) { + // 默认动画 return 0; } else if (okLayer.animStyle == 2) { + // 随机动画 return Math.floor(Math.random() * 7); } } diff --git a/lib/layui_plugins/okUtils/okUtils.js b/lib/layui_plugins/okUtils/okUtils.js index 8e676bd..43affae 100644 --- a/lib/layui_plugins/okUtils/okUtils.js +++ b/lib/layui_plugins/okUtils/okUtils.js @@ -1,8 +1,15 @@ layui.define("layer", function (exports) { var $ = layui.jquery; var okUtils = { - isFrontendBackendSeparate: true, + isFrontendBackendSeparate: true, baseUrl: "http://localhost:8080", + /** + * ajax()函数二次封装 + * @param url + * @param type + * @param param + * @returns {*|*|*} + */ ajax: function (url, type, param) { var deferred = $.Deferred(); var loadIndex; @@ -19,7 +26,7 @@ layui.define("layer", function (exports) { // 业务正常 deferred.resolve(data.data) } else { - // 业务错误 + // 业务异常 layer.msg(data.msg, {icon: 7, time: 2000}); deferred.reject("okUtils.ajax warn: " + data.msg); } diff --git a/pages/user/login.html b/pages/user/login.html index 25002c6..92294ef 100644 --- a/pages/user/login.html +++ b/pages/user/login.html @@ -6,7 +6,7 @@ - + @@ -41,6 +41,12 @@