Commit 09414565 by Adarsh K

Merge branch 'adarsh' into 'master'

Adarsh See merge request !107
parents 2cbe65ee 79995412
......@@ -310,7 +310,7 @@
</h5>
<ul *ngIf="addressService.addressList && addressService.addressList.length > 0">
<li *ngFor="let address of addressService.addressList; let i = index"
[ngClass]="{'no-devlivery': !address.nearest}">
[ngClass]="{'no-devlivery': !address.nearest}" [hidden]="address.addressId===''">
<h4 *ngIf="address.nearest === true">DELIVERS TO</h4>
<h4 *ngIf="address.nearest === false">DOES NOT DELIVER TO</h4>
<div>
......
......@@ -16,7 +16,8 @@
</div>
</div>
<div class="search-sctn">
<button class="nav_btn nav_search floatRight" *ngIf="!searchShow" (click)="goToPage('searchmodal')"></button>
<button class="nav_btn nav_search floatRight" *ngIf="!searchShow"
(click)="goToPage('searchmodal')"></button>
<button class="nav_btn nav_close floatRight" *ngIf="searchShow" (click)="searchClose()"></button>
</div>
</div>
......@@ -42,7 +43,8 @@
<h5>{{center.centerName}}</h5>
<p>{{center.description}}</p>
</div>
<img [src]="center.centerImg" onerror="this.src='./../../assets/getmi_malls/mall_banner/mall_4.png'" />
<img [src]="center.centerImg"
onerror="this.src='./../../assets/getmi_malls/mall_banner/mall_4.png'" />
</ion-slide>
</ion-slides>
</div>
......@@ -50,10 +52,12 @@
Featured Stores
</div>
<div class="featured_slider">
<ion-slides pager="false" [options]="slideOpts" *ngIf="shopperService.activeshoppers && shopperService.activeshoppers.length > 0">
<ion-slides pager="false" [options]="slideOpts"
*ngIf="shopperService.activeshoppers && shopperService.activeshoppers.length > 0">
<ion-slide *ngFor="let shopper of shopperService.activeshoppers">
<div class="feature_product" (click)="goToPage('productlist', shopper)">
<img [src]="shopper.featuredImage" onerror="this.src='./../../assets/getmi_malls/featured/featured1.png'" />
<img [src]="shopper.featuredImage"
onerror="this.src='./../../assets/getmi_malls/featured/featured1.png'" />
<div class="feature_overlay">
<h5>{{shopper.name}}</h5>
<p>{{shopper.caption}}</p>
......@@ -82,7 +86,8 @@
<ul *ngIf="centerService.nearcenters && centerService.nearcenters.length > 0">
<li *ngFor="let center of centerService.nearcenters" (click)="goToPage('storelist', center)">
<div class="nearby_image">
<img [src]="center.centerImg" onerror="this.src='./../../assets/getmi_malls/mall_298/mall2.png'" />
<img [src]="center.centerImg"
onerror="this.src='./../../assets/getmi_malls/mall_298/mall2.png'" />
</div>
<div class="nearby_detail">
<h5>
......@@ -103,8 +108,10 @@
</div>
<div class="featured_catagory_list">
<ul *ngIf="categoriesService.activecategories && categoriesService.activecategories.length > 0">
<li *ngFor="let categories of categoriesService.activecategories" (click)="goToPage('catstorelist', categories)">
<img [src]="categories.catImage" onerror="this.src='../assets/handsome-man-outdoors-drinking-coffee-with-sunglasses-guy-with-beard-instagram-effect_1212-818@3x.png'" />
<li *ngFor="let categories of categoriesService.activecategories"
(click)="goToPage('catstorelist', categories)">
<img [src]="categories.catImage"
onerror="this.src='../assets/handsome-man-outdoors-drinking-coffee-with-sunglasses-guy-with-beard-instagram-effect_1212-818@3x.png'" />
<div class="featured_overlay">
<h4>{{categories.catName}}</h4>
</div>
......@@ -136,10 +143,12 @@
<ion-content class="sort_wrappper">
<div class="location-finder">
<input type="text" placeholder="Search for location" (keydown.enter)="$event.preventDefault()" autocorrect="off" autocapitalize="off" spellcheck="off" type="text" #building>
<input type="text" placeholder="Search for location" (keydown.enter)="$event.preventDefault()"
autocorrect="off" autocapitalize="off" spellcheck="off" type="text" #building>
</div>
<agm-map [zoom]="20" [latitude]="lat" [longitude]="lng" [disableDefaultUI]="false" [zoomControl]="false" [backgroundColor]="'rgba(29, 27, 130,0.2)'">
<agm-map [zoom]="20" [latitude]="lat" [longitude]="lng" [disableDefaultUI]="false" [zoomControl]="false"
[backgroundColor]="'rgba(29, 27, 130,0.2)'">
<agm-marker [latitude]="lat" [longitude]="lng" [iconUrl]="
{
url: './assets/pin-2.svg',
......@@ -155,18 +164,40 @@
</h5>
<div class="clear"></div>
<div>
<!-- <ul class="address-ul">
<li>
<div>
<input class="styled-checkbox" name="addressId" id="styled-checkbox-00" type="radio"
(click)="viewNearStore()" />
<label for="styled-checkbox-00">
CURRENT LOCATION
</label>
</div>
<div>
<p>
{{getAddressCurrent()}}
</p>
</div>
<div class="clear"></div>
</li>
</ul> -->
<ul class="address-ul" *ngIf="addressService.addressList && addressService.addressList.length > 0">
<li *ngFor="let address of addressService.addressList; let i = index">
<div>
{{address.default}}
<input class="styled-checkbox" name="addressId" id="styled-checkbox-{{i}}" type="radio" (click)="setDefault(address)" [value]="address.addressId" #addressType [checked]="address.defaultVal == 1" />
<input class="styled-checkbox" name="addressId" id="styled-checkbox-{{i}}" type="radio"
(click)="setDefault(address)" [value]="address.addressId" #addressType
[checked]="address.defaultVal == 1" />
<label for="styled-checkbox-{{i}}">
{{address.addressType}}
</label>
</div>
<div>
<p>
{{address.building}}, <span *ngIf="address.landmark && address.landmark!==''">{{address.landmark}},</span>
{{address.building}}, <span
*ngIf="address.landmark && address.landmark!==''">{{address.landmark}},</span>
<!-- {{address.address}} -->
</p>
</div>
......
......@@ -12,6 +12,7 @@ import { SubjectService } from './../../config/subject.service';
import { AddressService } from './../../config/address.service';
import { SearchService } from './../../config/search.service';
import { ProductsService } from './../../config/products.service';
import * as firebase from 'firebase';
import { from } from 'rxjs';
import { ModalController } from '@ionic/angular';
......@@ -37,8 +38,8 @@ import { AuthService } from 'src/config/auth.service';
export class HomePage implements OnInit {
isShow = true;
searchShow = false;
public lat = 51.678418;
public lng = 7.809007;
public lat: number;
public lng: number;
loader: boolean;
address: any;
custId: any;
......@@ -77,14 +78,15 @@ export class HomePage implements OnInit {
this.custId = data.uid;
this.addressService.addList(data.uid);
this.subjectService.getAddressStateData().subscribe((state) => {
console.log(state);
this.addressService.defaultAddress(data.uid).then((addressData) => {
console.log(this.addressService.defaultAdd);
const latLng = this.addressService.defaultAdd.latLng;
// tslint:disable-next-line:max-line-length
this.centerService.getNearBy(latLng.latitude, latLng.longitude, this.service.distance);
this.getAddress(latLng.latitude, latLng.longitude);
});
if (state !== null) {
this.addressService.defaultAddress(data.uid).then((addressData) => {
console.log(this.addressService.defaultAdd);
const latLng = this.addressService.defaultAdd.latLng;
// tslint:disable-next-line:max-line-length
this.centerService.getNearBy(latLng.latitude, latLng.longitude, this.service.distance);
this.getAddress(latLng.latitude, latLng.longitude);
});
}
});
}
......@@ -118,7 +120,8 @@ export class HomePage implements OnInit {
}
This.lat = place.geometry.location.lat();
This.lng = place.geometry.location.lng();
This.getAddress(This.lat, This.lng);
// This.getAddress(This.lat, This.lng);
This.address = this.searchElementRef.nativeElement.value;
console.log(This.lat, This.lng, This.service.distance);
This.centerService.getNearBy(This.lat, This.lng, This.service.distance);
This.istoggle();
......@@ -133,6 +136,7 @@ export class HomePage implements OnInit {
const This = this;
if ('geolocation' in navigator) {
navigator.geolocation.getCurrentPosition(position => {
console.log('executed');
this.lat = position.coords.latitude;
this.lng = position.coords.longitude;
this.centerService.getNearBy(this.lat, this.lng, this.service.distance);
......@@ -150,14 +154,15 @@ export class HomePage implements OnInit {
console.log(status);
if (status === 'OK') {
if (results[0]) {
const addressData = results[1].formatted_address.split(', ');
this.address = addressData[0] + ', ' + addressData[1];
/* const addressData = results[0].formatted_address.split(', ');
this.address = addressData[0] + ', ' + addressData[1]; */
this.address = results[0].formatted_address;
console.log(this.address);
} else {
window.alert('No results found');
}
} else {
window.alert('Geocoder failed due to: ' + status);
console.log('Geocoder failed due to: ' + status);
}
}
);
......@@ -165,29 +170,47 @@ export class HomePage implements OnInit {
setDefault(address: any) {
this.loader = true;
this.addressService
.setDefaultAddress(address.addressId, this.custId)
.then(() => {
this.address = address.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
);
this.loader = false;
})
.catch(err => {
this.loader = false;
this.service.showToast(
'Something went wrong please try again!',
'top',
'my-error',
1000
);
});
if (address.addressId !== '') {
this.addressService
.setDefaultAddress(address.addressId, this.custId)
.then(() => {
this.address = address.building;
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
);
this.loader = false;
})
.catch(err => {
this.loader = false;
this.service.showToast(
'Something went wrong please try again!',
'top',
'my-error',
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() {
......@@ -195,6 +218,20 @@ export class HomePage implements OnInit {
this.searchService.searchList = [];
}
viewNearStore() {
if ('geolocation' in navigator) {
navigator.geolocation.getCurrentPosition(position => {
const latitude = position.coords.latitude;
const longitude = position.coords.longitude;
this.getAddress(latitude, longitude);
console.log(latitude, longitude, this.service.distance);
this.centerService.getNearBy(latitude, longitude, this.service.distance);
this.istoggle();
});
}
}
searchClose() {
this.searchShow = false;
}
......
......@@ -79,6 +79,9 @@ export class NearbyPage implements OnInit {
}
this.latitude = place.geometry.location.lat();
this.longitude = place.geometry.location.lng();
this.newCenterLat = place.geometry.location.lat();
this.newCenterLng = place.geometry.location.lng();
console.log(this.latitude, this.longitude);
this.zoom = 16;
});
});
......@@ -133,16 +136,18 @@ export class NearbyPage implements OnInit {
}
mapReady(map) {
console.log('called');
map.addListener('dragend', () => {
console.log(this.newCenterLat, this.newCenterLng);
this.getAddress(this.newCenterLat, this.newCenterLng);
});
}
centerChange(e) {
console.log('called - 2');
console.log(e);
this.newCenterLat = e.lat;
this.newCenterLng = e.lng;
this.getAddress(this.newCenterLat, this.newCenterLng);
// this.getAddress(this.newCenterLat, this.newCenterLng);
}
goToPage(path, data = null) {
......
......@@ -19,6 +19,7 @@ export class AddressService {
custAddress: AddressList;
centerLoc: CenterData;
addressState: number;
private geoCoder;
constructor(public afs: AngularFirestore, public subject: SubjectService) {
this.addressState = 0;
this.subject.getUserData().subscribe(userData => {
......@@ -40,6 +41,7 @@ export class AddressService {
orderRef.valueChanges().subscribe(value => {
this.addressList = [];
const res = value;
this.getAddressCurrent();
if (res.length > 0) {
res.forEach(item => {
// console.log(item);
......@@ -62,6 +64,52 @@ export class AddressService {
});
}
getAddressCurrent() {
const This = this;
this.geoCoder = new google.maps.Geocoder();
if ('geolocation' in navigator) {
navigator.geolocation.getCurrentPosition(position => {
const latitude = position.coords.latitude;
const longitude = position.coords.longitude;
this.geoCoder.geocode(
{ location: { lat: latitude, lng: longitude } },
(results, status) => {
console.log(results);
console.log(status);
if (status === 'OK') {
if (results[0]) {
/* const addressData = results[0].formatted_address.split(', ');
this.address = addressData[0] + ', ' + addressData[1]; */
const current = {
address: '',
addressType: 'CURRENT LOCATION',
latLng: new firebase.firestore.GeoPoint(latitude, longitude),
defaultVal: 0,
building: results[0].formatted_address,
landmark: '',
addressId: '',
nearest: false
};
console.log(current);
const index = this.addressList.findIndex(x => x.addressType === 'CURRENT LOCATION');
console.log(index);
if (index >= 0) {
This.addressList[index] = current;
} else {
This.addressList.unshift(current);
}
console.log(This.addressList);
}
}
}
);
});
}
}
public async defaultAddress(userId: string) {
await new Promise(resolve => {
const This = this;
......
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