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
import { Component, OnInit } from '@angular/core';
import { Location } from '@angular/common';
import { Router, ActivatedRoute } from '@angular/router';
import { ServiceService } from './../../config/service.service';
import { MyordersService } from './../../config/myorder.service';
@Component({
selector: 'app-orderplaced',
templateUrl: './orderplaced.page.html',
styleUrls: ['./orderplaced.page.scss']
})
export class OrderplacedPage implements OnInit {
deliveryTime: any;
cancelDelivery: any;
timeinterval: any;
constructor(
private router: Router,
private route: ActivatedRoute,
private location: Location,
private service: ServiceService,
private myOrder: MyordersService
) {
}
data: any;
relatedProd = {
slidesPerView: 2
};
ionViewWillEnter() {
this.deliveryTime = '00:00:00';
this.service.get('order').then(val => {
console.log('My Orders value', val);
this.data = val;
const This = this;
console.log(Math.round(Date.now() / 1000) + ' < ' + this.data.bookDate.seconds);
this.timeinterval = setInterval(() => {
This.getDeliveryTime(this.data.bookDate.seconds, this.data.time);
}, 1000);
});
}
unEscape(text: string) {
const regex = '%uFFFD';
return unescape(text.replace(/%uFFFD/g, ''));
}
getDeliveryTime(timeStamp, minute) {
let endDate = new Date(timeStamp * 1000);
endDate = new Date(endDate.getTime() + minute * 60000);
if (Math.round(Date.now() / 1000) < Math.round(endDate.getTime() / 1000)) {
// console.log(endDate);
const t = this.getTimeRemaining(endDate, new Date());
const minutes = t.minutes < 10 ? '0' + t.minutes : t.minutes;
const seconds = t.seconds < 10 ? '0' + t.seconds : t.seconds;
const hours = t.hours < 10 ? '0' + t.hours : t.hours;
this.deliveryTime = t.hours + ' : ' + minutes + ' : ' + seconds;
if (t.t <= 0) {
clearInterval(this.timeinterval);
}
}
}
getTimeRemaining(endtime, currDate) {
const t = Date.parse(endtime) - Date.parse(currDate);
this.cancelDelivery = t;
const hours = Math.floor((((t / 1000) / 60) / 60) % 60);
const seconds = Math.floor((t / 1000) % 60);
const minutes = Math.floor((t / 1000 / 60) % 60);
return {
t,
hours,
minutes,
seconds
};
}
ngOnInit() { }
goToPage(path, data = null) {
this.router.navigateByUrl(path, { queryParams: data });
document.body.scrollTop = document.documentElement.scrollTop = 0;
}
cancelOrder(orderId) {
this.service.set('orderId', orderId);
this.router.navigateByUrl('contact');
}
changeAddress(orderId) {
this.service.set('orderId', orderId);
this.router.navigateByUrl('changeaddress');
document.body.scrollTop = document.documentElement.scrollTop = 0;
}
goBack() {
this.location.back();
}
cancellOrder(orderId) {
console.log(orderId);
this.myOrder.cancelOrder(orderId).then(() => {
this.service.showToast('Order cancelled!', 'top', 'my-toast', 1000);
const This = this;
setTimeout(() => {
This.goToPage('ordercancelled');
}, 1100);
});
}
getStatus(status: number) {
switch (status) {
case 1:
return 'Booked';
break;
case 2:
return 'Shop Accepted';
break;
case 3:
return 'Rider Assigned';
break;
case 4:
return 'Reached Shop';
break;
case 5:
return 'Picked Up';
break;
case 6:
return 'Reached Location';
break;
case 7:
return 'Delivered';
break;
case 9:
return 'Completed';
break;
case 8:
return 'Rejected';
break;
case 10:
return 'Not Received';
break;
case 0:
return 'Cancelled';
break;
default:
return 'Finished';
}
}
}