|
@@ -0,0 +1,351 @@
|
|
|
+function getProfile() {
|
|
|
+ liff
|
|
|
+ .getProfile()
|
|
|
+ .then(profile => {
|
|
|
+ console.log(JSON.stringify(profile));
|
|
|
+ window.alert(JSON.stringify(profile));
|
|
|
+ })
|
|
|
+ .catch(e => {
|
|
|
+ console.log(e);
|
|
|
+ window.alert(e);
|
|
|
+ });
|
|
|
+}
|
|
|
+function getAccessToken() {
|
|
|
+ window.alert(liff.getAccessToken());
|
|
|
+}
|
|
|
+function getContext() {
|
|
|
+ window.alert(JSON.stringify(liff.getContext()));
|
|
|
+}
|
|
|
+
|
|
|
+function sendMessage() {
|
|
|
+ liff
|
|
|
+ .sendMessages([{ type: "text", text: "中文測試 Hello from LIFF2.0" }])
|
|
|
+ .then(() => {
|
|
|
+ window.alert("Message has been sent");
|
|
|
+ })
|
|
|
+ .catch(e => {
|
|
|
+ window.alert(e);
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+function login() {
|
|
|
+ liff.login();
|
|
|
+}
|
|
|
+
|
|
|
+function scanCode() {
|
|
|
+ liff
|
|
|
+ .scanCode()
|
|
|
+ .then(result => {
|
|
|
+ window.alert(JSON.stringify(result));
|
|
|
+ })
|
|
|
+ .catch(e => {
|
|
|
+ window.alert(e);
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+function openWindow() {
|
|
|
+ liff.openWindow({
|
|
|
+ url: "https://line.me/1657386781-XARmDogn",
|
|
|
+ external: true
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+function closeWindow() {
|
|
|
+ liff.closeWindow();
|
|
|
+}
|
|
|
+
|
|
|
+function logout() {
|
|
|
+ if (liff.isLoggedIn()) {
|
|
|
+ liff.logout();
|
|
|
+ window.alert("Successfully to Logout");
|
|
|
+ location.reload();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+// 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": "企業成長戰略課程",
|
|
|
+ "color": "#f39a00",
|
|
|
+ "align": "center",
|
|
|
+ "offsetTop": "3px",
|
|
|
+ "size": "lg",
|
|
|
+ "weight": "bold"
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "paddingAll": "15px"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "type": "box",
|
|
|
+ "layout": "vertical",
|
|
|
+ "contents": [
|
|
|
+ {
|
|
|
+ "type": "image",
|
|
|
+ "size": "full",
|
|
|
+ "margin": "none",
|
|
|
+ "url": "https://imgur.com/pfjoK8W.jpg",
|
|
|
+ "offsetTop": "-10px"
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "paddingStart": "5px",
|
|
|
+ "paddingEnd": "5px",
|
|
|
+ "height": "240px"
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ "body": {
|
|
|
+ "type": "box",
|
|
|
+ "layout": "vertical",
|
|
|
+ "contents": [
|
|
|
+ {
|
|
|
+ "type": "text",
|
|
|
+ "text": "由 MISA 企業院士及",
|
|
|
+ "weight": "bold",
|
|
|
+ "size": "md",
|
|
|
+ "align": "center",
|
|
|
+ "wrap": true,
|
|
|
+ "margin": "lg"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "type": "text",
|
|
|
+ "text": "國際級專業教練共同授課",
|
|
|
+ "weight": "bold",
|
|
|
+ "size": "md",
|
|
|
+ "align": "center",
|
|
|
+ "wrap": true,
|
|
|
+ "margin": "sm"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "type": "text",
|
|
|
+ "text": "專為 CEO / 高階主管打造",
|
|
|
+ "weight": "bold",
|
|
|
+ "size": "md",
|
|
|
+ "align": "center",
|
|
|
+ "wrap": true,
|
|
|
+ "margin": "sm"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "type": "text",
|
|
|
+ "text": " 「企業成長戰略課程」",
|
|
|
+ "weight": "bold",
|
|
|
+ "size": "md",
|
|
|
+ "align": "center",
|
|
|
+ "wrap": true,
|
|
|
+ "margin": "sm"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "type": "separator",
|
|
|
+ "margin": "xl"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "type": "text",
|
|
|
+ "text": "透過企經班的實戰實操課程",
|
|
|
+ "weight": "bold",
|
|
|
+ "size": "md",
|
|
|
+ "align": "center",
|
|
|
+ "margin": "xl",
|
|
|
+ "wrap": true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "type": "text",
|
|
|
+ "text": "推動組織變革、",
|
|
|
+ "weight": "bold",
|
|
|
+ "size": "md",
|
|
|
+ "align": "center",
|
|
|
+ "margin": "sm",
|
|
|
+ "wrap": true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "type": "text",
|
|
|
+ "text": "執行企業成長戰略 / 戰術!",
|
|
|
+ "weight": "bold",
|
|
|
+ "size": "md",
|
|
|
+ "align": "center",
|
|
|
+ "margin": "sm",
|
|
|
+ "wrap": true
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "offsetTop": "-20px"
|
|
|
+ },
|
|
|
+ "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://www.misaglobal.org/event"
|
|
|
+ },
|
|
|
+ "color": "#ffffff"
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "backgroundColor": "#f39a00",
|
|
|
+ "cornerRadius": "md"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "type": "box",
|
|
|
+ "layout": "vertical",
|
|
|
+ "contents": [
|
|
|
+ {
|
|
|
+ "type": "button",
|
|
|
+ "style": "link",
|
|
|
+ "height": "sm",
|
|
|
+ "action": {
|
|
|
+ "type": "uri",
|
|
|
+ "label": "活動分享",
|
|
|
+ "uri": "https://liff.googo.org/misa-course-3/?openInAppBrowser=1&openExternalBrowser=1"
|
|
|
+ },
|
|
|
+ "color": "#f39a00"
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "cornerRadius": "md",
|
|
|
+ "margin": "lg",
|
|
|
+ "borderColor": "#f39a00",
|
|
|
+ "borderWidth": "normal"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "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": "135px"
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "flex": 0,
|
|
|
+ "height": "200px",
|
|
|
+ "offsetTop": "-10px"
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ 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)
|
|
|
+ })
|
|
|
+
|
|
|
+ // 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([
|
|
|
+ // {
|
|
|
+ // 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);
|
|
|
+ // // });
|
|
|
+
|
|
|
+ // });
|
|
|
+}
|