From 6ab292fb7415be124651e312ec4f21c594568f17 Mon Sep 17 00:00:00 2001 From: chengkun <chengkun@ishangstudy.com> Date: Wed, 30 Apr 2025 18:16:09 +0800 Subject: [PATCH] 提交 --- js/layui/phpyun_layer.js | 384 +++++++++++++++++++++++++++--------------------------- 1 files changed, 191 insertions(+), 193 deletions(-) diff --git a/js/layui/phpyun_layer.js b/js/layui/phpyun_layer.js index a09af60..e01c048 100644 --- a/js/layui/phpyun_layer.js +++ b/js/layui/phpyun_layer.js @@ -12,216 +12,214 @@ * icon : 1 打勾,2打叉,5/9伤心,6/8笑脸,7感叹号 * callback : 消息展示结束后回调函数 */ -layui.use(['layer'], function(){ - var layer = layui.layer, - $ = layui.$; +layui.use(['layer'], function () { + var layer = layui.layer, + $ = layui.$; - //先保存原始的layer.msg()方法 - layer.oriMsg = layer.msg; + //先保存原始的layer.msg()方法 + layer.oriMsg = layer.msg; - //再重写layer.msg() - // layer.msg = function (msg, timeSecond = 1.5, icon = 6, callback = function(){}){ - layer.msg = function (msg, timeSecond , icon , callback ){ - timeSecond = (typeof timeSecond !== 'undefined') ? timeSecond : 1.5; - icon = (typeof icon !== 'undefined') ? icon : 6; - callback = (typeof callback !== 'undefined') ? callback : function(){}; + //再重写layer.msg() + // layer.msg = function (msg, timeSecond = 1.5, icon = 6, callback = function(){}){ + layer.msg = function (msg, timeSecond, icon, callback) { + timeSecond = (typeof timeSecond !== 'undefined') ? timeSecond : 1.5; + icon = (typeof icon !== 'undefined') ? icon : 6; + callback = (typeof callback !== 'undefined') ? callback : function () { }; - //兼容原本layui.use(['layer'])的layer.msg()用法 - if(typeof(timeSecond) == 'object'){ - if(typeof(icon) == 'function'){ - return layer.oriMsg(msg, timeSecond, icon); - } - else{ - return layer.oriMsg(msg, timeSecond); - } - } + //兼容原本layui.use(['layer'])的layer.msg()用法 + if (typeof (timeSecond) == 'object') { + if (typeof (icon) == 'function') { + return layer.oriMsg(msg, timeSecond, icon); + } + else { + return layer.oriMsg(msg, timeSecond); + } + } - var tm = timeSecond * 1000; + var tm = timeSecond * 1000; - //layui.use(['layer'])中icon: 1 打勾,2打叉,5伤心,6笑脸,7感叹号 - //layer.min.js中icon: 8失败,9成功 - if(icon == 8){ - icon = 5; - } - if(icon == 9){ - icon = 6; - } - - return layer.oriMsg(msg, - { - time : tm, - icon : icon, + //layui.use(['layer'])中icon: 1 打勾,2打叉,5伤心,6笑脸,7感叹号 + //layer.min.js中icon: 8失败,9成功 + if (icon == 8) { + icon = 2; + } + if (icon == 9) { + icon = 1; + } + console.log(icon); + return layer.msg(msg, + { + time: tm, + icon: icon, shade: [0.8, '#393D49'] //加过滤层黑色透明背景 - }, - function(){ - callback(); - } - ); - };//end layer.msg + }, + function () { + callback(); + } + ); + };//end layer.msg - //加载动画加遮罩层 - layer.oriLoad = layer.load; - layer.load = function(icon,options) - { - icon = (typeof icon !== 'undefined') ? icon : 0; - options = (typeof options == 'object') ? options : {}; - - options.shade = [0.8, '#393D49']; - return layer.oriLoad(icon, options); - }; + //加载动画加遮罩层 + layer.oriLoad = layer.load; + layer.load = function (icon, options) { + icon = (typeof icon !== 'undefined') ? icon : 0; + options = (typeof options == 'object') ? options : {}; - //alert对话框 - layer.oriAlert = layer.alert; - layer.alert = function(msg, icon, title, callback) - { - if(typeof icon == 'object'){ - //layui的layer模块原本调用方式 - if(typeof title == 'function'){ - return layer.oriAlert(msg, icon, title); - } - else{ - return layer.oriAlert(msg, icon); - } - }else if(typeof icon != 'undefined' && typeof title == 'undefined'){ - //兼容layer.min.js的调用方式 - return layer.msg(msg, 1.5, icon); - }else if(typeof callback == 'function'){ - return layer.oriAlert(msg, {title : title}, callback); - }else{ - return layer.oriAlert(msg); - } - } + options.shade = [0.8, '#393D49']; + return layer.oriLoad(icon, options); + }; - /** - * 【页面层(和父窗口属于同一个html页面)】 封装layer.open({type:1}) - * - * content : 展示的内容 : html代码(字符串),dom节点(例如:$("#id") ) - * area : ['300px', '200px'] - * offset : ['100px', '50px'] , 'auto', 'r' 等 - * options : {} 其他layui文档中的参数 - */ - // layer.page = function (content, title, area, offset = 'auto', options = {}){ - layer.page = function (content, title, area, offset , options ){ - offset = (typeof offset !== 'undefined') ? offset : 'auto'; - options = (typeof options !== 'undefined') ? options : {}; + //alert对话框 + layer.oriAlert = layer.alert; + layer.alert = function (msg, icon, title, callback) { + if (typeof icon == 'object') { + //layui的layer模块原本调用方式 + if (typeof title == 'function') { + return layer.oriAlert(msg, icon, title); + } + else { + return layer.oriAlert(msg, icon); + } + } else if (typeof icon != 'undefined' && typeof title == 'undefined') { + //兼容layer.min.js的调用方式 + return layer.msg(msg, 1.5, icon); + } else if (typeof callback == 'function') { + return layer.oriAlert(msg, { title: title }, callback); + } else { + return layer.oriAlert(msg); + } + } - options.type = 1; - options.content = content; - options.area = area; - options.offset = offset; - options.title = title; + /** + * 【页面层(和父窗口属于同一个html页面)】 封装layer.open({type:1}) + * + * content : 展示的内容 : html代码(字符串),dom节点(例如:$("#id") ) + * area : ['300px', '200px'] + * offset : ['100px', '50px'] , 'auto', 'r' 等 + * options : {} 其他layui文档中的参数 + */ + // layer.page = function (content, title, area, offset = 'auto', options = {}){ + layer.page = function (content, title, area, offset, options) { + offset = (typeof offset !== 'undefined') ? offset : 'auto'; + options = (typeof options !== 'undefined') ? options : {}; - return layer.open(options); - }; + options.type = 1; + options.content = content; + options.area = area; + options.offset = offset; + options.title = title; - //封装layer.open({type:2})【iframe页面层】 - // layer.iframe = function (url, title, area, offset = 'auto', options = {}){ - layer.iframe = function (url, title, area, offset, options ){//浏览器兼容写法 - offset = (typeof offset !== 'undefined') ? offset : 'auto'; - options = (typeof options !== 'undefined') ? options : {}; + return layer.open(options); + }; - options.type = 2; - options.content = url; - options.area = area; - options.offset = offset; - options.title = title; + //封装layer.open({type:2})【iframe页面层】 + // layer.iframe = function (url, title, area, offset = 'auto', options = {}){ + layer.iframe = function (url, title, area, offset, options) {//浏览器兼容写法 + offset = (typeof offset !== 'undefined') ? offset : 'auto'; + options = (typeof options !== 'undefined') ? options : {}; - return layer.open(options); - }; + options.type = 2; + options.content = url; + options.area = area; + options.offset = offset; + options.title = title; + + return layer.open(options); + }; });//end layui.use() -function monthclick(laydate,elem,hasdone){ - var timestamp=new Date(); - nowyear = timestamp.getFullYear(), - nowmonth = timestamp.getMonth() + 1; - if(nowmonth<10){ - nowmonth = "0"+ nowmonth; - } - nowday = timestamp.getDate(); - var max = ''; - if(elem=='#eduedate' || elem.indexOf("#edu_edate") >= 0){ - max = '2099-12-30'; - }else{ - max = nowyear+'-'+nowmonth+'-'+nowday; - } - laydateobj = - laydate.render({ - elem: elem, - type: 'month', - trigger : 'click', - max: max, - change: function(value, date, endDate){ - var nowtimestr=nowyear+'-'+nowmonth; - var oldVal = $(elem).val(); - if(nowtimestr>=value){ - $(elem).val(value); - }else{ - $(elem).val(nowtimestr); - } - if(oldVal.substr(0, 4) == value.substr(0, 4) || nowyear == value.substr(0, 4)){ - $('.laydate-btns-confirm').click(); - } - }, - done: function(value, date, endDate) { - if(hasdone==1){ - var id=elem.replace('#',''); - //checkonblur(id); - } - } - }); +function monthclick(laydate, elem, hasdone) { + var timestamp = new Date(); + nowyear = timestamp.getFullYear(), + nowmonth = timestamp.getMonth() + 1; + if (nowmonth < 10) { + nowmonth = "0" + nowmonth; + } + nowday = timestamp.getDate(); + var max = ''; + if (elem == '#eduedate' || elem.indexOf("#edu_edate") >= 0) { + max = '2099-12-30'; + } else { + max = nowyear + '-' + nowmonth + '-' + nowday; + } + laydateobj = + laydate.render({ + elem: elem, + type: 'month', + trigger: 'click', + max: max, + change: function (value, date, endDate) { + var nowtimestr = nowyear + '-' + nowmonth; + var oldVal = $(elem).val(); + if (nowtimestr >= value) { + $(elem).val(value); + } else { + $(elem).val(nowtimestr); + } + if (oldVal.substr(0, 4) == value.substr(0, 4) || nowyear == value.substr(0, 4)) { + $('.laydate-btns-confirm').click(); + } + }, + done: function (value, date, endDate) { + if (hasdone == 1) { + var id = elem.replace('#', ''); + //checkonblur(id); + } + } + }); } -if(typeof($) !== 'undefined'){ - $.layer = function(obj){ - var retval; - layui.use(['layer'], function(){ - var layer = layui.layer, - $ = layui.$; +if (typeof ($) !== 'undefined') { + $.layer = function (obj) { + var retval; + layui.use(['layer'], function () { + var layer = layui.layer, + $ = layui.$; - var offset = 'auto'; - if(obj.offset){ - offset = obj.offset; - } + var offset = 'auto'; + if (obj.offset) { + offset = obj.offset; + } - var content = ''; - if(obj.page){ - if(obj.page.dom){ - content = $(obj.page.dom); - }else if(obj.page.html){ - content = obj.page.html; - } - }else if(obj.iframe){ - if(obj.iframe.src){ - content = obj.iframe.src; - } - } - - var id = obj.id ? obj.id : ''; - - var close = obj.close ? obj.close : function(){}; - var laydata = { - content : content, - offset : offset, - id : id, - end : close - }; - if(obj.type){ - laydata.type = obj.type; - } - if(obj.title){ - laydata.title = obj.title; - } - if(obj.area){ - laydata.area = obj.area; - } - if(obj.zIndex){ - laydata.zIndex = obj.zIndex; - } - if(obj.success){ - laydata.success = obj.success; - } - retval = layer.open(laydata); - });// - - return retval; - };//end $.layer + var content = ''; + if (obj.page) { + if (obj.page.dom) { + content = $(obj.page.dom); + } else if (obj.page.html) { + content = obj.page.html; + } + } else if (obj.iframe) { + if (obj.iframe.src) { + content = obj.iframe.src; + } + } + + var id = obj.id ? obj.id : ''; + + var close = obj.close ? obj.close : function () { }; + var laydata = { + content: content, + offset: offset, + id: id, + end: close + }; + if (obj.type) { + laydata.type = obj.type; + } + if (obj.title) { + laydata.title = obj.title; + } + if (obj.area) { + laydata.area = obj.area; + } + if (obj.zIndex) { + laydata.zIndex = obj.zIndex; + } + if (obj.success) { + laydata.success = obj.success; + } + retval = layer.open(laydata); + });// + + return retval; + };//end $.layer } -- Gitblit v1.9.0