replyTicket.blade.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. @extends('user.layouts')
  2. @section('content')
  3. <div class="page-content">
  4. <div class="panel panel-bordered">
  5. <div class="panel-heading">
  6. <h1 class="panel-title cyan-600"><i class="icon wb-help-circle"></i> {{$ticket->title}} </h1>
  7. @if($ticket->status !== 2)
  8. <div class="panel-actions">
  9. <button class="btn btn-danger" onclick="closeTicket()"> {{trans('common.close')}} </button>
  10. </div>
  11. @endif
  12. </div>
  13. <div class="panel-body">
  14. <div class="chat-box">
  15. <div class="chats">
  16. <x-chat-unit :user="Auth::getUser()" :ticket="$ticket"/>
  17. @foreach ($replyList as $reply)
  18. <x-chat-unit :user="Auth::getUser()" :ticket="$reply"/>
  19. @endforeach
  20. </div>
  21. </div>
  22. </div>
  23. @if($ticket->status !== 2)
  24. <div class="panel-footer pb-30">
  25. <form>
  26. <div class="input-group">
  27. <input type="text" class="form-control" id="editor" placeholder="{{trans('user.ticket.reply_placeholder')}}"/>
  28. <span class="input-group-btn">
  29. <button type="button" class="btn btn-primary" onclick="replyTicket()"> {{trans('common.send')}}</button>
  30. </span>
  31. </div>
  32. </form>
  33. </div>
  34. @endif
  35. </div>
  36. </div>
  37. <p>如何上传图片?将图片通过https://prnt.sc/上传图片,然后生成链接发送给我们.</p>
  38. <p>人工客服会在十二小时内回复,请不要重复发工单.</p>
  39. <a href="/tickets" class="card-link">建议查看在线问答文档</a>
  40. @endsection
  41. @section('javascript')
  42. <script>
  43. //回车检测
  44. $(document).on('keypress', 'input', function(e) {
  45. if (e.which === 13) {
  46. replyTicket();
  47. return false;
  48. }
  49. });
  50. // 关闭工单
  51. function closeTicket() {
  52. swal.fire({
  53. title: '{{trans('user.ticket.close')}}',
  54. text: '{{trans('user.ticket.close_tips')}}',
  55. icon: 'question',
  56. showCancelButton: true,
  57. cancelButtonText: '{{trans('common.close')}}',
  58. confirmButtonText: '{{trans('common.confirm')}}',
  59. }).then((result) => {
  60. if (result.value) {
  61. $.ajax({
  62. method: 'POST',
  63. url: '{{route('closeTicket')}}',
  64. async: true,
  65. data: {_token: '{{csrf_token()}}', id: '{{$ticket->id}}'},
  66. dataType: 'json',
  67. success: function(ret) {
  68. swal.fire({
  69. title: ret.message,
  70. icon: 'success',
  71. timer: 1300,
  72. }).then(() => window.location.href = '{{route('ticket1')}}');
  73. },
  74. error: function() {
  75. swal.fire({title: '{{trans('user.ticket.error')}}', icon: 'error'});
  76. },
  77. });
  78. }
  79. });
  80. }
  81. // 回复工单
  82. function replyTicket() {
  83. const content = document.getElementById('editor').value;
  84. if (content.trim() === '') {
  85. swal.fire({title: '{{trans('validation.required', ['attribute' => trans('validation.attributes.content')])}}!', icon: 'warning', timer: 1500});
  86. return false;
  87. }
  88. swal.fire({
  89. title: '{{trans('user.ticket.reply_confirm')}}',
  90. icon: 'question',
  91. allowEnterKey: false,
  92. showCancelButton: true,
  93. cancelButtonText: '{{trans('common.close')}}',
  94. confirmButtonText: '{{trans('common.confirm')}}',
  95. }).then((result) => {
  96. if (result.value) {
  97. $.post('{{route('replyTicket')}}', {
  98. _token: '{{csrf_token()}}',
  99. id: '{{$ticket->id}}',
  100. content: content,
  101. }, function(ret) {
  102. if (ret.status === 'success') {
  103. swal.fire({
  104. title: ret.message,
  105. icon: 'success',
  106. timer: 1000,
  107. showConfirmButton: false,
  108. }).then(() => window.location.reload());
  109. } else {
  110. swal.fire({title: ret.message, icon: 'error'}).then(() => window.location.reload());
  111. }
  112. });
  113. }
  114. });
  115. }
  116. </script>
  117. @endsection