index.blade.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. <style type="text/css">
  2. .pagination{
  3. margin:0 !important;
  4. }
  5. </style>
  6. <div class="ibox float-e-margins">
  7. <div class="ibox-content" style="display: block;">
  8. <form action="{{ route('admin.course.coupons.index') }}" method="get" class="form-horizontal">
  9. <div class="col-md-9">
  10. <a href="{{ route('admin.course.coupons.create') }}" method="POST" class="btn btn-primary margin-bottom" no-pjax>添加优惠券</a>
  11. </div>
  12. <div class="col-md-3">
  13. <div class="form-group">
  14. <div class="input-group search_text">
  15. <input type="text" name="search" placeholder="优惠券名称" value="{{!empty(request('search'))?request('search'):''}}" class=" form-control"> <span class="input-group-btn"><button type="submit" class="btn btn-primary">查找</button></span>
  16. </div>
  17. </div>
  18. </div>
  19. </form>
  20. <div class="box-body table-responsive">
  21. <table class="table table-hover table-bordered" id="list_table">
  22. <thead>
  23. <tr>
  24. <th>优惠券名称</th>
  25. <th>类型</th>
  26. <th>起止时间</th>
  27. <th>有效时间</th>
  28. <th>抵用金额</th>
  29. <th>满*使用</th>
  30. <th>优惠折扣</th>
  31. <th>次数/名额</th>
  32. <th>抵扣类型</th>
  33. <th>是否启用</th>
  34. <th>操作</th>
  35. </tr>
  36. </thead>
  37. @if(count($coupons)>0)
  38. <tbody>
  39. @foreach($coupons as $value)
  40. <tr id="{{ $value->id }}">
  41. <td>
  42. {{ $value->name }}
  43. </td>
  44. <td>
  45. @if($value->type==1)现金券
  46. @elseif($value->type==2)活动券
  47. @elseif($value->type==3)折扣券
  48. @endif
  49. </td>
  50. <td>
  51. @if(!empty($value->start_time) && !empty($value->end_time))
  52. {{ $value->start_time }} - {{ $value->end_time }}
  53. @else
  54. 无限制
  55. @endif
  56. </td>
  57. <td>
  58. @if(!empty($value->use_day))
  59. {{ $value->use_day }}
  60. @if($value->date=='1')天
  61. @elseif($value->date=='2')月
  62. @elseif($value->date=='3')年
  63. @endif
  64. @else
  65. 永久
  66. @endif
  67. </td>
  68. <td>
  69. {{ $value->amount }}
  70. </td>
  71. <td>
  72. {{ $value->min_limit_amount }}
  73. </td>
  74. <td>
  75. @if($value->discount=='0')
  76. 无折扣
  77. @else
  78. {{ $value->discount }}
  79. @endif
  80. </td>
  81. <td>
  82. {{ $value->num }}
  83. </td>
  84. <td>
  85. @if(!empty($value->num_type))
  86. @if($value->num_type=='1')活动
  87. @elseif($value->num_type=='2')课程
  88. @elseif($value->num_type=='3')线上博物馆
  89. @endif
  90. @else
  91. @endif
  92. </td>
  93. <td><a class="status" cid="{{$value->id}}" status="{{$value->status}}">
  94. <i class="fa @if($value->status==1) fa-toggle-on @else fa-toggle-off @endif"></i></a></td>
  95. <td>
  96. <a href="{{ route('admin.course.coupons.edit',['id' => $value->id]) }}" class="btn btn-xs btn-primary">
  97. <i class="fa fa-pencil" data-toggle="tooltip" data-placement="top" title="编辑"></i>
  98. </a>
  99. <button onclick="checkCategory({{$value->id}})" class="btn btn-xs btn-danger">
  100. <i class="fa fa-trash" data-toggle="tooltip" data-placement="top" title="删除"></i>
  101. </button>
  102. </td>
  103. </tr>
  104. @endforeach
  105. </tbody>
  106. <tfoot>
  107. <tr>
  108. <td colspan="12">
  109. <div class="pull-left">
  110. &nbsp;&nbsp;共&nbsp;{!! $coupons->total() !!} 条记录
  111. </div>
  112. <div class="pull-right">
  113. {!! $coupons->appends(request()->except('page'))->render() !!}
  114. </div>
  115. </td>
  116. </tr>
  117. </tfoot>
  118. @else
  119. <tfoot>
  120. <tr>
  121. <td colspan="10">
  122. 当前无数据
  123. </td>
  124. </tr>
  125. </tfoot>
  126. @endif
  127. </table>
  128. </div>
  129. </div>
  130. <!-- /.col-lg-12 -->
  131. </div>
  132. <!-- /.row -->
  133. <script language="javascript">
  134. //折叠展示
  135. function displayData(_self) {
  136. if (_self.alt == "关闭") {
  137. jqshow($(_self).parent().parent().attr('id'), 'hide');
  138. $(_self).attr("src", "{!! url('assets/backend/images/open.gif') !!}");
  139. _self.alt = '打开';
  140. }
  141. else {
  142. jqshow($(_self).parent().parent().attr('id'), 'show');
  143. $(_self).attr("src", "{!! url('assets/backend/images/close.gif') !!}");
  144. _self.alt = '关闭';
  145. }
  146. }
  147. function jqshow(id, isshow) {
  148. var obj = $("#list_table tr[parent='" + id + "']");
  149. if (obj.length > 0) {
  150. obj.each(function (i) {
  151. jqshow($(this).attr('id'), isshow);
  152. });
  153. if (isshow == 'hide') {
  154. obj.hide();
  155. }
  156. else {
  157. obj.show();
  158. }
  159. }
  160. }
  161. //排序
  162. function toSort(id) {
  163. if (id != '') {
  164. var va = $('#s' + id).val();
  165. var part = /^\d+$/i;
  166. if (va != '' && va != undefined && part.test(va)) {
  167. $.get("{{ route('admin.course.advertising.advertising_sort') }}", {
  168. 'id': id,
  169. 'sort': va,
  170. _token: _token
  171. }, function (data) {
  172. if (data.status) {
  173. swal({
  174. title: "修改分类排序成功!",
  175. text: "",
  176. type: "success"
  177. }, function() {
  178. location.reload();
  179. });
  180. } else {
  181. swal("修改分类排序失败!", "", "error");
  182. }
  183. });
  184. }
  185. }
  186. }
  187. function checkCategory(id) {
  188. $.get("{{ route('admin.course.coupons.check') }}", {
  189. 'id': id,
  190. _token: _token
  191. }, function (data) {
  192. if (data.status) {
  193. deleteCategory(id);
  194. } else {
  195. swal('注意','该优惠券正在使用不能删除','warning');
  196. }
  197. });
  198. }
  199. function deleteCategory(id) {
  200. $.post("{{ route('admin.course.coupons.delete') }}", {
  201. 'id': id,
  202. _token: _token
  203. }, function (data) {
  204. if (data.status) {
  205. swal({
  206. title: "删除成功!",
  207. text: "",
  208. type: "success"
  209. }, function() {
  210. location.reload();
  211. });
  212. } else {
  213. swal("删除失败!", "该广告信息有误", "error");
  214. }
  215. });
  216. }
  217. $('.status').on('click', function () {
  218. var value = $(this).attr('status');
  219. var modelId = $(this).attr('cid');
  220. value = parseInt(value);
  221. modelId = parseInt(modelId);
  222. if (value == 1) {
  223. value = 0;
  224. } else {
  225. value = 1;
  226. }
  227. var that = $(this);
  228. $.post("{{route('admin.course.coupons.status')}}",
  229. {
  230. status: value,
  231. modelId: modelId
  232. },
  233. function (data, status) {
  234. console.log(data,status);
  235. if (status) {
  236. if (1 == value) {
  237. that.children().removeClass('fa-toggle-off');
  238. that.children().addClass('fa-toggle-on');
  239. that.attr('status',1);
  240. } else {
  241. that.children().removeClass('fa-toggle-on');
  242. that.children().addClass('fa-toggle-off');
  243. that.attr('status',0);
  244. }
  245. }
  246. });
  247. });
  248. </script>