pushList.blade.php 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. @extends('admin.table_layouts')
  2. @push('css')
  3. <link href="/assets/global/vendor/bootstrap-markdown/bootstrap-markdown.min.css" rel="stylesheet">
  4. @endpush
  5. @section('content')
  6. <div class="page-content container-fluid">
  7. <div class="panel">
  8. <div class="panel-heading">
  9. <h3 class="panel-title">{{ trans('admin.marketing.push.title') }}</h3>
  10. @can('admin.marketing.add')
  11. <div class="panel-actions">
  12. <button class="btn btn-primary disabled" data-toggle="modal" data-target="#send_modal" type="button">
  13. <i class="icon wb-plus"></i>{{ trans('admin.marketing.push.send') }}</button>
  14. </div>
  15. @endcan
  16. </div>
  17. <div class="panel-body">
  18. <form class="form-row">
  19. <div class="form-group col-lg-3 col-sm-6">
  20. <select class="form-control" id="status" name="status" data-plugin="selectpicker" data-style="btn-outline btn-primary"
  21. title="{{ trans('common.status.attribute') }}">
  22. <option value="0">{{ trans('common.to_be_send') }}</option>
  23. <option value="-1">{{ trans('common.failed') }}</option>
  24. <option value="1">{{ trans('common.success') }}</option>
  25. </select>
  26. </div>
  27. <div class="form-group col-lg-2 col-sm-6 btn-group">
  28. <button class="btn btn-primary" type="submit">{{ trans('common.search') }}</button>
  29. <a class="btn btn-danger" href="{{ route('admin.marketing.push') }}">{{ trans('common.reset') }}</a>
  30. </div>
  31. </form>
  32. {{-- <div class="alert alert-info alert-dismissible" role="alert"> --}}
  33. {{-- <button type="button" class="close" data-dismiss="alert" aria-label="{{ trans('common.close') }}"> --}}
  34. {{-- <span aria-hidden="true">×</span></button> --}}
  35. {{-- 仅会推送给关注了您的消息通道的用户 @can('admin.system.index')<a href="{{route('admin.system.index')}}" class="alert-link" target="_blank">设置PushBear</a> @else 设置PushBear @endcan --}}
  36. {{-- </div> --}}
  37. <table class="text-md-center" data-toggle="table" data-mobile-responsive="true">
  38. <thead class="thead-default">
  39. <tr>
  40. <th> #</th>
  41. <th> {{ trans('validation.attributes.title') }}</th>
  42. <th> {{ trans('validation.attributes.content') }}</th>
  43. <th> {{ trans('admin.marketing.send_status') }}</th>
  44. <th> {{ trans('admin.marketing.send_time') }}</th>
  45. <th> {{ trans('admin.marketing.error_message') }}</th>
  46. </tr>
  47. </thead>
  48. <tbody>
  49. @foreach ($pushes as $push)
  50. <tr>
  51. <td> {{ $push->id }} </td>
  52. <td> {{ $push->title }} </td>
  53. <td> {{ $push->content }} </td>
  54. <td> {{ $push->status_label }} </td>
  55. <td> {{ $push->created_at }} </td>
  56. <td> {{ $push->error }} </td>
  57. </tr>
  58. @endforeach
  59. </tbody>
  60. </table>
  61. </div>
  62. <div class="panel-footer">
  63. <div class="row">
  64. <div class="col-sm-4">
  65. {!! trans('admin.marketing.push.counts', ['num' => $pushes->total()]) !!}
  66. </div>
  67. <div class="col-sm-8">
  68. <nav class="Page navigation float-right">
  69. {{ $pushes->links() }}
  70. </nav>
  71. </div>
  72. </div>
  73. </div>
  74. </div>
  75. </div>
  76. @can('admin.marketing.add')
  77. <!-- 推送消息 -->
  78. <div class="modal fade" id="send_modal" data-focus-on="input:first" data-backdrop="static" data-keyboard="false" tabindex="-1">
  79. <div class="modal-dialog modal-lg modal-center">
  80. <div class="modal-content">
  81. <div class="modal-header">
  82. <button class="close" data-dismiss="modal" type="button" aria-label="{{ trans('common.close') }}">
  83. <span aria-hidden="true">×</span>
  84. </button>
  85. <h4 class="modal-title">{{ trans('admin.marketing.push.send') }}</h4>
  86. </div>
  87. <div class="modal-body">
  88. <div class="alert alert-danger" id="msg" style="display: none;"></div>
  89. <form class="form-horizontal" action="#" method="post">
  90. <div class="form-body">
  91. <div class="form-group">
  92. <div class="row">
  93. <label class="col-md-2 control-label" for="title"> {{ trans('validation.attributes.title') }} </label>
  94. <div class="col-md-6">
  95. <input class="form-control" id="title" name="title" type="text" />
  96. </div>
  97. </div>
  98. </div>
  99. <div class="form-group">
  100. <div class="row">
  101. <label class="col-md-2 control-label" for="content"> {{ trans('validation.attributes.content') }} </label>
  102. <div class="col-md-9">
  103. <textarea class="form-control" id="content" name="content" data-provide="markdown" data-iconlibrary="fa" rows="10"></textarea>
  104. </div>
  105. </div>
  106. </div>
  107. </div>
  108. </form>
  109. </div>
  110. <div class="modal-footer">
  111. <button class="btn btn-danger mr-auto" data-dismiss="modal">{{ trans('common.cancel') }}</button>
  112. <button class="btn btn-primary disabled" type="button" onclick="return send();">{{ trans('common.send') }}</button>
  113. </div>
  114. </div>
  115. </div>
  116. </div>
  117. @endcan
  118. @endsection
  119. @push('javascript')
  120. <script src="/assets/global/vendor/bootstrap-markdown/bootstrap-markdown.min.js"></script>
  121. <script src="/assets/global/vendor/marked/marked.min.js"></script>
  122. <script>
  123. $(document).ready(function() {
  124. $('#status').selectpicker('val', @json(Request::query('status')));
  125. });
  126. @can('admin.marketing.add')
  127. // 发送通道消息
  128. function send() {
  129. const title = $('#title').val();
  130. if (title.trim() === '') {
  131. $('#msg').show().html('{{ trans('validation.filled', ['attribute' => trans('validation.attributes.title')]) }}');
  132. title.focus();
  133. return false;
  134. }
  135. $.ajax({
  136. url: '{{ route('admin.marketing.add') }}',
  137. method: 'POST',
  138. data: {
  139. _token: '{{ csrf_token() }}',
  140. title: title,
  141. content: $('#content').val()
  142. },
  143. beforeSend: function() {
  144. $('#msg').show().html('{{ trans('admin.creating') }}');
  145. },
  146. success: function(ret) {
  147. if (ret.status === 'fail') {
  148. $('#msg').show().html(ret.message);
  149. return false;
  150. }
  151. $('#send_modal').modal('hide');
  152. },
  153. error: function() {
  154. $('#msg').show().html('{{ trans('common.request_failed') }}');
  155. },
  156. complete: function() {},
  157. });
  158. }
  159. // 关闭modal触发
  160. $('#send_modal').on('hide.bs.modal', function() {
  161. window.location.reload();
  162. });
  163. @endcan
  164. </script>
  165. @endpush