index.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. {extend name="public/container"}
  2. {block name="content"}
  3. <div class="layui-fluid">
  4. <div class="layui-row layui-col-space15" id="app">
  5. <div class="layui-col-md12">
  6. <div class="layui-card">
  7. <div class="layui-card-header">搜索条件</div>
  8. <div class="layui-card-body">
  9. <form class="layui-form layui-form-pane" action="">
  10. <div class="layui-form-item">
  11. <div class="layui-inline">
  12. <label class="layui-form-label">活动状态</label>
  13. <div class="layui-input-block">
  14. <select name="is_show">
  15. <option value="">全部</option>
  16. <option value="1">启用</option>
  17. <option value="0">暂停</option>
  18. </select>
  19. </div>
  20. </div>
  21. <div class="layui-inline">
  22. <label class="layui-form-label">活动名称</label>
  23. <div class="layui-input-block">
  24. <input type="text" name="title" class="layui-input" placeholder="请输入活动名称">
  25. </div>
  26. </div>
  27. <div class="layui-inline">
  28. <div class="layui-input-inline">
  29. <button class="layui-btn layui-btn-sm layui-btn-normal" lay-submit="search"
  30. lay-filter="search">
  31. <i class="layui-icon layui-icon-search"></i>搜索
  32. </button>
  33. </div>
  34. </div>
  35. </div>
  36. </form>
  37. </div>
  38. </div>
  39. </div>
  40. <!--活动列表-->
  41. <div class="layui-col-md12">
  42. <div class="layui-card">
  43. <div class="layui-card-header">活动列表</div>
  44. <div class="layui-card-body">
  45. <div class="layui-btn-container">
  46. <a class="layui-btn layui-btn-sm"
  47. href="javascript:$eb.createModalFrame(this.innerText,'{:Url('create')}')">新建活动</a>
  48. </div>
  49. <table class="layui-hide" id="List" lay-filter="List"></table>
  50. <!--图片-->
  51. <script type="text/html" id="main_img">
  52. <img style="cursor: pointer;display:{{d.main_img==null?'none':'block'}};" lay-event='open_image'
  53. src='{{d.main_img}}'>
  54. {{d.main_img==null?'暂无图片':''}}
  55. </script>
  56. <script type="text/html" id="label_img">
  57. <img style="cursor: pointer;display:{{d.label_img==null?'none':'block'}};"
  58. lay-event='open_image'
  59. src='{{d.label_img}}'>
  60. {{d.label_img==null?'暂无图片':''}}
  61. </script>
  62. <script type="text/html" id="border_img">
  63. <img style="cursor: pointer;display:{{d.border_img==null?'none':'block'}};"
  64. lay-event='open_image'
  65. src='{{d.border_img}}'>
  66. {{d.border_img==null?'暂无图片':''}}
  67. </script>
  68. <script type="text/html" id="price_color">
  69. <div style="width: 50px;height: 20px;background-color: #{{d.price_color}};"></div>
  70. </script>
  71. <script type="text/html" id="add_time">
  72. {{formatDate(d.add_time*1000)}}
  73. </script>
  74. <script type="text/html" id="is_show">
  75. <input type='checkbox' name="is_show" lay-skin='switch' value="{{d.id}}" lay-filter='is_show'
  76. lay-text='是|否' {{ d.is_show== 1 ? 'checked' : '' }}>
  77. </script>
  78. <script type="text/html" id="is_new">
  79. <input type='checkbox' name="is_new" lay-skin='switch' value="{{d.id}}" lay-filter='is_new'
  80. lay-text='是|否' {{ d.is_new== 1 ? 'checked' : '' }}>
  81. </script>
  82. <script type="text/html" id="detail">
  83. <a style="color: #0a6aa1;"
  84. href="{:url('ump.store_activity_product_/index')}?aid={{d.id}}">活动商品</a>
  85. </script>
  86. <script type="text/html" id="act">
  87. <button type="button" class="layui-btn layui-btn-xs" onclick="dropdown(this)">操作 <span
  88. class="caret"></span></button>
  89. <ul class="layui-nav-child layui-anim layui-anim-upbit">
  90. <li>
  91. <a lay-event='edit' href="javascript:$eb.createModalFrame(this.innerText,'{:Url('edit')}?id={{d.id}}')">
  92. <i class="fa fa-wrench"></i> 编辑
  93. </a>
  94. </li>
  95. <li>
  96. <a lay-event='delete' href="javascript:void(0)">
  97. <i class="fa fa-times"></i> 删除
  98. </a>
  99. </li>
  100. </ul>
  101. </script>
  102. </div>
  103. </div>
  104. </div>
  105. </div>
  106. </div>
  107. <script src="{__ADMIN_PATH}js/layuiList.js"></script>
  108. {/block}
  109. {block name="script"}
  110. <script>
  111. //实例化form
  112. layList.form.render();
  113. //加载列表
  114. layList.tableList('List', "{:Url('lst')}", function () {
  115. return [
  116. {field: 'id', title: '编号', sort: true, event: 'id', width: '6%', align: "center"},
  117. {field: 'title', title: '活动名称', align: "center"},
  118. {field: 'is_new', title: '新人专享', templet: '#is_new', width: '6%', align: "center"},
  119. {field: 'main_img', title: '活动主图', templet: '#main_img', width: '12%', align: "center"},
  120. {field: 'label_img', title: '商品标签图', templet: '#label_img', width: '12%', align: "center"},
  121. {field: 'price_color', title: '价格颜色', templet: '#price_color', width: '12%', align: "center"},
  122. {field: 'border_img', title: '边框图片', templet: '#border_img', width: '6%', align: "center"},
  123. {field: 'is_show', title: '启用', templet: '#is_show', width: '6%', align: "center"},
  124. {field: 'add_time', title: '添加时间', templet: '#add_time', width: '10%', align: "center"},
  125. {field: 'right', title: '活动商品', templet: '#detail', align: 'center', width: '8%'},
  126. {field: 'right', title: '操作', align: 'center', toolbar: '#act', width: '8%'},
  127. ];
  128. });
  129. //查询
  130. layList.search('search', function (where) {
  131. layList.reload(where, true);
  132. });
  133. layList.switch('is_show', function (odj, value) {
  134. if (odj.elem.checked == true) {
  135. layList.baseGet(layList.Url({
  136. c: 'ump.store_activity',
  137. a: 'set_show',
  138. p: {is_show: 1, id: value}
  139. }), function (res) {
  140. layList.msg(res.msg);
  141. });
  142. } else {
  143. layList.baseGet(layList.Url({
  144. c: 'ump.store_activity',
  145. a: 'set_show',
  146. p: {is_show: 0, id: value}
  147. }), function (res) {
  148. layList.msg(res.msg);
  149. });
  150. }
  151. });
  152. layList.switch('is_new', function (odj, value) {
  153. if (odj.elem.checked == true) {
  154. layList.baseGet(layList.Url({
  155. c: 'ump.store_activity',
  156. a: 'set_new',
  157. p: {is_new: 1, id: value}
  158. }), function (res) {
  159. layList.msg(res.msg);
  160. });
  161. } else {
  162. layList.baseGet(layList.Url({
  163. c: 'ump.store_activity',
  164. a: 'set_new',
  165. p: {is_new: 0, id: value}
  166. }), function (res) {
  167. layList.msg(res.msg);
  168. });
  169. }
  170. });
  171. //监听并执行排序
  172. layList.sort(['id', 'sort'], true);
  173. //点击事件绑定
  174. layList.tool(function (event, data, obj) {
  175. switch (event) {
  176. case 'delete':
  177. var url = layList.U({a: 'del', q: {id: data.id}});
  178. $eb.$swal('delete', function () {
  179. $eb.axios.get(url).then(function (res) {
  180. if (res.status == 200 && res.data.code == 200) {
  181. $eb.$swal('success', res.data.msg);
  182. obj.del();
  183. } else
  184. return Promise.reject(res.data.msg || '删除失败')
  185. }).catch(function (err) {
  186. $eb.$swal('error', err);
  187. });
  188. })
  189. break;
  190. case 'open_image':
  191. $eb.openImage(data.img);
  192. break;
  193. }
  194. });
  195. //下拉框
  196. $(document).click(function (e) {
  197. $('.layui-nav-child').hide();
  198. })
  199. function dropdown(that) {
  200. var oEvent = arguments.callee.caller.arguments[0] || event;
  201. oEvent.stopPropagation();
  202. var offset = $(that).offset();
  203. var top = offset.top - $(window).scrollTop();
  204. var index = $(that).parents('tr').data('index');
  205. $('.layui-nav-child').each(function (key) {
  206. if (key != index) {
  207. $(this).hide();
  208. }
  209. })
  210. if ($(document).height() < top + $(that).next('ul').height()) {
  211. $(that).next('ul').css({
  212. 'padding': 10,
  213. 'top': -($(that).parent('td').height() / 2 + $(that).height() + $(that).next('ul').height() / 2),
  214. 'min-width': 'inherit',
  215. 'position': 'absolute'
  216. }).toggle();
  217. } else {
  218. $(that).next('ul').css({
  219. 'padding': 10,
  220. 'top': $(that).parent('td').height() / 2 + $(that).height(),
  221. 'min-width': 'inherit',
  222. 'position': 'absolute'
  223. }).toggle();
  224. }
  225. };
  226. function formatDate(time) {
  227. var date = new Date(time);
  228. var YY = date.getFullYear() + '-';
  229. var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
  230. var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
  231. var hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
  232. var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
  233. var ss = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
  234. return YY + MM + DD + " " + hh + mm + ss;
  235. }
  236. </script>
  237. {/block}