2e27f44892c96df13fde8f7dc71790a4.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  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. <style>
  45. tbody tr td{
  46. position: relative;
  47. }
  48. tbody tr .icow-weibiaoti--{
  49. visibility: hidden;
  50. display: inline-block;
  51. color: #fff;
  52. height:18px;
  53. width:18px;
  54. background: #e0e0e0;
  55. text-align: center;
  56. line-height: 18px;
  57. vertical-align: middle;
  58. }
  59. tbody tr:hover .icow-weibiaoti--{
  60. visibility: visible;
  61. }
  62. tbody tr .icow-weibiaoti--.hidden{
  63. visibility: hidden !important;
  64. }
  65. .full .icow-weibiaoti--{
  66. margin-left:10px;
  67. }
  68. .full>span{
  69. display: -webkit-box;
  70. display: -webkit-flex;
  71. display: -ms-flexbox;
  72. display: flex;
  73. vertical-align: middle;
  74. align-items: center;
  75. }
  76. tbody tr .label{
  77. margin: 5px 0;
  78. }
  79. .goods_attribute a{
  80. cursor: pointer;
  81. }
  82. .newgoodsflag{
  83. width: 22px;height: 16px;
  84. background-color: #ff0000;
  85. color: #fff;
  86. text-align: center;
  87. position: absolute;
  88. bottom: 70px;
  89. left: 57px;
  90. font-size: 12px;
  91. }
  92. .a{cursor: pointer;}
  93. </style>
  94. </head>
  95. <body layadmin-themealias="default">
  96. <table id="demo" lay-filter="test"></table>
  97. <div class="layui-fluid">
  98. <div class="layui-card">
  99. <div class="layui-card-header layui-elem-quote">当前位置:<span class="line-text">兑换码管理</span></div>
  100. <div class="layui-card-body" style="padding:15px;">
  101. <form action="" method="get" class="form-horizontal form-search layui-form" role="form">
  102. <input type="hidden" name="c" value="virtualcard" />
  103. <input type="hidden" name="a" value="exchange_code" />
  104. <div class="layui-form-item">
  105. <div class="layui-inline">
  106. <div class="layui-input-inline">
  107. <input type="text" class="layui-input" name='keyword' value="<?php echo ($_GPC['keyword']); ?>" placeholder="输入关键词然后回车">
  108. </div>
  109. <div class="layui-input-inline">
  110. <button class="layui-btn layui-btn-sm" type="submit"> 搜索</button>
  111. </div>
  112. </div>
  113. </div>
  114. </form>
  115. <form action="" class="layui-form" lay-filter="example" method="post" >
  116. <div class="row">
  117. <div class="col-md-12">
  118. <div class="page-table-header">
  119. <span class="pull-right">
  120. <a href="<?php echo U('virtualcard/addCode', array('ok' => 1));?>" class="layui-btn layui-btn-sm"><i class="fa fa-plus"></i> 添加兑换码</a>
  121. </span>
  122. <div class="btn-group">
  123. <button class="btn btn-default btn-sm btn-operation" type="button" data-toggle='batch' data-href="<?php echo U('virtualcard/changecode',array('type'=>'state','value'=>1));?>">
  124. 启用
  125. </button>
  126. <button class="btn btn-default btn-sm btn-operation" type="button" data-toggle='batch' data-href="<?php echo U('virtualcard/changecode',array('type'=>'state','value'=>0));?>">
  127. 禁用
  128. </button>
  129. <button class="btn btn-default btn-sm btn-operation" type="button" data-toggle='batch-remove' data-confirm="确认要删除吗?" data-href="<?php echo U('virtualcard/deletecode');?>">
  130. 删除
  131. </button>
  132. </div>
  133. </div>
  134. <table class="table table-responsive" lay-even lay-skin="line" lay-size="lg">
  135. <thead>
  136. <tr>
  137. <th style="width:25px;">
  138. <input type='checkbox' name="checkall" lay-skin="primary" lay-filter="checkboxall" />
  139. </th>
  140. <th style="">ID</th>
  141. <th style="">兑换码名称</th>
  142. <th style="">有效期</th>
  143. <th style="">未使用数量</th>
  144. <th style="">已兑换数量</th>
  145. <th style="">关联商品数量</th>
  146. <th style="display:none;">状态</th>
  147. <th style="">操作</th>
  148. </tr>
  149. </thead>
  150. <tbody>
  151. <?php foreach( $list as $item ){ ?>
  152. <tr>
  153. <td>
  154. <input type='checkbox' name="item_checkbox" lay-skin="primary" value="<?php echo ($item['id']); ?>"/>
  155. </td>
  156. <td>
  157. <?php echo ($item['id']); ?>
  158. </td>
  159. <td>
  160. <?php echo ($item['code_name']); ?>
  161. </td>
  162. <td>
  163. <?php echo ($item['effect_name']); ?>
  164. </td>
  165. <td>
  166. <?php echo ($item['un_use_count']); ?>
  167. </td>
  168. <td>
  169. <?php echo ($item['has_use_count']); ?>
  170. </td>
  171. <td>
  172. <?php echo ($item['goods_count']); ?>
  173. </td>
  174. <td style="display:none;">
  175. <input type="checkbox" name="" lay-filter="statewsitch" data-href="<?php echo U('virtualcard/changecode',array('type'=>'state','id'=>$item['id']));?>" <?php if( $item['state']==1){ ?>checked<?php }else{ } ?> lay-skin="switch" lay-text="启用|禁用">
  176. </td>
  177. <td style="overflow:visible;position:relative">
  178. <a class='layui-btn layui-btn-xs' href="<?php echo U('virtualcard/addCode', array('id' => $item['id'], 'ok' => 1));?>" >
  179. <i class="layui-icon layui-icon-edit"></i>编辑
  180. </a>
  181. <a class='layui-btn layui-btn-xs' href="<?php echo U('virtualcard/exchangerecord', array('code_id' => $item['id'], 'ok' => 1));?>" >
  182. 兑换记录
  183. </a>
  184. <a class='layui-btn layui-btn-xs deldom' href="javascript:;" data-href="<?php echo U('virtualcard/deletecode',array('id' => $item['id']));?>" data-confirm='确认要删除吗?'>
  185. <i class="layui-icon">&#xe640;</i>删除
  186. </a>
  187. </td>
  188. </tr>
  189. <?php } ?>
  190. </tbody>
  191. <tfoot>
  192. <tr>
  193. <td colspan="5">
  194. <div class="page-table-header">
  195. <input type="checkbox" name="checkall" lay-skin="primary" lay-filter="checkboxall">
  196. <div class="btn-group">
  197. <button class="btn btn-default btn-sm btn-operation" type="button" data-toggle='batch' data-href="<?php echo U('virtualcard/changecode',array('type'=>'state','value'=>1));?>">
  198. 启用
  199. </button>
  200. <button class="btn btn-default btn-sm btn-operation" type="button" data-toggle='batch' data-href="<?php echo U('virtualcard/changecode',array('type'=>'state','value'=>0));?>">
  201. 禁用
  202. </button>
  203. <button class="btn btn-default btn-sm btn-operation" type="button" data-toggle='batch-remove' data-confirm="确认要删除吗?" data-href="<?php echo U('virtualcard/deletecode');?>">
  204. 删除
  205. </button>
  206. </div>
  207. </div>
  208. </td>
  209. <td colspan="3" style="text-align: right">
  210. <?php echo ($pager); ?>
  211. </td>
  212. </tr>
  213. </tfoot>
  214. </table>
  215. </div>
  216. </div>
  217. </form>
  218. </div>
  219. </div>
  220. </div>
  221. <script src="/layuiadmin/layui/layui.js"></script>
  222. <script>
  223. layui.config({
  224. base: '/layuiadmin/' //静态资源所在路径
  225. }).extend({
  226. index: 'lib/index' //主入口模块
  227. }).use('index');
  228. </script>
  229. <script>
  230. //由于模块都一次性加载,因此不用执行 layui.use() 来加载对应模块,直接使用即可:
  231. var layer = layui.layer;
  232. var $;
  233. layui.use(['jquery', 'layer','form'], function(){
  234. $ = layui.$;
  235. var form = layui.form;
  236. $('.deldom').click(function(){
  237. var s_url = $(this).attr('data-href');
  238. layer.confirm($(this).attr('data-confirm'), function(index){
  239. $.ajax({
  240. url:s_url,
  241. type:'post',
  242. dataType:'json',
  243. success:function(info){
  244. if(info.status == 0)
  245. {
  246. layer.msg(info.result.message,{icon: 1,time: 2000});
  247. }else if(info.status == 1){
  248. var go_url = location.href;
  249. if( info.result.hasOwnProperty("url") )
  250. {
  251. go_url = info.result.url;
  252. }
  253. layer.msg('操作成功',{time: 1000,
  254. end:function(){
  255. location.href = info.result.url;
  256. }
  257. });
  258. }
  259. }
  260. })
  261. });
  262. })
  263. $('.btn-operation').click(function(){
  264. var ids_arr = [];
  265. var obj = $(this);
  266. var s_toggle = $(this).attr('data-toggle');
  267. var s_url = $(this).attr('data-href');
  268. $("input[name=item_checkbox]").each(function() {
  269. if( $(this).prop('checked') )
  270. {
  271. ids_arr.push( $(this).val() );
  272. }
  273. })
  274. if(ids_arr.length < 1)
  275. {
  276. layer.msg('请选择要操作的内容');
  277. }else{
  278. var can_sub = true;
  279. if( s_toggle == 'batch-remove' )
  280. {
  281. can_sub = false;
  282. layer.confirm($(obj).attr('data-confirm'), function(index){
  283. $.ajax({
  284. url:s_url,
  285. type:'post',
  286. dataType:'json',
  287. data:{ids:ids_arr},
  288. success:function(info){
  289. if(info.status == 0)
  290. {
  291. layer.msg(info.result.message,{icon: 1,time: 2000});
  292. }else if(info.status == 1){
  293. var go_url = location.href;
  294. if( info.result.hasOwnProperty("url") )
  295. {
  296. go_url = info.result.url;
  297. }
  298. layer.msg('操作成功',{time: 1000,
  299. end:function(){
  300. location.href = info.result.url;
  301. }
  302. });
  303. }
  304. }
  305. })
  306. });
  307. }else{
  308. $.ajax({
  309. url:s_url,
  310. type:'post',
  311. dataType:'json',
  312. data:{ids:ids_arr},
  313. success:function(info){
  314. if(info.status == 0)
  315. {
  316. layer.msg(info.result.message,{icon: 1,time: 2000});
  317. }else if(info.status == 1){
  318. var go_url = location.href;
  319. if( info.result.hasOwnProperty("url") )
  320. {
  321. go_url = info.result.url;
  322. }
  323. layer.msg('操作成功',{time: 1000,
  324. end:function(){
  325. location.href = info.result.url;
  326. }
  327. });
  328. }
  329. }
  330. })
  331. }
  332. }
  333. })
  334. form.on('switch(statewsitch)', function(data){
  335. var s_url = $(this).attr('data-href')
  336. var s_value = 1;
  337. if(data.elem.checked)
  338. {
  339. s_value = 1;
  340. }else{
  341. s_value = 0;
  342. }
  343. $.ajax({
  344. url:s_url,
  345. type:'post',
  346. dataType:'json',
  347. data:{value:s_value},
  348. success:function(info){
  349. if(info.status == 0)
  350. {
  351. layer.msg(info.result.message,{icon: 1,time: 2000});
  352. }else if(info.status == 1){
  353. var go_url = location.href;
  354. if( info.result.hasOwnProperty("url") )
  355. {
  356. go_url = info.result.url;
  357. }
  358. layer.msg('操作成功',{time: 1000,
  359. end:function(){
  360. location.href = info.result.url;
  361. }
  362. });
  363. }
  364. }
  365. })
  366. });
  367. form.on('checkbox(checkboxall)', function(data){
  368. if(data.elem.checked)
  369. {
  370. $("input[name=item_checkbox]").each(function() {
  371. $(this).prop("checked", true);
  372. });
  373. $("input[name=checkall]").each(function() {
  374. $(this).prop("checked", true);
  375. });
  376. }else{
  377. $("input[name=item_checkbox]").each(function() {
  378. $(this).prop("checked", false);
  379. });
  380. $("input[name=checkall]").each(function() {
  381. $(this).prop("checked", false);
  382. });
  383. }
  384. form.render('checkbox');
  385. });
  386. //监听提交
  387. form.on('submit(formDemo)', function(data){
  388. $.ajax({
  389. url: data.form.action,
  390. type: data.form.method,
  391. data: data.field,
  392. dataType:'json',
  393. success: function (info) {
  394. if(info.status == 0)
  395. {
  396. layer.msg(info.result.message,{icon: 1,time: 2000});
  397. }else if(info.status == 1){
  398. var go_url = location.href;
  399. if( info.result.hasOwnProperty("url") )
  400. {
  401. go_url = info.result.url;
  402. }
  403. layer.msg('操作成功',{time: 1000,
  404. end:function(){
  405. location.href = info.result.url;
  406. }
  407. });
  408. }
  409. }
  410. });
  411. return false;
  412. });
  413. })
  414. </script>
  415. </body>