372 lines
11 KiB
HTML
372 lines
11 KiB
HTML
{extend name="base"/}
|
|
{block name="resources"}
|
|
<style>
|
|
.layui-table-view td:last-child>div{overflow: inherit;}
|
|
.operation-wrap{position: relative;}
|
|
.layui-table-box{overflow: inherit;}
|
|
.layui-table-body{overflow: inherit;}
|
|
.set-home{display:inline-block;margin-left: 5px;padding: 3px;font-size: 12px;line-height: 1;color: #fff;}
|
|
.popup-qrcode-wrap{text-align: center;background: #fff;border-radius: 2px;box-shadow: 0 2px 8px 0 rgba(200,201,204,.5);padding: 10px;position: absolute;z-index: 1;top: -73px;left: -180px;display: none;width: 170px;height: 230px;}
|
|
.popup-qrcode-wrap:before, .popup-qrcode-wrap:after {left: 100%;top: 50%;border: solid transparent;content: " ";height: 0;width: 0;position: absolute;pointer-events: none;}
|
|
.popup-qrcode-wrap:before {border-color: transparent;border-left-color: #e5e5e5;border-width: 8px;margin-top: -29px;}
|
|
.popup-qrcode-wrap:after {border-color: transparent;border-left-color: #ffffff;border-width: 7px;margin-top: -31px;}
|
|
.popup-qrcode-wrap img{width: 150px;height: 150px;max-width: initial;}
|
|
.popup-qrcode-wrap p{font-size: 12px;margin: 5px 0;line-height: 1.8!important;}
|
|
.popup-qrcode-wrap a{font-size: 12px;}
|
|
.popup-qrcode-wrap input{opacity: 0;position: absolute;}
|
|
.popup-qrcode-wrap .popup-qrcode-loadimg {width: 16px!important; height: 16px!important; margin-top: 107px;}
|
|
.edit-sort.len-short{width: 100px !important;}
|
|
</style>
|
|
{/block}
|
|
{block name="main"}
|
|
<!-- 搜索框 -->
|
|
<div class="single-filter-box">
|
|
<button class="layui-btn" onclick="createPage()">新建页面</button>
|
|
<div class="layui-form">
|
|
<div class="layui-input-inline">
|
|
<input type="text" name="search_text" placeholder="请输入页面名称" autocomplete="off" class="layui-input">
|
|
<button type="button" class="layui-btn layui-btn-primary" lay-filter="search" lay-submit>
|
|
<i class="layui-icon"></i>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 筛选面板 -->
|
|
<!--<div class="screen layui-collapse" lay-filter="selection_panel">-->
|
|
<!-- <div class="layui-colla-item">-->
|
|
<!-- <form class="layui-colla-content layui-form layui-show">-->
|
|
<!-- <div class="layui-form-item">-->
|
|
<!-- <div class="layui-inline">-->
|
|
<!-- <label class="layui-form-label">页面名称</label>-->
|
|
<!-- <div class="layui-input-inline">-->
|
|
<!-- <input type="text" name="search_text" placeholder="请输入页面名称" autocomplete="off" class="layui-input">-->
|
|
<!-- </div>-->
|
|
<!-- </div>-->
|
|
|
|
<!-- <div class="layui-inline">-->
|
|
<!-- <label class="layui-form-label">店铺模板</label>-->
|
|
<!-- <div class="layui-input-inline">-->
|
|
<!-- <select name="template_id" lay-filter="template_id">-->
|
|
<!-- {foreach name="$template_goods_list" item="vo"}-->
|
|
<!-- <option value="{$vo.goods_id}">{$vo.title}</option>-->
|
|
<!-- {/foreach}-->
|
|
<!-- </select>-->
|
|
<!-- </div>-->
|
|
<!-- </div>-->
|
|
|
|
<!-- <div class="layui-inline">-->
|
|
<!-- <label class="layui-form-label">页面类型</label>-->
|
|
<!-- <div class="layui-input-inline">-->
|
|
<!-- <select name="type" lay-filter="type">-->
|
|
<!-- <option value="">全部</option>-->
|
|
<!-- <option value="DIY_PAGE">自定义页面</option>-->
|
|
<!-- {foreach name="$template_list" item="vo"}-->
|
|
<!-- <option value="{$vo.name}">{$vo.title}</option>-->
|
|
<!-- {/foreach}-->
|
|
<!-- </select>-->
|
|
<!-- </div>-->
|
|
<!-- </div>-->
|
|
|
|
<!-- </div>-->
|
|
|
|
<!-- <div class="form-row">-->
|
|
<!-- <button class="layui-btn" lay-submit lay-filter="search">筛选</button>-->
|
|
<!-- <button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
|
|
<!-- </div>-->
|
|
<!-- </form>-->
|
|
<!-- </div>-->
|
|
<!--</div>-->
|
|
|
|
<table id="diy_list" lay-filter="diy_list"></table>
|
|
|
|
<script type="text/html" id="action">
|
|
<div class="operation-wrap" data-id="{{d.id}}">
|
|
<div class="table-btn">
|
|
<div class="popup-qrcode-wrap"><img class="popup-qrcode-loadimg" src="__STATIC__/loading/loading.gif" /></div>
|
|
{{# if(d.name != 'DIY_VIEW_INDEX' || d.is_default == 0){ }}
|
|
<a class="layui-btn" lay-event="setHome">设为主页</a>
|
|
{{# } }}
|
|
<a class="layui-btn text-color" lay-event="promote">推广</a>
|
|
<a class="layui-btn" lay-event="edit">编辑</a>
|
|
<a class="layui-btn" lay-event="copy">复制页面</a>
|
|
<a class="layui-btn" lay-event="delete">删除</a>
|
|
</div>
|
|
</div>
|
|
</script>
|
|
|
|
|
|
<!-- 编辑排序 -->
|
|
<script type="text/html" id="editSort">
|
|
<input name="sort" type="number" onchange="editSort({{d.id}}, this)" value="{{d.sort}}" class="layui-input edit-sort len-short">
|
|
</script>
|
|
|
|
<script type="text/html" id="toolbarOperation">
|
|
<button class="layui-btn layui-btn-primary" lay-event="delete">批量删除</button>
|
|
</script>
|
|
|
|
<script type="text/html" id="batchOperation">
|
|
<button class="layui-btn layui-btn-primary" lay-event="delete">批量删除</button>
|
|
</script>
|
|
|
|
<script type="text/html" id="createPageHtml">
|
|
<div class="layui-form">
|
|
|
|
<div class="layui-form-item">
|
|
<label class="layui-form-label sm"><span class="required">*</span>所属模板</label>
|
|
<div class="layui-input-inline len-mid">
|
|
<select name="template_id" lay-filter="template_id" lay-verify="required">
|
|
{foreach name="$template_goods_list" item="vo"}
|
|
<option value="{$vo.goods_id}">{$vo.title}</option>
|
|
{/foreach}
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="layui-form-item">
|
|
<label class="layui-form-label sm"><span class="required">*</span>页面名称</label>
|
|
<div class="layui-input-inline len-mid">
|
|
<input type="text" name="title" placeholder="请输入页面名称" lay-verify="required" autocomplete="off" maxlength="15" class="layui-input">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-row sm">
|
|
<button class="layui-btn" lay-submit lay-filter="createPage">确定</button>
|
|
<button class="layui-btn layui-btn-primary" onclick="layer.close(createPageIndex)">取消</button>
|
|
</div>
|
|
|
|
</div>
|
|
</script>
|
|
{/block}
|
|
{block name="script"}
|
|
<script>
|
|
var form,laytpl,table,repeat_flag = false,createPageIndex;
|
|
layui.use([ 'laytpl', 'form'], function () {
|
|
laytpl = layui.laytpl;
|
|
form = layui.form;
|
|
|
|
table = new Table({
|
|
id: 'diy_list',
|
|
elem: '#diy_list',
|
|
url: ns.url("shop/diy/lists"),
|
|
cols: [[{
|
|
type: 'checkbox',
|
|
width: '3%'
|
|
}, {
|
|
width: '20%',
|
|
title: '页面名称',
|
|
templet: function (res) {
|
|
var html = '';
|
|
html += `<span>${res.title}</span>`;
|
|
if (res.name == 'DIY_VIEW_INDEX' && res.is_default == 1)
|
|
html += `<span class="bg-color set-home">主页</span>`;
|
|
return html;
|
|
}
|
|
}, {
|
|
field: 'type_name',
|
|
width: '13%',
|
|
title: '页面类型',
|
|
}, {
|
|
field: 'click_num',
|
|
width: '8%',
|
|
title: '浏览量',
|
|
sort: true
|
|
}, {
|
|
width: '20%',
|
|
title: '创建时间',
|
|
templet: function (d) {
|
|
return ns.time_to_date(d.create_time);
|
|
}
|
|
}, {
|
|
field: 'sort',
|
|
width: '12%',
|
|
title: '排序',
|
|
templet: '#editSort',
|
|
sort: true
|
|
},{
|
|
title: '操作',
|
|
toolbar: '#action',
|
|
width: '25%',
|
|
align: 'right'
|
|
}]],
|
|
where: {
|
|
template_id: $("select[name='template_id']").val()
|
|
},
|
|
toolbar: '#toolbarOperation',
|
|
bottomToolbar: "#batchOperation"
|
|
});
|
|
|
|
|
|
//监听工具条
|
|
table.tool(function (obj) {
|
|
var data = obj.data;
|
|
if (obj.event === 'promote') {
|
|
promote(data.id,data.is_default);
|
|
} else if (obj.event === 'edit') {
|
|
window.open(ns.url("shop/diy/edit", {id: data.id}));
|
|
} else if (obj.event === "delete") {
|
|
deleteSiteDiyView(data.id);
|
|
} else if (obj.event === "setHome") {
|
|
$.ajax({
|
|
type: "post",
|
|
url: ns.url("shop/diy/setHome"),
|
|
data: {'id': data.id},
|
|
dataType: "JSON",
|
|
success: function (res) {
|
|
layer.msg(res.message);
|
|
if (res.code >= 0) {
|
|
table.reload();
|
|
}
|
|
}
|
|
});
|
|
} else if (obj.event === "copy") {
|
|
layer.confirm('确定要复制该页面吗?', function (index) {
|
|
$.ajax({
|
|
type: "post",
|
|
url: ns.url("shop/diy/copySiteDiyView"),
|
|
data: {'id': data.id},
|
|
dataType: "JSON",
|
|
success: function (res) {
|
|
layer.msg(res.message);
|
|
if (res.code >= 0) {
|
|
table.reload();
|
|
}
|
|
}
|
|
});
|
|
layer.close(index);
|
|
});
|
|
}
|
|
});
|
|
|
|
//批量操作
|
|
table.bottomToolbar(function (obj) {
|
|
if (obj.data.length < 1) {
|
|
layer.msg('请选择要操作的数据');
|
|
return;
|
|
}
|
|
switch (obj.event) {
|
|
case "delete":
|
|
var id_array = [];
|
|
for (var i in obj.data) id_array.push(obj.data[i].id);
|
|
deleteSiteDiyView(id_array.toString());
|
|
break;
|
|
}
|
|
});
|
|
|
|
//批量操作
|
|
table.toolbar(function (obj) {
|
|
if (obj.data.length < 1) {
|
|
layer.msg('请选择要操作的数据');
|
|
return;
|
|
}
|
|
switch (obj.event) {
|
|
case "delete":
|
|
var id_array = [];
|
|
for (var i in obj.data) id_array.push(obj.data[i].id);
|
|
deleteSiteDiyView(id_array.toString());
|
|
break;
|
|
}
|
|
});
|
|
|
|
// 搜索功能
|
|
form.on('submit(search)', function (data) {
|
|
table.reload({
|
|
page: {
|
|
curr: 1
|
|
},
|
|
where: data.field
|
|
});
|
|
return false;
|
|
});
|
|
|
|
form.on('submit(createPage)', function (data) {
|
|
location.href = ns.url('shop/diy/edit',data.field);
|
|
});
|
|
});
|
|
|
|
|
|
// 监听单元格编辑
|
|
function editSort(id, event){
|
|
var data = $(event).val();
|
|
|
|
if (data == '') {
|
|
$(event).val(0);
|
|
data = 0;
|
|
}
|
|
|
|
if(!new RegExp("^-?[0-9]\\d*$").test(data)){
|
|
layer.msg("排序号只能是整数");
|
|
return ;
|
|
}
|
|
if(data<0){
|
|
layer.msg("排序号必须大于0");
|
|
return ;
|
|
}
|
|
$.ajax({
|
|
type: 'POST',
|
|
url: ns.url("shop/diy/modifySort"),
|
|
data: {
|
|
id: id,
|
|
sort: data
|
|
},
|
|
dataType: 'JSON',
|
|
success: function(res) {
|
|
layer.msg(res.message);
|
|
if(res.code==0){
|
|
table.reload();
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
function createPage() {
|
|
location.href = ns.url('shop/diy/edit');
|
|
// createPageIndex = layer.open({
|
|
// type: 1,
|
|
// title: '创建新页面',
|
|
// content: $('#createPageHtml').html(),
|
|
// offset: 'auto',
|
|
// area: ['380px'],
|
|
// success: function (layero, index) {
|
|
// form.render();
|
|
// }
|
|
// });
|
|
}
|
|
|
|
// 删除店铺微页面
|
|
function deleteSiteDiyView(id_array) {
|
|
layer.confirm('确定要删除这些微页面模板吗', function (index) {
|
|
$.ajax({
|
|
url: ns.url("shop/diy/deleteSiteDiyView"),
|
|
data: {'id': id_array},
|
|
dataType: "JSON",
|
|
success: function (res) {
|
|
layer.msg(res.message);
|
|
if (res.code == 0) {
|
|
table.reload();
|
|
}
|
|
}
|
|
});
|
|
layer.close(index);
|
|
});
|
|
}
|
|
|
|
// 推广链接
|
|
function promote(id,is_default) {
|
|
$.ajax({
|
|
type: "POST",
|
|
url: ns.url("shop/diy/promote"),
|
|
data: {
|
|
id: id,
|
|
is_default: is_default
|
|
},
|
|
dataType: 'JSON',
|
|
success: function (res) {
|
|
if (res.code == 0) {
|
|
window.open(ns.url('index/index/h5preview',{ url : res.data.path.h5.url }));
|
|
}
|
|
}
|
|
});
|
|
}
|
|
</script>
|
|
{/block} |