-
Notifications
You must be signed in to change notification settings - Fork 3
/
checkout.js
202 lines (166 loc) · 6.86 KB
/
checkout.js
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
window.addEventListener("scroll", navigationChanging);
function navigationChanging() {
let navigationBar = document.getElementsByClassName("navigation_bar")[0];
navigationBar.classList.toggle("scrollingNavigation", window.scrollY > 0);
let hamburgerMenu = document.getElementsByClassName("hamburgerMenu")[0];
hamburgerMenu.classList.toggle("scrollHamburger", window.scrollY > 0);
}
function showLoginSignupPopup() {
let loginDiv = document.getElementsByClassName("loginPopupOverlay")[0];
loginDiv.classList.toggle("hide");
loginDiv.classList.add("active");
document.body.style.overflow = "hidden";
}
function showWelcomeContent() {
document.getElementsByClassName("welcomeNav")[0].classList.toggle("active");
}
function showMyAccount() {
let accountDiv = document.getElementsByClassName("myAccountOverlay")[0];
accountDiv.classList.remove("hide");
document.body.style.overflow = "hidden";
}
function logoutUser() {
let arr = [];
localStorage.setItem("currLoggedIn", JSON.stringify(arr));
document.getElementsByClassName("welcomeNav")[0].classList.add("hide");
document.getElementsByClassName("welcomeNav")[0].classList.remove("active");
document.getElementsByClassName("signupNav")[0].classList.remove("hide");
}
var final_data = JSON.parse(localStorage.getItem("finalBookedBike"));
//console.log(final_data);
var companyName = document.getElementById("company_name");
companyName.innerHTML = final_data[0].manufacturer;
var modelName = document.getElementById("model-name");
modelName.innerHTML = final_data[0].model;
var bikePic = document.getElementById("bike-pic");
var bikePic1 = document.createElement("img");
bikePic1.src = `${final_data[0].imgLink}`;
bikePic.appendChild(bikePic1);
//console.log(final_data[0].imgLink);
var adresslName = document.getElementById("abc2");
adresslName.innerHTML = final_data[0].address;
var excess = document.getElementById("excess");
excess.innerHTML = `Excess ₹ ${final_data[0].excess}/km`;
var freelKM = document.getElementById("freeKm");
freelKM.innerHTML = `${final_data[0].free}Kms free`;
var price_without_discount = document.getElementById("price_without_discount");
price_without_discount.innerHTML = `₹${final_data[0].price}`;
var start = JSON.parse(localStorage.getItem("startingDateObject"));
var end = JSON.parse(localStorage.getItem("endingDateObject"));
if (end == null) {
end = JSON.parse(localStorage.getItem("30daysdate"));
}
//console.log(start);
//console.log(end);
var month_day = document.getElementById("month_day");
month_day.innerHTML = start.date;
var monthYear = document.getElementById("monthYear");
monthYear.innerHTML = `${start.month} 21`;
var day = document.getElementById("day");
day.innerHTML = start.weekDay;
var timehrs = document.getElementById("timehrs");
timehrs.innerHTML = start.time;
var monthday1 = document.getElementById("month_day1");
monthday1.innerHTML = end.date;
var monthYear1 = document.getElementById("monthYear1");
monthYear1.innerHTML = `${end.month} 21`;
var day1 = document.getElementById("day1");
day1.innerHTML = end.weekDay;
var timehrs1 = document.getElementById("timehrs1");
timehrs1.innerHTML = end.time;
var promo_code = document.getElementById("inp");
var promo_code_discounted_amount = document.getElementById("promo-code-price1");
var promo_code_btn = document.getElementById("promocodetick");
var net_money = Number(final_data[0].price);
promo_code_btn.addEventListener("click", promo);
var promo_code_flag = false;
var count = 0;
function promo() {
if (promo_code.value == "MASAI30" && count < 1) {
promo_code_discounted_amount.style.fontSize = "14.5px";
promo_code_btn.src = "IMG_FILE/checked.png";
promo_code_discounted_amount.style.color = "red";
promo_code_discounted_amount.innerHTML = `-₹${net_money * 0.3}`;
net_money = final_data[0].price;
promo_code_flag = true;
count++;
} else {
promo_code_btn.src = "IMG_FILE/remove.png";
promo_code_discounted_amount.innerHTML = ``;
}
}
var discount_inner_image = document.createElement("img");
discount_inner_image.src = "IMG_FILE/insurance.svg";
var discount_image = document.getElementById("insureTheRide-btn");
var discount_price = document.getElementById("insureTheRide_price");
discount_image.addEventListener("click", adder);
var add = 0;
var promo_code_flag1 = false;
var payment_color = document.getElementById("checkbox");
var totalAmounttFinalPrice = document.getElementById("totalAmounttFinalPrice");
totalAmounttFinalPrice.innerHTML = `₹${net_money}`;
var payment_total_color = document.getElementById("payment-total");
payment_color.addEventListener("click", test);
var c = 0;
function adder() {
add++;
if (add % 2 != 0 && c < 1) {
discount_inner_image.style.display = "block";
discount_image.style.border = "transparent";
discount_image.appendChild(discount_inner_image);
discount_price.style.fontSize = "15px";
discount_price.style.color = "green";
discount_price.innerHTML = `+₹${19}`;
// net_money = net_money - net_money * 0.3;
net_money = net_money + 19;
totalAmounttFinalPrice.innerHTML = `₹${net_money}`;
c++
promo_code_flag1 = true;
} else {
discount_inner_image.style.display = "none";
discount_image.style.border = "0.3px solid grey";
discount_price.innerHTML = `₹${0}`;
}
}
var add2 = 0;
function test() {
add2++;
if (add2 % 2 != 0) {
if (promo_code_flag == true) {
promo_code_flag = false;
// net_money = net_money - net_money * 0.3;
if (promo_code_flag1 == true) {
promo_code_flag1 = false;
net_money = net_money + 19;
} else {
net_money = net_money;
}
} else {
net_money = net_money;
if (promo_code_flag1 == true) {
promo_code_flag1 = false;
net_money = net_money + 19;
} else {
net_money = net_money;
}
}
payment_total_color.style.background = "rgb(29,45,81)";
payment_total_color.style.opacity = "100";
payment_total_color.innerHTML = `PAYMENT ₹${net_money}`;
totalAmounttFinalPrice.innerHTML = `₹${net_money}`;
// console.log(net_money);
payment_total_color.addEventListener("click", paymentPage);
localStorage.setItem("onnbike_price", net_money);
function paymentPage() {
window.open("payment.html", "_parent");
}
} else if (add2 == 0) {
payment_total_color.style.background = "rgb(210,211,212)";
payment_total_color.style.opacity = "0.6";
} else {
payment_total_color.style.background = "rgb(210,211,212)";
payment_total_color.style.opacity = "0.6";
payment_total_color.style.cursor = "not-allowed";
}
console.log(add2);
}