2020-01-01 13:17:19 +08:00
|
|
|
{extend name="public/base" /}
|
|
|
|
|
|
|
|
{block name="body"}
|
|
|
|
<div class="layui-fluid">
|
|
|
|
<div class="layui-row layui-col-space15">
|
|
|
|
<div class="layui-col-md12">
|
|
|
|
<div class="layui-card">
|
|
|
|
<div class="layui-card-body">
|
|
|
|
|
|
|
|
<div class="layui-form" wid100 lay-filter="">
|
|
|
|
|
|
|
|
<div class="layui-upload">
|
|
|
|
<button type="button" class="layui-btn layui-btn-normal" id="slid-add">添加</button>
|
|
|
|
<div class="layui-upload-list">
|
|
|
|
<table class="layui-table">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>ID</th>
|
|
|
|
<th>名称</th>
|
2021-07-22 10:43:48 +08:00
|
|
|
<th>图片/icon</th>
|
2020-01-01 13:17:19 +08:00
|
|
|
<th>位置</th>
|
|
|
|
<th>路径</th>
|
2020-01-02 16:23:03 +08:00
|
|
|
<th>颜色</th>
|
2020-01-01 13:17:19 +08:00
|
|
|
<th>开始</th>
|
|
|
|
<th>结束</th>
|
|
|
|
<th>状态</th>
|
|
|
|
<th>操作</th>
|
|
|
|
</tr></thead>
|
|
|
|
|
|
|
|
<tbody id="demoList">
|
|
|
|
{volist name="slider" id="vo"}
|
|
|
|
<tr>
|
|
|
|
<th>{$vo.id}</th>
|
|
|
|
<th>{$vo.slid_name}</th>
|
2021-07-07 17:17:58 +08:00
|
|
|
<th>{notempty name="$vo.slid_img"}{if $vo.slid_type == '头部菜单'}<div><i class="layui-icon {$vo.slid_img}"></i></div>{else /}<img src="{$vo.slid_img}" height="40" width="80" />{/if}{/notempty}</th>
|
2020-01-01 13:17:19 +08:00
|
|
|
<th>{$vo.slid_type}</th>
|
|
|
|
<th><a href="{$vo.slid_href}" target="_blank">{$vo.slid_href}</a></th>
|
2020-01-02 16:23:03 +08:00
|
|
|
<th>{$vo.slid_color}</th>
|
2020-01-01 13:17:19 +08:00
|
|
|
<th>{$vo.slid_start|date='Y-m-d'}</th>
|
|
|
|
<th>{$vo.slid_over|date='Y-m-d'}</th>
|
|
|
|
<th>{$vo.slid_status ?'显示':'禁止'}</th>
|
|
|
|
<th>
|
2021-08-03 17:33:48 +08:00
|
|
|
<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit" id-data="{$vo.id}"><i class="layui-icon layui-icon-edit"></i></a>
|
2020-04-07 17:11:12 +08:00
|
|
|
{if condition="checkRuleButton('admin/Slider/delete')"}
|
2021-08-03 17:33:48 +08:00
|
|
|
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del" id-data="{$vo.id}"><i class="layui-icon layui-icon-delete"></i></a>
|
|
|
|
{else /}<a class="layui-btn layui-btn-disabled layui-btn-danger layui-btn-xs"><i class="layui-icon layui-icon-delete"></i></a>{/if}
|
2020-01-01 13:17:19 +08:00
|
|
|
</th>
|
|
|
|
</tr>
|
|
|
|
{/volist}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{/block}
|
|
|
|
{block name="js"}
|
|
|
|
<script>
|
|
|
|
layui.config({
|
|
|
|
base: '/static/admin/' //静态资源所在路径
|
|
|
|
}).extend({
|
|
|
|
index: 'lib/index' //主入口模块
|
2021-06-10 13:39:51 +08:00
|
|
|
}).use(['index','layer','table','form'], function(){
|
2020-01-01 13:17:19 +08:00
|
|
|
var $ = layui.jquery
|
|
|
|
,layer = layui.layer
|
|
|
|
,table = layui.table
|
2021-06-10 13:39:51 +08:00
|
|
|
,form = layui.form;
|
2020-01-01 13:17:19 +08:00
|
|
|
//添加幻灯
|
|
|
|
$('#slid-add').on('click', function(){
|
|
|
|
layer.open({
|
|
|
|
type: 2,
|
2021-07-22 10:43:48 +08:00
|
|
|
title: '添加链接',
|
2020-01-01 13:17:19 +08:00
|
|
|
content: 'add.html',
|
|
|
|
maxmin: true,
|
2021-07-07 17:17:58 +08:00
|
|
|
area : ['460px' , '530px'],
|
2020-01-01 13:17:19 +08:00
|
|
|
btn: ['确定', '取消'],
|
|
|
|
yes: function(index, layero){
|
|
|
|
var iframeWindow = window['layui-layer-iframe'+ index]
|
|
|
|
,submitID = 'LAY-slider-submit'
|
|
|
|
,submit = layero.find('iframe').contents().find('#'+ submitID);
|
|
|
|
|
|
|
|
//监听提交
|
|
|
|
iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
|
|
|
|
var field = data.field; //获取提交的字段
|
|
|
|
|
|
|
|
//提交 Ajax 成功后,静态更新表格中的数据
|
|
|
|
$.ajax({
|
|
|
|
type:"post",
|
2020-01-02 16:23:03 +08:00
|
|
|
url:"{:url('admin/slider/add')}",
|
|
|
|
data:{"slid_type":field.slid_type,"slid_name":field.slid_name,"slid_color":field.slid_color,"slid_start":field.slid_start,"slid_over":field.slid_over,"slid_href":field.slid_href,"slid_img":field.slid_img},
|
2020-01-01 13:17:19 +08:00
|
|
|
daType:"json",
|
|
|
|
success:function (data){
|
2021-06-10 13:39:51 +08:00
|
|
|
if (data.code == 0) {
|
2020-01-01 13:17:19 +08:00
|
|
|
layer.msg(data.msg,{
|
|
|
|
icon:6,
|
|
|
|
time:2000
|
|
|
|
}, function(){
|
|
|
|
location.reload();
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
layer.open({
|
2021-03-01 12:17:56 +08:00
|
|
|
title:'添加失败',
|
2020-01-01 13:17:19 +08:00
|
|
|
content:data.msg,
|
|
|
|
icon:5,
|
|
|
|
anim:6
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
layer.close(index);
|
|
|
|
});
|
|
|
|
submit.trigger('click');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2020-01-02 16:23:03 +08:00
|
|
|
//编辑广告
|
2020-01-01 13:17:19 +08:00
|
|
|
$('a[lay-event=edit]').on('click', function(){
|
|
|
|
var id = $(this).attr('id-data');
|
|
|
|
layer.open({
|
|
|
|
type: 2,
|
2021-07-22 10:43:48 +08:00
|
|
|
title: '编辑链接',
|
2020-01-01 13:17:19 +08:00
|
|
|
content: 'edit.html?id='+ id,
|
|
|
|
maxmin: true,
|
2021-07-22 10:43:48 +08:00
|
|
|
area : ['460px' , '530px'],
|
2020-01-01 13:17:19 +08:00
|
|
|
btn: ['确定', '取消'],
|
|
|
|
yes: function(index, layero){
|
|
|
|
var iframeWindow = window['layui-layer-iframe'+ index]
|
|
|
|
,submitID = 'LAY-slider-submit'
|
|
|
|
,submit = layero.find('iframe').contents().find('#'+ submitID);
|
|
|
|
|
|
|
|
//监听提交
|
|
|
|
iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
|
|
|
|
var field = data.field; //获取提交的字段
|
|
|
|
//console.log(field);
|
|
|
|
|
|
|
|
//提交 Ajax 成功后,静态更新表格中的数据
|
|
|
|
$.ajax({
|
|
|
|
type:"post",
|
|
|
|
url:"{:url('admin/slider/edit')}",
|
2020-01-02 16:23:03 +08:00
|
|
|
data:{"id":id,"slid_type":field.slid_type,"slid_name":field.slid_name,"slid_color":field.slid_color,"slid_start":field.slid_start,"slid_over":field.slid_over,"slid_href":field.slid_href,"slid_img":field.slid_img},
|
2020-01-01 13:17:19 +08:00
|
|
|
daType:"json",
|
|
|
|
success:function (data){
|
2021-06-10 13:39:51 +08:00
|
|
|
if (data.code == 0) {
|
2020-01-01 13:17:19 +08:00
|
|
|
layer.msg(data.msg,{
|
|
|
|
icon:6,
|
|
|
|
time:2000
|
|
|
|
}, function(){
|
|
|
|
location.reload();
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
layer.open({
|
2021-03-01 12:17:56 +08:00
|
|
|
title:'添加失败',
|
2020-01-01 13:17:19 +08:00
|
|
|
content:data.msg,
|
|
|
|
icon:5,
|
|
|
|
anim:6
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
layer.close(index);
|
|
|
|
});
|
|
|
|
submit.trigger('click');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
//删除幻灯
|
|
|
|
$('a[lay-event=del]').on('click', function(){
|
|
|
|
var id = $(this).attr('id-data');
|
|
|
|
layer.confirm('确定删除?', {icon: 3, title:'删除幻灯'}, function(index){
|
|
|
|
//提交 Ajax 成功后,静态更新表格中的数据
|
|
|
|
$.ajax({
|
|
|
|
type:"post",
|
|
|
|
url:"{:url('admin/slider/delete')}",
|
|
|
|
data:{"id":id},
|
|
|
|
daType:"json",
|
|
|
|
success:function (data){
|
2021-06-10 13:39:51 +08:00
|
|
|
if (data.code == 0) {
|
2020-01-01 13:17:19 +08:00
|
|
|
layer.msg(data.msg,{
|
|
|
|
icon:6,
|
|
|
|
time:2000
|
|
|
|
}, function(){
|
|
|
|
location.reload();
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
layer.open({
|
2021-03-01 12:17:56 +08:00
|
|
|
title:'删除失败',
|
2020-01-01 13:17:19 +08:00
|
|
|
content:data.msg,
|
|
|
|
icon:5,
|
|
|
|
anim:6
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
layer.close(index);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
{/block}
|