-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodeInput.html
More file actions
151 lines (137 loc) · 4.62 KB
/
codeInput.html
File metadata and controls
151 lines (137 loc) · 4.62 KB
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>輸入通行碼Input</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<style>
/* 在<style>标签中添加 CSS 样式 */
.rounded-image {
border-radius: 50%;
}
.center-image {
margin: 0 auto;
display: block;
}
.shadowed-image {
display: block;
margin: 0 auto;
box-shadow: 5px 5px 10px #888888; /* 阴影效果 */
}
</style>
</head>
<body>
<div class="row" style="margin: 10px">
<div id="output"></div>
<div class="col-12" style="margin: 10px">
<label>code:</label>
<input type="text" id="codeInput" value="" class="form-control" />
<br />
<button class="btn btn-success btn-block" id="sure">確定</button>
</div>
</div>
<script src="https://static.line-scdn.net/liff/edge/2/sdk.js"></script>
<script>
function initializeLiff(myLiffId) {
liff.init({
liffId: myLiffId,
withLoginOnExternalBrowser: true, // Enable automatic login process
}).then(() => {
if (!liff.isLoggedIn()) {
alert("用戶未登入");
liff.login();
} else {
//alert("用戶已登入");
}
}).catch((err) => {
alert("初始化失敗:" + err);
console.log('初始化失敗', err);
});
}
function showConfirm() {
// 顯示確認框
let result = confirm("確定要執行這個動作嗎?");
// 按下確定時的動作
if (result) {
//alert("你選擇了確定,執行動作!");
// 在這裡可以放執行的代碼
liff.closeWindow();
} else {
alert("你取消了動作。");
}
}
function sendLineImgMsg(msg_text) {
str1 = "https://i.imgur.com/AZo9p9G.jpg?" + msg_text;
liff.sendMessages([{
type: 'image',
originalContentUrl: str1,
previewImageUrl: str1
}]).then(() => {
//console.log("message sent");
//alert("message sent");
showConfirm();
})
.catch(err => { alert(err.message) })
}
function sendLineMsg(msg_text) {
//alert(msg_text);
liff.sendMessages([
{
type: "text",
text: msg_text,
},
])
.then(() => {
//console.log("message sent");
//alert("message sent");
showConfirm();
})
.catch((err) => {
console.log("error", err);
alert(err);
});
}
function sendShareMsg(msg_text) {
alert(msg_text);
liff.shareTargetPicker([
{
text: msg_text,
},
])
.then(() => {
console.log("share message sent");
alert("sharre message sent");
})
.catch((err) => {
console.log("error", err);
alert(err);
});
}
function pushMsg(code) {
//alert(code);
//if (pname == '' || pdatetime == '' || proom == '') { //資料檢查
//alert(pdatetime);
//alert(pname);
//alert(proom);
//alert('每個項目都必須輸入!');
//sendLineMsg(proom);
//liff.closeWindow();
//return;
//}
msg = "CMD_CODE_" + code
sendLineImgMsg(msg);
//sendShareMsg(proom);
//liff.closeWindow();
}
$(document).ready(function () {
//alert("ready");
initializeLiff('2004227013-LVl43rrZ'); //接收傳遞的 liffid 參數
$('#sure').click(function (e) { //按下確定鈕
pushMsg($('#codeInput').val());
});
});
</script>
</body>
</html>