config.blade.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. @extends('base.base')
  2. @section('base')
  3. <!-- 内容区域 -->
  4. <div class="main-panel">
  5. <div class="content-wrapper">
  6. <div class="page-header">
  7. <h3 class="page-title">
  8. <span class="page-title-icon bg-gradient-primary text-white mr-2">
  9. <i class="mdi mdi-settings"></i>
  10. </span>
  11. {{ __('auto.咖啡渠道修改') }}
  12. </h3>
  13. <nav aria-label="breadcrumb">
  14. <ol class="breadcrumb">
  15. <li class="breadcrumb-item"><a href="#">{{ __('auto.咖啡管理') }}</a></li>
  16. <li class="breadcrumb-item active" aria-current="page">{{ __('auto.咖啡渠道修改') }}</li>
  17. <li class="breadcrumb-item active" aria-current="page">{{ __('auto.查看渠道') }}</li>
  18. </ol>
  19. </nav>
  20. </div>
  21. <div class="row">
  22. <div class="col-lg-12 grid-margin stretch-card">
  23. <div class="card">
  24. <div class="card-body">
  25. <h4 class="card-title">{{ __('auto.查看渠道') }}</h4>
  26. <div class="mb-2">
  27. <button type="button" class="btn btn-sm btn-outline-secondary" id="toggle-closed-btn">
  28. 显示已关闭渠道
  29. </button>
  30. </div>
  31. <form action="" method="post" class="form-ajax">
  32. {!! csrf_field() !!}
  33. <div class="table-responsive">
  34. <table class="table table-bordered table-striped">
  35. <thead>
  36. <tr>
  37. <th style="min-width: 80px;">ID</th>
  38. <th style="min-width: 180px;">{{ __('auto.渠道名称') }}</th>
  39. <th style="min-width: 120px;">Cash(1)</th>
  40. <th style="min-width: 120px;">PayPal(2)</th>
  41. <th style="min-width: 120px;">Apple(4)</th>
  42. <th style="min-width: 120px;">Google(8)</th>
  43. <th style="min-width: 150px;">{{ __('auto.当前状态') }}</th>
  44. </tr>
  45. </thead>
  46. <tbody>
  47. @foreach($list as $k => $v)
  48. @php
  49. $remarks = [];
  50. if (!empty($v->remarks)) {
  51. $decoded = \GuzzleHttp\json_decode($v->remarks, true);
  52. if (is_array($decoded)) {
  53. $remarks = $decoded;
  54. }
  55. }
  56. $weights = $remarks['weight'] ?? ($remarks['weights'] ?? []);
  57. $payTypes = (int)($v->pay_types ?? 0);
  58. $payRate = config('pay.' . ($v->config_key ?? '') . '.pay_rate', []);
  59. $rateText = function ($method) use ($payRate) {
  60. $methodRate = $payRate[$method] ?? null;
  61. if (is_array($methodRate) && count($methodRate) >= 2) {
  62. return $methodRate[0] . '%+' . $methodRate[1];
  63. }
  64. return '-';
  65. };
  66. @endphp
  67. <tr data-status="{{ (int)$v->status }}">
  68. <td>{{ $v->id }}</td>
  69. <td>{{ $v->name }}</td>
  70. <input type="hidden" name="config[{{$v->id}}][sort]" value="{{$v->sort}}">
  71. <td>
  72. <div style="display:flex; align-items:center; gap:6px;">
  73. <input class="form-control form-control-sm" type="number" min="0"
  74. style="width:72px;"
  75. name="config[{{$v->id}}][weight][1]"
  76. value="{{ $weights['type_1'] ?? '' }}"
  77. placeholder="{{ (($payTypes & 1) === 1) ? '0' : 'N/A' }}"
  78. {{ (($payTypes & 1) === 1) ? '' : 'disabled' }}>
  79. <small style="white-space:nowrap; color:#495057; font-size:13px;">{{ $rateText(1) }}</small>
  80. </div>
  81. </td>
  82. <td>
  83. <div style="display:flex; align-items:center; gap:6px;">
  84. <input class="form-control form-control-sm" type="number" min="0"
  85. style="width:72px;"
  86. name="config[{{$v->id}}][weight][2]"
  87. value="{{ $weights['type_2'] ?? '' }}"
  88. placeholder="{{ (($payTypes & 2) === 2) ? '0' : 'N/A' }}"
  89. {{ (($payTypes & 2) === 2) ? '' : 'disabled' }}>
  90. <small style="white-space:nowrap; color:#495057; font-size:13px;">{{ $rateText(2) }}</small>
  91. </div>
  92. </td>
  93. <td>
  94. <div style="display:flex; align-items:center; gap:6px;">
  95. <input class="form-control form-control-sm" type="number" min="0"
  96. style="width:72px;"
  97. name="config[{{$v->id}}][weight][4]"
  98. value="{{ $weights['type_4'] ?? '' }}"
  99. placeholder="{{ (($payTypes & 4) === 4) ? '0' : 'N/A' }}"
  100. {{ (($payTypes & 4) === 4) ? '' : 'disabled' }}>
  101. <small style="white-space:nowrap; color:#495057; font-size:13px;">{{ $rateText(4) }}</small>
  102. </div>
  103. </td>
  104. <td>
  105. <div style="display:flex; align-items:center; gap:6px;">
  106. <input class="form-control form-control-sm" type="number" min="0"
  107. style="width:72px;"
  108. name="config[{{$v->id}}][weight][8]"
  109. value="{{ $weights['type_8'] ?? '' }}"
  110. placeholder="{{ (($payTypes & 8) === 8) ? '0' : 'N/A' }}"
  111. {{ (($payTypes & 8) === 8) ? '' : 'disabled' }}>
  112. <small style="white-space:nowrap; color:#495057; font-size:13px;">{{ $rateText(8) }}</small>
  113. </div>
  114. </td>
  115. <td>
  116. @component('components.select', [
  117. 'name' => "config[{$v->id}][status]",
  118. 'class' => $v->status == 1 ? 'btn-primary' : 'btn-danger',
  119. 'options' => [1 => __('auto.开启'), -1 => __('auto.关闭')],
  120. 'default' => $v->status])
  121. @endcomponent
  122. </td>
  123. </tr>
  124. @endforeach
  125. </tbody>
  126. </table>
  127. </div>
  128. <div class="mt-3">
  129. <button class="btn btn-sm btn-primary">{{ __('auto.提交') }}</button>
  130. </div>
  131. </form>
  132. </div>
  133. </div>
  134. </div>
  135. </div>
  136. </div>
  137. </div>
  138. <script>
  139. (function () {
  140. var showClosed = false;
  141. var btn = document.getElementById('toggle-closed-btn');
  142. if (!btn) return;
  143. function renderRows() {
  144. var rows = document.querySelectorAll('tr[data-status]');
  145. for (var i = 0; i < rows.length; i++) {
  146. var row = rows[i];
  147. var status = parseInt(row.getAttribute('data-status') || '0', 10);
  148. if (!showClosed && status === -1) {
  149. row.style.display = 'none';
  150. } else {
  151. row.style.display = '';
  152. }
  153. }
  154. btn.textContent = showClosed ? '隐藏已关闭渠道' : '显示已关闭渠道';
  155. }
  156. btn.addEventListener('click', function () {
  157. showClosed = !showClosed;
  158. renderRows();
  159. });
  160. renderRows();
  161. })();
  162. </script>
  163. @endsection