index.php 12 KB

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