goodsList.blade.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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="" @if(Request::get('type') == '') selected hidden @endif>类型</option>
  19. <option value="1" @if(Request::get('type') == '1') selected hidden @endif>流量包</option>
  20. <option value="2" @if(Request::get('type') == '2') selected hidden @endif>套餐</option>
  21. <option value="3" @if(Request::get('type') == '3') selected hidden @endif>余额充值</option>
  22. </select>
  23. </div>
  24. <div class="form-group col-lg-2 col-sm-4">
  25. <select class="form-control" id="status" name="status" onChange="Search()">
  26. <option value="" @if(Request::get('status') == '') selected hidden @endif>状态</option>
  27. <option value="1" @if(Request::get('status') == '1') selected hidden @endif>上架</option>
  28. <option value="0" @if(Request::get('status') == '0') selected hidden @endif>下架</option>
  29. </select>
  30. </div>
  31. <div class="form-group col-lg-2 col-sm-4 btn-group">
  32. <button class="btn btn-primary" onclick="Search()">搜 索</button>
  33. <a href="/shop/goodsList" class="btn btn-danger">重 置</a>
  34. </div>
  35. </div>
  36. <table class="text-md-center" data-toggle="table" data-mobile-responsive="true">
  37. <thead class="thead-default">
  38. <tr>
  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. <th> 操作</th>
  50. </tr>
  51. </thead>
  52. <tbody>
  53. @if($goodsList->isEmpty())
  54. <tr>
  55. <td colspan="11">暂无数据</td>
  56. </tr>
  57. @else
  58. @foreach($goodsList as $goods)
  59. <tr>
  60. <td> {{$goods->id}} </td>
  61. <td> {{$goods->name}} </td>
  62. <td>
  63. @if($goods->type == 1)
  64. 流量包
  65. @elseif($goods->type == 2)
  66. 套餐
  67. @else
  68. 充值
  69. @endif
  70. </td>
  71. <td>
  72. @if($goods->logo)
  73. <a href="{{$goods->logo}}" target="_blank"><img src="{{$goods->logo}}" alt="logo" class="h-50"/></a>
  74. @endif
  75. </td>
  76. <td> {{$goods->type == 3 ? '' : $goods->traffic_label}} </td>
  77. <td> {{$goods->price}}元</td>
  78. <td> {{$goods->sort}} </td>
  79. <td>
  80. @if($goods->is_hot)
  81. <span class="badge badge-lg badge-danger">是</span>
  82. @else
  83. <span class="badge badge-lg badge-default">否</span>
  84. @endif
  85. </td>
  86. <td>
  87. {{$goods->limit_num}}
  88. </td>
  89. <td>
  90. @if($goods->status)
  91. <span class="badge badge-lg badge-success">上架</span>
  92. @else
  93. <span class="badge badge-lg badge-default">下架</span>
  94. @endif
  95. </td>
  96. <td>
  97. <div class="btn-group">
  98. <a href="/shop/editGoods/{{$goods->id}}" class="btn btn-primary"><i class="icon wb-edit"></i></a>
  99. <button class="btn btn-danger" onclick="delGoods('{{$goods->id}}','{{$goods->name}}')"><i class="icon wb-trash"></i></button>
  100. </div>
  101. </td>
  102. </tr>
  103. @endforeach
  104. @endif
  105. </tbody>
  106. </table>
  107. </div>
  108. <div class="panel-footer">
  109. <div class="row">
  110. <div class="col-sm-4">
  111. 共 <code>{{$goodsList->total()}}</code> 个商品
  112. </div>
  113. <div class="col-sm-8">
  114. <nav class="Page navigation float-right">
  115. {{$goodsList->links()}}
  116. </nav>
  117. </div>
  118. </div>
  119. </div>
  120. </div>
  121. </div>
  122. @endsection
  123. @section('script')
  124. <script src="/assets/global/vendor/bootstrap-table/bootstrap-table.min.js" type="text/javascript"></script>
  125. <script src="/assets/global/vendor/bootstrap-table/extensions/mobile/bootstrap-table-mobile.min.js" type="text/javascript"></script>
  126. <script type="text/javascript">
  127. // 搜索
  128. function Search() {
  129. window.location.href = '/shop/goodsList?type=' + $("#type option:selected").val() + '&status=' + $("#status option:selected").val();
  130. }
  131. // 删除商品
  132. function delGoods(id, name) {
  133. swal.fire({
  134. title: '警告',
  135. text: '确定删除商品 【' + name + '】 ?',
  136. type: 'warning',
  137. showCancelButton: true,
  138. cancelButtonText: '取消',
  139. confirmButtonText: '确定',
  140. }).then((result) => {
  141. if (result.value) {
  142. $.post("/shop/delGoods", {id: id, _token: '{{csrf_token()}}'}, function (ret) {
  143. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false,})
  144. .then(() => {
  145. window.location.reload();
  146. })
  147. });
  148. }
  149. });
  150. }
  151. </script>
  152. @endsection