[add] 登入後跳轉到一樣參數的分享

This commit is contained in:
建喵 2022-12-29 10:53:27 +08:00
parent 81d86648db
commit f6b10993cc
2 changed files with 202 additions and 19 deletions

View File

@ -1,5 +1,6 @@
<head> <head>
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>JianMiau - LIFF</title> <title>JianMiau - LIFF</title>
<link rel="stylesheet" href="style.css"> <link rel="stylesheet" href="style.css">
</head> </head>
@ -27,5 +28,5 @@
style="color: #3f3f3f;"><i><a href="https://ari-yk.github.io/" style="color: #3f3f3f; text-decoration: none;">Ari.</a> &copy; 2019</i></code> style="color: #3f3f3f;"><i><a href="https://ari-yk.github.io/" style="color: #3f3f3f; text-decoration: none;">Ari.</a> &copy; 2019</i></code>
</h3> </h3>
</center> --> </center> -->
<script src="liff-starter.js"></script> <script type="text/javascript" language="javascript" src="liff-starter.js" charset="utf-8"></script>
</body> </body>

View File

@ -5,7 +5,7 @@ window.onload = function (_0xe315c8) {
}) })
.then(() => { .then(() => {
if (!liff.isLoggedIn()) { if (!liff.isLoggedIn()) {
liff.login(); liff.login({ redirectUri: location.href });
} else { } else {
getP(); getP();
} }
@ -55,12 +55,16 @@ function getP() {
sendMessages(data); sendMessages(data);
}); });
} else { } else {
document.body.innerHTML = "";
makeText(); makeText();
makeImage(); makeImage();
makeVideo(); makeVideo();
makeAudio(); makeAudio();
makeSticker(); makeSticker();
meProfile(); meProfile();
// makeTest();
// makeDouDou();
makeBW();
} }
} }
function getParameterByName(stringParam, window_href) { function getParameterByName(stringParam, window_href) {
@ -137,6 +141,7 @@ function makeSticker() {
var stk = getParameterByName("stk"); var stk = getParameterByName("stk");
var sid = getParameterByName("sid"); var sid = getParameterByName("sid");
var pkg = getParameterByName("pkg"); var pkg = getParameterByName("pkg");
var size = getParameterByName("size") ?? "mega";
var pngtype = ""; var pngtype = "";
if (stk === "anim") { if (stk === "anim") {
pngtype = "/IOS/sticker_animation@2x.png"; pngtype = "/IOS/sticker_animation@2x.png";
@ -144,28 +149,94 @@ function makeSticker() {
pngtype = "/IOS/sticker@2x.png"; pngtype = "/IOS/sticker@2x.png";
} }
const data = [{ const data1 = [{
"type": "template", "type": "flex",
"altText": "Sticker", "altText": "Sticker",
"template": { "contents":
"type": "image_carousel", {
"columns": [{ "type": "carousel",
"imageUrl": "https://stickershop.line-scdn.net/stickershop/v1/sticker/" + sid + pngtype, "contents": [
"action": { {
"type": "uri", "type": "bubble",
"uri": "line://shop/sticker/detail/" + pkg "size": size,
"body": {
"type": "box",
"layout": "vertical",
"contents": [
{
"type": "image",
"url": "https://stickershop.line-scdn.net/stickershop/v1/sticker/85913166/IOS/sticker_animation@2x.png",
"size": "full",
"aspectMode": "cover",
"animated": true,
"backgroundColor": "#FFFFFF00"
}
],
"paddingAll": "none"
},
"action": {
"type": "uri",
"label": "action",
"uri": "https://line.me/S/sticker/12378"
}
} }
}] ]
} }
}]; }];
const data = [{
"type": "flex",
"altText": "Sticker",
"contents":
{
"type": "bubble",
"size": size,
"body": {
"type": "box",
"layout": "vertical",
"contents": [
{
"type": "image",
"url": "https://stickershop.line-scdn.net/stickershop/v1/sticker/" + sid + pngtype,
"size": "full",
"aspectMode": "cover",
"animated": true,
"backgroundColor": "#FFFFFF00"
}
],
"paddingAll": "none"
},
"action": {
"type": "uri",
"label": "action",
"uri": "https://line.me/S/sticker/" + pkg
}
}
}];
// const data = [{
// "type": "template",
// "altText": "Sticker",
// "template": {
// "type": "image_carousel",
// "columns": [{
// "imageUrl": "https://stickershop.line-scdn.net/stickershop/v1/sticker/" + sid + pngtype,
// "action": {
// "type": "uri",
// // "uri": "line://shop/sticker/detail/" + pkg
// "uri": "https://line.me/S/sticker/" + pkg
// }
// }]
// }
// }];
sendMessages(data); sendMessages(data);
} }
} }
function meProfile() { function meProfile() {
var type = getParameterByName("type"); var type = getParameterByName("type");
liff.getProfile().then(function (data) { liff.getProfile().then(function (profileData) {
var statusMessage = data.statusMessage; var statusMessage = profileData.statusMessage;
if (statusMessage == null) { if (statusMessage == null) {
var statusMessage = ""; var statusMessage = "";
} }
@ -175,13 +246,13 @@ function meProfile() {
if (type === "profile") { if (type === "profile") {
const data = [{ const data = [{
"type": "template", "type": "template",
"altText": "Profile " + data.displayName, "altText": "Profile " + profileData.displayName,
"template": { "template": {
"type": "buttons", "type": "buttons",
"thumbnailImageUrl": data.pictureUrl, "thumbnailImageUrl": profileData.pictureUrl,
"imageAspectRatio": "square", "imageAspectRatio": "square",
"imageSize": "cover", "imageSize": "cover",
"title": data.displayName, "title": profileData.displayName,
"text": statusMessage, "text": statusMessage,
"actions": [{ "actions": [{
"type": "uri", "type": "uri",
@ -196,6 +267,119 @@ function meProfile() {
}); });
} }
function makeTest() {
var type = getParameterByName("type");
if (type === "test") {
const data = [{
"type": "flex",
"altText": "ㄟ, 我跟你說件事",
"contents":
{
"type": "bubble",
"size": "mega",
"body": {
"type": "box",
"layout": "vertical",
"contents": [
{
"type": "image",
"url": "https://i.imgur.com/BNF0CiC.png",
"size": "full",
"aspectRatio": "20:13",
"aspectMode": "cover",
"animated": false,
"backgroundColor": "#FFFFFF00"
}
],
"paddingAll": "none"
},
"action": {
"type": "uri",
"label": "action",
"uri": "https://i.imgur.com/BNF0CiC.png"
}
}
}];
sendMessages(data);
}
}
function makeDouDou() {
var type = getParameterByName("type");
if (type === "豆豆") {
const data = [{
"type": "flex",
"altText": "ㄟ, 我跟你說件事",
"contents":
{
"type": "bubble",
"size": "mega",
"body": {
"type": "box",
"layout": "vertical",
"contents": [
{
"type": "image",
"url": "https://i.imgur.com/BNF0CiC.png",
"size": "full",
"aspectRatio": "20:13",
"aspectMode": "cover",
"animated": false,
"backgroundColor": "#FFFFFF00"
}
],
"paddingAll": "none"
},
"action": {
"type": "uri",
"label": "action",
"uri": "https://i.imgur.com/BNF0CiC.png"
}
}
}];
sendMessages(data);
}
}
function makeBW() {
var type = getParameterByName("type");
if (type === "柏威") {
const data = [{
"type": "flex",
"altText": "ㄟ, 我跟你說件事",
"contents":
{
"type": "bubble",
"size": "mega",
"body": {
"type": "box",
"layout": "vertical",
"contents": [
{
"type": "image",
"url": "https://i.imgur.com/BNF0CiC.png",
"size": "full",
"aspectRatio": "20:13",
"aspectMode": "cover",
"animated": false,
"backgroundColor": "#FFFFFF00"
}
],
"paddingAll": "none"
},
"action": {
"type": "uri",
"label": "action",
"uri": "https://i.imgur.com/BNF0CiC.png"
}
}
}];
sendMessages(data);
}
}
function sendMessages(data) { function sendMessages(data) {
if (liff.isInClient()) { if (liff.isInClient()) {
liff.sendMessages(data).then(function () { liff.sendMessages(data).then(function () {
@ -216,6 +400,4 @@ function sendMessages(data) {
document.getElementById("error").innerHTML = `你的 LINE App 暫時不支援 Share Target Picker`; document.getElementById("error").innerHTML = `你的 LINE App 暫時不支援 Share Target Picker`;
} }
} }
} }