livechat.html 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>在线客服</title>
  7. <!-- uni webview SDK -->
  8. <script src="./js/uni.webview.1.5.8.js"></script>
  9. <style>
  10. * {
  11. margin: 0;
  12. padding: 0;
  13. box-sizing: border-box;
  14. font-family: system-ui, sans-serif;
  15. }
  16. .container {
  17. width: 100%;
  18. min-height: 100vh;
  19. background-color: #fff;
  20. }
  21. /* ========================
  22. 四色旋转 Loading(和PDF同款)
  23. ======================== */
  24. .loading-container {
  25. position: fixed;
  26. top: 0;
  27. left: 0;
  28. width: 100vw;
  29. height: 100vh;
  30. background: #fff;
  31. display: flex;
  32. align-items: center;
  33. justify-content: center;
  34. z-index: 99999;
  35. transition: opacity 0.3s ease;
  36. }
  37. .loading2 {
  38. width: 30px;
  39. height: 30px;
  40. position: relative;
  41. transform: rotate(10deg);
  42. }
  43. .loading2 .shape {
  44. border-radius: 5px;
  45. }
  46. .shape {
  47. position: absolute;
  48. width: 10px;
  49. height: 10px;
  50. border-radius: 1px;
  51. }
  52. .shape.shape1 {
  53. left: 0;
  54. background-color: #1890FF;
  55. }
  56. .shape.shape2 {
  57. right: 0;
  58. background-color: #91CB74;
  59. }
  60. .shape.shape3 {
  61. bottom: 0;
  62. background-color: #FAC858;
  63. }
  64. .shape.shape4 {
  65. bottom: 0;
  66. right: 0;
  67. background-color: #EE6666;
  68. }
  69. /* 动画 */
  70. .loading2 {
  71. animation: rotation 1s infinite linear;
  72. }
  73. .loading2 .shape1 {
  74. animation: animation2shape1 0.5s ease 0s infinite alternate;
  75. }
  76. .loading2 .shape2 {
  77. animation: animation2shape2 0.5s ease 0s infinite alternate;
  78. }
  79. .loading2 .shape3 {
  80. animation: animation2shape3 0.5s ease 0s infinite alternate;
  81. }
  82. .loading2 .shape4 {
  83. animation: animation2shape4 0.5s ease 0s infinite alternate;
  84. }
  85. @keyframes rotation {
  86. 0% {
  87. transform: rotate(0deg);
  88. }
  89. 100% {
  90. transform: rotate(360deg);
  91. }
  92. }
  93. @keyframes animation2shape1 {
  94. from {
  95. transform: translate(0, 0);
  96. }
  97. to {
  98. transform: translate(20px, 20px);
  99. }
  100. }
  101. @keyframes animation2shape2 {
  102. from {
  103. transform: translate(0, 0);
  104. }
  105. to {
  106. transform: translate(-20px, 20px);
  107. }
  108. }
  109. @keyframes animation2shape3 {
  110. from {
  111. transform: translate(0, 0);
  112. }
  113. to {
  114. transform: translate(20px, -20px);
  115. }
  116. }
  117. @keyframes animation2shape4 {
  118. from {
  119. transform: translate(0, 0);
  120. }
  121. to {
  122. transform: translate(-20px, -20px);
  123. }
  124. }
  125. </style>
  126. </head>
  127. <body>
  128. <!-- 全屏 Loading -->
  129. <div class="loading-container" id="loading">
  130. <div class="loading2">
  131. <div class="shape shape1"></div>
  132. <div class="shape shape2"></div>
  133. <div class="shape shape3"></div>
  134. <div class="shape shape4"></div>
  135. </div>
  136. </div>
  137. <div class="container"></div>
  138. <script>
  139. window.__lc = window.__lc || {};
  140. window.__lc.license = 18945964;
  141. // 隐藏 loading
  142. function hideLoading() {
  143. const el = document.getElementById('loading');
  144. if (el) {
  145. el.style.opacity = '0';
  146. setTimeout(() => {
  147. el.style.display = 'none';
  148. }, 300);
  149. }
  150. }
  151. (function (n, t, c) {
  152. function i(n) { return e._h ? e._h.apply(null, n) : e._q.push(n) }
  153. var e = {
  154. _q: [], _h: null, _v: "2.0",
  155. on: function () { i(["on", c.call(arguments)]) },
  156. once: function () { i(["once", c.call(arguments)]) },
  157. off: function () { i(["off", c.call(arguments)]) },
  158. get: function () {
  159. if (!e._h) throw new Error("[LiveChatWidget] You can't use getters before load.");
  160. return i(["get", c.call(arguments)])
  161. },
  162. call: function () { i(["call", c.call(arguments)]) },
  163. init: function () {
  164. var n = t.createElement("script");
  165. n.async = !0;
  166. n.type = "text/javascript";
  167. n.src = "https://cdn.livechatinc.com/tracking.js";
  168. t.head.appendChild(n);
  169. }
  170. };
  171. !n.__lc.asyncInit && e.init();
  172. n.LiveChatWidget = n.LiveChatWidget || e;
  173. // 等待 SDK 加载完成 → 打开客服并隐藏 loading
  174. setTimeout(() => {
  175. LiveChatWidget.call('maximize');
  176. }, 300);
  177. // 关闭客服 → 返回上一页
  178. LiveChatWidget.on('visibility_changed', (data) => {
  179. if (data.visibility === 'maximized') {
  180. hideLoading();
  181. }
  182. if (data.visibility === 'closed' || data.visibility === 'minimized') {
  183. try {
  184. uni.navigateBack();
  185. } catch (e) {
  186. history.back();
  187. }
  188. }
  189. });
  190. })(window, document, [].slice);
  191. </script>
  192. </body>
  193. </html>