zopim.html 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport">
  7. <!-- Google Fonts -->
  8. <script type="text/javascript">
  9. window.__lc = window.__lc || {};
  10. window.__lc.license = 18945964;
  11. (function (n, t, c) {
  12. function i(n) {
  13. return e._h ? e._h.apply(null, n) : e._q.push(n);
  14. }
  15. var e = {
  16. _q: [],
  17. _h: null,
  18. _v: "2.0",
  19. on: function () {
  20. i(["on", c.call(arguments)]);
  21. },
  22. once: function () {
  23. i(["once", c.call(arguments)]);
  24. },
  25. off: function () {
  26. i(["off", c.call(arguments)]);
  27. },
  28. get: function () {
  29. if (!e._h)
  30. throw new Error(
  31. "[LiveChatWidget] You can't use getters before load."
  32. );
  33. return i(["get", c.call(arguments)]);
  34. },
  35. call: function () {
  36. i(["call", c.call(arguments)]);
  37. },
  38. init: function () {
  39. var n = t.createElement("script");
  40. (n.async = !0),
  41. (n.type = "text/javascript"),
  42. (n.src = "https://cdn.livechatinc.com/tracking.js"),
  43. t.head.appendChild(n);
  44. },
  45. };
  46. !n.__lc.asyncInit && e.init(),
  47. (n.LiveChatWidget = n.LiveChatWidget || e);
  48. })(window, document, [].slice);
  49. </script>
  50. <noscript>
  51. <a href="https://www.livechat.com/chat-with/18945964/" rel="nofollow">Chat with us</a>, powered by
  52. <!-- <a
  53. href="https://www.livechat.com/?welcome"
  54. rel="noopener nofollow"
  55. target="_blank"
  56. >LiveChat</a
  57. > -->
  58. </noscript>
  59. <style>
  60. @media (max-width: 760px) {
  61. #chat-widget-container {
  62. left: 0 !important;
  63. bottom: 0px !important;
  64. }
  65. }
  66. </style>
  67. <title>CWGMarkets</title>
  68. </head>
  69. <body>
  70. <script src="assets/vendor/jquery/jquery.min.js"></script>
  71. <script>
  72. //客服
  73. var $zopim = null
  74. let rep = setInterval(aTimer, 1000)
  75. function aTimer() {
  76. if ($zopim) {
  77. $zopim(function () {
  78. let lang = window.localStorage.getItem("lang")
  79. if (['cn', 'zhHant'].indexOf(localStorage.getItem('lang')) != -1) {
  80. $zopim.livechat.setLanguage('zh_CN');
  81. } else {
  82. $zopim.livechat.setLanguage('en');
  83. }
  84. window.clearInterval(rep)
  85. // $("#launcher") && $("#launcher").css("display", "none")
  86. });
  87. if ($("body").width() > 768) {
  88. $("#launcher") && $("#launcher").css("bottom", $("#footer-body").height() + "px")
  89. $("#webWidget") && $("#webWidget").css("bottom", $("#footer-body").height() + "px")
  90. }
  91. }
  92. }
  93. </script>
  94. <script>
  95. function adjustChatWidgetContainerHeight() {
  96. const $chatWidget = $('#chat-widget');
  97. const $chatWidgetContainer = $('#chat-widget-container');
  98. const href = window.location.href;
  99. const queryString = href.includes('?') ? href.split('?')[1] : '';
  100. const urlParams = new URLSearchParams(queryString);
  101. const statusBarHeight = urlParams.get('statusBarHeight') || 0;
  102. if ($chatWidget.length && $chatWidgetContainer.length) {
  103. const isHidden = $chatWidget.css('display') === 'none';
  104. window.parent.postMessage({
  105. type: 'chatWidgetStatus',
  106. isHidden: isHidden
  107. }, '*');
  108. $chatWidget.css({
  109. 'padding-top': statusBarHeight + 'px',
  110. 'box-sizing': 'border-box',
  111. 'background-color': 'rgb(248, 248, 248)'
  112. });
  113. const $dragHandle = $('#chat-drag-handle');
  114. if (isHidden) {
  115. if ($dragHandle.length) {
  116. $dragHandle.show();
  117. }
  118. } else {
  119. if ($dragHandle.length) {
  120. $dragHandle.hide();
  121. }
  122. }
  123. var newRule = ''
  124. if (isHidden) {
  125. newRule = `
  126. @media (max-width: 760px) {
  127. #chat-widget-container {
  128. left: 0 !important;
  129. height: 100px !important;
  130. width: 100px !important;
  131. bottom: 0px !important;
  132. }
  133. }
  134. `;
  135. } else {
  136. newRule = `
  137. @media (max-width: 760px) {
  138. #chat-widget-container {
  139. left: 0 !important;
  140. height: 100% !important;
  141. width: 100% !important;
  142. bottom: 0px !important;
  143. }
  144. }
  145. `;
  146. }
  147. const styleTag = document.createElement('style');
  148. styleTag.type = 'text/css';
  149. styleTag.appendChild(document.createTextNode(newRule));
  150. document.head.appendChild(styleTag);
  151. }
  152. }
  153. function waitForChatWidget() {
  154. const $chatWidget = $('#chat-widget');
  155. if ($chatWidget.length) {
  156. const observer = new MutationObserver(adjustChatWidgetContainerHeight);
  157. observer.observe($chatWidget[0], {
  158. attributes: true,
  159. attributeFilter: ['style']
  160. });
  161. adjustChatWidgetContainerHeight();
  162. } else {
  163. setTimeout(waitForChatWidget, 500);
  164. }
  165. }
  166. $(document).ready(() => {
  167. waitForChatWidget();
  168. // 检查 chat-widget-minimized 是否存在,并通知父页面
  169. function notifyParentChatMinimizedReady() {
  170. const minimized = document.getElementById('chat-widget-minimized') || document.querySelector('.chat-widget-minimized');
  171. if (minimized) {
  172. window.parent.postMessage({ type: 'chatWidgetMinimizedReady' }, '*');
  173. } else {
  174. setTimeout(notifyParentChatMinimizedReady, 300);
  175. }
  176. }
  177. notifyParentChatMinimizedReady();
  178. });
  179. window.addEventListener('message', function (event) {
  180. if (event.data && event.data.type === 'openChat') {
  181. const chatWidget = document.getElementById('chat-widget-minimized');
  182. const iframeDoc = chatWidget.contentDocument || chatWidget.contentWindow.document;
  183. const button = iframeDoc.querySelector('button');
  184. if (button) {
  185. button.click();
  186. }
  187. }
  188. });
  189. </script>
  190. </body>
  191. </html>