coupon.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. {template 'common/header'}
  2. <ul class="nav nav-tabs">
  3. <li {if $do == 'display'}class="active"{/if}><a href="{php echo url('activity/coupon/display', array());}">卡券列表</a></li>
  4. <li {if $do == 'post' && !$couponid}class="active"{/if}><a href="javascript:;" data-toggle="modal" data-target="#cardtype-modal">添加卡券</a></li>
  5. {if $do == 'post' && $couponid}<li class="active"><a href="{php echo url('activity/coupon/post', array('id' => $couponid))}">编辑卡券</a></li>{/if}
  6. </ul>
  7. <div class="modal fade" id="cardtype-modal" tabindex="-1" role="dialog" aria-hidden="true">
  8. <div class="modal-dialog">
  9. <div class="modal-content">
  10. <div class="modal-header">
  11. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  12. <h4 class="modal-title" id="myModalLabel">选择你要创建的卡券类型</h4>
  13. </div>
  14. <div class="modal-body clearfix form-horizontal">
  15. <div class="form-group marbot0">
  16. <label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
  17. <div class="col-sm-9 col-xs-12">
  18. <label class="radio-inline">
  19. <input type="radio" name="type" value="{COUPON_TYPE_DISCOUNT}"/> 折扣券
  20. </label>
  21. <div class="help-block">可为用户提供消费折扣</div>
  22. </div>
  23. </div>
  24. <div class="form-group marbot0">
  25. <label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
  26. <div class="col-sm-9 col-xs-12">
  27. <label class="radio-inline">
  28. <input type="radio" name="type" value="{COUPON_TYPE_CASH}"/> 代金券
  29. </label>
  30. <div class="help-block">可为用户提供抵扣现金服务。可设置成为“满*元,减*元”</div>
  31. </div>
  32. </div>
  33. {if COUPON_TYPE == WECHAT_COUPON}
  34. <div class="form-group marbot0">
  35. <label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
  36. <div class="col-sm-9 col-xs-12">
  37. <label class="radio-inline">
  38. <input type="radio" name="type" value="{COUPON_TYPE_GIFT}"/> 礼品券
  39. </label>
  40. <div class="help-block">可为用户提供消费送赠品服务</div>
  41. </div>
  42. </div>
  43. <div class="form-group marbot0">
  44. <label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
  45. <div class="col-sm-9 col-xs-12">
  46. <label class="radio-inline">
  47. <input type="radio" name="type" value="{COUPON_TYPE_GROUPON}"/> 团购券
  48. </label>
  49. <div class="help-block">可为用户提供团购套餐服务</div>
  50. </div>
  51. </div>
  52. <div class="form-group marbot0">
  53. <label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
  54. <div class="col-sm-9 col-xs-12">
  55. <label class="radio-inline">
  56. <input type="radio" name="type" value="{COUPON_TYPE_GENERAL}"/> 优惠券
  57. </label>
  58. <div class="help-block">即“通用券”,建议当以上四种无法满足需求时采用</div>
  59. </div>
  60. </div>
  61. {/if}
  62. </div>
  63. <div class="modal-footer">
  64. <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
  65. <button type="button" class="btn btn-primary" data-dismiss="modal" onclick="location.href='{php echo url('activity/coupon/post')}&type=' + $('#cardtype-modal input[type=radio]:checked').val()">确定</button>
  66. </div>
  67. </div>
  68. </div>
  69. </div>
  70. {if $_W['account']['level'] == ACCOUNT_SERVICE_VERIFY || $_W['account']['level'] == ACCOUNT_SUBSCRIPTION_VERIFY}
  71. <div class="panel panel-default">
  72. <div class="panel-heading">
  73. 是否使用系统卡券:
  74. <input type="checkbox" name="flag" value="0" {if intval($uni_setting['coupon_type']) == SYSTEM_COUPON} checked="checked" {/if}/>
  75. </div>
  76. </div>
  77. {/if}
  78. <div class="main">
  79. <div class="panel panel-info">
  80. <div class="panel-heading">筛选</div>
  81. <div class="panel-body">
  82. <form action="./index.php" method="get" class="form-horizontal" role="form">
  83. <input type="hidden" name="c" value="activity" />
  84. <input type="hidden" name="a" value="coupon" />
  85. <input type="hidden" name="type" value="{$_GPC['type']}" />
  86. <div class="form-group">
  87. <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">卡券类型</label>
  88. <div class="col-sm-7 col-lg-9 col-xs-12 btn-group">
  89. <a href="{php echo filter_url('type:');}" class="btn {if $_GPC['type'] == ''}btn-primary{else}btn-default{/if}">不限</a>
  90. <a href="{php echo filter_url('type:'.COUPON_TYPE_DISCOUNT);}" class="btn {if $_GPC['type'] == COUPON_TYPE_DISCOUNT}btn-primary{else}btn-default{/if}">折扣券</a>
  91. <a href="{php echo filter_url('type:'.COUPON_TYPE_CASH);}" class="btn {if $_GPC['type'] == COUPON_TYPE_CASH}btn-primary{else}btn-default{/if}">代金券</a>
  92. {if COUPON_TYPE == WECHAT_COUPON}
  93. <a href="{php echo filter_url('type:'.COUPON_TYPE_GIFT);}" class="btn {if $_GPC['type'] == COUPON_TYPE_GIFT}btn-primary{else}btn-default{/if}">礼品券</a>
  94. <a href="{php echo filter_url('type:'.COUPON_TYPE_GROUPON);}" class="btn {if $_GPC['type'] == COUPON_TYPE_GROUPON}btn-primary{else}btn-default{/if}">团购券</a>
  95. <a href="{php echo filter_url('type:'.COUPON_TYPE_GENERAL);}" class="btn {if $_GPC['type'] == COUPON_TYPE_GENERAL}btn-primary{else}btn-default{/if}">优惠券</a>
  96. {/if}
  97. </div>
  98. </div>
  99. <div class="form-group">
  100. <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">审核状态</label>
  101. <div class="col-sm-7 col-lg-9 col-xs-12">
  102. <div class="btn-group">
  103. <a href="{php echo filter_url('status:');}" class="btn {if $_GPC['status'] == ''}btn-primary{else}btn-default{/if}">不限</a>
  104. <a href="{php echo filter_url('status:1');}" class="btn {if $_GPC['status'] == 1}btn-primary{else}btn-default{/if}">审核中</a>
  105. <a href="{php echo filter_url('status:2');}" class="btn {if $_GPC['status'] == 2}btn-primary{else}btn-default{/if}">未通过</a>
  106. <a href="{php echo filter_url('status:3');}" class="btn {if $_GPC['status'] == 3}btn-primary{else}btn-default{/if}">已通过</a>
  107. </div>
  108. </div>
  109. </div>
  110. <div class="form-group">
  111. <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">可用会员组</label>
  112. <div class="col-sm-7 col-lg-9 col-xs-12">
  113. <select name="groupid" class="form-control">
  114. {loop $groups $row}
  115. <option {if $_GPC['groupid'] == $row['id']}selected{/if} value="{$row['id']}">{$row['name']}</option>
  116. {/loop}
  117. </select>
  118. </div>
  119. </div>
  120. <div class="form-group">
  121. <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">可用门店</label>
  122. <div class="col-sm-7 col-lg-9 col-xs-12">
  123. <select name="storeid" class="form-control">
  124. <option value="0">不限</option>
  125. {loop $location_store $row}
  126. <option {if $_GPC['storeid'] == $row['id']}selected{/if} value="{$row['id']}">{$row['business_name']}</option>
  127. {/loop}
  128. </select>
  129. </div>
  130. </div>
  131. <div class="form-group">
  132. <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">可用模块</label>
  133. <div class="col-sm-7 col-lg-9 col-xs-12">
  134. <select name="moduleid" class="form-control">
  135. <option value="0">不限</option>
  136. {loop $module $row}
  137. {if empty($row['issystem'])}
  138. <option {if $_GPC['moduleid'] == $row['name']}selected{/if} value="{$row['name']}">{$row['title']}</option>
  139. {/if}
  140. {/loop}
  141. </select>
  142. </div>
  143. </div>
  144. <div class="form-group">
  145. <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">券标题</label>
  146. <div class="col-sm-7 col-lg-9 col-xs-12">
  147. <input class="form-control" name="title" placeholder="券标题" type="text" value="{$_GPC['title']}">
  148. </div>
  149. <div class="pull-right col-xs-12 col-sm-3 col-lg-2">
  150. <button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
  151. </div>
  152. </div>
  153. </form>
  154. </div>
  155. </div>
  156. <div class="modal fade" id="quantity-modal" tabindex="-1" role="dialog" aria-hidden="true">
  157. <div class="modal-dialog">
  158. <div class="modal-content">
  159. <div class="modal-header">
  160. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  161. <h4 class="modal-title" id="myModalLabel">修改库存</h4>
  162. </div>
  163. <div class="modal-body clearfix form-horizontal">
  164. <input type="text" class="form-control" name="quantity" />
  165. </div>
  166. <div class="modal-footer">
  167. <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
  168. <button type="button" class="btn btn-primary" data-dismiss="modal" onclick="util.ajaxshow('{php echo url('activity/coupon/modifystock')}&id=&quantity=' + $('input[name=quantity]').val() + '&id='+window.couponid)">确定</button>
  169. </div>
  170. </div>
  171. </div>
  172. </div>
  173. <div class="panel panel-default">
  174. <div class="table-responsive panel-body">
  175. <table class="table table-hover">
  176. <thead class="navbar-inner">
  177. <tr>
  178. <th width="80px">卡券类型</th>
  179. <th width="120px">卡券名称</th>
  180. <th width="150px">卡券有效期</th>
  181. <th width="70px">状态</th>
  182. <th width="100px">库存</th>
  183. <th width="50px">限领</th>
  184. <th width="80px">上架状态</th>
  185. <th style="width:450px; text-align:right;">操作</th>
  186. </tr>
  187. </thead>
  188. <tbody>
  189. {loop $list $item}
  190. <tr>
  191. <td>{$item['type'][0]}</td>
  192. <td>{$item['title']}</td>
  193. <td>
  194. {$item['date_info']}
  195. </td>
  196. <td>
  197. {if $item['status'] == '1'}
  198. <span class="label label-info">审核中</span>
  199. {elseif $item['status'] == '2'}
  200. <span class="label label-danger">未通过</span>
  201. {elseif $item['status'] == '3'}
  202. <span class="label label-success">已通过</span>
  203. {elseif $item['status'] == '4'}
  204. <span class="label label-default">卡券被商户删除</span>
  205. {elseif $item['status'] == '5'}
  206. <span class="label label-warning">已在公众平台投放</span>
  207. {/if}
  208. </td>
  209. <td>{$item['quantity']}</td>
  210. <td>{$item['get_limit']}</td>
  211. <td>
  212. {if $item['is_display'] == 1}
  213. <span class="label label-success">上架中</span>
  214. {else}
  215. <span class="label label-danger">已下架</span>
  216. {/if}
  217. </td>
  218. <td style="text-align:right;">
  219. {if COUPON_TYPE == WECHAT_COUPON}<a href="javascript:;" onclick="util.ajaxshow('{php echo url('activity/coupon/selfconsume', array('id' => $item['id']))}')" class="btn {if $item['is_selfconsume'] == 1}btn-danger{else}btn-success{/if} btn-sm toggle-selfconsume" title="自助核销">{if $item['is_selfconsume'] == 1}关闭自助核销{else}开启自助核销{/if}</a>
  220. <a href="#put-coupon" data-toggle="modal" data-cid={$item['id']} class="btn btn-default btn-sm js-publish">投放</a>
  221. {/if}
  222. <a href="javascript:;" class="btn btn-default btn-sm" onclick="window.couponid = '{$item['id']}';$('input[name=quantity]').val('');" data-toggle="modal" data-target="#quantity-modal">修改库存</a>
  223. <a href="javascript:;" onclick="util.ajaxshow('{php echo url('activity/coupon/toggle', array('id' => $item['id']))}')" class="btn btn-default btn-sm toggle-display" title="上架/下架">{if $item['is_display'] == 1}下架{else}上架{/if}</a>
  224. <a href="{php echo url('activity/coupon/detail', array('id' => $item['id']))}" class="btn btn-success btn-sm" title="查看详情">查看详情</a>
  225. <a href="{php echo url('activity/consume/display', array('couponid' => $item['id'], 'status' => '3'))}" class="btn btn-default btn-sm" title="领取记录">领取记录</a>
  226. <a href="{php echo url('activity/coupon/del', array('id' => $item['id']))}" class="btn btn-default btn-sm" title="删除" onclick="if(!confirm('删除后将不可恢复,确定删除吗?')) return false;">删除</a>
  227. </td>
  228. </tr>
  229. {/loop}
  230. </tbody>
  231. </table>
  232. </div>
  233. </div>
  234. {if COUPON_TYPE == WECHAT_COUPON}
  235. <a class="btn btn-success js-sync pull-left" onclick="util.ajaxshow('{php echo url('activity/coupon/sync', array('type' => 1))}')">更新全部卡券最新状态</a>
  236. {/if}
  237. <div class="pull-right">{$pager}</div>
  238. </div>
  239. {if COUPON_TYPE == WECHAT_COUPON}
  240. <div class="modal fade" id="put-coupon">
  241. <div class="modal-dialog">
  242. <div class="modal-content">
  243. <div class="modal-body">
  244. <div class="form-group">
  245. <ul class="nav nav-tabs" role="tablist">
  246. <li role="presentation" class="active"><a href="#put-qrcode" aria-controls="qrcode" role="tab" data-toggle="tab">二维码</a></li>
  247. <li role="presentation"><a href="#put-coupon-record" aria-controls="put-coupon-record" role="tab" data-toggle="tab">领取记录</a></li>
  248. </ul>
  249. </div>
  250. <div class="tab-content">
  251. <div role="tabpanel" class="tab-pane active text-center" id="put-qrcode">
  252. <div class="alert alert-info text-left">
  253. 该投放二维码有效期至:<span class="js-qrcode-expire"></span> <br />
  254. 如果您要大量投放卡券,请使用卡券营销功能
  255. </div>
  256. <img src="" class="js-qrcode-src">
  257. </div>
  258. <div role="tabpanel" class="tab-pane" id="put-coupon-record">
  259. <div class="alert alert-info text-left">
  260. 共有 <span class="js-qrcode-record-total"></span> 人领取
  261. </div>
  262. <table class="table table-hover">
  263. <thead class="table table-hover">
  264. <tr>
  265. <th style="width: 20%;"></th>
  266. <th>昵称</th>
  267. <th style="width: 30%;">领取时间</th>
  268. </tr>
  269. </thead>
  270. <tbody class="js-qrcode-record"></tbody>
  271. </table>
  272. </div>
  273. </div>
  274. </div>
  275. </div>
  276. </div>
  277. </div>
  278. <script type="text/javascript">
  279. $(document).on('click', '.js-publish', function() {
  280. cid = $(this).data('cid');
  281. $.post("{php echo url('activity/coupon/publish')}", {'cid' : cid}, function(data) {
  282. var data = $.parseJSON(data);
  283. if (data.message.errno == '0') {
  284. var coupon = data.message.message.coupon;
  285. $('.js-qrcode-src').attr('src', coupon.url);
  286. $('.js-qrcode-expire').html(coupon.expire);
  287. $('.js-qrcode-record-total').html(data.message.message.total);
  288. var record = data.message.message.record;
  289. if (record) {
  290. $('.js-qrcode-record').html('');
  291. for (i in record) {
  292. $('.js-qrcode-record').append('<tr><td><img src="'+record[i].avatar+'" width="50" /></td><td><a href="#">'+record[i].nickname+'</a></td><td><a href="#">'+record[i].createtime+'</a></td></tr>');
  293. }
  294. }
  295. } else {
  296. $('#put-coupon').modal('hide');
  297. util.message(data.message.message);
  298. }
  299. });
  300. });
  301. </script>
  302. {/if}
  303. <script>
  304. $(function(){
  305. require(['bootstrap.switch'], function() {
  306. angular.bootstrap(document, ['app']);
  307. $(":checkbox[name='flag']").bootstrapSwitch();
  308. $(':checkbox').on('switchChange.bootstrapSwitch', function(e, state){
  309. $this = $(this);
  310. var status = this.checked ? 1 : 2;
  311. var hint = status == 1 ? '切换为系统卡券将不显示微信卡券及微信门店' : '切换为微信卡券将不显示系统卡券及系统门店';
  312. if (confirm(hint) == false) {
  313. location.href = location.href;
  314. return false;
  315. }
  316. $.post("{php echo url('activity/coupon/exchange_coupon_type');}", {'status' : status}, function(resp){
  317. resp = $.parseJSON(resp);
  318. if (resp.message.errno < 0) {
  319. util.message(resp.message.message, location.href, 'error');
  320. } else {
  321. util.message(resp.message.message, location.href, 'success');
  322. }
  323. });
  324. });
  325. });
  326. });
  327. </script>
  328. {template 'common/footer'}