123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378 |
- 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"
- },
- {
- "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/q9CAJyY.jpg",
- "offsetTop": "-10px"
- }
- ],
- "paddingStart": "5px",
- "paddingEnd": "5px",
- "height": "190px"
- }
- ]
- },
- "body": {
- "type": "box",
- "layout": "vertical",
- "contents": [
- {
- "type": "text",
- "text": "曾國棟董事長從打球過程中",
- "weight": "bold",
- "size": "md",
- "align": "center",
- "wrap": true,
- "margin": "lg"
- },
- {
- "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",
- "wrap": true,
- "margin": "xl"
- },
- {
- "type": "text",
- "text": "後面卻沒有步步為營",
- "weight": "bold",
- "size": "md",
- "align": "center",
- "wrap": true,
- "margin": "sm"
- },
- {
- "type": "text",
- "text": "反而導致慘敗",
- "weight": "bold",
- "size": "md",
- "align": "center",
- "wrap": true,
- "margin": "sm"
- },
- {
- "type": "text",
- "text": "企業經營如同",
- "weight": "bold",
- "size": "md",
- "align": "center",
- "wrap": true,
- "margin": "xl"
- },
- {
- "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
- },
- {
- "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/program-packages/736f4c40-d411-4f1f-bc05-c4bcc417dc43"
- },
- "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-program-1/?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": "3 分鐘精華",
- "uri": "https://www.youtube.com/watch?v=OJmSi2vk_nI"
- },
- "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": "195px",
- "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);
- // // });
- // });
- }
|