同步更改
This commit is contained in:
@@ -1,24 +1,30 @@
|
||||
{include file="public/header" /}
|
||||
<div class="config-container">
|
||||
<!-- 页面头部样式 -->
|
||||
<div class="config-header" style="display: flex;flex-direction: column;flex-wrap: wrap;align-items: flex-start;">
|
||||
<div class="maintitle">
|
||||
<i class="layui-icon layui-icon-notice"></i>
|
||||
<span>内容推送列表</span>
|
||||
</div>
|
||||
<div style="display: flex;align-items: flex-start;flex-direction: column;gap: 15px;margin-bottom: 10px;">
|
||||
<div>
|
||||
<button class="layui-btn layui-bg-blue" onclick="add()">
|
||||
<i class="layui-icon layui-icon-add-1"></i>添加推送
|
||||
</button>
|
||||
<button type="button" class="layui-btn layui-btn-primary layui-border-blue" onclick="refresh()">
|
||||
<i class="layui-icon layui-icon-refresh"></i>刷新
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="config-header" style="display: flex;flex-direction: column;flex-wrap: wrap;align-items: flex-start;">
|
||||
<div class="maintitle">
|
||||
<i class="layui-icon layui-icon-notice"></i>
|
||||
<span>内容推送列表</span>
|
||||
</div>
|
||||
<div style="display: flex;align-items: flex-start;flex-direction: column;gap: 15px;margin-bottom: 10px;">
|
||||
<div>
|
||||
<!-- <button class="layui-btn layui-bg-blue" onclick="add()">
|
||||
<i class="layui-icon layui-icon-add-1"></i>添加推送
|
||||
</button> -->
|
||||
<button class="layui-btn layui-bg-blue" onclick="setting()">
|
||||
<i class="layui-icon layui-icon-set-fill"></i>推送配置
|
||||
</button>
|
||||
<button type="button" class="layui-btn layui-btn-primary layui-border-green" onclick="pushSelected()">
|
||||
<i class="layui-icon layui-icon-release"></i>推送
|
||||
</button>
|
||||
<button type="button" class="layui-btn layui-btn-primary layui-border-blue" onclick="refresh()">
|
||||
<i class="layui-icon layui-icon-refresh"></i>刷新
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table id="contentPushTable" lay-filter="contentPushTable"></table>
|
||||
<table id="contentPushTable" lay-filter="contentPushTable"></table>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
@@ -33,32 +39,48 @@
|
||||
url: '{$config["admin_route"]}yunzeradmin/contentpushlist',
|
||||
page: true,
|
||||
cols: [[
|
||||
{field: 'id', title: 'ID', width: 80, sort: true},
|
||||
{field: 'title', title: '标题', width: 200},
|
||||
{field: 'type', title: '类型', width: 100, templet: function(d){
|
||||
return d.type == 1 ? '普通推送' : '重要推送';
|
||||
}},
|
||||
{field: 'status', title: '状态', width: 100, templet: function(d){
|
||||
return d.status == 1 ?
|
||||
'<span class="layui-badge layui-bg-green">启用</span>' :
|
||||
'<span class="layui-badge">禁用</span>';
|
||||
}},
|
||||
{field: 'sort', title: '排序', width: 100, sort: true},
|
||||
{field: 'create_time', title: '创建时间', width: 180},
|
||||
{title: '操作', width: 200, toolbar: '#tableBar', fixed: 'right'}
|
||||
{ type: 'checkbox', fixed: 'left' }, // 多选全选
|
||||
// {field: 'id', title: 'ID', width: 80, sort: true},
|
||||
{
|
||||
field: 'type', title: '类型', width: 80, templet: function (d) {
|
||||
return d.type == 'article' ? '文章' : '资源';
|
||||
}
|
||||
},
|
||||
{ field: 'title', title: '标题' },
|
||||
{
|
||||
field: 'url', title: '链接', templet: function (d) {
|
||||
if (d.type == 'article') {
|
||||
return '<a href="https://www.yunzer.cn/index/articles/detail?id=' + d.id + '" target="_blank">https://www.yunzer.cn/index/articles/detail?id=' + d.id + '</a>';
|
||||
} else if (d.type == 'resource') {
|
||||
return '<a href="https://www.yunzer.cn/index/resources/detail?id=' + d.id + '" target="_blank">https://www.yunzer.cn/index/resources/detail?id=' + d.id + '</a>';
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'push', title: '推送状态', width: 100, templet: function (d) {
|
||||
return d.push == 1 ?
|
||||
'<span class="layui-badge layui-bg-green">已推送</span>' :
|
||||
'<span class="layui-badge">未推送</span>';
|
||||
}
|
||||
},
|
||||
// {field: 'sort', title: '排序', width: 100, sort: true},
|
||||
{ field: 'create_time', title: '创建时间', width: 180 },
|
||||
// {title: '操作', width: 200, toolbar: '#tableBar', fixed: 'right'}
|
||||
]],
|
||||
limit: 10,
|
||||
limits: [10, 20, 30, 50]
|
||||
});
|
||||
|
||||
// 监听工具条
|
||||
table.on('tool(contentPushTable)', function(obj){
|
||||
table.on('tool(contentPushTable)', function (obj) {
|
||||
var data = obj.data;
|
||||
if(obj.event === 'edit'){
|
||||
if (obj.event === 'edit') {
|
||||
edit(data.id);
|
||||
} else if(obj.event === 'del'){
|
||||
} else if (obj.event === 'del') {
|
||||
del(data.id);
|
||||
} else if(obj.event === 'status'){
|
||||
} else if (obj.event === 'status') {
|
||||
changeStatus(data.id, data.status);
|
||||
}
|
||||
});
|
||||
@@ -119,6 +141,81 @@
|
||||
}, 'json');
|
||||
}
|
||||
|
||||
//配置
|
||||
function setting() {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '推送配置',
|
||||
shade: 0.3,
|
||||
area: ['1000px', '800px'],
|
||||
content: "{$config['admin_route']}yunzeradmin/contentpushsetting"
|
||||
});
|
||||
}
|
||||
|
||||
//推送数据
|
||||
function pushSelected() {
|
||||
var checkStatus = layui.table.checkStatus('contentPushTable');
|
||||
var data = checkStatus.data;
|
||||
if (data.length === 0) {
|
||||
layer.msg('请先选择要推送的数据', { icon: 2 });
|
||||
return;
|
||||
}
|
||||
|
||||
$.getJSON("{$config['admin_route']}yunzeradmin/contentpushsetting", function (res) {
|
||||
if (res.code !== 0 || !res.data || res.data.length === 0) {
|
||||
layer.msg('暂无可用推送平台');
|
||||
return;
|
||||
}
|
||||
|
||||
var html = '<div style="padding:10px;"><table class="layui-table"><thead><tr><th>ID</th><th>平台名称</th><th>类型标识</th></tr></thead><tbody>';
|
||||
res.data.forEach(function (item) {
|
||||
if (item.status == 1) {
|
||||
html += '<tr style="cursor:pointer" data-type="' + item.platformType + '" data-title="' + item.title.replace(/'/g, "\\'") + '">';
|
||||
html += '<td>' + item.id + '</td>';
|
||||
html += '<td>' + item.title + '</td>';
|
||||
html += '<td>' + item.platformType + '</td>';
|
||||
html += '</tr>';
|
||||
}
|
||||
});
|
||||
html += '</tbody></table></div>';
|
||||
|
||||
layer.open({
|
||||
type: 1,
|
||||
title: '选择推送平台',
|
||||
area: ['500px', '350px'],
|
||||
content: html,
|
||||
success: function (layero, index) {
|
||||
// 事件委托,避免全局变量
|
||||
$(layero).find('tr[data-type]').on('click', function () {
|
||||
var platformType = $(this).data('type');
|
||||
var platformTitle = $(this).data('title');
|
||||
layer.close(index);
|
||||
|
||||
var urls = [];
|
||||
data.forEach(function (item) {
|
||||
urls.push('https://www.yunzer.cn/index/' + (item.type === 'resource' ? 'resources' : 'articles') + '/detail?id=' + item.id);
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
url: "{$config['admin_route']}yunzeradmin/gopush",
|
||||
type: "POST",
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify({
|
||||
platformType: platformType,
|
||||
urls: urls
|
||||
}),
|
||||
dataType: "json",
|
||||
success: function (res) {
|
||||
layer.msg(res.msg, { icon: res.code === 0 ? 1 : 2, time: 5000 });
|
||||
layui.table.reload('contentPushTable');
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// 刷新列表
|
||||
function refresh() {
|
||||
layui.table.reload('contentPushTable');
|
||||
@@ -126,10 +223,9 @@
|
||||
</script>
|
||||
|
||||
<!-- 表格操作列模板 -->
|
||||
<script type="text/html" id="tableBar">
|
||||
<!-- <script type="text/html" id="tableBar">
|
||||
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
|
||||
<a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del">删除</a>
|
||||
<a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="status">状态</a>
|
||||
</script>
|
||||
</script> -->
|
||||
|
||||
{include file="public/tail" /}
|
||||
Reference in New Issue
Block a user