Selaa lähdekoodia

QRcode Scanner (LIFF)

Mike 3 vuotta sitten
vanhempi
commit
20749584ab
1 muutettua tiedostoa jossa 36 lisäystä ja 36 poistoa
  1. 36 36
      ArkCard-web/collect.html

+ 36 - 36
ArkCard-web/collect.html

@@ -370,47 +370,47 @@
     <script charset="utf-8" src="https://static.line-scdn.net/liff/edge/2/sdk.js"></script>
 
 <script>
-$(document).ready(function() {
-    liff.init({
-        liffId: "1656494344-JovNdOv0"
-    })
-    .then(() => {
-        const context = liff.getContext();
-        console.log(context.contextId);
+liff.init({
+    liffId: "1656494344-JovNdOv0"
+})
+.then(() => {
+    const context = liff.getContext();
+    console.log(context.contextId);
 
-        liff.login({ redirectUri: "https://ark.cards/collect.html?"+context.contextId });  // test
+    liff.login({ redirectUri: "https://ark.cards/collect.html?"+context.contextId });  // test   
 
-        // scanCodeV2 call
-        liff.scanCodeV2().then(result => {
-            // e.g. result = { value: "Hello LIFF app!" }
-            console.log('scanCodeV2()'); // test
-        }).catch(err => {
-            console.log(err);
-        });
+    /*
+    // login
+    if (!liff.isLoggedIn()) {
+        console.log("您未登入");
+        liff.login({ redirectUri: "https://ark.cards/collect.html?U171a225ef8a06a3491f1d94310b7b265" });  // test
 
-        /*
-        // login
-        if (!liff.isLoggedIn()) {
-            console.log("您未登入");
-            liff.login({ redirectUri: "https://ark.cards/collect.html?U171a225ef8a06a3491f1d94310b7b265" });  // test
+        // // scanCodeV2 call
+        // liff.scanCodeV2().then(result => {
+        //     // e.g. result = { value: "Hello LIFF app!" }
+        //     console.log('scanCodeV2()'); // test
+        // }).catch(err => {
+        //     console.log(err);
+        // });
+    } else {
+        console.log("您已登入");
+    }
+    */
+})
+.catch((err) => {
+    console.log("初始化失敗");
+});
 
-            // // scanCodeV2 call
-            // liff.scanCodeV2().then(result => {
-            //     // e.g. result = { value: "Hello LIFF app!" }
-            //     console.log('scanCodeV2()'); // test
-            // }).catch(err => {
-            //     console.log(err);
-            // });
-        } else {
-            console.log("您已登入");
-        }
-        */
-    })
-    .catch((err) => {
-        console.log("初始化失敗");
-    });
+$(".qrcode").click(function () {
+    alert('QRCode Scanner Starting...'); // test
 
-    
+    // scanCodeV2 call
+    liff.scanCodeV2().then(result => {
+        // e.g. result = { value: "Hello LIFF app!" }
+        alert(result.value); // test
+    }).catch(err => {
+        console.log(err);
+    });
 });
 </script>
 </body>