define(["jquery", "easy-admin", "echarts", "echarts-theme", "miniAdmin", "miniTheme", "miniTab", "swiper"], function ($, ea, echarts, undefined, miniAdmin, miniTheme, miniTab) { return { index: function () { var options = { iniUrl: ea.url('ajax/initAdmin'), // 初始化接口 clearUrl: ea.url("ajax/clearCache"), // 缓存清理接口 urlHashLocation: true, // 是否打开hash定位 bgColorDefault: false, // 主题默认配置 multiModule: true, // 是否开启多模块 menuChildOpen: false, // 是否默认展开菜单 loadingTime: 0, // 初始化加载时间 pageAnim: true, // iframe窗口动画 maxTabNum: 20, // 最大的tab打开数量 }; miniAdmin.render(options); $('.login-out').on("click", function () { ea.request.get({ url: 'login/out', prefix: true, }, function (res) { ea.msg.success(res.msg, function () { window.location = ea.url('login/index'); }) }); }); }, welcome: function () { miniTab.listen(); new Swiper('.mySwiper', { pagination: { el: '.swiper-pagination', clickable: true, }, }) /** * 查看公告信息 **/ $('body').on('click', '.layuimini-notice', function () { var title = $(this).children('.layuimini-notice-title').text(), noticeTime = $(this).children('.layuimini-notice-extra').text(), content = $(this).children('.layuimini-notice-content').html(); var html = '
${html}`
layer.open({
type: 1,
title: 'composer 信息',
area: ['50%', '90%'],
shade: 0.8,
shadeClose: true,
scrollbar: false,
content: html,
success: function () {
layui.code({elem: '.code-demo', theme: 'dark', lang: 'php'});
}
})
}, function (error) {
console.error(error)
return false;
})
}
})
/**
* ✅ 定时检查未分配订单 + 播放提示音
*/
setInterval(function () {
ea.request.get({
url: ea.url('index/get_order'),
}, function (res) {
// 假设接口返回格式:{code:1, data:{count:2}}
let audio;
if (res.code === 1 && res.data > 0) {
// 若不存在则动态创建
audio = document.createElement('audio');
audio.id = 'order-audio';
audio.src = '/1.mp3'; // ✅ 修改为你的提示音路径
audio.autoplay = true;
audio.volume = 1.0;
document.body.appendChild(audio);
audio.play().then(r => {});
layui.table.reload(init.table_render_id);
}
}, function (err) {
console.error('检查未分配订单失败', err);
});
}, 10000); // 每60秒执行一次
},
editAdmin: function () {
let form = layui.form
form.on('radio(loginType-filter)', function (data) {
let elem = data.elem
let value = elem.value
if (value === '2') {
let width = screen.width < 768 ? '85%' : '60%'
ea.open('绑定谷歌验证码', ea.url('index/set2fa'), width, '75%')
}
});
ea.listen();
},
editPassword: function () {
ea.listen();
},
set2fa: function () {
ea.listen();
},
};
});