-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathorder.html
More file actions
256 lines (221 loc) · 8.25 KB
/
order.html
File metadata and controls
256 lines (221 loc) · 8.25 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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
<!DOCTYPE html>
<html lang="en">
<head>
<title>Developer's community - Develonity</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Mukta:300,400,700">
<link rel="stylesheet" href="fonts/icomoon/style.css">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/magnific-popup.css">
<link rel="stylesheet" href="css/jquery-ui.css">
<link rel="stylesheet" href="css/owl.carousel.min.css">
<link rel="stylesheet" href="css/owl.theme.default.min.css">
<link rel="stylesheet" href="css/aos.css">
<link rel="stylesheet" href="css/style.css">
<style>
.orderForm {
width: 500px;
margin: auto;
}
</style>
</head>
<body>
<div class="site-wrap">
<header class="site-navbar" role="banner">
<div class="site-navbar-top">
<div class="container">
<div class="row align-items-center">
<div class="col-6 col-md-4 order-2 order-md-1 site-search-icon text-left">
<form action="" class="site-block-top-search">
<!-- <span class="icon icon-search2"></span>
<input type="text" class="form-control border-0" placeholder="Search"> -->
</form>
</div>
<div class="col-12 mb-3 mb-md-0 col-md-4 order-1 order-md-2 text-center">
<div class="site-logo">
<a href="index.html" class="js-logo-clone">Develonity</a>
</div>
</div>
<div class="col-6 col-md-4 order-3 order-md-3 text-right">
<div class="site-top-icons">
<ul>
<li id="logoutPlace"></li>
<li id="loginedPerson">
<a href="signUp.html" class="icon icon-person"> </a>
</li>
<li>
<a href="#" class="icon icon-heart-o"></a>
</li>
<li>
<a href="orderList.html" class="site-cart">
<span class="icon icon-shopping_cart"></span>
</a>
</li>
<li class="d-inline-block d-md-none ml-md-0">
<a href="#" class="site-menu-toggle js-menu-toggle"
><span class="icon-menu"></span
></a>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<nav
class="site-navigation text-right text-md-center"
role="navigation"
>
<div class="container">
<ul class="site-menu js-clone-nav d-none d-md-block">
<li><a href="index.html">Home</a></li>
<li><a onclick="community()">Community</a></li>
<li><a href="QnA.html">Q&A</a></li>
<li><a href="shop.html">GiftCard Shop</a></li>
</ul>
</div>
</nav>
</header>
<div class="bg-light py-3">
<div class="container">
<div class="row">
<div class="col-md-12 mb-0"><strong class="text-black">주문하기</strong></div>
</div>
</div>
</div>
<div class="orderForm">
<div class="form-floating mb-3">
<h3>주문하기</h3>
<div id="orderInfo">
</div>
<button onclick="order()">주문하기</button>
</div>
</div>
<script src="js/jquery-3.3.1.min.js"></script>
<script src="js/jquery-ui.js"></script>
<script src="js/popper.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/owl.carousel.min.js"></script>
<script src="js/jquery.magnific-popup.min.js"></script>
<script src="js/aos.js"></script>
<script src="js/main.js"></script>
<script>
$(function () {
var settings = {
url: "http://52.79.252.88:8080/api/user/me/profile",
method: "GET",
timeout: 0,
headers: {
Authorization: localStorage.getItem("accessToken"),
},
};
$.ajax(settings)
.done(function (response) {
console.log(response);
$("#loginedPerson").empty();
$("#loginedPerson").append(
`<a href=myProfile.html class="icon icon-person"> </a>`
);
$("#logoutPlace").append(
`<button style="font-size: 12px; cursor: pointer" onclick="logout()">
로그아웃
</button>`
);
})
.fail(function (response) {
var settings2 = {
url: "http://52.79.252.88:8080/api/reissue",
method: "POST",
timeout: 0,
headers: {
Refresh: localStorage.getItem("refreshToken"),
},
};
$.ajax(settings2).done(function (response) {
localStorage.setItem("accessToken", response.accessToken);
localStorage.setItem("refreshToken", response.refreshToken);
location.reload(true);
});
});
});
</script>
<script>
$(document).ready(function () {
getGiftCardOrderInfo()
});
function getGiftCardOrderInfo() {
$('#orderInfo').empty()
var settings = {
"url": `http://52.79.252.88:8080/api/gift-cards/${localStorage.getItem("giftCardId")}`,
"method": "GET",
"timeout": 0,
};
$.ajax(settings).done(function (response) {
console.log(response);
let productId = localStorage.getItem("giftCardId")
let productName = response['name']
let productPrice = response['price']
let temp_html = `<div class="form-floating">
<input type="text" class="form-control" id="floatingProductId" placeholder="${productId}" disabled>
<label for="floatingProductId">상품ID</label>
</div>
<div class="form-floating">
<input type="text" class="form-control" id="floatingProductName" placeholder="${productName}" disabled>
<label for="floatingProductName">상품명</label>
</div>
<div class="form-floating">
<input type="text" class="form-control" id="floatingPrice" placeholder="${productPrice}" disabled>
<label for="floatingPrice">가격</label>
</div>
<div class="form-floating">
<input type="text" class="form-control" id="floatingName" placeholder="받는분의 성함">
<label for="floatingName">Name</label>
</div>
<div class="form-floating">
<input type="text" class="form-control" id="floatingPhoneNumber" placeholder="받는분의 전화번호">
<label for="floatingPhoneNumber">Phone Number</label>
</div>`
$('#orderInfo').append(temp_html)
});
}
function community() {
alert(
"해당 기능은 시간관계상 프론트 구현을 하지 못하여 이용이 어렵습니다. 죄송합니다."
);
}
function order() {
var settings = {
"url": "http://52.79.252.88:8080/api/order",
"method": "POST",
"timeout": 0,
"headers": {
"Authorization": localStorage.getItem('accessToken')
},
"contentType": 'application/json',
"data": JSON.stringify({
"recipientName": $('#floatingName').val(),
"phoneNumber": $('#floatingPhoneNumber').val(),
"giftCardId": localStorage.getItem("giftCardId")
}),
};
$.ajax(settings).done(function (response) {
console.log(response.status);
alert('주문 완료');
window.location = '/orderList.html'
}).fail(function (response) {
console.log(response)
if(response['status'] === 0) {
alert("로그인이 필요합니다. 로그인 창으로 이동합니다.")
window.location='/signUp.html'
}
else {
console.log(response.responseJSON);
alert(response.responseJSON['message']);
}
console.log(response)
});
}
</script>
</body>
</html>