-
Notifications
You must be signed in to change notification settings - Fork 3
/
buyservice.js
125 lines (69 loc) · 2.14 KB
/
buyservice.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
let firstdata =JSON.parse( localStorage.getItem("buyfirst"))||[];
console.log(firstdata);
let second = JSON.parse(localStorage.getItem("buysecond"));
let third = JSON.parse(localStorage.getItem("buythird"));
if(firstdata!==null){
displaydata(firstdata);
}else if(second!==null){
displaydata(second);
}
else if(third!==null){
displaydata(third);
}
function displaydata(firstdata){
document.querySelector("#cartmain").innerHTML="";
let cart = document.querySelector("#cartmain");
firstdata.forEach((el)=>{
cart.innerHTML=`
<div>
<p >Name of Service: </p><span>${el.name}</span>
<p class="price">Price: </p><span>${el.price}</span>
<p class="feedback"></p>
</div>
`
})
}
function displaydata(second){
document.querySelector("#cartmain").innerHTML="";
let cart = document.querySelector("#cartmain");
second.forEach((el)=>{
cart.innerHTML=`
<div>
<p>Name of Service: ${el.name}</p>
<p class="price">Price: ${el.price}</p>
</div>
`
})
}
function displaydata(third){
document.querySelector("#cartmain").innerHTML="";
let cart = document.querySelector("#cartmain");
third.forEach((el)=>{
cart.innerHTML=`
<div>
<p>Name of Service: ${el.name}</p>
<p class="price">Price: ${el.price}</p>
</div>
`
})
}
let buynow = document.querySelector("#buyit");
buynow.addEventListener("click",otp);
let pass = Math.floor(Math.random()*9000+1000);
let ins = document.querySelector("#pas");
ins.setAttribute("value",pass);
function otp(){
let ot = window.prompt("Enter you pin");
let promise = new Promise((res,rej)=>{
if(ot==pass){
res("Payment Succesfull :D");
}else{
rej("Incorrect PIN!!!!!!!!!!")
}
});
promise.then((data)=>{alert(data);window.location.href="/job.html"}).catch((err)=>alert(err));
}
let logout = document.querySelector("#logout");
logout.addEventListener("click",()=>{
window.location.href="./index.html";
})