index.blade.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. @extends('admin.layouts')
  2. @section('css')
  3. <link href="/assets/global/vendor/bootstrap-table/bootstrap-table.min.css" type="text/css" rel="stylesheet">
  4. @endsection
  5. @section('content')
  6. <div class="page-content container-fluid">
  7. <div class="panel panel-bordered">
  8. <div class="panel-heading">
  9. <h1 class="panel-title"><i class="icon wb-shopping-cart" aria-hidden="true"></i>商品列表</h1>
  10. <div class="panel-actions">
  11. <a href="{{route('goods.create')}}" class="btn btn-primary"><i class="icon wb-plus"></i>添加商品</a>
  12. </div>
  13. </div>
  14. <div class="panel-body">
  15. <div class="form-row">
  16. <div class="form-group col-lg-2 col-sm-4">
  17. <select class="form-control" id="type" name="type" onChange="Search()">
  18. <option value="" hidden>类型</option>
  19. <option value="1">流量包</option>
  20. <option value="2">套餐</option>
  21. </select>
  22. </div>
  23. <div class="form-group col-lg-2 col-sm-4">
  24. <select class="form-control" id="status" name="status" onChange="Search()">
  25. <option value="" hidden>状态</option>
  26. <option value="1">上架</option>
  27. <option value="0">下架</option>
  28. </select>
  29. </div>
  30. <div class="form-group col-lg-2 col-sm-4 btn-group">
  31. <button class="btn btn-primary" onclick="Search()">搜 索</button>
  32. <a href="{{route('goods.index')}}" class="btn btn-danger">重 置</a>
  33. </div>
  34. </div>
  35. <table class="text-md-center" data-toggle="table" data-mobile-responsive="true">
  36. <thead class="thead-default">
  37. <tr>
  38. <th> #</th>
  39. <th> 名称</th>
  40. <th> 类型</th>
  41. <th> 图片</th>
  42. <th> 内含流量</th>
  43. <th> 售价</th>
  44. <th> 排序</th>
  45. <th> 热销</th>
  46. <th> 限购数</th>
  47. <th> 状态</th>
  48. <th> 操作</th>
  49. </tr>
  50. </thead>
  51. <tbody>
  52. @foreach($goodsList as $goods)
  53. <tr>
  54. <td> {{$goods->id}} </td>
  55. <td> {{$goods->name}} </td>
  56. <td>
  57. @if($goods->type == 1)
  58. 流量包
  59. @elseif($goods->type == 2)
  60. 套餐
  61. @else
  62. 充值
  63. @endif
  64. </td>
  65. <td>
  66. @if($goods->logo)
  67. <a href="{{$goods->logo}}" target="_blank">
  68. <img src="{{$goods->logo}}" alt="logo" class="h-50"/>
  69. </a>
  70. @endif
  71. </td>
  72. <td> {{$goods->traffic_label}} </td>
  73. <td> {{$goods->price}}元</td>
  74. <td> {{$goods->sort}} </td>
  75. <td>
  76. @if($goods->is_hot)
  77. <span class="badge badge-lg badge-danger">是</span>
  78. @else
  79. <span class="badge badge-lg badge-default">否</span>
  80. @endif
  81. </td>
  82. <td>
  83. {{$goods->limit_num}}
  84. </td>
  85. <td>
  86. @if($goods->status)
  87. <span class="badge badge-lg badge-success">上架</span>
  88. @else
  89. <span class="badge badge-lg badge-default">下架</span>
  90. @endif
  91. </td>
  92. <td>
  93. <div class="btn-group">
  94. <a href="{{route('goods.edit',$goods->id)}}" class="btn btn-primary">
  95. <i class="icon wb-edit"></i>
  96. </a>
  97. <button onclick="delGoods('{{route('goods.destroy',$goods->id)}}','{{$goods->name}}')" class="btn btn-danger">
  98. <i class="icon wb-trash"></i>
  99. </button>
  100. </div>
  101. </td>
  102. </tr>
  103. @endforeach
  104. </tbody>
  105. </table>
  106. </div>
  107. <div class="panel-footer">
  108. <div class="row">
  109. <div class="col-sm-4">
  110. 共 <code>{{$goodsList->total()}}</code> 个商品
  111. </div>
  112. <div class="col-sm-8">
  113. <nav class="Page navigation float-right">
  114. {{$goodsList->links()}}
  115. </nav>
  116. </div>
  117. </div>
  118. </div>
  119. </div>
  120. </div>
  121. @endsection
  122. @section('script')
  123. <script src="/assets/global/vendor/bootstrap-table/bootstrap-table.min.js" type="text/javascript"></script>
  124. <script src="/assets/global/vendor/bootstrap-table/extensions/mobile/bootstrap-table-mobile.min.js"
  125. type="text/javascript"></script>
  126. <script type="text/javascript">
  127. $(document).ready(function () {
  128. $('#type').val({{Request::get('type')}});
  129. $('#status').val({{Request::get('status')}});
  130. });
  131. // 搜索
  132. function Search() {
  133. window.location.href = '{{route('goods.index')}}?type=' + $("#type option:selected").val() + '&status=' + $("#status option:selected").val();
  134. }
  135. // 删除商品
  136. function delGoods(url, name) {
  137. swal.fire({
  138. title: '警告',
  139. text: '确定删除商品 【' + name + '】 ?',
  140. type: 'warning',
  141. showCancelButton: true,
  142. cancelButtonText: '取消',
  143. confirmButtonText: '确定',
  144. }).then((result) => {
  145. if (result.value) {
  146. $.ajax({
  147. url: url,
  148. type: 'DELETE',
  149. dataType: 'json',
  150. data: {_token: '{{csrf_token()}}'},
  151. success: function (ret) {
  152. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false,})
  153. .then(() => {
  154. window.location.reload();
  155. })
  156. },
  157. });
  158. }
  159. });
  160. }
  161. </script>
  162. @endsection