海南旅游SAAS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

272 lines
9.8 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. <style>
  2. .chat-container { padding: 20px 40px; height: calc(100vh - 160px) }
  3. .msg-chat {
  4. position: relative; background-color: white; padding: 40px 20px 50px 20px;
  5. border-top-right-radius: 8px; border-bottom-right-radius: 8px; height: 100%;
  6. }
  7. .msg-chat-list { height: 100%; overflow-y: auto; overflow-x: hidden; padding-bottom: 20px; }
  8. .msg-user { margin: 5px 0px; line-height: 30px; }
  9. .msg-name { display: inline-block; font-size: 14px; font-weight: bold; padding: 0px 5px; }
  10. .msg-avatar { display: inline-block; }
  11. .msg-avatar img { width: 30px; height: 30px; border-radius: 50%; }
  12. .msg-content { display: inline-block; background-color: #f4f4f4; padding: 20px; border-radius: 10px; }
  13. .msg-content-image { max-width: 120px; max-height: 120px; }
  14. .msg-send { position: absolute; bottom: 0; left: 0; z-index: 999; height: 50px; }
  15. .msg-send .input-group-addon { width: 40px; border: none; line-height: 2.7; background-color: #dbe3e6; cursor: pointer; }
  16. .msg-send .input-group-addon.msg-text { background-color: #586cb1; color: white; padding: 5px 10px; width: 60px; line-height: 2.8; }
  17. .msg-time { padding: 0 5px; color: gray; font-size: 12px; margin: 5px 0; }
  18. .msg-list {
  19. position: relative; background-color: white;
  20. border-top-left-radius: 5px; border-bottom-left-radius: 5px;
  21. height: 100%; border-right: 1px solid #dbe3e6; overflow-y: auto;
  22. padding: 20px 10px;
  23. }
  24. .msg-list-item { position: relative; border: 1px solid #dbe3e6; padding: 10px; border-radius: 5px; margin-bottom: 1px; cursor: pointer; }
  25. .msg-list-item:hover { border-color: green; }
  26. .msg-list-item.active { border: 2px solid green; box-shadow: 0px 0px 4px green; }
  27. .msg-list-title { font-weight: bold; font-size: 14px; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; border-radius: 5px; padding: 2px 5px; overflow: hidden; text-overflow: ellipsis; margin-bottom: 5px; }
  28. .msg-list-content { color: gray; background-color: #f4f4f4; border-radius: 5px; padding: 2px 5px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  29. .msg-list-badge {
  30. position: absolute; right: 5px; top: 5px;
  31. width: 10px; height: 10px; border-radius: 10px;
  32. }
  33. .background-red { background-color: red; }
  34. .background-gray { background-color: gray; }
  35. </style>
  36. <div class="row chat-container">
  37. <div class="col-lg-3 col-md-4 msg-list">
  38. @if(empty($user_list))
  39. <div class="text-center">暂无工单数据</div>
  40. @else
  41. @foreach($user_list as $key => $item)
  42. @if($workorder['workorder_id']==$item['workorder_id'])
  43. <div class="msg-list-item active" onclick="window.location.href = '?workorder_id={{$item['workorder_id']}}'">
  44. @else
  45. <div class="msg-list-item" onclick="window.location.href = '?workorder_id={{$item['workorder_id']}}'">
  46. @endif
  47. <div class="msg-user">
  48. <div class="msg-avatar">
  49. <img src="{{$item['avatar']}}" alt="头像" title="头像" />
  50. </div>
  51. <div class="msg-name">
  52. {{$item['name']}}
  53. </div>
  54. </div>
  55. <div class="msg-list-title">
  56. {{$item['content']}}
  57. </div>
  58. <div class="msg-list-content">
  59. {{$item['last_message']}}
  60. </div>
  61. <div class="msg-time">
  62. {{$item['last_message_time']}}
  63. </div>
  64. @if($item['items_count'] > 0)
  65. <div class="msg-list-badge background-red">{{$item['items_count']}}</div>
  66. @endif
  67. </div>
  68. @endforeach
  69. @endif
  70. </div>
  71. <div class="col-lg-9 col-md-8 msg-chat">
  72. @if(empty($msg_list))
  73. <div class="text-center">暂无工单数据</div>
  74. @else
  75. <div class="input-group input-group-lg msg-send">
  76. <input name="msg-input" type="text" class="form-control" style="border-radius: 0; border-color: #dbe3e6; text-align: center;">
  77. <div class="input-group-addon msg-image"><span class="fa fa-picture-o"></span></div>
  78. <div class="input-group-addon msg-text">发送</div>
  79. <input type="file" class="hidden image" name="image">
  80. </div>
  81. <div class="msg-chat-list">
  82. @foreach($msg_list as $key => $item)
  83. @if($item['type'] == 'op')
  84. <div class="row">
  85. <div class="col-lg-11 text-left">
  86. <div class="msg-user">
  87. <div class="msg-avatar">
  88. <img src="{{$item['avatar']}}" alt="头像" title="头像" />
  89. </div>
  90. <div class="msg-name">
  91. {{$item['name']}}
  92. </div>
  93. </div>
  94. <div class="msg-content">
  95. @if($item['it_type'] == 1)
  96. {{$item['content']}}
  97. @elseif($item['it_type'] == 2)
  98. <img class="msg-content-image" onclick="viewImage(this)" src="{{$item['content']}}" alt="图片" title="图片" />
  99. @endif
  100. </div>
  101. <div class="msg-time">
  102. {{$item['created_at_text']}}
  103. @if($item['is_read'] == 0)
  104. <span class="unread">[ 新消息 ]</span>
  105. @endif
  106. </div>
  107. </div>
  108. </div>
  109. @elseif($item['type'] == 'my')
  110. <div class="row">
  111. <div class="col-lg-11 offset-1 text-right">
  112. <div class="msg-user">
  113. <div class="msg-name">
  114. {{$item['name']}}
  115. </div>
  116. <div class="msg-avatar">
  117. <img src="{{$item['avatar']}}" alt="头像" title="头像" />
  118. </div>
  119. </div>
  120. <div class="msg-content text-left">
  121. @if($item['it_type'] == 1)
  122. {{$item['content']}}
  123. @elseif($item['it_type'] == 2)
  124. <img class="msg-content-image" onclick="viewImage(this)" src="{{$item['content']}}" alt="图片" title="图片" />
  125. @endif
  126. </div>
  127. <div class="msg-time">
  128. {{$item['created_at_text']}}
  129. @if($item['is_read'] == 0)
  130. <span class="unread">[ 新消息 ]</span>
  131. @endif
  132. </div>
  133. </div>
  134. </div>
  135. @endif
  136. @endforeach
  137. </div>
  138. @endif
  139. </div>
  140. <div class="hidden-forms">
  141. <input type="hidden" name="workorder-id" value="{{$workorder['workorder_id']??1}}">
  142. </div>
  143. </div>
  144. <div class="template-op hidden">
  145. <div class="row">
  146. <div class="col-lg-11 text-left">
  147. <div class="msg-user">
  148. <div class="msg-avatar">
  149. <img src="/vendor/dcat-admin/images/default-avatar.jpg" alt="头像" title="头像" />
  150. </div>
  151. <div class="msg-name">
  152. 代理商AbcD
  153. </div>
  154. </div>
  155. <div class="msg-content">#contents</div>
  156. <div class="msg-time">#times</div>
  157. </div>
  158. </div>
  159. </div>
  160. <div class="template-my hidden">
  161. <div class="row">
  162. <div class="col-lg-11 offset-1 text-right">
  163. <div class="msg-user">
  164. <div class="msg-name">
  165. {{$user->name}}
  166. </div>
  167. <div class="msg-avatar">
  168. <img src="{{\Illuminate\Support\Facades\Storage::url($user->avatar)}}" alt="头像" title="头像" />
  169. </div>
  170. </div>
  171. <div class="msg-content text-left">#contents</div>
  172. <div class="msg-time">#times</div>
  173. </div>
  174. </div>
  175. </div>
  176. <div class="modal fade" tabindex="-1" role="dialog" id="viewImage">
  177. <div class="modal-dialog modal-lg" role="document">
  178. <div class="modal-content">
  179. <img src="" style="width: 100%; height: 100%;" />
  180. </div>
  181. </div>
  182. </div>
  183. <script src="js/helper.js" type="application/javascript"></script>
  184. <script>
  185. Dcat.ready(function() {
  186. // 获取元素距离父级元素顶部的距离
  187. let offsetTop = $('.msg-list-item.active').position().top
  188. $(".msg-list").animate({ scrollTop: offsetTop - 20}, 1)
  189. $(".msg-chat-list").animate({ scrollTop: $(".msg-chat-list")[0].scrollHeight - $('.msg-chat-list').height() + 600 }, 1)
  190. $('.msg-image').on('click', function (e) {
  191. $('.image').click();
  192. });
  193. $('.image').on('change', function (e) {
  194. let formData = new FormData()
  195. formData.append("image", $(this)[0].files[0])
  196. formData.append("workorder_id", $('input[name=workorder-id]').val())
  197. $.ajax({
  198. url: '/admin-supplier/send_image',
  199. type: 'POST',
  200. data: formData,
  201. processData: false,
  202. contentType: false,
  203. dataType: 'json',
  204. success: function(res) {
  205. let imageUrl = res.data.content
  206. let msgTime = res.data.created_at
  207. let templateHtml = $('.template-my').html()
  208. let imgDoc = '<img class="msg-content-image" onclick="viewImage(this)" src="'+imageUrl+'" alt="图片" title="图片" />'
  209. templateHtml = templateHtml.replace('#contents', imgDoc)
  210. templateHtml = templateHtml.replace('#times', msgTime)
  211. $(".msg-chat-list").append(templateHtml)
  212. $(".msg-chat-list").animate({ scrollTop: $(".msg-chat-list")[0].scrollHeight - $('.msg-chat-list').height() + 600 }, 1)
  213. },
  214. error: function (error) {
  215. console.log(error)
  216. }
  217. });
  218. });
  219. $('input[name=msg-input]').on('keyup', function (e) {
  220. if (e.keyCode == 13) {
  221. $('.msg-text').click()
  222. }
  223. });
  224. $('.msg-text').on('click', function (e) {
  225. let msgText = $('input[name=msg-input]').val()
  226. let workorderId = $('input[name=workorder-id]').val()
  227. $.ajax({
  228. url: '/admin-supplier/send_text',
  229. type: 'POST',
  230. data: {content: msgText, workorder_id: workorderId},
  231. dataType: 'json',
  232. success: function(res) {
  233. let msgText = res.data.content
  234. let msgTime = res.data.created_at
  235. let templateHtml = $('.template-my').html()
  236. templateHtml = templateHtml.replace('#contents', msgText)
  237. templateHtml = templateHtml.replace('#times', msgTime)
  238. $(".msg-chat-list").append(templateHtml)
  239. $('input[name=msg-input]').val('')
  240. $(".msg-chat-list").animate({ scrollTop: $(".msg-chat-list")[0].scrollHeight - $('.msg-chat-list').height() }, 1)
  241. },
  242. error: function (error) {
  243. console.log(error)
  244. }
  245. });
  246. });
  247. });
  248. </script>