Commit 78ca2550 by Adarsh K

new changes

parent 79995412
...@@ -57,6 +57,7 @@ export class ChangeaddressPage implements OnInit { ...@@ -57,6 +57,7 @@ export class ChangeaddressPage implements OnInit {
this.lat = ''; this.lat = '';
this.lng = ''; this.lng = '';
this.type = 0; this.type = 0;
this.zoom = 16;
const users = this.service.get('user').then(data => { const users = this.service.get('user').then(data => {
if (data) { if (data) {
data = JSON.parse(data); data = JSON.parse(data);
...@@ -100,7 +101,7 @@ export class ChangeaddressPage implements OnInit { ...@@ -100,7 +101,7 @@ export class ChangeaddressPage implements OnInit {
navigator.geolocation.getCurrentPosition(position => { navigator.geolocation.getCurrentPosition(position => {
this.latitude = position.coords.latitude; this.latitude = position.coords.latitude;
this.longitude = position.coords.longitude; this.longitude = position.coords.longitude;
this.zoom = 8; this.zoom = 16;
this.getAddress(this.latitude, this.longitude); this.getAddress(this.latitude, this.longitude);
}); });
} }
...@@ -116,7 +117,7 @@ export class ChangeaddressPage implements OnInit { ...@@ -116,7 +117,7 @@ export class ChangeaddressPage implements OnInit {
console.log(e); console.log(e);
this.newCenterLat = e.lat; this.newCenterLat = e.lat;
this.newCenterLng = e.lng; this.newCenterLng = e.lng;
this.getAddress(this.newCenterLat, this.newCenterLng); // this.getAddress(this.newCenterLat, this.newCenterLng);
} }
markerDragEnd($event: MouseEvent) { markerDragEnd($event: MouseEvent) {
......
...@@ -195,9 +195,8 @@ ...@@ -195,9 +195,8 @@
</label> </label>
</div> </div>
<div> <div>
<p> <p>{{address.building}}<span *ngIf="address.landmark && address.landmark!==''">,
{{address.building}}, <span {{address.landmark}}</span>
*ngIf="address.landmark && address.landmark!==''">{{address.landmark}},</span>
<!-- {{address.address}} --> <!-- {{address.address}} -->
</p> </p>
</div> </div>
......
...@@ -78,13 +78,15 @@ export class HomePage implements OnInit { ...@@ -78,13 +78,15 @@ export class HomePage implements OnInit {
this.custId = data.uid; this.custId = data.uid;
this.addressService.addList(data.uid); this.addressService.addList(data.uid);
this.subjectService.getAddressStateData().subscribe((state) => { this.subjectService.getAddressStateData().subscribe((state) => {
console.log(state);
if (state !== null) { if (state !== null) {
this.addressService.defaultAddress(data.uid).then((addressData) => { this.addressService.defaultAddress(data.uid).then((addressData) => {
console.log(this.addressService.defaultAdd); console.log(this.addressService.defaultAdd);
const latLng = this.addressService.defaultAdd.latLng; const latLng = this.addressService.defaultAdd.latLng;
// tslint:disable-next-line:max-line-length // tslint:disable-next-line:max-line-length
this.centerService.getNearBy(latLng.latitude, latLng.longitude, this.service.distance); this.centerService.getNearBy(latLng.latitude, latLng.longitude, this.service.distance);
this.getAddress(latLng.latitude, latLng.longitude); this.address = this.addressService.defaultAdd.building;
// this.getAddress(latLng.latitude, latLng.longitude);
}); });
} }
}); });
...@@ -107,7 +109,7 @@ export class HomePage implements OnInit { ...@@ -107,7 +109,7 @@ export class HomePage implements OnInit {
const This = this; const This = this;
setTimeout(() => { setTimeout(() => {
This.mapsAPILoader.load().then(() => { This.mapsAPILoader.load().then(() => {
This.setCurrentLocation(); // This.setCurrentLocation();
This.geoCoder = new google.maps.Geocoder(); This.geoCoder = new google.maps.Geocoder();
const autocomplete = new google.maps.places.Autocomplete(This.searchElementRef.nativeElement, { const autocomplete = new google.maps.places.Autocomplete(This.searchElementRef.nativeElement, {
types: ['address'] types: ['address']
...@@ -170,47 +172,29 @@ export class HomePage implements OnInit { ...@@ -170,47 +172,29 @@ export class HomePage implements OnInit {
setDefault(address: any) { setDefault(address: any) {
this.loader = true; this.loader = true;
if (address.addressId !== '') { this.addressService
this.addressService .setDefaultAddress(address.addressId, this.custId)
.setDefaultAddress(address.addressId, this.custId) .then(() => {
.then(() => { this.address = address.building;
this.address = address.building; this.lat = address.latLng.latitude;
this.lat = address.latLng.latitude; this.lng = address.latLng.longitude;
this.lng = address.latLng.longitude; console.log(address.latLng);
console.log(address.latLng); this.centerService.getNearBy(
this.centerService.getNearBy( address.latLng.latitude,
address.latLng.latitude, address.latLng.longitude,
address.latLng.longitude, this.service.distance
this.service.distance );
); this.loader = false;
this.loader = false; })
}) .catch(err => {
.catch(err => { this.loader = false;
this.loader = false; this.service.showToast(
this.service.showToast( 'Something went wrong please try again!',
'Something went wrong please try again!', 'top',
'top', 'my-error',
'my-error', 1000
1000 );
); });
});
} else {
const This = this;
This.address = address.building;
console.log(address);
this.lat = address.latLng.latitude;
this.lng = address.latLng.longitude;
console.log(address.latLng);
this.centerService.getNearBy(
address.latLng.latitude,
address.latLng.longitude,
this.service.distance
);
setTimeout(() => {
This.loader = false;
}, 1000);
}
} }
clickSearch() { clickSearch() {
......
...@@ -49,6 +49,8 @@ export class NearbyPage implements OnInit { ...@@ -49,6 +49,8 @@ export class NearbyPage implements OnInit {
public service: ServiceService, public service: ServiceService,
public authService: AuthService public authService: AuthService
) { ) {
this.latitude = 0;
this.longitude = 0;
this.successState = false; this.successState = false;
this.type = 0; this.type = 0;
const users = this.service.get('user').then(data => { const users = this.service.get('user').then(data => {
...@@ -90,11 +92,7 @@ export class NearbyPage implements OnInit { ...@@ -90,11 +92,7 @@ export class NearbyPage implements OnInit {
// google maps zoom level // google maps zoom level
private setCurrentLocation() { private setCurrentLocation() {
console.log('map-called');
if ('geolocation' in navigator) { if ('geolocation' in navigator) {
console.log(navigator);
/* this.latitude = -33.87276;
this.longitude = 151.20534; */
this.zoom = 16; this.zoom = 16;
this.getAddress(this.latitude, this.longitude); this.getAddress(this.latitude, this.longitude);
navigator.geolocation.getCurrentPosition(position => { navigator.geolocation.getCurrentPosition(position => {
...@@ -138,8 +136,14 @@ export class NearbyPage implements OnInit { ...@@ -138,8 +136,14 @@ export class NearbyPage implements OnInit {
mapReady(map) { mapReady(map) {
console.log('called'); console.log('called');
map.addListener('dragend', () => { map.addListener('dragend', () => {
console.log(this.searchElementRef.nativeElement.value);
console.log(this.newCenterLat, this.newCenterLng); console.log(this.newCenterLat, this.newCenterLng);
this.getAddress(this.newCenterLat, this.newCenterLng); this.getAddress(this.newCenterLat, this.newCenterLng);
const This = this;
setTimeout(() => {
This.searchElementRef.nativeElement.value = this.address;
}, 500);
}); });
} }
centerChange(e) { centerChange(e) {
......
...@@ -107,16 +107,18 @@ ...@@ -107,16 +107,18 @@
<div class="delivery-wrap"> <div class="delivery-wrap">
<h4 class="floatLeft">DELIVERY</h4> <h4 class="floatLeft">DELIVERY</h4>
<span class="floatRight" *ngIf="cancelDelivery > 0 && data.orderStatus != 0 && data.orderStatus != 8"><img <span class="floatRight"
*ngIf="cancelDelivery > 0 && data.orderStatus != 0 && data.orderStatus != 8"><img
class="ng-tns-c3-0" src="../../assets/edit.png" (click)="changeAddress(data.orderId)" /></span> class="ng-tns-c3-0" src="../../assets/edit.png" (click)="changeAddress(data.orderId)" /></span>
<div class="clear"></div> <div class="clear"></div>
</div> </div>
<h5 *ngIf="data.deliveryAddress"> <h5 *ngIf="data.deliveryAddress">
{{data.deliveryAddress.addressType}} {{data.deliveryAddress.addressType}},
<!-- ,<br />{{data.deliveryAddress.address}} -->, <!-- ,<br />{{data.deliveryAddress.address}} -->
<br /> {{data.deliveryAddress.building}}<span *ngIf="data.deliveryAddress.landmark && data.deliveryAddress.landmark!==''"><br />, <br /> {{data.deliveryAddress.building}}<span
*ngIf="data.deliveryAddress.landmark && data.deliveryAddress.landmark!==''"><br />,
{{data.deliveryAddress.landmark}}</span> {{data.deliveryAddress.landmark}}</span>
</h5> </h5>
<!-- <hr /> --> <!-- <hr /> -->
...@@ -182,7 +184,8 @@ ...@@ -182,7 +184,8 @@
<ion-footer> <ion-footer>
<div class="footer-btn"> <div class="footer-btn">
<button class="cancel_btn" (click)="cancelOrder(data.orderId)" *ngIf="cancelDelivery > 0 && data.orderStatus != 0 && data.orderStatus != 8"> <button class="cancel_btn" (click)="cancelOrder(data.orderId)"
*ngIf="cancelDelivery > 0 && data.orderStatus != 0 && data.orderStatus != 8">
CANCEL THIS ORDER CANCEL THIS ORDER
</button> </button>
</div> </div>
......
...@@ -41,7 +41,7 @@ export class AddressService { ...@@ -41,7 +41,7 @@ export class AddressService {
orderRef.valueChanges().subscribe(value => { orderRef.valueChanges().subscribe(value => {
this.addressList = []; this.addressList = [];
const res = value; const res = value;
this.getAddressCurrent(); // this.getAddressCurrent();
if (res.length > 0) { if (res.length > 0) {
res.forEach(item => { res.forEach(item => {
// console.log(item); // console.log(item);
...@@ -169,6 +169,7 @@ export class AddressService { ...@@ -169,6 +169,7 @@ export class AddressService {
} }
async setDefaultAddress(addId: string, userId: string) { async setDefaultAddress(addId: string, userId: string) {
console.log(addId, userId);
return await new Promise(resolve => { return await new Promise(resolve => {
this.afs this.afs
.collection('address', ref => ref.where('uid', '==', userId)) .collection('address', ref => ref.where('uid', '==', userId))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment