123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- // const liffId = "1657279859-Nz2nKkQA";
- 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() {
- console.log('login');
- // liff.login();
- liff.login({
- // 使用者登入後要去到哪個頁面
- redirectUri: 'https://liff.googo.org/liff2-taroboba-yuan/'
- });
- // (async () => {
- // await liff.init({ liffId: liffId })
- // if (new URL(window.location).searchParams.get('liff.state')) return
- // const liffLoginRedirect = sessionStorage.getItem('liffLoginRedirect')
- // if (_.isString(liffLoginRedirect)) {
- // sessionStorage.removeItem('liffLoginRedirect')
- // location.href = liffLoginRedirect
- // console.log(liffLoginRedirect)
- // }
- // })()
- }
- function scanCode() {
- liff
- .scanCode()
- .then(result => {
- window.alert(JSON.stringify(result));
- })
- .catch(e => {
- window.alert(e);
- });
- }
- function openWindow() {
- liff.openWindow({
- url: "https://sirateek.me",
- 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 redisdata = '';
- function shareTargetPicker() {
- const url = 'https://liff.googo.org:9898/liff2-taroboba-yuan'
- axios
- .get(url)
- .then(({ data }) => {
- console.log('data', 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);
- });
- });
- }
- (function test() {
- setTimeout(() => {
- liff.isLoggedIn();
- console.log('123');
- }, 3000);
- })();
|