index.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. {extend name="public/container"}
  2. {block name="head_top"}
  3. <script type="text/javascript" src="{__PLUG_PATH}jquery.downCount.js"></script>
  4. {/block}
  5. {block name="content"}
  6. <div class="layui-fluid">
  7. <div class="layui-row layui-col-space15" id="app">
  8. <div class="layui-col-md12">
  9. <div class="layui-card">
  10. <div class="layui-card-header">秒杀商品搜索</div>
  11. <div class="layui-card-body">
  12. <div class="alert alert-success alert-dismissable">
  13. <button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>
  14. 目前拥有{$countSeckill}个秒杀商品
  15. </div>
  16. <form class="layui-form">
  17. <div class="layui-form-item">
  18. <div class="layui-inline">
  19. <label class="layui-form-label">搜  索:</label>
  20. <div class="layui-input-inline">
  21. <input type="text" name="store_name" lay-verify="store_name" style="width: 100%" autocomplete="off" placeholder="请输入商品名称,关键字,编号" class="layui-input">
  22. </div>
  23. </div>
  24. <div class="layui-inline">
  25. <label class="layui-form-label">秒杀状态:</label>
  26. <div class="layui-input-inline">
  27. <select name="status" lay-verify="status">
  28. <option value="">全部</option>
  29. <option value="1">开启</option>
  30. <option value="0">关闭</option>
  31. </select>
  32. </div>
  33. </div>
  34. </div>
  35. <div class="layui-form-item">
  36. <label class="layui-form-label">
  37. <button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="search" style="font-size:14px;line-height: 9px;">
  38. <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>搜索</button>
  39. <button lay-submit="export" lay-filter="export" class="layui-btn layui-btn-primary layui-btn-sm">
  40. <i class="layui-icon layui-icon-delete layuiadmin-button-btn" ></i> Excel导出</button>
  41. </label>
  42. </div>
  43. </form>
  44. </div>
  45. </div>
  46. </div>
  47. <div class="layui-col-md12">
  48. <div class="layui-card">
  49. <div class="layui-card-header">秒杀商品列表</div>
  50. <div class="layui-card-body">
  51. <div class="layui-btn-container">
  52. <a class="layui-btn layui-btn-sm" onclick="$eb.createModalFrame(this.innerText,'{:Url('create')}',{h:700,w:1100});">添加秒杀商品</a>
  53. </div>
  54. <table class="layui-hide" id="seckillList" lay-filter="seckillList"></table>
  55. <script type="text/html" id="status">
  56. <input type='checkbox' name='status' lay-skin='switch' value="{{d.id}}" lay-filter='status' lay-text='开启|关闭' {{ d.status == 1 ? 'checked' : '' }}>
  57. </script>
  58. <script type="text/html" id="stopTime">
  59. <div class="count-time-{{d.id}}" data-time="{{d._stop_time}}">
  60. <span class="days">00</span>
  61. :
  62. <span class="hours">00</span>
  63. :
  64. <span class="minutes">00</span>
  65. :
  66. <span class="seconds">00</span>
  67. </div>
  68. </script>
  69. <script type="text/html" id="statusCn">
  70. {{ d.status == 1 ? d.start_name : '关闭' }}
  71. </script>
  72. <script type="text/html" id="barDemo">
  73. <button type="button" class="layui-btn layui-btn-xs" onclick="$eb.createModalFrame('{{d.title}}-设置规格','{:Url('attr_list')}?id={{d.id}}',{h:1000,w:1400});"><i class="layui-icon layui-icon-util"></i>规格</button>
  74. <button type="button" class="layui-btn layui-btn-xs" onclick="dropdown(this)">操作<span class="caret"></span></button>
  75. <ul class="layui-nav-child layui-anim layui-anim-upbit">
  76. <li>
  77. <a href="javascript:void(0);" onclick="$eb.createModalFrame('{{d.title}}-编辑','{:Url('edit')}?id={{d.id}}')"><i class="layui-icon layui-icon-edit"></i> 编辑活动</a>
  78. </li>
  79. <li>
  80. <a href="javascript:void(0);" onclick="$eb.createModalFrame('{{d.title}}-编辑内容','{:Url('edit_content')}?id={{d.id}}')"><i class="layui-icon layui-icon-edit"></i>编辑内容</a>
  81. </li>
  82. <li>
  83. <a href="javascript:void(0);" class="delstor" lay-event='delstor'><i class="layui-icon layui-icon-delete"></i> 删除</a>
  84. </li>
  85. </ul>
  86. </script>
  87. </div>
  88. </div>
  89. </div>
  90. </div>
  91. </div>
  92. {/block}
  93. {block name="script"}
  94. <script src="{__ADMIN_PATH}js/layuiList.js"></script>
  95. <script src="{__FRAME_PATH}js/content.min.js?v=1.0.0"></script>
  96. <script>
  97. setTime();
  98. function setTime() {
  99. setTimeout(function () {
  100. $eb.axios.get("{:Url('get_seckill_id')}").then(function(res){
  101. $.each(res.data.count,function (index,item) {
  102. var time = $('.count-time-'+item).attr('data-time');
  103. if(time != ''){
  104. $('.count-time-'+item).downCount({
  105. date: time,
  106. offset: +8
  107. });
  108. }
  109. })
  110. }).catch(function(err){
  111. console.log(err);
  112. });
  113. },2000);
  114. }
  115. </script>
  116. <script>
  117. layList.form.render();
  118. layList.tableList('seckillList',"{:Url('get_seckill_list')}",function () {
  119. return [
  120. {field: 'id', title: 'ID', sort: true,width:'6%',event:'id'},
  121. {field: 'image', title: '商品图片', width: '10%',templet: '<p><img src="{{d.image}}" alt="{{d.title}}" class="open_image" data-image="{{d.image}}"></p>'},
  122. {field: 'title', title: '活动标题'},
  123. {field: 'info', title: '活动简介',width:'20%'},
  124. {field: 'ot_price', title: '原价',width:'6%'},
  125. {field: 'price', title: '秒杀价',width:'6%'},
  126. {field: 'quota_show', title: '限量',width:'6%'},
  127. {field: 'quota', title: '限量剩余',width:'6%'},
  128. {field: 'start_name', title: '秒杀状态',width:'6%',toolbar:"#statusCn"},
  129. {field: 'stop_time', title: '结束时间', width: '8%',toolbar: '#stopTime'},
  130. {field: 'status', title: '状态',width:'6%',toolbar:"#status"},
  131. {field: 'right', title: '操作',width:'10%', align: 'center', toolbar: '#barDemo'}
  132. ]
  133. });
  134. layList.tool(function (event,data,obj) {
  135. switch (event) {
  136. case 'delstor':
  137. var url=layList.U({c:'ump.store_seckill',a:'delete',q:{id:data.id}});
  138. $eb.$swal('delete',function(){
  139. $eb.axios.get(url).then(function(res){
  140. if(res.status == 200 && res.data.code == 200) {
  141. $eb.$swal('success',res.data.msg);
  142. obj.del();
  143. }else
  144. return Promise.reject(res.data.msg || '删除失败')
  145. }).catch(function(err){
  146. $eb.$swal('error',err);
  147. });
  148. })
  149. break;
  150. }
  151. })
  152. $(document).click(function (e) {
  153. $('.layui-nav-child').hide();
  154. })
  155. function dropdown(that){
  156. var oEvent = arguments.callee.caller.arguments[0] || event;
  157. oEvent.stopPropagation();
  158. var offset = $(that).offset();
  159. var top=offset.top-$(window).scrollTop();
  160. var index = $(that).parents('tr').data('index');
  161. $('.layui-nav-child').each(function (key) {
  162. if (key != index) {
  163. $(this).hide();
  164. }
  165. })
  166. if($(document).height() < top+$(that).next('ul').height()){
  167. $(that).next('ul').css({
  168. 'padding': 10,
  169. 'top': - ($(that).parent('td').height() / 2 + $(that).height() + $(that).next('ul').height()/2),
  170. 'min-width': 'inherit',
  171. 'position': 'absolute'
  172. }).toggle();
  173. }else{
  174. $(that).next('ul').css({
  175. 'padding': 10,
  176. 'top':$(that).parent('td').height() / 2 + $(that).height(),
  177. 'min-width': 'inherit',
  178. 'position': 'absolute'
  179. }).toggle();
  180. }
  181. }
  182. layList.search('search',function(where){
  183. layList.reload(where);
  184. setTime();
  185. });
  186. layList.search('export',function(where){
  187. location.href=layList.U({c:'ump.store_seckill',a:'save_excel',q:{status:where.status,store_name:where.store_name}});
  188. })
  189. layList.switch('status',function (odj,value,name) {
  190. if (odj.elem.checked == true) {
  191. layList.baseGet(layList.Url({
  192. c: 'ump.store_seckill',
  193. a: 'set_seckill_status',
  194. p: {status: 1, id: value}
  195. }), function (res) {
  196. layList.msg(res.msg);
  197. }, function () {
  198. odj.elem.checked = false;
  199. layui.form.render();
  200. layer.open({
  201. type: 1
  202. ,offset: 'auto'
  203. ,id: 'layerDemoauto' //防止重复弹出
  204. ,content: '<div style="padding: 20px 100px;">请先配置规格</div>'
  205. ,btn: '设置规格'
  206. ,btnAlign: 'c' //按钮居中
  207. ,shade: 0 //不显示遮罩
  208. ,yes: function(){
  209. layer.closeAll();
  210. $eb.createModalFrame('设置规格','{:Url('attr_list')}?id='+value+'',{h:1000,w:1400});
  211. }
  212. });
  213. });
  214. } else {
  215. layList.baseGet(layList.Url({
  216. c: 'ump.store_seckill',
  217. a: 'set_seckill_status',
  218. p: {status: 0, id: value}
  219. }), function (res) {
  220. layList.msg(res.msg);
  221. });
  222. }
  223. })
  224. $('.js-group-btn').on('click',function(){
  225. $('.js-group-btn').css({zIndex:1});
  226. $(this).css({zIndex:2});
  227. });
  228. $('#delstor').on('click',function(){
  229. window.t = $(this);
  230. var _this = $(this),url =_this.data('url');
  231. $eb.$swal('delete',function(){
  232. $eb.axios.get(url).then(function(res){
  233. console.log(res);
  234. if(res.status == 200 && res.data.code == 200) {
  235. $eb.$swal('success',res.data.msg);
  236. _this.parents('tr').remove();
  237. }else
  238. return Promise.reject(res.data.msg || '删除失败')
  239. }).catch(function(err){
  240. $eb.$swal('error',err);
  241. });
  242. })
  243. });
  244. $(document).on('click',".open_image",function (e) {
  245. var image = $(this).data('image');
  246. $eb.openImage(image);
  247. });
  248. </script>
  249. {/block}