6a15c3aef56010bb5d7c1839af77143d.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. <?php if (!defined('THINK_PATH')) exit();?><!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': '<?php echo ($_W['uniacid']); ?>',<?php } ?>
  22. <?php if( !empty($_W['acid']) ){ ?>'acid': '<?php echo ($_W['acid']); ?>',<?php } ?>
  23. <?php if (!empty($_W['openid']) ) { ?>'openid': '<?php echo ($_W['openid']); ?>',<?php } ?>
  24. <?php if( !empty($_W['uid']) ) { ?>'uid': '<?php echo ($_W['uid']); ?>',<?php } ?>
  25. 'isfounder': <?php if (!empty($_W['isfounder']) ) { ?>1<?php }else{ ?>0<?php } ?>,
  26. 'siteroot': '<?php echo ($_W['siteroot']); ?>',
  27. 'siteurl': '<?php echo ($_W['siteurl']); ?>',
  28. 'attachurl': '<?php echo ($_W['attachurl']); ?>',
  29. 'attachurl_local': '<?php echo ($_W['attachurl_local']); ?>',
  30. 'attachurl_remote': '<?php echo ($_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': <?php echo 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. <?php echo 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='<?php echo ($k); ?>' <?php if( $gpc['catid']==$k){ ?>selected<?php } ?>><?php echo ($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="<?php echo ($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="<?php echo 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="<?php echo 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="">优惠券名称</th>
  99. <th style=" ">优惠<br/>使用条件</th>
  100. <th style=" ">剩余数量/已使用/已发出</th>
  101. <th style="width:130px;">首页领券</th>
  102. <th style="width:130px;">首页弹窗</th>
  103. <th style="width:50px;">排序</th>
  104. <th style="width:200px;">创建时间</th>
  105. <th style="width: 200px;">操作</th>
  106. </tr>
  107. </thead>
  108. <tbody>
  109. <?php foreach( $list as $row ){ ?>
  110. <tr>
  111. <td>
  112. <input type='checkbox' value="<?php echo ($row['id']); ?>" name="item_checkbox" lay-skin="primary"/>
  113. </td>
  114. <td>
  115. <?php echo ($row['id']); ?>
  116. </td>
  117. <td>
  118. <p style="line-height:30px;"><?php echo ($row['voucher_title']); ?></p>
  119. <label class='label label-success'>购物</label>
  120. <?php if( !empty($row['catid'])){ ?>
  121. <label class='label label-primary'><?php echo ($category[$row['catid']]); ?></label>
  122. <?php } ?>
  123. <?php if($row['is_new_man'] == 1){ ?>
  124. <label class='layui-badge'>新人券</label>
  125. <?php } ?>
  126. </td>
  127. <td>
  128. <?php echo ($row['credit']); ?> 元<br/>
  129. <?php if( $row['limit_money']>0){ ?>
  130. <span class="text-danger">满<?php echo ($row['limit_money']); ?>可用</span>
  131. <?php }else{ ?>
  132. <span class="text-warning">不限</span>
  133. <?php } ?>
  134. </td>
  135. <td>
  136. <?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 } ?>
  137. &nbsp;&nbsp;已使用: <?php echo ($row['usetotal']); ?>&nbsp;&nbsp;已发出: <?php echo ($row['send_count']); ?>
  138. </td>
  139. <td>
  140. <input type="checkbox" name="" lay-filter="statewsitch" data-href="<?php echo U('marketing/change',array('type'=>'is_index_show','id'=>$row['id']));?>" <?php if( $row['is_index_show']==1){ ?>checked<?php }else{ } ?> lay-skin="switch" lay-text="显示|隐藏">
  141. </td>
  142. <td>
  143. <input type="checkbox" name="" lay-filter="statewsitch" data-href="<?php echo U('marketing/change',array('type'=>'is_index_alert','id'=>$row['id']));?>" <?php if( $row['is_index_alert']==1){ ?>checked<?php }else{ } ?> lay-skin="switch" lay-text="显示|隐藏">
  144. </td>
  145. <td>
  146. <a href='javascript:;' class="setOrder" data-id="<?php echo ($row['id']); ?>" data-value="<?php echo ($row['displayorder']); ?>" data-href="<?php echo U('marketing/displayordercoupon',array('id'=>$row['id']));?>" ><?php echo ($row['displayorder']); ?></a>
  147. </td>
  148. <td><?php echo date('Y-m-d',$row['add_time']);?> <?php echo date('H:i',$row['add_time']);?></td>
  149. <td>
  150. <div class="btn-group">
  151. <a class="layui-btn layui-btn-xs" href="<?php echo U('marketing/addcoupon',array('id'=> $row['id'],'ok'=>1));;?>">
  152. <i class="layui-icon layui-icon-edit"></i>编辑</a>
  153. <a class="layui-btn layui-btn-danger layui-btn-xs deldom" href="javascript:;" data-href="<?php echo U('marketing/deletecoupon',array('id' => $row['id']));?>" data-confirm="确定要删除该优惠券吗?"><i class="layui-icon">&#xe640;</i>删除</a>
  154. </div>
  155. </td>
  156. </tr>
  157. <?php } ?>
  158. </tbody>
  159. <tfoot>
  160. <tr>
  161. <td colspan="3">
  162. <input type="checkbox" name="checkall" lay-skin="primary" lay-filter="checkboxall" />
  163. <span class="btn-group">
  164. <button class="btn btn-default btn-sm dropdown-toggle btn-operation" type="button" data-toggle='batch-remove' data-confirm="确认要删除?" data-href="<?php echo U('marketing/deletecoupon');?>">
  165. <i class="layui-icon">&#xe640;</i>删除
  166. </button>
  167. </span>
  168. </td>
  169. <td colspan="6" style="text-align: right"><?php echo ($pager); ?></td>
  170. </tr>
  171. </tfoot>
  172. </table>
  173. <?php }else{ ?>
  174. <div class='panel panel-default'>
  175. <div class='panel-body' style='text-align: center;padding:30px;'>
  176. 暂时没有任何优惠券!
  177. </div>
  178. </div>
  179. <?php } ?>
  180. </form>
  181. </div>
  182. </div>
  183. </div>
  184. </div>
  185. <script src="/layuiadmin/layui/layui.js"></script>
  186. <script>
  187. layui.config({
  188. base: '/layuiadmin/' //静态资源所在路径
  189. }).extend({
  190. index: 'lib/index' //主入口模块
  191. }).use('index');
  192. </script>
  193. <script>
  194. var layer = layui.layer;
  195. var $;
  196. layui.use(['jquery', 'layer', 'form'], function(){
  197. $ = layui.$;
  198. var form = layui.form;
  199. $('.deldom').click(function(){
  200. var s_url = $(this).attr('data-href');
  201. layer.confirm($(this).attr('data-confirm'), function(index){
  202. $.ajax({
  203. url:s_url,
  204. type:'post',
  205. dataType:'json',
  206. success:function(info){
  207. if(info.status == 0)
  208. {
  209. layer.msg(info.result.message,{icon: 1,time: 2000});
  210. }else if(info.status == 1){
  211. var go_url = location.href;
  212. if( info.result.hasOwnProperty("url") )
  213. {
  214. go_url = info.result.url;
  215. }
  216. layer.msg('操作成功',{time: 1000,
  217. end:function(){
  218. location.href = info.result.url;
  219. }
  220. });
  221. }
  222. }
  223. })
  224. });
  225. })
  226. $('.btn-operation').click(function(){
  227. var ids_arr = [];
  228. var obj = $(this);
  229. var s_toggle = $(this).attr('data-toggle');
  230. var s_url = $(this).attr('data-href');
  231. $("input[name=item_checkbox]").each(function() {
  232. if( $(this).prop('checked') )
  233. {
  234. ids_arr.push( $(this).val() );
  235. }
  236. })
  237. if(ids_arr.length < 1)
  238. {
  239. layer.msg('请选择要操作的内容');
  240. }else{
  241. var can_sub = true;
  242. if( s_toggle == 'batch-remove' )
  243. {
  244. can_sub = false;
  245. layer.confirm($(obj).attr('data-confirm'), function(index){
  246. $.ajax({
  247. url:s_url,
  248. type:'post',
  249. dataType:'json',
  250. data:{ids:ids_arr},
  251. success:function(info){
  252. if(info.status == 0)
  253. {
  254. layer.msg(info.result.message,{icon: 1,time: 2000});
  255. }else if(info.status == 1){
  256. var go_url = location.href;
  257. if( info.result.hasOwnProperty("url") )
  258. {
  259. go_url = info.result.url;
  260. }
  261. layer.msg('操作成功',{time: 1000,
  262. end:function(){
  263. location.href = info.result.url;
  264. }
  265. });
  266. }
  267. }
  268. })
  269. });
  270. }else{
  271. $.ajax({
  272. url:s_url,
  273. type:'post',
  274. dataType:'json',
  275. data:{ids:ids_arr},
  276. success:function(info){
  277. if(info.status == 0)
  278. {
  279. layer.msg(info.result.message,{icon: 1,time: 2000});
  280. }else if(info.status == 1){
  281. var go_url = location.href;
  282. if( info.result.hasOwnProperty("url") )
  283. {
  284. go_url = info.result.url;
  285. }
  286. layer.msg('操作成功',{time: 1000,
  287. end:function(){
  288. location.href = info.result.url;
  289. }
  290. });
  291. }
  292. }
  293. })
  294. }
  295. }
  296. })
  297. form.on('switch(statewsitch)', function(data){
  298. var s_url = $(this).attr('data-href')
  299. var s_value = 1;
  300. if(data.elem.checked)
  301. {
  302. s_value = 1;
  303. }else{
  304. s_value = 0;
  305. }
  306. $.ajax({
  307. url:s_url,
  308. type:'post',
  309. dataType:'json',
  310. data:{value:s_value},
  311. success:function(info){
  312. if(info.status == 0)
  313. {
  314. layer.msg(info.result.message,{icon: 1,time: 2000});
  315. }else if(info.status == 1){
  316. var go_url = location.href;
  317. if( info.result.hasOwnProperty("url") )
  318. {
  319. go_url = info.result.url;
  320. }
  321. layer.msg('操作成功',{time: 1000,
  322. end:function(){
  323. location.href = info.result.url;
  324. }
  325. });
  326. }
  327. }
  328. })
  329. });
  330. form.on('checkbox(checkboxall)', function(data){
  331. if(data.elem.checked)
  332. {
  333. $("input[name=item_checkbox]").each(function() {
  334. $(this).prop("checked", true);
  335. });
  336. $("input[name=checkall]").each(function() {
  337. $(this).prop("checked", true);
  338. });
  339. }else{
  340. $("input[name=item_checkbox]").each(function() {
  341. $(this).prop("checked", false);
  342. });
  343. $("input[name=checkall]").each(function() {
  344. $(this).prop("checked", false);
  345. });
  346. }
  347. form.render('checkbox');
  348. });
  349. //监听提交
  350. form.on('submit(formDemo)', function(data){
  351. $.ajax({
  352. url: data.form.action,
  353. type: data.form.method,
  354. data: data.field,
  355. dataType:'json',
  356. success: function (info) {
  357. if(info.status == 0)
  358. {
  359. layer.msg(info.result.message,{icon: 1,time: 2000});
  360. }else if(info.status == 1){
  361. var go_url = location.href;
  362. if( info.result.hasOwnProperty("url") )
  363. {
  364. go_url = info.result.url;
  365. }
  366. layer.msg('操作成功',{time: 1000,
  367. end:function(){
  368. location.href = info.result.url;
  369. }
  370. });
  371. }
  372. }
  373. });
  374. return false;
  375. });
  376. $('.setOrder').click(function(e){
  377. var _this = $(this);
  378. var id = _this.data('id');
  379. var value = _this.data('value');
  380. layer.prompt({
  381. formType: 2
  382. ,title: '修改 ID 为 ['+ id +'] 的排序'
  383. ,value: value
  384. }, function(value, index){
  385. layer.close(index);
  386. var s_url = _this.data('href');
  387. $.ajax({
  388. url:s_url,
  389. type:'post',
  390. dataType:'json',
  391. data: {value: value},
  392. success:function(info){
  393. if(info.status == 0)
  394. {
  395. layer.msg(info.result.message,{icon: 1,time: 2000});
  396. }else if(info.status == 1){
  397. var go_url = location.href;
  398. if( info.result.hasOwnProperty("url") )
  399. {
  400. go_url = info.result.url;
  401. }
  402. layer.msg('操作成功',{time: 1000,
  403. end:function(){
  404. location.href = info.result.url;
  405. }
  406. });
  407. }
  408. }
  409. })
  410. });
  411. })
  412. })
  413. </script>
  414. </body>
  415. </html>