index.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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="statusCn">
  59. {{ d.status == 1 ? d.start_name : '关闭' }}
  60. </script>
  61. <script type="text/html" id="barDemo">
  62. <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>
  63. <button type="button" class="layui-btn layui-btn-xs" onclick="dropdown(this)">操作<span class="caret"></span></button>
  64. <ul class="layui-nav-child layui-anim layui-anim-upbit">
  65. <li>
  66. <a href="javascript:void(0);" onclick="$eb.createModalFrame('{{d.title}}-编辑','{:Url('edit')}?id={{d.id}}')"><i class="layui-icon layui-icon-edit"></i> 编辑活动</a>
  67. </li>
  68. <li>
  69. <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>
  70. </li>
  71. <li>
  72. <a href="javascript:void(0);" class="delstor" lay-event='delstor'><i class="layui-icon layui-icon-delete"></i> 删除</a>
  73. </li>
  74. </ul>
  75. </script>
  76. </div>
  77. </div>
  78. </div>
  79. </div>
  80. </div>
  81. {/block}
  82. {block name="script"}
  83. <script src="{__ADMIN_PATH}js/layuiList.js"></script>
  84. <script src="{__FRAME_PATH}js/content.min.js?v=1.0.0"></script>
  85. <script>
  86. layList.form.render();
  87. layList.tableList('seckillList',"{:Url('get_exchange_list')}",function () {
  88. return [
  89. {field: 'id', title: 'ID', sort: true,width:'6%',event:'id'},
  90. {field: 'image', title: '商品图片', width: '10%',templet: '<p><img src="{{d.image}}" alt="{{d.title}}" class="open_image" data-image="{{d.image}}"></p>'},
  91. {field: 'title', title: '活动标题'},
  92. {field: 'info', title: '活动简介',width:'20%'},
  93. {field: 'ot_price', title: '原价',width:'6%'},
  94. {field: 'price', title: '兑换价',width:'6%'},
  95. {field: 'money', title: '兑换代币',width:'6%'},
  96. {field: 'money_type', title: '兑换币种',width:'6%'},
  97. {field: 'quota_show', title: '限量',width:'6%'},
  98. {field: 'quota', title: '限量剩余',width:'6%'},
  99. // {field: 'start_name', title: '活动状态',width:'6%',toolbar:"#statusCn"},
  100. {field: 'status', title: '状态',width:'6%',toolbar:"#status"},
  101. {field: 'right', title: '操作',width:'10%', align: 'center', toolbar: '#barDemo'}
  102. ]
  103. });
  104. layList.tool(function (event,data,obj) {
  105. switch (event) {
  106. case 'delstor':
  107. var url=layList.U({c:'ump.store_exchange',a:'delete',q:{id:data.id}});
  108. $eb.$swal('delete',function(){
  109. $eb.axios.get(url).then(function(res){
  110. if(res.status == 200 && res.data.code == 200) {
  111. $eb.$swal('success',res.data.msg);
  112. obj.del();
  113. }else
  114. return Promise.reject(res.data.msg || '删除失败')
  115. }).catch(function(err){
  116. $eb.$swal('error',err);
  117. });
  118. })
  119. break;
  120. }
  121. })
  122. $(document).click(function (e) {
  123. $('.layui-nav-child').hide();
  124. })
  125. function dropdown(that){
  126. var oEvent = arguments.callee.caller.arguments[0] || event;
  127. oEvent.stopPropagation();
  128. var offset = $(that).offset();
  129. var top=offset.top-$(window).scrollTop();
  130. var index = $(that).parents('tr').data('index');
  131. $('.layui-nav-child').each(function (key) {
  132. if (key != index) {
  133. $(this).hide();
  134. }
  135. })
  136. if($(document).height() < top+$(that).next('ul').height()){
  137. $(that).next('ul').css({
  138. 'padding': 10,
  139. 'top': - ($(that).parent('td').height() / 2 + $(that).height() + $(that).next('ul').height()/2),
  140. 'min-width': 'inherit',
  141. 'position': 'absolute'
  142. }).toggle();
  143. }else{
  144. $(that).next('ul').css({
  145. 'padding': 10,
  146. 'top':$(that).parent('td').height() / 2 + $(that).height(),
  147. 'min-width': 'inherit',
  148. 'position': 'absolute'
  149. }).toggle();
  150. }
  151. }
  152. layList.search('search',function(where){
  153. layList.reload(where);
  154. setTime();
  155. });
  156. layList.search('export',function(where){
  157. location.href=layList.U({c:'ump.store_exchange',a:'save_excel',q:{status:where.status,store_name:where.store_name}});
  158. })
  159. layList.switch('status',function (odj,value,name) {
  160. if (odj.elem.checked == true) {
  161. layList.baseGet(layList.Url({
  162. c: 'ump.store_exchange',
  163. a: 'set_exchange_status',
  164. p: {status: 1, id: value}
  165. }), function (res) {
  166. layList.msg(res.msg);
  167. }, function () {
  168. odj.elem.checked = false;
  169. layui.form.render();
  170. layer.open({
  171. type: 1
  172. ,offset: 'auto'
  173. ,id: 'layerDemoauto' //防止重复弹出
  174. ,content: '<div style="padding: 20px 100px;">请先配置规格</div>'
  175. ,btn: '设置规格'
  176. ,btnAlign: 'c' //按钮居中
  177. ,shade: 0 //不显示遮罩
  178. ,yes: function(){
  179. layer.closeAll();
  180. $eb.createModalFrame('设置规格','{:Url('attr_list')}?id='+value+'',{h:1000,w:1400});
  181. }
  182. });
  183. });
  184. } else {
  185. layList.baseGet(layList.Url({
  186. c: 'ump.store_exchange',
  187. a: 'set_exchange_status',
  188. p: {status: 0, id: value}
  189. }), function (res) {
  190. layList.msg(res.msg);
  191. });
  192. }
  193. })
  194. $('.js-group-btn').on('click',function(){
  195. $('.js-group-btn').css({zIndex:1});
  196. $(this).css({zIndex:2});
  197. });
  198. $('#delstor').on('click',function(){
  199. window.t = $(this);
  200. var _this = $(this),url =_this.data('url');
  201. $eb.$swal('delete',function(){
  202. $eb.axios.get(url).then(function(res){
  203. console.log(res);
  204. if(res.status == 200 && res.data.code == 200) {
  205. $eb.$swal('success',res.data.msg);
  206. _this.parents('tr').remove();
  207. }else
  208. return Promise.reject(res.data.msg || '删除失败')
  209. }).catch(function(err){
  210. $eb.$swal('error',err);
  211. });
  212. })
  213. });
  214. $(document).on('click',".open_image",function (e) {
  215. var image = $(this).data('image');
  216. $eb.openImage(image);
  217. });
  218. </script>
  219. {/block}