1
This commit is contained in:
208
public/static/admin/js/mall/blackip.js
Normal file
208
public/static/admin/js/mall/blackip.js
Normal file
@ -0,0 +1,208 @@
|
||||
define(["jquery", "easy-admin"], function ($, ea) {
|
||||
|
||||
var init = {
|
||||
table_elem: '#currentTable',
|
||||
table_render_id: 'currentTableRenderId',
|
||||
index_url: 'mall.blackip/index',
|
||||
add_url: 'mall.blackip/add',
|
||||
edit_url: 'mall.blackip/edit',
|
||||
delete_url: 'mall.blackip/delete',
|
||||
export_url: 'mall.blackip/export',
|
||||
modify_url: 'mall.blackip/modify',
|
||||
recycle_url: 'mall.blackip/recycle',
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
index: function () {
|
||||
ea.table.render({
|
||||
init: init,
|
||||
toolbar: ['refresh',
|
||||
[{
|
||||
text: '添加',
|
||||
url: init.add_url,
|
||||
method: 'open',
|
||||
auth: 'add',
|
||||
class: 'layui-btn layui-btn-normal layui-btn-sm',
|
||||
icon: 'fa fa-plus ',
|
||||
extend: 'data-width="90%" data-height="95%"',
|
||||
}],
|
||||
'delete', 'export', 'recycle'],
|
||||
cols: [[
|
||||
{type: "checkbox"},
|
||||
{field: 'id', width: 80, title: 'ID', searchOp: '='},
|
||||
{field: 'ip', width: 100, title: 'IP'},
|
||||
{field: 'create_time', minWidth: 80, title: '创建时间', search: 'range'},
|
||||
{
|
||||
width: 250,
|
||||
title: '操作',
|
||||
templet: ea.table.tool,
|
||||
operat: [
|
||||
['delete']
|
||||
]
|
||||
}
|
||||
]],
|
||||
done: (res) => {
|
||||
// 状态为1的商品背景高亮 展示写法 可根据自己项目自定义
|
||||
$.each(res.data, function (idx, item) {
|
||||
if (item.status === 1) {
|
||||
$(`tr[data-index="${idx}"]`).css({
|
||||
'background': 'linear-gradient(to left, #77eb7c, #bbffbe, #ffffff, transparent)',
|
||||
'bblackip': 'none',
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
ea.listen();
|
||||
},
|
||||
add: function () {
|
||||
layui.util.on({
|
||||
AiOptimization: function (data) {
|
||||
let layOn = $(data).attr('lay-on')
|
||||
$(data).attr('lay-on', layOn + 'Loading')
|
||||
aiOptimization(data)
|
||||
},
|
||||
})
|
||||
|
||||
var demo1 = xmSelect.render({
|
||||
el: '#demo1',
|
||||
name: 'xxx', // form表单提交的name
|
||||
theme: {color: getComputedStyle(document.documentElement).getPropertyValue('--ea8-theme-main-color') || '#16b777'},
|
||||
data: [
|
||||
{name: 'Make', value: 1},
|
||||
{name: 'PHP', value: 2},
|
||||
{name: 'Great Again', value: 3},
|
||||
]
|
||||
})
|
||||
|
||||
ea.listen();
|
||||
},
|
||||
edit: function () {
|
||||
layui.util.on({
|
||||
AiOptimization: function (data) {
|
||||
let layOn = $(data).attr('lay-on')
|
||||
$(data).attr('lay-on', layOn + 'Loading')
|
||||
aiOptimization(data)
|
||||
},
|
||||
})
|
||||
|
||||
var demo1 = xmSelect.render({
|
||||
el: '#demo1',
|
||||
name: 'xxx', // form表单提交的name
|
||||
theme: {color: getComputedStyle(document.documentElement).getPropertyValue('--ea8-theme-main-color') || '#16b777'},
|
||||
data: [
|
||||
{name: 'Make', value: 1},
|
||||
{name: 'PHP', value: 2, selected: true,},
|
||||
{name: 'Great Again', value: 3, selected: true,},
|
||||
]
|
||||
})
|
||||
|
||||
ea.listen();
|
||||
},
|
||||
stock: function () {
|
||||
ea.listen();
|
||||
},
|
||||
recycle: function () {
|
||||
init.index_url = init.recycle_url;
|
||||
ea.table.render({
|
||||
init: init,
|
||||
toolbar: ['refresh',
|
||||
[{
|
||||
class: 'layui-btn layui-btn-sm',
|
||||
method: 'get',
|
||||
field: 'id',
|
||||
icon: 'fa fa-refresh',
|
||||
text: '全部恢复',
|
||||
title: '确定恢复?',
|
||||
auth: 'recycle',
|
||||
url: init.recycle_url + '?type=restore',
|
||||
checkbox: true
|
||||
}, {
|
||||
class: 'layui-btn layui-btn-danger layui-btn-sm',
|
||||
method: 'get',
|
||||
field: 'id',
|
||||
icon: 'fa fa-delete',
|
||||
text: '彻底删除',
|
||||
title: '确定彻底删除?',
|
||||
auth: 'recycle',
|
||||
url: init.recycle_url + '?type=delete',
|
||||
checkbox: true
|
||||
}], 'export',
|
||||
],
|
||||
cols: [[
|
||||
{type: "checkbox"},
|
||||
{field: 'id', width: 80, title: 'ID', searchOp: '='},
|
||||
{field: 'sort', width: 80, title: '排序', edit: 'text'},
|
||||
{field: 'cate_id', minWidth: 80, title: '商品分类', search: 'select', selectList: cateSelects, laySearch: true},
|
||||
{field: 'title', minWidth: 80, title: '商品名称'},
|
||||
{field: 'logo', minWidth: 80, title: '分类图片', search: false, templet: ea.table.image},
|
||||
{field: 'status', title: '状态', width: 85, selectList: {0: '禁用', 1: '启用'}},
|
||||
// 演示多选,实际数据库并无 status2 字段,搜索后会报错
|
||||
{
|
||||
field: 'status2', title: '演示多选', width: 105, search: 'xmSelect', selectList: {1: '模拟选项1', 2: '模拟选项2', 3: '模拟选项3', 4: '模拟选项4', 5: '模拟选项5'}, hide: true,
|
||||
searchOp: 'in', templet: function (res) {
|
||||
// 根据自己实际项目进行输出
|
||||
return res?.status2 || '模拟数据'
|
||||
}
|
||||
},
|
||||
{field: 'create_time', minWidth: 80, title: '创建时间', search: 'range'},
|
||||
{field: 'delete_time', minWidth: 80, title: '删除时间', search: 'range'},
|
||||
{
|
||||
width: 250,
|
||||
title: '操作',
|
||||
templet: ea.table.tool,
|
||||
operat: [
|
||||
[{
|
||||
title: '确认恢复?',
|
||||
text: '恢复数据',
|
||||
filed: 'id',
|
||||
url: init.recycle_url + '?type=restore',
|
||||
method: 'get',
|
||||
auth: 'recycle',
|
||||
class: 'layui-btn layui-btn-xs layui-btn-success',
|
||||
}, {
|
||||
title: '想好了吗?',
|
||||
text: '彻底删除',
|
||||
filed: 'id',
|
||||
method: 'get',
|
||||
url: init.recycle_url + '?type=delete',
|
||||
auth: 'recycle',
|
||||
class: 'layui-btn layui-btn-xs layui-btn-normal layui-bg-red',
|
||||
}]]
|
||||
}
|
||||
]],
|
||||
});
|
||||
ea.listen();
|
||||
},
|
||||
};
|
||||
|
||||
function aiOptimization(data) {
|
||||
let layOn = $(data).attr('lay-on')
|
||||
let title = $('input[name="title"]').val()
|
||||
|
||||
// 告诉AI 你需要做什么
|
||||
let message = `优化这个标题 ${title}`
|
||||
|
||||
if ($.trim(title) === '') {
|
||||
ea.msg.error('标题不能为空', function () {
|
||||
$(data).attr('lay-on', layOn.split('Loading')[0])
|
||||
})
|
||||
return false
|
||||
}
|
||||
let url = ea.url('mall.blackip/aiOptimization')
|
||||
ea.request.post({url: url, data: {message: message}}, function (res) {
|
||||
let content = res.data?.choices[0]?.message?.content
|
||||
// stream 为true 时,AI 内容会逐字输出
|
||||
let stream = true
|
||||
ea.ai.chat(content, {stream: stream}, function () {
|
||||
$(data).attr('lay-on', layOn.split('Loading')[0])
|
||||
})
|
||||
}, function (error) {
|
||||
ea.msg.error(error.msg, function () {
|
||||
$(data).attr('lay-on', layOn.split('Loading')[0])
|
||||
})
|
||||
})
|
||||
}
|
||||
});
|
||||
41
public/static/admin/js/mall/cate.js
Normal file
41
public/static/admin/js/mall/cate.js
Normal file
@ -0,0 +1,41 @@
|
||||
define(["jquery", "easy-admin"], function ($, ea) {
|
||||
|
||||
var init = {
|
||||
table_elem: '#currentTable',
|
||||
table_render_id: 'currentTableRenderId',
|
||||
index_url: 'mall.cate/index',
|
||||
add_url: 'mall.cate/add',
|
||||
edit_url: 'mall.cate/edit',
|
||||
delete_url: 'mall.cate/delete',
|
||||
export_url: 'mall.cate/export',
|
||||
modify_url: 'mall.cate/modify',
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
index: function () {
|
||||
ea.table.render({
|
||||
init: init,
|
||||
cols: [[
|
||||
{type: "checkbox"},
|
||||
{field: 'id', width: 80, title: 'ID', searchOp: '='},
|
||||
{field: 'sort', width: 80, title: '排序', edit: 'text'},
|
||||
{field: 'title', minWidth: 80, title: '分类名称'},
|
||||
{field: 'image', minWidth: 80, title: '分类图片', search: false, templet: ea.table.image},
|
||||
{field: 'remark', minWidth: 80, title: '备注信息'},
|
||||
{field: 'status', title: '状态', width: 85, search: 'select', selectList: {0: '禁用', 1: '启用'}, templet: ea.table.switch},
|
||||
{field: 'create_time', minWidth: 80, title: '创建时间', search: 'range'},
|
||||
{width: 250, title: '操作', templet: ea.table.tool}
|
||||
]],
|
||||
});
|
||||
|
||||
ea.listen();
|
||||
},
|
||||
add: function () {
|
||||
ea.listen();
|
||||
},
|
||||
edit: function () {
|
||||
ea.listen();
|
||||
},
|
||||
};
|
||||
});
|
||||
247
public/static/admin/js/mall/goods.js
Normal file
247
public/static/admin/js/mall/goods.js
Normal file
@ -0,0 +1,247 @@
|
||||
define(["jquery", "easy-admin"], function ($, ea) {
|
||||
|
||||
var init = {
|
||||
table_elem: '#currentTable',
|
||||
table_render_id: 'currentTableRenderId',
|
||||
index_url: 'mall.goods/index',
|
||||
add_url: 'mall.goods/add',
|
||||
edit_url: 'mall.goods/edit',
|
||||
delete_url: 'mall.goods/delete',
|
||||
export_url: 'mall.goods/export',
|
||||
modify_url: 'mall.goods/modify',
|
||||
stock_url: 'mall.goods/stock',
|
||||
recycle_url: 'mall.goods/recycle',
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
index: function () {
|
||||
ea.table.render({
|
||||
init: init,
|
||||
toolbar: ['refresh',
|
||||
[{
|
||||
text: '添加',
|
||||
url: init.add_url,
|
||||
method: 'open',
|
||||
auth: 'add',
|
||||
class: 'layui-btn layui-btn-normal layui-btn-sm',
|
||||
icon: 'fa fa-plus ',
|
||||
extend: 'data-width="90%" data-height="95%"',
|
||||
}],
|
||||
'delete', 'export', 'recycle'],
|
||||
cols: [[
|
||||
{type: "checkbox"},
|
||||
{field: 'id', width: 80, title: 'ID', searchOp: '='},
|
||||
{field: 'sort', width: 80, title: '排序', edit: 'text'},
|
||||
{field: 'cate_id', width: 100, title: '商品分类', search: 'select', selectList: cateSelects, laySearch: true},
|
||||
{field: 'title', width: 100, title: '商品名称'},
|
||||
{field: 'logo', width: 100, title: '分类图片', search: false, templet: ea.table.image},
|
||||
{field: 'market_price', width: 100, title: '市场价', templet: ea.table.price},
|
||||
{field: 'discount_price', width: 100, title: '折扣价', templet: ea.table.price},
|
||||
{field: 'total_stock', width: 100, title: '库存统计'},
|
||||
{field: 'stock', width: 100, title: '剩余库存'},
|
||||
{field: 'virtual_sales', width: 100, title: '虚拟销量'},
|
||||
{field: 'sales', width: 80, title: '销量'},
|
||||
{field: 'status', title: '状态', width: 85, selectList: {0: '禁用', 1: '启用'}, templet: ea.table.switch},
|
||||
// 演示多选,实际数据库并无 status2 字段,搜索后会报错
|
||||
{
|
||||
field: 'status2', title: '演示多选', width: 105, search: 'xmSelect', selectList: {1: '模拟选项1', 2: '模拟选项2', 3: '模拟选项3', 4: '模拟选项4', 5: '模拟选项5'}, hide: true,
|
||||
searchOp: 'in', templet: function (res) {
|
||||
// 根据自己实际项目进行输出
|
||||
return res?.status2 || '模拟数据'
|
||||
}
|
||||
},
|
||||
{field: 'create_time', minWidth: 80, title: '创建时间', search: 'range'},
|
||||
{
|
||||
width: 250,
|
||||
title: '操作',
|
||||
templet: ea.table.tool,
|
||||
operat: [
|
||||
[{
|
||||
templet: function (d) {
|
||||
return `<button type="button" class="layui-btn layui-btn-xs">自定义 ${d.id}</button>`
|
||||
}
|
||||
}, {
|
||||
text: '编辑',
|
||||
url: init.edit_url,
|
||||
method: 'open',
|
||||
auth: 'edit',
|
||||
class: 'layui-btn layui-btn-xs layui-btn-success',
|
||||
extend: 'data-width="90%" data-height="95%"',
|
||||
}, {
|
||||
text: '入库',
|
||||
url: init.stock_url,
|
||||
method: 'open',
|
||||
auth: 'stock',
|
||||
class: 'layui-btn layui-btn-xs layui-btn-normal',
|
||||
visible: function (row) {
|
||||
return row.status === 1;
|
||||
},
|
||||
}],
|
||||
'delete']
|
||||
}
|
||||
]],
|
||||
done: (res) => {
|
||||
// 状态为1的商品背景高亮 展示写法 可根据自己项目自定义
|
||||
$.each(res.data, function (idx, item) {
|
||||
if (item.status === 1) {
|
||||
$(`tr[data-index="${idx}"]`).css({
|
||||
'background': 'linear-gradient(to left, #77eb7c, #bbffbe, #ffffff, transparent)',
|
||||
'border': 'none',
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
ea.listen();
|
||||
},
|
||||
add: function () {
|
||||
layui.util.on({
|
||||
AiOptimization: function (data) {
|
||||
let layOn = $(data).attr('lay-on')
|
||||
$(data).attr('lay-on', layOn + 'Loading')
|
||||
aiOptimization(data)
|
||||
},
|
||||
})
|
||||
|
||||
var demo1 = xmSelect.render({
|
||||
el: '#demo1',
|
||||
name: 'xxx', // form表单提交的name
|
||||
theme: {color: getComputedStyle(document.documentElement).getPropertyValue('--ea8-theme-main-color') || '#16b777'},
|
||||
data: [
|
||||
{name: 'Make', value: 1},
|
||||
{name: 'PHP', value: 2},
|
||||
{name: 'Great Again', value: 3},
|
||||
]
|
||||
})
|
||||
|
||||
ea.listen();
|
||||
},
|
||||
edit: function () {
|
||||
layui.util.on({
|
||||
AiOptimization: function (data) {
|
||||
let layOn = $(data).attr('lay-on')
|
||||
$(data).attr('lay-on', layOn + 'Loading')
|
||||
aiOptimization(data)
|
||||
},
|
||||
})
|
||||
|
||||
var demo1 = xmSelect.render({
|
||||
el: '#demo1',
|
||||
name: 'xxx', // form表单提交的name
|
||||
theme: {color: getComputedStyle(document.documentElement).getPropertyValue('--ea8-theme-main-color') || '#16b777'},
|
||||
data: [
|
||||
{name: 'Make', value: 1},
|
||||
{name: 'PHP', value: 2, selected: true,},
|
||||
{name: 'Great Again', value: 3, selected: true,},
|
||||
]
|
||||
})
|
||||
|
||||
ea.listen();
|
||||
},
|
||||
stock: function () {
|
||||
ea.listen();
|
||||
},
|
||||
recycle: function () {
|
||||
init.index_url = init.recycle_url;
|
||||
ea.table.render({
|
||||
init: init,
|
||||
toolbar: ['refresh',
|
||||
[{
|
||||
class: 'layui-btn layui-btn-sm',
|
||||
method: 'get',
|
||||
field: 'id',
|
||||
icon: 'fa fa-refresh',
|
||||
text: '全部恢复',
|
||||
title: '确定恢复?',
|
||||
auth: 'recycle',
|
||||
url: init.recycle_url + '?type=restore',
|
||||
checkbox: true
|
||||
}, {
|
||||
class: 'layui-btn layui-btn-danger layui-btn-sm',
|
||||
method: 'get',
|
||||
field: 'id',
|
||||
icon: 'fa fa-delete',
|
||||
text: '彻底删除',
|
||||
title: '确定彻底删除?',
|
||||
auth: 'recycle',
|
||||
url: init.recycle_url + '?type=delete',
|
||||
checkbox: true
|
||||
}], 'export',
|
||||
],
|
||||
cols: [[
|
||||
{type: "checkbox"},
|
||||
{field: 'id', width: 80, title: 'ID', searchOp: '='},
|
||||
{field: 'sort', width: 80, title: '排序', edit: 'text'},
|
||||
{field: 'cate_id', minWidth: 80, title: '商品分类', search: 'select', selectList: cateSelects, laySearch: true},
|
||||
{field: 'title', minWidth: 80, title: '商品名称'},
|
||||
{field: 'logo', minWidth: 80, title: '分类图片', search: false, templet: ea.table.image},
|
||||
{field: 'status', title: '状态', width: 85, selectList: {0: '禁用', 1: '启用'}},
|
||||
// 演示多选,实际数据库并无 status2 字段,搜索后会报错
|
||||
{
|
||||
field: 'status2', title: '演示多选', width: 105, search: 'xmSelect', selectList: {1: '模拟选项1', 2: '模拟选项2', 3: '模拟选项3', 4: '模拟选项4', 5: '模拟选项5'}, hide: true,
|
||||
searchOp: 'in', templet: function (res) {
|
||||
// 根据自己实际项目进行输出
|
||||
return res?.status2 || '模拟数据'
|
||||
}
|
||||
},
|
||||
{field: 'create_time', minWidth: 80, title: '创建时间', search: 'range'},
|
||||
{field: 'delete_time', minWidth: 80, title: '删除时间', search: 'range'},
|
||||
{
|
||||
width: 250,
|
||||
title: '操作',
|
||||
templet: ea.table.tool,
|
||||
operat: [
|
||||
[{
|
||||
title: '确认恢复?',
|
||||
text: '恢复数据',
|
||||
filed: 'id',
|
||||
url: init.recycle_url + '?type=restore',
|
||||
method: 'get',
|
||||
auth: 'recycle',
|
||||
class: 'layui-btn layui-btn-xs layui-btn-success',
|
||||
}, {
|
||||
title: '想好了吗?',
|
||||
text: '彻底删除',
|
||||
filed: 'id',
|
||||
method: 'get',
|
||||
url: init.recycle_url + '?type=delete',
|
||||
auth: 'recycle',
|
||||
class: 'layui-btn layui-btn-xs layui-btn-normal layui-bg-red',
|
||||
}]]
|
||||
}
|
||||
]],
|
||||
});
|
||||
ea.listen();
|
||||
},
|
||||
};
|
||||
|
||||
function aiOptimization(data) {
|
||||
let layOn = $(data).attr('lay-on')
|
||||
let title = $('input[name="title"]').val()
|
||||
|
||||
// 告诉AI 你需要做什么
|
||||
let message = `优化这个标题 ${title}`
|
||||
|
||||
if ($.trim(title) === '') {
|
||||
ea.msg.error('标题不能为空', function () {
|
||||
$(data).attr('lay-on', layOn.split('Loading')[0])
|
||||
})
|
||||
return false
|
||||
}
|
||||
let url = ea.url('mall.goods/aiOptimization')
|
||||
ea.request.post({url: url, data: {message: message}}, function (res) {
|
||||
let content = res.data?.choices[0]?.message?.content
|
||||
// stream 为true 时,AI 内容会逐字输出
|
||||
let stream = true
|
||||
ea.ai.chat(content, {stream: stream}, function () {
|
||||
$(data).attr('lay-on', layOn.split('Loading')[0])
|
||||
})
|
||||
}, function (error) {
|
||||
ea.msg.error(error.msg, function () {
|
||||
$(data).attr('lay-on', layOn.split('Loading')[0])
|
||||
})
|
||||
})
|
||||
}
|
||||
});
|
||||
114
public/static/admin/js/mall/order.js
Normal file
114
public/static/admin/js/mall/order.js
Normal file
@ -0,0 +1,114 @@
|
||||
define(["jquery", "easy-admin"], function ($, ea) {
|
||||
|
||||
var init = {
|
||||
table_elem: '#currentTable',
|
||||
table_render_id: 'currentTableRenderId',
|
||||
index_url: 'mall.order/index',
|
||||
add_url: 'mall.order/add',
|
||||
edit_url: 'mall.order/edit',
|
||||
delete_url: 'mall.order/delete',
|
||||
export_url: 'mall.order/export',
|
||||
modify_url: 'mall.order/modify',
|
||||
recharge_url: 'mall.order/recharge',
|
||||
blockip_url: 'mall.order/blockip',
|
||||
recycle_url: 'mall.order/recycle',
|
||||
};
|
||||
|
||||
let checkTimer = null; // 定时器对象
|
||||
let autoCheckEnabled = true; // 默认启用
|
||||
let autoCheckId = 1; // 默认启用
|
||||
|
||||
return {
|
||||
|
||||
index: function () {
|
||||
ea.table.render({
|
||||
init: init,
|
||||
toolbar: [
|
||||
'refresh', 'delete', 'export', 'recycle'
|
||||
],
|
||||
cols: [[
|
||||
{type: "checkbox"},
|
||||
{field: 'id', width: 80, title: 'ID', searchOp: '='},
|
||||
{field: 'rid', width: 100, title: '订单号'},
|
||||
{field: 'money', width: 100, title: '金额'},
|
||||
{field: 'ip', width: 100, title: 'IP'},
|
||||
{field: 'url', width: 100, title: '支付链接', edit: true},
|
||||
{field: 'status', title: '状态', width: 85, selectList: {0: '未分配', 1: '已分配', 2: '已支付'}},
|
||||
{field: 'create_time', minWidth: 80, title: '创建时间', search: 'range'},
|
||||
{
|
||||
width: 500,
|
||||
title: '操作',
|
||||
templet: ea.table.tool,
|
||||
operat: [
|
||||
[{
|
||||
class: 'layui-btn layui-btn-success layui-btn-xs',
|
||||
method: 'open',
|
||||
field: 'id',
|
||||
text: '编辑支付链接',
|
||||
url: init.edit_url,
|
||||
extend: 'data-width="90%" data-height="95%"',
|
||||
}],
|
||||
[{
|
||||
class: 'layui-btn layui-btn-danger layui-btn-xs',
|
||||
method: 'get',
|
||||
field: 'id',
|
||||
text: '确认支付',
|
||||
url: init.recharge_url,
|
||||
}],
|
||||
[{
|
||||
class: 'layui-btn layui-btn-danger layui-btn-xs',
|
||||
method: 'get',
|
||||
field: 'id',
|
||||
text: 'IP拉黑',
|
||||
url: init.blockip_url,
|
||||
}],
|
||||
'delete'
|
||||
]
|
||||
}
|
||||
]],
|
||||
done: (res) => {
|
||||
$.each(res.data, function (idx, item) {
|
||||
if (item.status === 1) {
|
||||
$(`tr[data-index="${idx}"]`).css({
|
||||
'background': 'linear-gradient(to left, #77eb7c, #bbffbe, #ffffff, transparent)',
|
||||
'border': 'none',
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
// 🔁 定时检测逻辑
|
||||
checkTimer = setInterval(function () {
|
||||
ea.request.get({
|
||||
url: ea.url('index/get_order'),
|
||||
}, function (res) {
|
||||
if (res.code === 1 && res.data.count > 0) {
|
||||
let audio = document.getElementById('order-audio');
|
||||
if (!audio) {
|
||||
audio = document.createElement('audio');
|
||||
audio.id = 'order-audio';
|
||||
audio.src = '/1.mp3'; // 你的提示音路径
|
||||
audio.autoplay = true;
|
||||
audio.volume = 1.0;
|
||||
document.body.appendChild(audio);
|
||||
}
|
||||
if (autoCheckId !== res.data.rid) {
|
||||
autoCheckId = res.data.rid;
|
||||
layui.table.reload(init.table_render_id);
|
||||
}
|
||||
audio.play().catch(err => console.warn('播放失败', err));
|
||||
}
|
||||
}, function (err) {
|
||||
console.error('检查未分配订单失败', err);
|
||||
});
|
||||
}, 5000); // 每10秒执行一次
|
||||
|
||||
ea.listen();
|
||||
},
|
||||
|
||||
edit: function () {
|
||||
ea.listen();
|
||||
},
|
||||
};
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user