SyuanYu 2 år sedan
förälder
incheckning
306302a27b
1 ändrade filer med 258 tillägg och 245 borttagningar
  1. 258 245
      misa-liff/js/liff-functions.js

+ 258 - 245
misa-liff/js/liff-functions.js

@@ -63,264 +63,277 @@ function logout() {
 }
 
 
-function createFlexMessageData() {
-  var flex = {
-    "type": "flex",
-    "altText": redistitle,
-    "contents": redisdata,
-  };
-
-  return flex;
-}
-
-// var _title = "MISA 向您分享了最新消息!";
-
 // function createFlexMessageData() {
-//   var myFlexContent = {
-//     "type": "bubble",
-//     "hero": {
-//       "type": "box",
-//       "layout": "vertical",
-//       "contents": [
-//         {
-//           "type": "box",
-//           "layout": "vertical",
-//           "contents": [
-//             {
-//               "type": "text",
-//               "text": "MISA 沙龍小聚",
-//               "color": "#ffffff",
-//               "align": "center",
-//               "offsetTop": "3px",
-//               "size": "lg",
-//               "weight": "bold"
-//             }
-//           ],
-//           "backgroundColor": "#f39a00",
-//           "paddingAll": "15px"
-//         },
-//         {
-//           "type": "box",
-//           "layout": "vertical",
-//           "contents": [
-//             {
-//               "type": "image",
-//               "size": "full",
-//               "margin": "none",
-//               "url": "https://upload.cc/i1/2022/12/02/TrCvmp.jpg"
-//             }
-//           ],
-//           "paddingStart": "5px",
-//           "paddingEnd": "5px",
-//           "height": "220px",
-//           "paddingTop": "10px"
-//         }
-//       ]
-//     },
-//     "body": {
-//       "type": "box",
-//       "layout": "vertical",
-//       "contents": [
-//         {
-//           "type": "text",
-//           "text": "2022 年即將過去,",
-//           "weight": "bold",
-//           "size": "sm",
-//           "align": "center"
-//         },
-//         {
-//           "type": "text",
-//           "text": "MISA 將在 12 月份舉辦兩場沙龍小聚",
-//           "weight": "bold",
-//           "size": "sm",
-//           "align": "center",
-//           "wrap": true,
-//           "margin": "sm"
-//         },
-//         {
-//           "type": "text",
-//           "text": "歡迎各位 MISA 校友前來共襄盛舉!",
-//           "weight": "bold",
-//           "size": "sm",
-//           "align": "center",
-//           "margin": "sm"
-//         },
-//         {
-//           "type": "separator",
-//           "margin": "md"
-//         },
-//         {
-//           "type": "text",
-//           "text": "本次 12/21 的沙龍小聚由",
-//           "weight": "bold",
-//           "size": "sm",
-//           "align": "center",
-//           "margin": "md"
-//         },
-//         {
-//           "type": "text",
-//           "text": "「數位行銷賈伯斯」 之稱的王偉羽校友",
-//           "weight": "bold",
-//           "size": "sm",
-//           "align": "center",
-//           "margin": "sm"
-//         },
-//         {
-//           "type": "text",
-//           "text": "以及邀請商周 CEO 學院",
-//           "weight": "bold",
-//           "size": "sm",
-//           "align": "center",
-//           "margin": "sm"
-//         },
-//         {
-//           "type": "text",
-//           "text": "「最高滿意度講師」 吳兆田博士",
-//           "weight": "bold",
-//           "size": "sm",
-//           "align": "center",
-//           "margin": "sm"
-//         },
-//         {
-//           "type": "text",
-//           "text": "透過互動體驗帶領企業主利用策略、工具",
-//           "weight": "bold",
-//           "size": "sm",
-//           "align": "center",
-//           "wrap": true,
-//           "margin": "sm"
-//         },
-//         {
-//           "type": "text",
-//           "text": "應對現代「人才荒」的挑戰",
-//           "weight": "bold",
-//           "size": "sm",
-//           "align": "center",
-//           "margin": "sm"
-//         }
-//       ]
-//     },
-//     "footer": {
-//       "type": "box",
-//       "layout": "vertical",
-//       "spacing": "sm",
-//       "contents": [
-//         {
-//           "type": "box",
-//           "layout": "vertical",
-//           "contents": [
-//             {
-//               "type": "button",
-//               "style": "link",
-//               "height": "sm",
-//               "action": {
-//                 "type": "uri",
-//                 "label": "馬上報名",
-//                 "uri": "https://pse.is/4k9ysk"
-//               },
-//               "color": "#ffffff"
-//             }
-//           ],
-//           "backgroundColor": "#f39a00",
-//           "cornerRadius": "md"
-//         },
-//         {
-//           "type": "box",
-//           "layout": "vertical",
-//           "contents": [
-//             {
-//               "type": "button",
-//               "style": "link",
-//               "height": "sm",
-//               "action": {
-//                 "type": "uri",
-//                 "label": "官方網站",
-//                 "uri": "https://www.misaglobal.org/"
-//               },
-//               "color": "#f39a00"
-//             }
-//           ],
-//           "cornerRadius": "md",
-//           "margin": "lg",
-//           "borderColor": "#f39a00",
-//           "borderWidth": "normal"
-//         },
-//         {
-//           "type": "box",
-//           "layout": "vertical",
-//           "contents": [
-//             {
-//               "type": "image",
-//               "url": "https://static.kolable.com/images/misa/logo.png/120?v=1641520480847"
-//             }
-//           ],
-//           "margin": "none",
-//           "position": "absolute",
-//           "offsetStart": "108px",
-//           "offsetTop": "77px"
-//         }
-//       ],
-//       "flex": 0,
-//       "height": "150px"
-//     }
-//   };
-
 //   var flex = {
 //     "type": "flex",
-//     "altText": _title,
-//     "contents": myFlexContent,
+//     "altText": redistitle,
+//     "contents": redisdata,
 //   };
 
 //   return flex;
 // }
 
+var _title = "MISA 向您分享了最新消息!";
+
+function createFlexMessageData() {
+  var myFlexContent = {
+    "type": "bubble",
+    "hero": {
+      "type": "box",
+      "layout": "vertical",
+      "contents": [
+        {
+          "type": "box",
+          "layout": "vertical",
+          "contents": [
+            {
+              "type": "text",
+              "text": "MISA 沙龍小聚",
+              "color": "#ffffff",
+              "align": "center",
+              "offsetTop": "3px",
+              "size": "lg",
+              "weight": "bold"
+            }
+          ],
+          "backgroundColor": "#f39a00",
+          "paddingAll": "15px"
+        },
+        {
+          "type": "box",
+          "layout": "vertical",
+          "contents": [
+            {
+              "type": "image",
+              "size": "full",
+              "margin": "none",
+              "url": "https://upload.cc/i1/2022/12/02/TrCvmp.jpg"
+            }
+          ],
+          "paddingStart": "5px",
+          "paddingEnd": "5px",
+          "height": "220px",
+          "paddingTop": "10px"
+        }
+      ]
+    },
+    "body": {
+      "type": "box",
+      "layout": "vertical",
+      "contents": [
+        {
+          "type": "text",
+          "text": "2022 年即將過去,",
+          "weight": "bold",
+          "size": "sm",
+          "align": "center"
+        },
+        {
+          "type": "text",
+          "text": "MISA 將在 12 月份舉辦兩場沙龍小聚",
+          "weight": "bold",
+          "size": "sm",
+          "align": "center",
+          "wrap": true,
+          "margin": "sm"
+        },
+        {
+          "type": "text",
+          "text": "歡迎各位 MISA 校友前來共襄盛舉!",
+          "weight": "bold",
+          "size": "sm",
+          "align": "center",
+          "margin": "sm"
+        },
+        {
+          "type": "separator",
+          "margin": "md"
+        },
+        {
+          "type": "text",
+          "text": "本次 12/21 的沙龍小聚由",
+          "weight": "bold",
+          "size": "sm",
+          "align": "center",
+          "margin": "md"
+        },
+        {
+          "type": "text",
+          "text": "「數位行銷賈伯斯」 之稱的王偉羽校友",
+          "weight": "bold",
+          "size": "sm",
+          "align": "center",
+          "margin": "sm"
+        },
+        {
+          "type": "text",
+          "text": "以及邀請商周 CEO 學院",
+          "weight": "bold",
+          "size": "sm",
+          "align": "center",
+          "margin": "sm"
+        },
+        {
+          "type": "text",
+          "text": "「最高滿意度講師」 吳兆田博士",
+          "weight": "bold",
+          "size": "sm",
+          "align": "center",
+          "margin": "sm"
+        },
+        {
+          "type": "text",
+          "text": "透過互動體驗帶領企業主利用策略、工具",
+          "weight": "bold",
+          "size": "sm",
+          "align": "center",
+          "wrap": true,
+          "margin": "sm"
+        },
+        {
+          "type": "text",
+          "text": "應對現代「人才荒」的挑戰",
+          "weight": "bold",
+          "size": "sm",
+          "align": "center",
+          "margin": "sm"
+        }
+      ]
+    },
+    "footer": {
+      "type": "box",
+      "layout": "vertical",
+      "spacing": "sm",
+      "contents": [
+        {
+          "type": "box",
+          "layout": "vertical",
+          "contents": [
+            {
+              "type": "button",
+              "style": "link",
+              "height": "sm",
+              "action": {
+                "type": "uri",
+                "label": "馬上報名",
+                "uri": "https://pse.is/4k9ysk"
+              },
+              "color": "#ffffff"
+            }
+          ],
+          "backgroundColor": "#f39a00",
+          "cornerRadius": "md"
+        },
+        {
+          "type": "box",
+          "layout": "vertical",
+          "contents": [
+            {
+              "type": "button",
+              "style": "link",
+              "height": "sm",
+              "action": {
+                "type": "uri",
+                "label": "官方網站",
+                "uri": "https://www.misaglobal.org/"
+              },
+              "color": "#f39a00"
+            }
+          ],
+          "cornerRadius": "md",
+          "margin": "lg",
+          "borderColor": "#f39a00",
+          "borderWidth": "normal"
+        },
+        {
+          "type": "box",
+          "layout": "vertical",
+          "contents": [
+            {
+              "type": "image",
+              "url": "https://static.kolable.com/images/misa/logo.png/120?v=1641520480847"
+            }
+          ],
+          "margin": "none",
+          "position": "absolute",
+          "offsetStart": "108px",
+          "offsetTop": "77px"
+        }
+      ],
+      "flex": 0,
+      "height": "150px"
+    }
+  };
+
+  var flex = {
+    "type": "flex",
+    "altText": _title,
+    "contents": myFlexContent,
+  };
+
+  return flex;
+}
+
 var redisdata = '';
 
 function shareTargetPicker() {
 
-  // liff.shareTargetPicker([
-  //   createFlexMessageData()
-  // ])
-  //   .then(function (res) {
-  //     if (res) {
-  //       // succeeded in sending a message through TargetPicker
-  //       console.log(`[${res.status}] Message sent!`)
-  //     } else {
-  //       const [majorVer, minorVer] = (liff.getLineVersion() || "").split('.');
-  //       if (parseInt(majorVer) == 10 && parseInt(minorVer) < 11) {
-  //         // LINE 10.3.0 - 10.10.0
-  //         // Old LINE will access here regardless of user's action
-  //         console.log('TargetPicker was opened at least. Whether succeeded to send message is unclear')
-  //       } else {
-  //         // LINE 10.11.0 -
-  //         // sending message canceled
-  //         console.log('TargetPicker was closed!')
-  //       }
-  //     }
-  //   }).catch(function (error) {
-  //     // something went wrong before sending a message
-  //     console.log('something wrong happen', error)
-  //   })
+  liff.shareTargetPicker([
+    createFlexMessageData()
+  ])
+    .then(function (res) {
+      if (res) {
+        // succeeded in sending a message through TargetPicker
+        console.log(`[${res.status}] Message sent!`)
+      } else {
+        const [majorVer, minorVer] = (liff.getLineVersion() || "").split('.');
+        if (parseInt(majorVer) == 10 && parseInt(minorVer) < 11) {
+          // LINE 10.3.0 - 10.10.0
+          // Old LINE will access here regardless of user's action
+          console.log('TargetPicker was opened at least. Whether succeeded to send message is unclear')
+        } else {
+          // LINE 10.11.0 -
+          // sending message canceled
+          console.log('TargetPicker was closed!')
+        }
+      }
+    }).catch(function (error) {
+      // something went wrong before sending a message
+      console.log('something wrong happen', error)
+    })
 
-  const url = 'https://liff.googo.org:9898/misa-liff'
-  axios
-    .get(url)
-    .then(({data}) => {
-      redisdata=data.data;
-      redistitle=data.title;
-      console.log(redistitle);
-      console.log(redisdata);
+  // const url = 'https://liff.googo.org:9898/misa-liff'
+  // axios
+  //   .get(url)
+  //   .then(({data}) => {
+  //     redisdata=data.data;
+  //     redistitle=data.title;
+  //     console.log(redistitle);
+  //     console.log(redisdata);
 
-      liff
-      .shareTargetPicker([
-        createFlexMessageData()      
-      ])
-      .then(() => {
-        alert("Shared to the friend(s) you picked");
-      })
-      .catch(function(res) {
-        alert(res);
-      });
+  //     liff.shareTargetPicker([
+  //       {
+  //         type: "text",
+  //         text: "Test!"
+  //       }
+  //     ])
+  //       .then(
+  //         console.log("ShareTargetPicker was launched")
+  //       ).catch(function (res) {
+  //         alert(res);
+  //         console.log("Failed to launch ShareTargetPicker", res)
+  //       })
 
-    });
+  //     // liff
+  //     // .shareTargetPicker([
+  //     //   createFlexMessageData()      
+  //     // ])
+  //     // .then(() => {
+  //     //   alert("Shared to the friend(s) you picked");
+  //     // })
+  //     // .catch(function(res) {
+  //     //   alert(res);
+  //     // });
+
+  //   });
 }