| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243 |
- {extend name="public/container"}
- {block name="content"}
- <div class="layui-fluid">
- <div class="layui-row layui-col-space15" id="app">
- <div class="layui-col-md12">
- <div class="layui-card">
- <div class="layui-card-header">搜索条件</div>
- <div class="layui-card-body">
- <form class="layui-form layui-form-pane" action="">
- <div class="layui-form-item">
- <div class="layui-inline">
- <label class="layui-form-label">活动状态</label>
- <div class="layui-input-block">
- <select name="is_show">
- <option value="">全部</option>
- <option value="1">启用</option>
- <option value="0">暂停</option>
- </select>
- </div>
- </div>
- <div class="layui-inline">
- <label class="layui-form-label">活动名称</label>
- <div class="layui-input-block">
- <input type="text" name="title" class="layui-input" placeholder="请输入活动名称">
- </div>
- </div>
- <div class="layui-inline">
- <div class="layui-input-inline">
- <button class="layui-btn layui-btn-sm layui-btn-normal" lay-submit="search"
- lay-filter="search">
- <i class="layui-icon layui-icon-search"></i>搜索
- </button>
- </div>
- </div>
- </div>
- </form>
- </div>
- </div>
- </div>
- <!--活动列表-->
- <div class="layui-col-md12">
- <div class="layui-card">
- <div class="layui-card-header">活动列表</div>
- <div class="layui-card-body">
- <div class="layui-btn-container">
- <a class="layui-btn layui-btn-sm"
- href="javascript:$eb.createModalFrame(this.innerText,'{:Url('create')}')">新建活动</a>
- </div>
- <table class="layui-hide" id="List" lay-filter="List"></table>
- <!--图片-->
- <script type="text/html" id="main_img">
- <img style="cursor: pointer;display:{{d.main_img==null?'none':'block'}};" lay-event='open_image'
- src='{{d.main_img}}'>
- {{d.main_img==null?'暂无图片':''}}
- </script>
- <script type="text/html" id="label_img">
- <img style="cursor: pointer;display:{{d.label_img==null?'none':'block'}};"
- lay-event='open_image'
- src='{{d.label_img}}'>
- {{d.label_img==null?'暂无图片':''}}
- </script>
- <script type="text/html" id="border_img">
- <img style="cursor: pointer;display:{{d.border_img==null?'none':'block'}};"
- lay-event='open_image'
- src='{{d.border_img}}'>
- {{d.border_img==null?'暂无图片':''}}
- </script>
- <script type="text/html" id="price_color">
- <div style="width: 50px;height: 20px;background-color: #{{d.price_color}};"></div>
- </script>
- <script type="text/html" id="add_time">
- {{formatDate(d.add_time*1000)}}
- </script>
- <script type="text/html" id="is_show">
- <input type='checkbox' name="is_show" lay-skin='switch' value="{{d.id}}" lay-filter='is_show'
- lay-text='是|否' {{ d.is_show== 1 ? 'checked' : '' }}>
- </script>
- <script type="text/html" id="is_new">
- <input type='checkbox' name="is_new" lay-skin='switch' value="{{d.id}}" lay-filter='is_new'
- lay-text='是|否' {{ d.is_new== 1 ? 'checked' : '' }}>
- </script>
- <script type="text/html" id="detail">
- <a style="color: #0a6aa1;"
- href="{:url('ump.store_activity_product_/index')}?aid={{d.id}}">活动商品</a>
- </script>
- <script type="text/html" id="act">
- <button type="button" class="layui-btn layui-btn-xs" onclick="dropdown(this)">操作 <span
- class="caret"></span></button>
- <ul class="layui-nav-child layui-anim layui-anim-upbit">
- <li>
- <a lay-event='edit' href="javascript:$eb.createModalFrame(this.innerText,'{:Url('edit')}?id={{d.id}}')">
- <i class="fa fa-wrench"></i> 编辑
- </a>
- </li>
- <li>
- <a lay-event='delete' href="javascript:void(0)">
- <i class="fa fa-times"></i> 删除
- </a>
- </li>
- </ul>
- </script>
- </div>
- </div>
- </div>
- </div>
- </div>
- <script src="{__ADMIN_PATH}js/layuiList.js"></script>
- {/block}
- {block name="script"}
- <script>
- //实例化form
- layList.form.render();
- //加载列表
- layList.tableList('List', "{:Url('lst')}", function () {
- return [
- {field: 'id', title: '编号', sort: true, event: 'id', width: '6%', align: "center"},
- {field: 'title', title: '活动名称', align: "center"},
- {field: 'is_new', title: '新人专享', templet: '#is_new', width: '6%', align: "center"},
- {field: 'main_img', title: '活动主图', templet: '#main_img', width: '12%', align: "center"},
- {field: 'label_img', title: '商品标签图', templet: '#label_img', width: '12%', align: "center"},
- {field: 'price_color', title: '价格颜色', templet: '#price_color', width: '12%', align: "center"},
- {field: 'border_img', title: '边框图片', templet: '#border_img', width: '6%', align: "center"},
- {field: 'is_show', title: '启用', templet: '#is_show', width: '6%', align: "center"},
- {field: 'add_time', title: '添加时间', templet: '#add_time', width: '10%', align: "center"},
- {field: 'right', title: '活动商品', templet: '#detail', align: 'center', width: '8%'},
- {field: 'right', title: '操作', align: 'center', toolbar: '#act', width: '8%'},
- ];
- });
- //查询
- layList.search('search', function (where) {
- layList.reload(where, true);
- });
- layList.switch('is_show', function (odj, value) {
- if (odj.elem.checked == true) {
- layList.baseGet(layList.Url({
- c: 'ump.store_activity',
- a: 'set_show',
- p: {is_show: 1, id: value}
- }), function (res) {
- layList.msg(res.msg);
- });
- } else {
- layList.baseGet(layList.Url({
- c: 'ump.store_activity',
- a: 'set_show',
- p: {is_show: 0, id: value}
- }), function (res) {
- layList.msg(res.msg);
- });
- }
- });
- layList.switch('is_new', function (odj, value) {
- if (odj.elem.checked == true) {
- layList.baseGet(layList.Url({
- c: 'ump.store_activity',
- a: 'set_new',
- p: {is_new: 1, id: value}
- }), function (res) {
- layList.msg(res.msg);
- });
- } else {
- layList.baseGet(layList.Url({
- c: 'ump.store_activity',
- a: 'set_new',
- p: {is_new: 0, id: value}
- }), function (res) {
- layList.msg(res.msg);
- });
- }
- });
- //监听并执行排序
- layList.sort(['id', 'sort'], true);
- //点击事件绑定
- layList.tool(function (event, data, obj) {
- switch (event) {
- case 'delete':
- var url = layList.U({a: 'del', q: {id: data.id}});
- $eb.$swal('delete', function () {
- $eb.axios.get(url).then(function (res) {
- if (res.status == 200 && res.data.code == 200) {
- $eb.$swal('success', res.data.msg);
- obj.del();
- } else
- return Promise.reject(res.data.msg || '删除失败')
- }).catch(function (err) {
- $eb.$swal('error', err);
- });
- })
- break;
- case 'open_image':
- $eb.openImage(data.img);
- break;
- }
- });
- //下拉框
- $(document).click(function (e) {
- $('.layui-nav-child').hide();
- })
- function dropdown(that) {
- var oEvent = arguments.callee.caller.arguments[0] || event;
- oEvent.stopPropagation();
- var offset = $(that).offset();
- var top = offset.top - $(window).scrollTop();
- var index = $(that).parents('tr').data('index');
- $('.layui-nav-child').each(function (key) {
- if (key != index) {
- $(this).hide();
- }
- })
- if ($(document).height() < top + $(that).next('ul').height()) {
- $(that).next('ul').css({
- 'padding': 10,
- 'top': -($(that).parent('td').height() / 2 + $(that).height() + $(that).next('ul').height() / 2),
- 'min-width': 'inherit',
- 'position': 'absolute'
- }).toggle();
- } else {
- $(that).next('ul').css({
- 'padding': 10,
- 'top': $(that).parent('td').height() / 2 + $(that).height(),
- 'min-width': 'inherit',
- 'position': 'absolute'
- }).toggle();
- }
- };
- function formatDate(time) {
- var date = new Date(time);
- var YY = date.getFullYear() + '-';
- var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
- var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
- var hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
- var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
- var ss = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
- return YY + MM + DD + " " + hh + mm + ss;
- }
- </script>
- {/block}
|