goodsList.blade.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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="/shop/addGoods" 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="/shop/goodsList" 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. @if($goodsList->isEmpty())
  53. <tr>
  54. <td colspan="11">暂无数据</td>
  55. </tr>
  56. @else
  57. @foreach($goodsList as $goods)
  58. <tr>
  59. <td> {{$goods->id}} </td>
  60. <td> {{$goods->name}} </td>
  61. <td>
  62. @if($goods->type == 1)
  63. 流量包
  64. @elseif($goods->type == 2)
  65. 套餐
  66. @else
  67. 充值
  68. @endif
  69. </td>
  70. <td>
  71. @if($goods->logo)
  72. <a href="{{$goods->logo}}" target="_blank"><img src="{{$goods->logo}}" alt="logo" class="h-50"/></a>
  73. @endif
  74. </td>
  75. <td> {{$goods->traffic_label}} </td>
  76. <td> {{$goods->price}}元</td>
  77. <td> {{$goods->sort}} </td>
  78. <td>
  79. @if($goods->is_hot)
  80. <span class="badge badge-lg badge-danger">是</span>
  81. @else
  82. <span class="badge badge-lg badge-default">否</span>
  83. @endif
  84. </td>
  85. <td>
  86. {{$goods->limit_num}}
  87. </td>
  88. <td>
  89. @if($goods->status)
  90. <span class="badge badge-lg badge-success">上架</span>
  91. @else
  92. <span class="badge badge-lg badge-default">下架</span>
  93. @endif
  94. </td>
  95. <td>
  96. <div class="btn-group">
  97. <a href="/shop/editGoods/{{$goods->id}}" class="btn btn-primary"><i class="icon wb-edit"></i></a>
  98. <button class="btn btn-danger" onclick="delGoods('{{$goods->id}}','{{$goods->name}}')"><i class="icon wb-trash"></i></button>
  99. </div>
  100. </td>
  101. </tr>
  102. @endforeach
  103. @endif
  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" type="text/javascript"></script>
  125. <script type="text/javascript">
  126. $(document).ready(function () {
  127. $('#type').val({{Request::get('type')}});
  128. $('#status').val({{Request::get('status')}});
  129. });
  130. // 搜索
  131. function Search() {
  132. window.location.href = '/shop/goodsList?type=' + $("#type option:selected").val() + '&status=' + $("#status option:selected").val();
  133. }
  134. // 删除商品
  135. function delGoods(id, name) {
  136. swal.fire({
  137. title: '警告',
  138. text: '确定删除商品 【' + name + '】 ?',
  139. type: 'warning',
  140. showCancelButton: true,
  141. cancelButtonText: '取消',
  142. confirmButtonText: '确定',
  143. }).then((result) => {
  144. if (result.value) {
  145. $.post("/shop/delGoods", {id: id, _token: '{{csrf_token()}}'}, function (ret) {
  146. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false,})
  147. .then(() => {
  148. window.location.reload();
  149. })
  150. });
  151. }
  152. });
  153. }
  154. </script>
  155. @endsection