grant_group.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. {extend name="public/container"}
  2. {block name="head_top"}
  3. <script src="{__FRAME_PATH}js/content.min.js"></script>
  4. <script src="{__PLUG_PATH}sweetalert2/sweetalert2.all.min.js"></script>
  5. {/block}
  6. {block name="content"}
  7. <div class="row">
  8. <div class="col-sm-12">
  9. <div class="ibox">
  10. <div class="ibox-content">
  11. <div class="row">
  12. <div class="col-sm-8 m-b-xs">
  13. <form action="" class="form-inline">
  14. <i class="fa fa-search" style="margin-right: 10px;"></i>
  15. <div class="input-group" style="width: 80%">
  16. <input type="text" name="title" value="{$where.title}" placeholder="请输入优惠券名称" class="input-sm form-control"> <span class="input-group-btn">
  17. <button type="submit" class="btn btn-sm btn-primary"> 搜索</button> </span>
  18. </div>
  19. </form>
  20. </div>
  21. </div>
  22. <div class="table-responsive">
  23. <table class="table table-striped table-bordered">
  24. <thead>
  25. <tr>
  26. <th class="text-center">优惠券名称</th>
  27. <th class="text-center">优惠券面值</th>
  28. <th class="text-center">优惠券最低消费</th>
  29. <th class="text-center">优惠券有效期限</th>
  30. <th class="text-center">操作</th>
  31. </tr>
  32. </thead>
  33. <tbody class="">
  34. {volist name="list" id="vo"}
  35. <tr>
  36. <td class="text-center">
  37. {$vo.title}
  38. </td>
  39. <td class="text-center">
  40. {$vo.coupon_price}
  41. </td>
  42. <td class="text-center">
  43. {$vo.use_min_price}
  44. </td>
  45. <td class="text-center">
  46. {$vo.coupon_time}天
  47. </td>
  48. <td class="text-center">
  49. <button class="btn btn-primary btn-xs grant" data-id="{$vo['id']}" data-url="{:Url('ump.storeCouponUser/grant_group',array('id'=>$vo['id']))}" type="button"><i class="fa fa-arrow-circle-o-right"></i> 发放
  50. </button>
  51. </td>
  52. </tr>
  53. {/volist}
  54. </tbody>
  55. </table>
  56. </div>
  57. {include file="public/inner_page"}
  58. </div>
  59. </div>
  60. </div>
  61. </div>
  62. {/block}
  63. {block name="script"}
  64. <script>
  65. var group = {$group};
  66. $('.grant').on('click',function(){
  67. window.t = $(this);
  68. var _this = $(this),url =_this.data('url');
  69. var option = {};
  70. $.each(group,function (item,index) {
  71. option[index.id] = index.name;
  72. })
  73. var inputOptions = new Promise(function(resolve) {
  74. resolve(option);
  75. });
  76. swal({
  77. title: '请选择要给哪个组发放',
  78. input: 'radio',
  79. inputOptions: inputOptions,
  80. inputValidator: function(result) {
  81. return new Promise(function(resolve, reject) {
  82. if (result) {
  83. resolve();
  84. } else {
  85. reject('请选择要给哪个组发放优惠卷');
  86. }
  87. });
  88. }
  89. }).then(function(result) {
  90. if (result) {
  91. swal({
  92. title: "您确定要发放优惠券吗?",
  93. text:"发放后将无法撤回,请谨慎操作!",
  94. type: "warning",
  95. showCancelButton: true,
  96. confirmButtonColor: "#DD6B55",
  97. confirmButtonText:"是的,我要发放!",
  98. cancelButtonText:"让我再考虑一下…",
  99. closeOnConfirm: false,
  100. closeOnCancel: false
  101. }).then(function(){
  102. $eb.axios.post(url,{group:result}).then(function(res){
  103. if(res.status == 200 && res.data.code == 200) {
  104. swal(res.data.msg);
  105. }else
  106. return Promise.reject(res.data.msg || '发放失败')
  107. }).catch(function(err){
  108. swal(err);
  109. });
  110. }).catch(console.log);
  111. }
  112. })
  113. });
  114. </script>
  115. {/block}