Browse Source

Merge branch 'user/fengchang/tryintegragefbmessager' of fxie/hichina2023 into master

fxie 1 year ago
parent
commit
83481508fb
1 changed files with 37 additions and 0 deletions
  1. 37 0
      hichina-main-front-mobile-first/src/pages/ContactPage.vue

+ 37 - 0
hichina-main-front-mobile-first/src/pages/ContactPage.vue

@@ -26,11 +26,48 @@
         />
       </div>
     </div>
+    <!-- Messenger Chat Plugin Code -->
+    <div id="fb-root"></div>
+
+    <!-- Your Chat Plugin code -->
+    <div id="fb-customer-chat" class="fb-customerchat"></div>
   </q-page>
 </template>
 
 <script>
 export default {
   name: "ContactPage",
+  setup() {
+    function setupChat() {
+      var chatbox = document.getElementById("fb-customer-chat");
+      chatbox.setAttribute("page_id", "1534271790187013");
+      chatbox.setAttribute("attribution", "biz_inbox");
+    }
+    function initFacebookSDK() {
+      window.fbAsyncInit = function () {
+        FB.init({
+          xfbml: true,
+          version: "v17.0",
+        });
+      };
+
+      (function (d, s, id) {
+        var js,
+          fjs = d.getElementsByTagName(s)[0];
+        if (d.getElementById(id)) return;
+        js = d.createElement(s);
+        js.id = id;
+        js.src = "https://connect.facebook.net/en_US/sdk/xfbml.customerchat.js";
+        fjs.parentNode.insertBefore(js, fjs);
+      })(document, "script", "facebook-jssdk");
+    }
+    onMounted(() => {
+      setupChat();
+    });
+
+    onBeforeMount(() => {
+      initFacebookSDK();
+    });
+  },
 };
 </script>