-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathseat.js
More file actions
48 lines (43 loc) · 1.72 KB
/
seat.js
File metadata and controls
48 lines (43 loc) · 1.72 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
let seatInfo;
window.onload = function () {
const scheduleId = new URLSearchParams(window.location.search).get('scheduleId');
fetch("https://qquickqqueue.store/api/musicals/seat/" + scheduleId, {
method: 'GET',
headers: {
"Content-Type": "application/json",
"ACCESS-TOKEN": getAccessTokenFromCookie()
}
})
.then(Response => {
return Response.json();
})
.then(Data => {
const seatList = Data.data;
let text = '';
seatList.forEach(seat => {
if (seat.columnNum === 1) {
text += '<br>';
}
const button = `<button id="seat${seat.id}" class="${seat.grade}" ${seat.reserved ? 'disabled' : ''} onclick="showSeatInfo(${seat.id}, ${seat.rowNum}, ${seat.columnNum}, '${seat.grade}', ${seat.price}, ${seat.reserved})"></button>`;
text += button + ' ';
});
document.getElementById("seatList").innerHTML = text;
})
}
function showSeatInfo(id, rowNum, columnNum, grade, price, reserved) {
var result = confirm(`행: ${rowNum}, 열: ${columnNum}, 등급: ${grade}, 가격: ${price}, 예약여부: ${reserved ? '예약됨' : '예약 가능'}` + "\n" + "결제 하시겠습니까?");
if (result === true) {
seatInfo = [id, rowNum, columnNum, grade, price];
window.location.href = "payment.html?schedule-seat-id=" + id;
}
}
function getAccessTokenFromCookie() {
const cookies = document.cookie.split(';');
for (const cookie of cookies) {
const [name, value] = cookie.trim().split('=');
if (name === 'access_token') {
return value;
}
}
return null;
}