You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
307 lines
8.1 KiB
307 lines
8.1 KiB
function genCard(vcard) {
|
|
// 名片預覽
|
|
let vcardLink;
|
|
if (vcard.url.trim().length > 0) {
|
|
if (vcard.nc_func.indexOf("nourl") !== -1) {
|
|
vcardLink = `{
|
|
"type": "text",
|
|
"text": "${vcard.url}",
|
|
"color": "#ffffff",
|
|
"size": "sm"
|
|
},
|
|
`;
|
|
} else {
|
|
vcardLink = `
|
|
{
|
|
"type": "text",
|
|
"text": "${vcard.url}",
|
|
"color": "#ffffff",
|
|
"size": "sm",
|
|
"action": {
|
|
"type": "uri",
|
|
"label": "action",
|
|
"uri": "${vcard.url}"
|
|
}
|
|
},
|
|
`;
|
|
}
|
|
} else {
|
|
vcardLink = "";
|
|
}
|
|
|
|
let vcardAvatar;
|
|
if (vcard.avatar.trim().length > 0) {
|
|
vcardAvatar = `
|
|
{
|
|
"type": "image",
|
|
"url": "${vcard.avatar}",
|
|
"size": "full",
|
|
"aspectRatio": "1:1",
|
|
"aspectMode": "cover",
|
|
"action": {
|
|
"type": "uri",
|
|
"label": "action",
|
|
"uri": "${vcard.nfcurl}&cardid=1"
|
|
}
|
|
}
|
|
`;
|
|
} else {
|
|
vcardAvatar = "";
|
|
}
|
|
|
|
let vcardAddr;
|
|
if (vcard.address.trim().length > 0) {
|
|
vcardAddr = `
|
|
{
|
|
"type": "text",
|
|
"text": "${vcard.address}",
|
|
"color": "#ffffff",
|
|
"size": "sm",
|
|
"wrap": true,
|
|
"action": {
|
|
"type": "uri",
|
|
"label": "action",
|
|
"uri": "https://www.google.com.tw/maps/place/${encodeURIComponent(
|
|
vcard.address
|
|
)}"
|
|
}
|
|
},
|
|
`;
|
|
} else {
|
|
vcardAddr = "";
|
|
}
|
|
|
|
let vcardTel;
|
|
if (vcard.tel.trim().length > 0) {
|
|
vcardTel = `
|
|
{
|
|
"type": "text",
|
|
"text": "${vcard.tel}",
|
|
"color": "#ffffff",
|
|
"size": "sm",
|
|
"wrap": true,
|
|
"action": {
|
|
"type": "uri",
|
|
"label": "action",
|
|
"uri": "https://www.google.com.tw/maps/place/${encodeURIComponent(
|
|
vcard.address
|
|
)}"
|
|
}
|
|
},
|
|
`;
|
|
} else {
|
|
vcardTel = "";
|
|
}
|
|
|
|
let vcardPhone;
|
|
if (vcard.phone.trim().length > 0) {
|
|
vcardPhone = `
|
|
{
|
|
"type": "text",
|
|
"text": "${vcard.phone}",
|
|
"size": "lg",
|
|
"margin": "sm",
|
|
"action": {
|
|
"type": "uri",
|
|
"label": "action",
|
|
"uri": "tel:${vcard.phone}"
|
|
}
|
|
}
|
|
`;
|
|
} else {
|
|
vcardPhone = "";
|
|
}
|
|
|
|
let vcardEmail;
|
|
if (vcard.email.trim().length > 0) {
|
|
vcardEmail = `
|
|
{
|
|
"type": "text",
|
|
"text": "${vcard.email}",
|
|
"color": "#ffffff",
|
|
"size": "sm",
|
|
"action": {
|
|
"type": "uri",
|
|
"label": "action",
|
|
"data": "mailto:${vcard.email}"
|
|
}
|
|
},
|
|
`;
|
|
} else {
|
|
vcardEmail = "";
|
|
}
|
|
|
|
// 名片發送
|
|
|
|
let card = `
|
|
{
|
|
"altText": "UTel電子名片",
|
|
"type": "flex",
|
|
"contents":
|
|
{
|
|
"type": "bubble",
|
|
"size": "giga",
|
|
"body": {
|
|
"type": "box",
|
|
"layout": "horizontal",
|
|
"contents": [
|
|
{
|
|
"type": "box",
|
|
"layout": "vertical",
|
|
"contents": [
|
|
{
|
|
"type": "box",
|
|
"layout": "vertical",
|
|
"contents": [${vcardAvatar}],
|
|
"cornerRadius": "150px",
|
|
"width": "60%",
|
|
"borderWidth": "bold",
|
|
"borderColor": "#f5c520",
|
|
"margin": "none"
|
|
},
|
|
{
|
|
"type": "text",
|
|
"text": "${vcard.name}",
|
|
"size": "xl",
|
|
"weight": "bold",
|
|
"margin": "md"
|
|
},
|
|
{
|
|
"type": "text",
|
|
"text": "${vcard.title}",
|
|
"size": "md",
|
|
"weight": "regular",
|
|
"color": "#666666",
|
|
"action": {
|
|
"type": "uri",
|
|
"label": "action",
|
|
"uri": "${vcard.nfcurl}&cardid=1"
|
|
}
|
|
},
|
|
${vcardPhone}
|
|
],
|
|
"alignItems": "center",
|
|
"paddingTop": "5%",
|
|
"paddingBottom": "8%",
|
|
"width": "35%"
|
|
},
|
|
{
|
|
"type": "box",
|
|
"layout": "vertical",
|
|
"contents": [
|
|
{
|
|
"type": "box",
|
|
"layout": "vertical",
|
|
"contents": [
|
|
{
|
|
"type": "text",
|
|
"text": "${vcard.company}",
|
|
"color": "#ffffff",
|
|
"size": "xl",
|
|
"weight": "bold"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"type": "box",
|
|
"layout": "vertical",
|
|
"contents": [
|
|
${vcardTel}
|
|
${vcardLink}
|
|
${vcardEmail}
|
|
${vcardAddr}
|
|
{
|
|
"type": "box",
|
|
"layout": "horizontal",
|
|
"justifyContent": "space-between",
|
|
"contents": [
|
|
{
|
|
"type": "box",
|
|
"layout": "vertical",
|
|
"contents": [
|
|
{
|
|
"type": "button",
|
|
"action": {
|
|
"type": "uri",
|
|
"label": "加入好友",
|
|
"uri": "http://linecorp.com/"
|
|
},
|
|
"color": "#dddddd",
|
|
"height": "sm",
|
|
"style": "link"
|
|
}
|
|
],
|
|
"borderWidth": "light",
|
|
"borderColor": "#dddddd",
|
|
"cornerRadius": "lg",
|
|
"width": "48%",
|
|
"height": "36px"
|
|
},
|
|
{
|
|
"type": "box",
|
|
"layout": "vertical",
|
|
"contents": [
|
|
{
|
|
"type": "button",
|
|
"action": {
|
|
"type": "uri",
|
|
"label": "分享名片",
|
|
"uri": "http://linecorp.com/"
|
|
},
|
|
"color": "#dddddd",
|
|
"height": "sm"
|
|
}
|
|
],
|
|
"cornerRadius": "lg",
|
|
"borderColor": "#dddddd",
|
|
"borderWidth": "light",
|
|
"height": "36px",
|
|
"width": "48%"
|
|
}
|
|
],
|
|
"margin": "md"
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"backgroundColor": "#353e45",
|
|
"paddingBottom": "4%",
|
|
"paddingStart": "5%",
|
|
"paddingEnd": "5%",
|
|
"width": "66%",
|
|
"justifyContent": "space-between",
|
|
"paddingTop": "4%"
|
|
},
|
|
{
|
|
"type": "box",
|
|
"layout": "vertical",
|
|
"contents": [
|
|
{
|
|
"type": "image",
|
|
"url": "https://369cycle.zltest.com.tw/tggo/template/bg-01.png",
|
|
"size": "full"
|
|
}
|
|
],
|
|
"position": "absolute",
|
|
"width": "67%",
|
|
"height": "70%",
|
|
"offsetEnd": "none",
|
|
"justifyContent": "flex-end"
|
|
}
|
|
],
|
|
"paddingAll": "0px",
|
|
"action": {
|
|
"type": "uri",
|
|
"label": "action",
|
|
"uri": "https://utel.zltest.com.tw/card/?params=i7Kq7O59hPX1MJ%2Bqd8zQKBwuyc%2F%2BZ%2BZs%2BZXtXBy4zvg%3D&cardid=1"
|
|
},
|
|
"height": "250px"
|
|
}
|
|
}
|
|
}
|
|
`;
|
|
return { card };
|
|
}
|
|
|
|
export { genCard };
|