coupon.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <?php $shoname_name = D('Home/Front')->get_config_by_name('shoname'); ?>
  6. <title><?php echo $shoname; ?></title>
  7. <link rel="shortcut icon" href="" />
  8. <meta name="renderer" content="webkit">
  9. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  10. <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  11. <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
  12. <!-- 让IE8/9支持媒体查询,从而兼容栅格 -->
  13. <!--[if lt IE 9]>
  14. <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
  15. <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
  16. <![endif]-->
  17. <link href="./resource/css/bootstrap.min.css?v=201903260001" rel="stylesheet">
  18. <link href="./resource/css/common.css?v=201903260001" rel="stylesheet">
  19. <script type="text/javascript">
  20. window.sysinfo = {
  21. <?php if (!empty($_W['uniacid']) ){ ?>'uniacid': '{$_W['uniacid']}',<?php } ?>
  22. <?php if( !empty($_W['acid']) ){ ?>'acid': '{$_W['acid']}',<?php } ?>
  23. <?php if (!empty($_W['openid']) ) { ?>'openid': '{$_W['openid']}',<?php } ?>
  24. <?php if( !empty($_W['uid']) ) { ?>'uid': '{$_W['uid']}',<?php } ?>
  25. 'isfounder': <?php if (!empty($_W['isfounder']) ) { ?>1<?php }else{ ?>0<?php } ?>,
  26. 'siteroot': '{$_W['siteroot']}',
  27. 'siteurl': '{$_W['siteurl']}',
  28. 'attachurl': '{$_W['attachurl']}',
  29. 'attachurl_local': '{$_W['attachurl_local']}',
  30. 'attachurl_remote': '{$_W['attachurl_remote']}',
  31. 'module': {'url' : '<?php if( defined('MODULE_URL') ) { ?>{MODULE_URL}<?php } ?>', 'name' : '<?php if (defined('IN_MODULE') ) { ?>{IN_MODULE}<?php } ?>'},
  32. 'cookie': {'pre': ''},
  33. 'account': {:json_encode($_W['account'])},
  34. };
  35. </script>
  36. <script type="text/javascript" src="./resource/js/lib/jquery-1.11.1.min.js"></script>
  37. <script type="text/javascript" src="./resource/js/lib/bootstrap.min.js"></script>
  38. <script type="text/javascript" src="./resource/js/app/util.js?v=201903260001"></script>
  39. <script type="text/javascript" src="./resource/js/app/common.min.js?v=201903260001"></script>
  40. <script type="text/javascript" src="./resource/js/require.js?v=201903260001"></script>
  41. <script type="text/javascript" src="./resource/js/lib/jquery.nice-select.js?v=201903260001"></script>
  42. <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
  43. <link href="/static/css/snailfish.css" rel="stylesheet">
  44. </head>
  45. <body layadmin-themealias="default">
  46. <div class="layui-fluid">
  47. <div class="layui-card">
  48. <div class="layui-card-header layui-elem-quote">当前位置:<span class="line-text">优惠券管理</span></div>
  49. <div class="layui-card-body" style="padding:15px;">
  50. <div class="page-content">
  51. <form action="" method="get" class="form-horizontal form-search layui-form" role="form" id="form1">
  52. <input type="hidden" name="c" value="marketing" />
  53. <input type="hidden" name="a" value="coupon" />
  54. <div class="layui-form-item">
  55. <!-- <div class='layui-input-inline' style='width: 280px;'>
  56. {:tpl_form_field_daterange('time', array('placeholder'=>'创建时间'),true);}
  57. </div> -->
  58. <span class="layui-input-inline" style="width:120px;">
  59. <select name='gettype' class="layui-input layui-unselect" >
  60. <option value=''>首页显示</option>
  61. <option value='0' <?php if( $gpc['gettype']=='0'){ ?>selected<?php } ?>>不显示</option>
  62. <option value='1' <?php if( $gpc['gettype']=='1'){ ?>selected<?php } ?>>显示</option>
  63. </select>
  64. </span>
  65. <span class="layui-input-inline" style="width:120px;">
  66. <select name='catid' class="layui-input layui-unselect" >
  67. <option value=''>分类</option>
  68. <?php foreach( $category as $k => $c ){ ?>
  69. <option value='{$k}' <?php if( $gpc['catid']==$k){ ?>selected<?php } ?>>{$c}</option>
  70. <?php } ?>
  71. </select>
  72. </span>
  73. <div class="layui-input-inline" style="width:250px;">
  74. <input type="text" class="form-control" name='keyword' value="{$gpc['keyword']}" placeholder="优惠券名称">
  75. </div>
  76. <span class="layui-input-inline">
  77. <button class="btn btn-primary" type="submit"> 搜索</button>
  78. </span>
  79. </div>
  80. </form>
  81. <form action="" class="layui-form" lay-filter="example" method="post" >
  82. <div class="page-table-header">
  83. <span class="pull-right">
  84. <a href="{:U('marketing/addcoupon', array('ok' => 1))}" class="layui-btn layui-btn-sm"><i class="fa fa-plus"></i> 添加优惠券</a>
  85. </span>
  86. <span class="btn-group">
  87. <button class="btn btn-default btn-sm dropdown-toggle btn-operation" type="button" data-toggle='batch-remove' data-confirm="确认要删除?" data-href="{:U('marketing/deletecoupon')}">
  88. <i class="layui-icon">&#xe640;</i>删除
  89. </button>
  90. </span>
  91. </div>
  92. <?php if( count($list)>0){ ?>
  93. <table class="layui-table" lay-skin="line" lay-size="lg">
  94. <thead class="navbar-inner" >
  95. <tr>
  96. <th style="width:25px;"><input type='checkbox' name="checkall" lay-skin="primary" lay-filter="checkboxall" /></th>
  97. <th style="width:50px;">ID</th>
  98. <th style="width:50px;">排序</th>
  99. <th style="">优惠券名称</th>
  100. <th style=" ">优惠<br/>使用条件</th>
  101. <th style=" ">剩余数量/已使用/已发出</th>
  102. <th style="width:130px;">首页领券</th>
  103. <th style="width:200px;">创建时间</th>
  104. <th style="width: 200px;">操作</th>
  105. </tr>
  106. </thead>
  107. <tbody>
  108. <?php foreach( $list as $row ){ ?>
  109. <tr>
  110. <td>
  111. <input type='checkbox' value="{$row['id']}" name="item_checkbox" lay-skin="primary"/>
  112. </td>
  113. <td>
  114. {$row['id']}
  115. </td>
  116. <td>
  117. <a href='javascript:;' class="setOrder" data-id="{$row['id']}" data-value="{$row['displayorder']}" data-href="{:U('marketing/displayordercoupon',array('id'=>$row['id']))}" >{$row['displayorder']}</a>
  118. </td>
  119. <td>
  120. <p style="line-height:30px;">{$row['voucher_title']}</p>
  121. <label class='label label-success'>购物</label>
  122. <?php if( !empty($row['catid'])){ ?>
  123. <label class='label label-primary'>{$category[$row['catid']]['name']}</label>
  124. <?php } ?>
  125. <?php if($row['is_new_man'] == 1){ ?>
  126. <label class='layui-badge'>新人券</label>
  127. <?php } ?>
  128. </td>
  129. <td>
  130. {$row['credit']} 元<br/>
  131. <?php if( $row['limit_money']>0){ ?>
  132. <span class="text-danger">满{$row['limit_money']}可用</span>
  133. <?php }else{ ?>
  134. <span class="text-warning">不限</span>
  135. <?php } ?>
  136. </td>
  137. <td>
  138. <?php if( $row['total_count']==-1){ ?>无限<?php }else{ ?>剩余:<?php echo ($row['total_count'] - $row['send_count']) < 0 ? 0:$row['total_count'] - $row['send_count']; ?> <?php } ?>
  139. &nbsp;&nbsp;已使用: {$row['usetotal']}&nbsp;&nbsp;已发出: {$row['send_count']}
  140. </td>
  141. <td>
  142. <input type="checkbox" name="" lay-filter="statewsitch" data-href="{:U('marketing/change',array('type'=>'is_index_show','id'=>$row['id']))}" <?php if( $row['is_index_show']==1){ ?>checked<?php }else{ ?><?php } ?> lay-skin="switch" lay-text="显示|隐藏">
  143. </td>
  144. <td>{:date('Y-m-d',$row['add_time'])} {:date('H:i',$row['add_time'])}</td>
  145. <td>
  146. <div class="btn-group">
  147. <a class="layui-btn layui-btn-xs" href="{:U('marketing/addcoupon',array('id'=> $row['id'],'ok'=>1));}">
  148. <i class="layui-icon layui-icon-edit"></i>编辑</a>
  149. <a class="layui-btn layui-btn-danger layui-btn-xs deldom" href="javascript:;" data-href="{:U('marketing/deletecoupon',array('id' => $row['id']))}" data-confirm="确定要删除该优惠券吗?"><i class="layui-icon">&#xe640;</i>删除</a>
  150. </div>
  151. </td>
  152. </tr>
  153. <?php } ?>
  154. </tbody>
  155. <tfoot>
  156. <tr>
  157. <td colspan="3">
  158. <input type="checkbox" name="checkall" lay-skin="primary" lay-filter="checkboxall" />
  159. <span class="btn-group">
  160. <button class="btn btn-default btn-sm dropdown-toggle btn-operation" type="button" data-toggle='batch-remove' data-confirm="确认要删除?" data-href="{:U('marketing/deletecoupon')}">
  161. <i class="layui-icon">&#xe640;</i>删除
  162. </button>
  163. </span>
  164. </td>
  165. <td colspan="6" style="text-align: right">{$pager}</td>
  166. </tr>
  167. </tfoot>
  168. </table>
  169. <?php }else{ ?>
  170. <div class='panel panel-default'>
  171. <div class='panel-body' style='text-align: center;padding:30px;'>
  172. 暂时没有任何优惠券!
  173. </div>
  174. </div>
  175. <?php } ?>
  176. </form>
  177. </div>
  178. </div>
  179. </div>
  180. </div>
  181. <script src="/layuiadmin/layui/layui.js"></script>
  182. <script>
  183. layui.config({
  184. base: '/layuiadmin/' //静态资源所在路径
  185. }).extend({
  186. index: 'lib/index' //主入口模块
  187. }).use('index');
  188. </script>
  189. <script>
  190. var layer = layui.layer;
  191. var $;
  192. layui.use(['jquery', 'layer', 'form'], function(){
  193. $ = layui.$;
  194. var form = layui.form;
  195. $('.deldom').click(function(){
  196. var s_url = $(this).attr('data-href');
  197. layer.confirm($(this).attr('data-confirm'), function(index){
  198. $.ajax({
  199. url:s_url,
  200. type:'post',
  201. dataType:'json',
  202. success:function(info){
  203. if(info.status == 0)
  204. {
  205. layer.msg(info.result.message,{icon: 1,time: 2000});
  206. }else if(info.status == 1){
  207. var go_url = location.href;
  208. if( info.result.hasOwnProperty("url") )
  209. {
  210. go_url = info.result.url;
  211. }
  212. layer.msg('操作成功',{time: 1000,
  213. end:function(){
  214. location.href = info.result.url;
  215. }
  216. });
  217. }
  218. }
  219. })
  220. });
  221. })
  222. $('.btn-operation').click(function(){
  223. var ids_arr = [];
  224. var obj = $(this);
  225. var s_toggle = $(this).attr('data-toggle');
  226. var s_url = $(this).attr('data-href');
  227. $("input[name=item_checkbox]").each(function() {
  228. if( $(this).prop('checked') )
  229. {
  230. ids_arr.push( $(this).val() );
  231. }
  232. })
  233. if(ids_arr.length < 1)
  234. {
  235. layer.msg('请选择要操作的内容');
  236. }else{
  237. var can_sub = true;
  238. if( s_toggle == 'batch-remove' )
  239. {
  240. can_sub = false;
  241. layer.confirm($(obj).attr('data-confirm'), function(index){
  242. $.ajax({
  243. url:s_url,
  244. type:'post',
  245. dataType:'json',
  246. data:{ids:ids_arr},
  247. success:function(info){
  248. if(info.status == 0)
  249. {
  250. layer.msg(info.result.message,{icon: 1,time: 2000});
  251. }else if(info.status == 1){
  252. var go_url = location.href;
  253. if( info.result.hasOwnProperty("url") )
  254. {
  255. go_url = info.result.url;
  256. }
  257. layer.msg('操作成功',{time: 1000,
  258. end:function(){
  259. location.href = info.result.url;
  260. }
  261. });
  262. }
  263. }
  264. })
  265. });
  266. }else{
  267. $.ajax({
  268. url:s_url,
  269. type:'post',
  270. dataType:'json',
  271. data:{ids:ids_arr},
  272. success:function(info){
  273. if(info.status == 0)
  274. {
  275. layer.msg(info.result.message,{icon: 1,time: 2000});
  276. }else if(info.status == 1){
  277. var go_url = location.href;
  278. if( info.result.hasOwnProperty("url") )
  279. {
  280. go_url = info.result.url;
  281. }
  282. layer.msg('操作成功',{time: 1000,
  283. end:function(){
  284. location.href = info.result.url;
  285. }
  286. });
  287. }
  288. }
  289. })
  290. }
  291. }
  292. })
  293. form.on('switch(statewsitch)', function(data){
  294. var s_url = $(this).attr('data-href')
  295. var s_value = 1;
  296. if(data.elem.checked)
  297. {
  298. s_value = 1;
  299. }else{
  300. s_value = 0;
  301. }
  302. $.ajax({
  303. url:s_url,
  304. type:'post',
  305. dataType:'json',
  306. data:{value:s_value},
  307. success:function(info){
  308. if(info.status == 0)
  309. {
  310. layer.msg(info.result.message,{icon: 1,time: 2000});
  311. }else if(info.status == 1){
  312. var go_url = location.href;
  313. if( info.result.hasOwnProperty("url") )
  314. {
  315. go_url = info.result.url;
  316. }
  317. layer.msg('操作成功',{time: 1000,
  318. end:function(){
  319. location.href = info.result.url;
  320. }
  321. });
  322. }
  323. }
  324. })
  325. });
  326. form.on('checkbox(checkboxall)', function(data){
  327. if(data.elem.checked)
  328. {
  329. $("input[name=item_checkbox]").each(function() {
  330. $(this).prop("checked", true);
  331. });
  332. $("input[name=checkall]").each(function() {
  333. $(this).prop("checked", true);
  334. });
  335. }else{
  336. $("input[name=item_checkbox]").each(function() {
  337. $(this).prop("checked", false);
  338. });
  339. $("input[name=checkall]").each(function() {
  340. $(this).prop("checked", false);
  341. });
  342. }
  343. form.render('checkbox');
  344. });
  345. //监听提交
  346. form.on('submit(formDemo)', function(data){
  347. $.ajax({
  348. url: data.form.action,
  349. type: data.form.method,
  350. data: data.field,
  351. dataType:'json',
  352. success: function (info) {
  353. if(info.status == 0)
  354. {
  355. layer.msg(info.result.message,{icon: 1,time: 2000});
  356. }else if(info.status == 1){
  357. var go_url = location.href;
  358. if( info.result.hasOwnProperty("url") )
  359. {
  360. go_url = info.result.url;
  361. }
  362. layer.msg('操作成功',{time: 1000,
  363. end:function(){
  364. location.href = info.result.url;
  365. }
  366. });
  367. }
  368. }
  369. });
  370. return false;
  371. });
  372. $('.setOrder').click(function(e){
  373. var _this = $(this);
  374. var id = _this.data('id');
  375. var value = _this.data('value');
  376. layer.prompt({
  377. formType: 2
  378. ,title: '修改 ID 为 ['+ id +'] 的排序'
  379. ,value: value
  380. }, function(value, index){
  381. layer.close(index);
  382. var s_url = _this.data('href');
  383. $.ajax({
  384. url:s_url,
  385. type:'post',
  386. dataType:'json',
  387. data: {value: value},
  388. success:function(info){
  389. if(info.status == 0)
  390. {
  391. layer.msg(info.result.message,{icon: 1,time: 2000});
  392. }else if(info.status == 1){
  393. var go_url = location.href;
  394. if( info.result.hasOwnProperty("url") )
  395. {
  396. go_url = info.result.url;
  397. }
  398. layer.msg('操作成功',{time: 1000,
  399. end:function(){
  400. location.href = info.result.url;
  401. }
  402. });
  403. }
  404. }
  405. })
  406. });
  407. })
  408. })
  409. </script>
  410. </body>
  411. </html>