Ver Fonte

QRcode Scanner (LIFF)

Mike há 3 anos atrás
pai
commit
2ed7507e33
1 ficheiros alterados com 32 adições e 13 exclusões
  1. 32 13
      ArkCard-web/collect.html

+ 32 - 13
ArkCard-web/collect.html

@@ -375,23 +375,42 @@ $(document).ready(function() {
         liffId: "1656494344-JovNdOv0"
     })
     .then(() => {
-        // alert('liff.init()'); // test
+        const context = liff.getContext();
+        console.log(context.contextId);
+
+        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
+
+            // // 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("初始化失敗");
     });
 
-    // login
-    if (!liff.isLoggedIn()) {
-        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);
-        // });
-    }
+    
 });
 </script>
 </body>