forked from iamyjc/smsreal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
97 lines (88 loc) · 4.63 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<!DOCTYPE html>
<html lang="zh-TW">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
<link rel="stylesheet" href="https://pro.fontawesome.com/releases/v5.10.0/css/all.css" integrity="sha384-AYmEC3Yw5cVb3ZcuHtOA93w35dYTsvhLPVnYs9eStHfGJvOvKxVfELGroGkvsg+p" crossorigin="anonymous"/>
<link rel="stylesheet" href="css/main.css"/>
<title>簡訊實聯制:一鍵傳訊</title>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-J7MF6B92HW"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-J7MF6B92HW');
</script>
</head>
<body>
<div class="container-fluid text-center">
<div class="row justify-content-md-center">
<div class="header col-12">
<p class="h1"><span id="store">行政院</span> 簡訊實聯制</p>
</div>
<div class="col-6 col-lg-3">
<a id="storeId-android" class="btn btn-success btn-lg" href="sms:1922?body=場所代碼:208640524134744 本次實聯簡訊限防疫目的使用。">我是 <i class="fab fa-2x fa-android"></i><br/> Android 手機</a>
</div>
<div class="col-6 col-lg-3">
<a id="storeId-ios" class="btn btn-dark btn-lg" href="sms:1922&body=場所代碼:208640524134744 本次實聯簡訊限防疫目的使用。">我是 <i class="fab fa-2x fa-apple fa-inverse"></i><br/> iPhone 手機 </a>
</div>
<div class="col-12" id="store-qrcode">
<img src="images/208640524134744.png" class="img-fluid" alt="市場寢具店QRCode">
</div>
<div class="col-12">
<h2>場所代碼:<span id="store-code"></span></h2>
</div>
</div>
<div class="fixed-bottom">Create by <a href="mail:[email protected]">YJC</a></div>
</div>
<!-- Bootstrap JS -->
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-Atwg2Pkwv9vp0ygtn1JAojH0nYbwNJLPhwyoVbhoPwBhjQPR5VtM2+xf0Uwh9KtT" crossorigin="anonymous"></script>
<script>
// 呼叫Google API產生QRCode
function getQRCodeByGoogle(content){
content = encodeURIComponent(content);
return 'http://chart.apis.google.com/chart?cht=qr&chl=' + content + '&chs=340x340';
}
window.onload = function(){
let url = new URL(location.href);
let id, store;
// 有參數才取值
if(url.search.indexOf('?')!=-1)
{
id = url.searchParams.get('id');
store = url.searchParams.get('store');
}
// 簡訊按鈕
if (id) {
let storeIdAndroid = document.getElementById("storeId-android");
storeIdAndroid.href = 'sms:1922?body=場所代碼:' + id + ' 本次實聯簡訊限防疫目的使用。';
let storeIdIos = document.getElementById("storeId-ios");
storeIdIos.href = 'sms:1922&body=場所代碼:' + id + ' 本次實聯簡訊限防疫目的使用。';
}
if (store) {
let storeName = document.getElementById("store");
storeName.innerHTML = store;
}
// 場所QRCode
let msg = 'smsto:1922:場所代碼:' + id + ' 本次實聯簡訊限防疫目的使用。';
let imgSrc = getQRCodeByGoogle(msg);
let storeQrcode = document.getElementById("store-qrcode");
storeQrcode.innerHTML = '<img src="' + imgSrc + '" alt="" />';
// 場所代碼
let idArr = "";
for (let i = 0, len = id.length / 4; i < len; i++) {
let subStr = id.substr(0, 4);
idArr = idArr + subStr + " ";
id = id.replace(subStr, "");
}
let storeCode = document.getElementById("store-code");
storeCode.innerHTML = idArr;
};
</script>
</body>
</html>