/** layui-v2.5.6 MIT License By https://www.layui.com */
layui.define("jquery", function(e) {
"use strict";
var t = layui.$, // 引入 jQuery 库
i = {
// 固定操作栏(侧边固定按钮)
fixbar: function(e) {
var i, n,
a = "layui-fixbar", // 固定按钮的 CSS 类名
o = "layui-fixbar-top", // 顶部按钮的 CSS 类名
r = t(document), // 获取文档对象
l = t("body"); // 获取页面的 body 元素
// 配置项默认值
e = t.extend({ showHeight: 200 }, e);
// 如果没有设置 bar1 和 bar2 的图标,默认使用图标
e.bar1 = e.bar1 === !0 ? "" : e.bar1;
e.bar2 = e.bar2 === !0 ? "" : e.bar2;
// 设置背景颜色样式
e.bgcolor = e.bgcolor ? "background-color:" + e.bgcolor : "";
var c = [e.bar1, e.bar2, ""];
// 创建固定操作栏的 HTML 结构
var u = t([
'
',
e.bar1 ? '- '+c[0]+"
" : "",
e.bar2 ? '- '+c[1]+"
" : "",
'- '+c[2]+"
",
"
"
].join(""));
var g = u.find("."+o);
// 滚动事件:当页面滚动到指定高度时,显示操作栏
var s = function() {
var t = r.scrollTop();
t >= e.showHeight ? i || (g.show(), i = 1) : i && (g.hide(), i = 0);
};
// 如果操作栏未渲染,则将其添加到页面
t("."+a)[0] || (
"object" == typeof e.css && u.css(e.css),
l.append(u),
s(),
// 绑定点击事件
u.find("li").on("click", function() {
var i = t(this),
n = i.attr("lay-type");
"top" === n && t("html,body").animate({ scrollTop: 0 }, 200);
e.click && e.click.call(this, n);
}),
r.on("scroll", function() {
clearTimeout(n);
n = setTimeout(function() {
s();
}, 100);
})
);
},
// 倒计时功能
countdown: function(e, t, i) {
var n = this,
a = "function" == typeof t, // 如果 t 是函数
o = new Date(e).getTime(), // 目标时间戳
r = new Date(!t || a ? (new Date).getTime() : t).getTime(), // 当前时间戳
l = o - r, // 计算时间差
c = [
Math.floor(l / 864e5), // 天数
Math.floor(l / 36e5) % 24, // 小时
Math.floor(l / 6e4) % 60, // 分钟
Math.floor(l / 1e3) % 60 // 秒
];
// 如果 t 是函数,则执行回调
a && (i = t);
var u = setTimeout(function() {
n.countdown(e, r + 1e3, i);
}, 1e3);
// 回调函数,传递时间差和时间数组
return i && i(l > 0 ? c : [0, 0, 0, 0], t, u),
l <= 0 && clearTimeout(u), // 当倒计时结束,清除定时器
u;
},
// 将时间格式化为“XX时间前”
timeAgo: function(e, t) {
var i = this,
n = [[], []],
a = (new Date).getTime() - new Date(e).getTime(); // 计算当前时间与给定时间的差值
if (a > 26784e5) { // 如果时间差超过 31 天,显示完整的时间
a = new Date(e);
n[0][0] = i.digit(a.getFullYear(), 4);
n[0][1] = i.digit(a.getMonth() + 1);
n[0][2] = i.digit(a.getDate());
t || (n[1][0] = i.digit(a.getHours()), n[1][1] = i.digit(a.getMinutes()), n[1][2] = i.digit(a.getSeconds()));
return n[0].join("-") + " " + n[1].join(":");
}
if (a >= 864e5) return (a / 1e3 / 60 / 60 / 24 | 0) + "天前";
if (a >= 36e5) return (a / 1e3 / 60 / 60 | 0) + "小时前";
if (a >= 18e4) return (a / 1e3 / 60 | 0) + "分钟前";
return a < 0 ? "未来" : "刚刚";
},
// 数字补零
digit: function(e, t) {
var i = "";
e = String(e);
t = t || 2;
for (var n = e.length; n < t; n++) i += "0";
return e < Math.pow(10, t) ? i + (0 | e) : e;
},
// 将时间转为指定格式字符串
toDateString: function(e, t) {
var i = this,
n = new Date(e || new Date),
a = [i.digit(n.getFullYear(), 4), i.digit(n.getMonth() + 1), i.digit(n.getDate())],
o = [i.digit(n.getHours()), i.digit(n.getMinutes()), i.digit(n.getSeconds())];
return t = t || "yyyy-MM-dd HH:mm:ss",
t.replace(/yyyy/g, a[0])
.replace(/MM/g, a[1])
.replace(/dd/g, a[2])
.replace(/HH/g, o[0])
.replace(/mm/g, o[1])
.replace(/ss/g, o[2]);
},
// 转义 HTML 字符
escape: function(e) {
return String(e || "").replace(/&(?!#?[a-zA-Z0-9]+;)/g, "&")
.replace(//g, ">")
.replace(/'/g, "'")
.replace(/"/g, """);
},
// 自定义事件绑定
event: function(e, n, a) {
var o = t("body");
return a = a || "click", // 默认事件类型为 "click"
n = i.event[e] = t.extend(!0, i.event[e], n) || {},
i.event.UTIL_EVENT_CALLBACK = i.event.UTIL_EVENT_CALLBACK || {},
o.off(a, "*[" + e + "]", i.event.UTIL_EVENT_CALLBACK[e]),
i.event.UTIL_EVENT_CALLBACK[e] = function() {
var i = t(this),
a = i.attr(e);
"function" == typeof n[a] && n[a].call(this, i);
},
o.on(a, "*[" + e + "]", i.event.UTIL_EVENT_CALLBACK[e]),
n;
}
};
// 窗口大小变化事件(自适应布局)
!function(e, t, i) {
"$:nomunge";
function n() {
a = t[l](function() {
o.each(function() {
var t = e(this),
i = t.width(),
n = t.height(),
a = e.data(this, u);
(i !== a.w || n !== a.h) && t.trigger(c, [a.w = i, a.h = n]);
});
n();
}, r[g]);
}
var a,
o = e([]),
r = e.resize = e.extend(e.resize, {}),
l = "setTimeout",
c = "resize",
u = c + "-special-event",
g = "delay",
s = "throttleWindow";
r[g] = 250;
r[s] = !0;
e.event.special[c] = {
setup: function() {
if (!r[s] && this[l]) return !1;