Commit 82134784 by Adarsh K

new changes

parent 844f21ef
......@@ -31,6 +31,7 @@
"@ionic-native/status-bar": "^5.12.0",
"@ionic/angular": "^4.7.1",
"@ionic/storage": "^2.2.0",
"@types/googlemaps": "^3.38.0",
"agm-direction": "^0.7.8",
"cordova-android": "^8.0.0",
"cordova-plugin-device": "^2.0.2",
......@@ -100,4 +101,4 @@
"android"
]
}
}
}
\ No newline at end of file
......@@ -49,6 +49,7 @@ export class AddaddresssPage implements OnInit {
) { }
ngOnInit() {
}
goToPage(path, data = null) {
......
......@@ -65,14 +65,14 @@
<span class="floatLeft">ITEMS</span>
<span class="floatRight" *ngIf="cartService.cartTotal">A$ {{cartService.cartTotal}}</span>
<div class="clear"></div>
</h5>
</h5>
<ion-grid class="p0" *ngIf="cartService.carts && cartService.carts.length > 0">
<ion-row *ngFor="let carts of cartService.carts">
<ion-col size="6" class="p0">
<h6 class="textLeft">{{carts.prodName}}</h6>
</ion-col>
<ion-col size="2" class="p0">
<h6 class="textRight"><strong>1 X</strong></h6>
<h6 class="textRight"><strong>{{carts.qty}} X</strong></h6>
</ion-col>
<ion-col size="4" class="p0">
<h6 class="textRight"><strong>A$ {{carts.price}}</strong></h6>
......@@ -89,7 +89,7 @@
<ion-row>
<ion-col class="p0">
<h6>
Shamjith KS<br> +00 0000 888 888<br> Carnival Infopark Infopark Kochi<br> 682030, Kerala, India
{{custAddress.building}},<br/> {{custAddress.landmark}},<br/> {{custAddress.address}}
</h6>
</ion-col>
</ion-row>
......@@ -101,7 +101,13 @@
<div class="clear"></div>
</h5>
<div class="payment_method">
<input type="radio" id="test1" name="radio-group" checked (click)="getwaypaypal()">
<input type="radio" name="payments" id="cod" name="radio-group" checked="true">
<label for="paypal">
<p>COD</p>
</label>
</div>
<!-- <div class="payment_method">
<input type="radio" name="payments" id="paypal" name="radio-group" checked (click)="getwaypaypal()">
<label for="test1">
<p>PayPal</p>
</label>
......@@ -110,7 +116,7 @@
<input class="card_no borderNone widthFull" placeholder="PayPal ID">
</div>
<div class="payment_method">
<input type="radio" id="test2" name="radio-group" (click)="getwayafterpay()">
<input type="radio" name="payments" id="afterpay" name="radio-group" (click)="getwayafterpay()">
<label for="test2">
<p>AfterPay</p>
</label>
......@@ -120,14 +126,14 @@
<input class="cv_number" placeholder="CVV">
</div>
<div class="payment_method">
<input type="radio" id="test3" name="radio-group" (click)="getwaypayk()">
<input type="radio" name="payments" id="payk" name="radio-group" (click)="getwaypayk()">
<label for="test3">
<p>PayK</p>
</label>
</div>
<div class="card_div" [hidden]="gateway !=3">
<input class="card_no borderNone widthFull" placeholder="PafyK ID">
</div>
</div> -->
<div class="delivery_time">
<ul>
<li>
......@@ -144,13 +150,37 @@
<div class="coupon_code">
<input class="" placeholder="COUPON CODE"><button class="add_btn">ADD</button>
</div>
<br/>
<h6>
<span class="floatLeft">PRODUCT COST</span>
<span class="floatRight" *ngIf="cartService.cartTotal">A$ {{cartService.cartTotal}}</span>
<div class="clear"></div>
</h6>
<h6>
<span class="floatLeft">DELIVERY CHARGE</span>
<span class="floatRight" *ngIf="cartService.cartTotal">A$ {{getDeliveryCharge(cartService.cartTotal)}}</span>
<div class="clear"></div>
</h6>
<h6>
<span class="floatLeft">GST/TAX</span>
<span class="floatRight" *ngIf="cartService.cartTotal">A$ {{getTax(cartService.cartTotal)}}</span>
<div class="clear"></div>
</h6>
<h6 *ngIf="discountApplied">
<span class="floatLeft">DISCOUNT</span>
<span class="floatRight">(-) A$ {{discount}}</span>
<div class="clear"></div>
</h6>
<hr>
<div class="total_div">
<ion-row>
<ion-col>
<p class="textLeft">Total Price:</p>
</ion-col>
<ion-col>
<p class="textRight" *ngIf="cartService.cartTotal">A$ {{cartService.cartTotal}}</p>
<p class="textRight" *ngIf="cartService.cartTotal">A$ {{getTotal(cartService.cartTotal)}}</p>
</ion-col>
</ion-row>
</div>
......
......@@ -6,6 +6,10 @@ import { CartsService } from './../../config/cart.service';
import { OrdersService } from './../../config/order.service';
import { ModalController } from '@ionic/angular';
import { DeliverypopPage } from '../deliverypop/deliverypop.page';
import { ServiceService } from './../../config/service.service';
import { AddressService } from './../../config/address.service';
import { AddressList } from './../../config/services/address'
import { zip } from 'rxjs';
@Component({
......@@ -20,11 +24,18 @@ export class CartPage implements OnInit {
count: any;
gateway: any;
loader = false;
custId: any;
custAddress: AddressList;
cartwizard = {
initialSlide: 0,
speed: 1000,
allowTouchMove: false
};
deliveryCharge: number;
taxAmount: number;
discountApplied: boolean;
discount: number;
totalAmt: number;
constructor(
private router: Router,
......@@ -32,16 +43,36 @@ export class CartPage implements OnInit {
private location: Location,
public cartService: CartsService,
public orderService: OrdersService,
public modalController: ModalController
public modalController: ModalController,
public service: ServiceService,
public addressService: AddressService
) {
this.currentIndex = 0;
this.count = 1;
this.gateway = 1;
this.deliveryCharge = 0;
this.taxAmount = 0;
this.discountApplied = false;
this.discount = 0;
this.cartService.cartList();
const users = this.service.get('user').then((data) => {
if (data) {
data = JSON.parse(data);
this.custId = data.uid;
this.addressService.addList(data.uid);
}
});
}
ngOnInit() {
let address = this.addressService.addressList.find(x => x.defaultVal === 1);
if (!address) {
address = this.addressService.addressList[0];
}
this.custAddress = address;
console.log(address);
}
getwaypaypal() {
......@@ -52,6 +83,19 @@ export class CartPage implements OnInit {
this.gateway = 2;
}
getDeliveryCharge(amount) {
if (amount >= 150) {
this.deliveryCharge = 0;
} else {
this.deliveryCharge = 10;
}
return this.deliveryCharge;
}
getTax(amount) {
return this.taxAmount = (amount * 10) / 100;
}
getwaypayk() {
this.gateway = 3;
}
......@@ -125,4 +169,10 @@ export class CartPage implements OnInit {
});
}
getTotal(total) {
const actualTotal = (this.deliveryCharge + this.taxAmount + total) - this.discount;
this.totalAmt = actualTotal;
return actualTotal;
}
}
......@@ -9,6 +9,7 @@ import { HomePage } from './home.page';
import { AgmCoreModule } from '@agm/core';
import { AgmDirectionModule } from 'agm-direction';
import { from } from 'rxjs';
......
......@@ -5,11 +5,13 @@
</ion-menu-toggle>
<div class="nav_title floatLeft relative">
<input class="search_bar" placeholder="Search here.. eg:shirts, retailers etc..." (click)="clickSearch()">
<input class="search_bar" placeholder="Search here.. eg:shirts, retailers etc..." (click)="clickSearch()" (input)="searchFun($event.target.value)" #searchText>
</div>
<button class="nav_btn nav_search floatRight">
<button class="nav_btn nav_search floatRight" *ngIf="!searchShow">
</button>
<button class="nav_btn nav_exit floatRight" *ngIf="searchShow" (click)="searchClose()">
</button>
<div class="clear"></div>
</div>
<ion-content>
......@@ -21,7 +23,7 @@
<img src="../assets/Group 11_2.png">
</ion-col>
<ion-col class="textRight">
<p class="floatRight" (click)="istoggle()">Territory Queens</p>
<p class="floatRight" (click)="istoggle()">{{address}}</p>
</ion-col>
</ion-row>
</div>
......@@ -116,49 +118,25 @@
</div>
<ion-content class="sort_wrappper">
<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"></agm-marker>
</agm-map>
<div class="add_address_wrapper">
<h5>
<span class="floatLeft">NEW ADDRESS</span>
<span class="floatRight">ADD NEW</span>
<span class="floatRight" (click)="istoggle(); goToPage('nearby')">ADD NEW</span>
<div class="clear"></div>
</h5>
<ul>
<li>
<div class="floatLeft">
<input class="styled-checkbox " id="styled-checkbox-1" type="radio" value="value1">
<label for="styled-checkbox-1">
<ul *ngIf="addressService.addressList && addressService.addressList.length > 0">
<li *ngFor="let address of addressService.addressList; let i = index">
<div class="floatLeft">{{address.default}}
<input class="styled-checkbox" name="addressId" id="styled-checkbox-{{i}}" type="radio" (click)="setDefault(address.addressId)" [value]="address.addressId" #addressType [checked]="address.defaultVal == 1">
<label for="styled-checkbox-{{i}}"> {{address.addressType}}
</label>
</div>
<div class="floatLeft">
<p>
Shamjith KS<br> Carnival Infopark, Infopark Kochi <br> 682030, Kerala, India
</p>
</div>
<div class="clear"></div>
</li>
<li>
<div class="floatLeft">
<input class="styled-checkbox " id="styled-checkbox-2" type="radio" value="value2">
<label for="styled-checkbox-2">
</label>
</div>
<div class="floatLeft">
<p>
Shamjith KS<br> Carnival Infopark, Infopark Kochi <br> 682030, Kerala, India
</p>
</div>
<div class="clear"></div>
</li>
<li>
<div class="floatLeft">
<input class="styled-checkbox " id="styled-checkbox-3" type="radio" value="value3">
<label for="styled-checkbox-3">
</label>
</div>
<div class="floatLeft">
<p>
Shamjith KS<br> Carnival Infopark, Infopark Kochi <br> 682030, Kerala, India
{{address.building}}, {{address.landmark}}, {{address.address}}
</p>
</div>
<div class="clear"></div>
......@@ -172,10 +150,7 @@
<div class="search_item_list" *ngIf="searchShow" [@slideInOut]>
<ul (click)="clickSearch()">
<li>Listing 1</li>
<li>Listing 2</li>
<li>Listing 3</li>
<li>Listing 4</li>
<ul *ngIf="searchService.searchList">
<li *ngFor="let search of searchService.searchList" (click)="viewPage(search)">{{search.text}}</li>
</ul>
</div>
\ No newline at end of file
......@@ -267,7 +267,8 @@
margin: 0px;
padding: 0px;
color: rgba(176, 174, 199, 1);
padding-left: 5px;
padding-top:5px;
padding-bottom: 5px;
}
.styled-checkbox {
position: absolute; // take it out of document flow
......
import { Component, OnInit } from '@angular/core';
import { Location } from '@angular/common';
import { trigger, transition, animate, style } from '@angular/animations';
import { MapsAPILoader, MouseEvent } from '@agm/core';
import { Router, ActivatedRoute } from '@angular/router';
import { MenuController } from '@ionic/angular';
import { CenterService } from './../../config/center.service';
import { ShoppersService } from './../../config/shopper.service';
import { CategoriesService } from './../../config/category.service';
import { ServiceService } from './../../config/service.service';
import { AddressService } from './../../config/address.service';
import { SearchService } from './../../config/search.service';
import { ProductsService } from './../../config/products.service';
import { from } from 'rxjs';
import { ModalController } from "@ionic/angular";
import { ModalController } from '@ionic/angular';
@Component({
selector: "app-home",
templateUrl: "./home.page.html",
styleUrls: ["./home.page.scss"],
selector: 'app-home',
templateUrl: './home.page.html',
styleUrls: ['./home.page.scss'],
animations: [
trigger("slideInOut", [
transition(":enter", [
style({ transform: "translateY(100%)" }),
animate("200ms ease-in", style({ transform: "translateY(0%)" }))
trigger('slideInOut', [
transition(':enter', [
style({ transform: 'translateY(100%)' }),
animate('200ms ease-in', style({ transform: 'translateY(0%)' }))
]),
transition(":leave", [
animate("200ms ease-out", style({ transform: "translateY(100%)" }))
transition(':leave', [
animate('200ms ease-out', style({ transform: 'translateY(100%)' }))
])
])
]
})
export class HomePage implements OnInit {
isShow = false;
searchShow = false;
public lat = 51.678418;
public lng = 7.809007;
address: any;
custId: any;
private geoCoder;
slideOpts = {
slidesPerView: 1.5
};
......@@ -44,25 +52,83 @@ export class HomePage implements OnInit {
public centerService: CenterService,
public shopperService: ShoppersService,
public categoriesService: CategoriesService,
public addressService: AddressService,
public service: ServiceService,
public modalController: ModalController
) {}
public modalController: ModalController,
private mapsAPILoader: MapsAPILoader,
private searchService: SearchService,
private productsService: ProductsService
) {
}
ngOnInit() {
this.mapsAPILoader.load().then(() => {
this.setCurrentLocation();
this.geoCoder = new google.maps.Geocoder();
});
this.menuCtrl.enable(true);
const users = this.service.get('user').then((data) => {
if (data) {
data = JSON.parse(data);
this.custId = data.uid;
this.addressService.addList(data.uid);
}
});
}
private setCurrentLocation() {
if ('geolocation' in navigator) {
navigator.geolocation.getCurrentPosition(position => {
this.lat = position.coords.latitude;
this.lng = position.coords.longitude;
this.getAddress(this.lat, this.lng);
});
}
}
getAddress(latitude, 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];
console.log(this.address);
} else {
window.alert('No results found');
}
} else {
window.alert('Geocoder failed due to: ' + status);
}
}
);
}
setDefault(addressId: any) {
this.addressService.setDefaultAddress(addressId, this.custId);
}
clickSearch() {
this.searchShow = !this.searchShow;
this.searchShow = true;
this.searchService.searchList = [];
}
searchClose() {
this.searchShow = false;
}
ionViewWillEnter() {
this.menuCtrl.enable(true);
}
goToPage(path, data = null) {
console.log(data);
this.service.set("params", data);
this.service.set('params', data);
this.router.navigateByUrl(path, { queryParams: data });
document.body.scrollTop = document.documentElement.scrollTop = 0;
}
......@@ -74,5 +140,34 @@ export class HomePage implements OnInit {
istoggle() {
this.isShow = !this.isShow;
}
viewPage(datas: any) {
console.log(datas);
let data;
let url;
if (datas.type === 'shopper') {
data = datas.data;
this.service.set('params', data);
url = 'productlist';
} else if (datas.type === 'category') {
data = datas.data;
this.service.set('params', data);
url = 'catstorelist';
} else {
data = datas.data;
data.size = this.service.splitSep(data.size);
data.tag = this.service.splitSep(data.tag);
data.color = this.service.splitSep(data.color),
url = 'productdetail';
this.productsService.setProd(data);
}
this.searchClose();
this.router.navigateByUrl(url, { queryParams: data});
document.body.scrollTop = document.documentElement.scrollTop = 0;
}
searchFun(data: string) {
this.searchService.search(data);
}
}
......@@ -10,15 +10,45 @@
<ion-content>
<div class="nearby_map">
<agm-map [latitude]="lat" [longitude]="lng" [zoom]="15" [backgroundColor]="'rgba(29, 27, 130,0.2)'">
<agm-map [latitude]="latitude" [longitude]="longitude" [zoom]="8" [backgroundColor]="'rgba(29, 27, 130,0.2)'">
<agm-marker [latitude]="latitude" [longitude]="longitude" [markerDraggable]="true" (dragEnd)="markerDragEnd($event)"></agm-marker>
</agm-map>
<div class="add_address_wrapper">
<h5>DELIVERY</h5>
<p>{{address}}</p>
<input class="" placeholder="House No./ Building No">
<input class="" placeholder="Landmark">
<button class="add_btn">ADD</button>
</div>
<form (ngSubmit)="onSubmit(addressForm.value); addressForm.reset()" #addressForm="ngForm" method="post" class="form-horizontal">
<div class="add_address_wrapper">
<h5>DELIVERY</h5>
<p>{{address}}</p>
<input [(ngModel)]="addressForm.building" name="building" #building="ngModel" name="building" required placeholder="House No./ Building No">
<div class="md-errors-spacer" [hidden]="building.valid || landmark.pristine" class="ion-padding-start">
Building Name is required
</div>
<input [(ngModel)]="addressForm.landmark" name="landmark" #landmark="ngModel" name="landmark" required placeholder="Landmark">
<div class="md-errors-spacer" [hidden]="landmark.valid || landmark.pristine" class="ion-padding-start">
Landmark is required
</div>
<ion-grid>
<ion-row>
<ion-col>
<h6>
<input class="styled-checkbox" id="styled-check-1" type="radio" value="Home" [(ngModel)]="addressForm.addressType" name="addressType" #addressType="ngModel" required>
<label for="styled-check-1"><span>Home</span></label></h6>
</ion-col>
<ion-col>
<h6>
<input class="styled-checkbox" id="styled-check-2" type="radio" value="Work" [(ngModel)]="addressForm.addressType" name="addressType" #addressType="ngModel" required>
<label for="styled-check-2"><span>Office</span></label></h6>
</ion-col>
<ion-col>
<h6>
<input class="styled-checkbox" id="styled-check-3" type="radio" value="Other" [(ngModel)]="addressForm.addressType" name="addressType" #addressType="ngModel" required>
<label for="styled-check-3"><span>Others</span></label></h6>
</ion-col>
</ion-row>
<div class="md-errors-spacer" [hidden]="addressType.valid || addressType.pristine" class="ion-padding-start">
Address Type is required
</div>
</ion-grid>
<button class="add_btn" type="submit" [disabled]="!addressForm.form.valid">ADD</button>
</div>
</form>
</div>
</ion-content>
\ No newline at end of file
......@@ -63,4 +63,54 @@
color: #fff;
border-radius: 4px;
}
}
.styled-checkbox {
position: absolute; // take it out of document flow
opacity: 0; // hide it
&+label {
position: relative;
cursor: pointer;
padding: 0;
}
// Box.
&+label:before {
content: '';
margin-right: 10px;
display: inline-block;
vertical-align: text-top;
width: 20px;
height: 20px;
border-radius: 10px;
background: white;
border: 1px solid rgba(215, 213, 228, 1);
}
// Box hover
// Box checked
&:checked+label:before {
background: #29285b;
}
// Disabled state label.
&:disabled+label {
color: #b8b8b8;
cursor: auto;
}
// Disabled box.
&:disabled+label:before {
box-shadow: none;
background: #ddd;
}
// Checkmark. Could be replaced with an image
&:checked+label:after {
content: '';
position: absolute;
left: 6px;
top: 11px;
background: white;
width: 2px;
height: 2px;
box-shadow: 2px 0 0 white, 4px 0 0 white, 4px -2px 0 white, 4px -4px 0 white, 4px -6px 0 white, 4px -8px 0 white;
transform: rotate(45deg);
}
}
\ No newline at end of file
import {Component,OnInit,ViewChild,ElementRef,NgZone} from "@angular/core";
import {Component, OnInit, ViewChild, ElementRef, NgZone} from '@angular/core';
import { Location } from '@angular/common';
import { Router, ActivatedRoute } from '@angular/router';
import { MapsAPILoader, MouseEvent } from "@agm/core";
import { MapsAPILoader, MouseEvent } from '@agm/core';
import { Address } from './../../config/services/address';
import { AddressService } from './../../config/address.service';
import { ServiceService } from './../../config/service.service';
import { NgForm } from '@angular/forms';
import * as firebase from 'firebase';
@Component({
selector: "app-nearby",
templateUrl: "./nearby.page.html",
styleUrls: ["./nearby.page.scss"]
selector: 'app-nearby',
templateUrl: './nearby.page.html',
styleUrls: ['./nearby.page.scss']
})
export class NearbyPage implements OnInit {
latitude: number;
longitude: number;
zoom: number;
address: string;
private geoCoder;
addressForm: NgForm;
addressData = new Address('', '', '', '', true, '', 0, '');
successState: boolean;
uid: string;
public searchElementRef: ElementRef;
constructor(
......@@ -22,11 +31,21 @@ export class NearbyPage implements OnInit {
private route: ActivatedRoute,
private location: Location,
private mapsAPILoader: MapsAPILoader,
private ngZone: NgZone
) {}
private ngZone: NgZone,
public addressService: AddressService,
public service: ServiceService
) {
this.successState = false;
const users = this.service.get('user').then((data) => {
if (data) {
data = JSON.parse(data);
this.uid = data.uid;
}
});
}
ngOnInit() {
//load Places Autocomplete
// load Places Autocomplete
this.mapsAPILoader.load().then(() => {
this.setCurrentLocation();
this.geoCoder = new google.maps.Geocoder();
......@@ -35,7 +54,7 @@ export class NearbyPage implements OnInit {
// google maps zoom level
private setCurrentLocation() {
if ("geolocation" in navigator) {
if ('geolocation' in navigator) {
navigator.geolocation.getCurrentPosition(position => {
this.latitude = position.coords.latitude;
this.longitude = position.coords.longitude;
......@@ -58,15 +77,16 @@ export class NearbyPage implements OnInit {
(results, status) => {
console.log(results);
console.log(status);
if (status === "OK") {
if (status === 'OK') {
if (results[0]) {
this.zoom = 12;
this.address = results[0].formatted_address;
console.log(this.address);
} else {
window.alert("No results found");
window.alert('No results found');
}
} else {
window.alert("Geocoder failed due to: " + status);
window.alert('Geocoder failed due to: ' + status);
}
}
);
......@@ -80,11 +100,30 @@ export class NearbyPage implements OnInit {
goBack() {
window.history.back();
}
onSubmit(data: any) {
console.log(data);
const postData: Address = {
address: this.address,
addressType: data.addressType,
building: data.building,
landmark: data.landmark,
defaultVal: 0,
uid: this.uid,
latLng: new firebase.firestore.GeoPoint(this.latitude, this.longitude),
status: true
};
this.addressService.addressCreate(postData);
this.successState = true;
setTimeout(() => {
this.successState = false;
}, 3000);
}
}
interface marker {
lat: number;
lng: number;
label?: string;
draggable: boolean;
interface Marker {
lat: number;
lng: number;
label?: string;
draggable: boolean;
}
......@@ -5,14 +5,14 @@
<div class="nav_title floatLeft">
</div>
<button class="nav_btn nav_cart floatRight" (click)="goToPage('cart')">
<div class="not">1</div>
<div class="not" *ngIf="cartService.carts">{{cartService.carts.length}}</div>
</button>
<div class="clear"></div>
</div>
<ion-content>
<div class="product_detail_wrapper" *ngIf="product">
<div class="product_banner">
<div class="fav_icon"></div>
<div [ngClass]="checkFavStatus(product.prodId)" (click)="changeFav(product.prodId)"></div>
<div class="featured_badge" *ngIf="product.featured">Featured</div>
<img [src]="product.image" onerror="this.src='../assets/[email protected]'">
</div>
......@@ -22,7 +22,7 @@
<h3>{{product.prodName}}</h3>
<p><strong><span><img src="../assets/Path61_2.png"></span>0</strong>&nbsp; {{product.category}}, {{product.subCate}}
<br/>
<span *ngFor="let tag of product.tag">#{{tag}}</span>
<span *ngFor="let tag of product.tag">#{{tag}}&nbsp;</span>
</p>
</ion-col>
<ion-col size="4">
......@@ -31,7 +31,25 @@
</ion-col>
</ion-row>
</div>
<div class="product_div_content">
<h5>Color</h5>
<div class="size_div">
<ul *ngIf="product.size">
<ion-slides pager="false" [options]="slideOpts">
<ion-slide *ngFor="let color of product.color; let i = index">
<li>
<button id="custom_check_button">
<label>
<input id="{{color}}" type="radio" name="color" value="{{color}}" (click)="cartService.choose_color(color)" [checked]="i==0">
<p>{{color}}</p>
</label>
</button>
</li>
</ion-slide>
</ion-slides>
</ul>
</div>
<h5>Size</h5>
<div class="size_div">
<ul *ngIf="product.size">
......@@ -127,8 +145,7 @@
<li (click)="viewProd(similar)">
<div class="product_image">
<img [src]="similar.image" onerror="this.src='../assets/[email protected]'">
<div class="fav_icon">
</div>
<div [ngClass]="checkFavStatus(similar.prodId)" (click)="changeFav(similar.prodId)"></div>
</div>
<h5>{{similar.prodName}}</h5>
<p>{{similar.price}}</p>
......
......@@ -14,6 +14,17 @@
top: 15px;
right: 15px;
}
.fav_fill {
width: 30px;
height: 30px;
background-image: url("../../assets/fav_fill.png");
background-position: center;
background-repeat: no-repeat;
background-size: 24px;
position: absolute;
top: 15px;
right: 15px;
}
.featured_badge {
position: absolute;
bottom: 20px;
......@@ -233,6 +244,18 @@
background-repeat: no-repeat;
background-size: 24px;
}
.fav_fill {
position: absolute;
top: 10px;
right: 10px;
font-size: 27px;
width: 30px;
height: 30px;
background-image: url("../../assets/fav_fill.png");
background-position: center;
background-repeat: no-repeat;
background-size: 24px;
}
img {
width: 100%;
height: 100%;
......
......@@ -39,6 +39,8 @@ export class ProductdetailPage implements OnInit {
this.service.get('params').then((val) => {
this.data = val;
});
this.cartService.cartList();
console.log(this.prodService.fav);
}
ngOnInit() {
......@@ -103,6 +105,7 @@ export class ProductdetailPage implements OnInit {
} else {
// alert('Product added to cart');
}
this.cartService.cartList();
});
}
......@@ -110,4 +113,24 @@ export class ProductdetailPage implements OnInit {
this.getProd(prod);
}
checkFavStatus(index) {
const state = this.prodService.fav.findIndex(x => x === index);
return state > -1 ? 'fav_fill' : 'fav_icon';
}
changeFav(index) {
const state = this.prodService.fav.findIndex(x => x === index);
console.log(state);
console.log(this.prodService.fav);
if (state > -1) {
this.prodService.fav.splice(state, 1);
this.prodService.changeFav(index, 'yes');
} else {
this.prodService.fav.push(index);
this.prodService.changeFav(index, 'no');
}
return;
console.log(this.prodService.fav);
}
}
......@@ -30,7 +30,7 @@
<li *ngFor="let product of prodService.product; let i = index">
<div class="product_image">
<img [src]="product.image" onerror="this.src='../assets/[email protected]'" (click)="prodDetails(i)">
<div class="fav_fill" (click)="changeFav(product.prodId)" *ngIf="checkFavStatus(product.prodId)">
<div [ngClass]="checkFavStatus(product.prodId)" (click)="changeFav(product.prodId)">
</div>
<div class="featured_badge" *ngIf="product.featured">Featured</div>
</div>
......@@ -43,30 +43,30 @@
<div class="sort_inner">
<h4>Sort By</h4>
<ul>
<li>
<input class="styled-checkbox" id="styled-checkbox-1" type="radio" value="value1">
<!-- <li>
<input class="styled-checkbox" id="styled-checkbox-1" type="radio" value="popular" name="sort" (click)="setValue($event.target.value)">
<label for="styled-checkbox-1">Popularity</label>
</li>
<li>
<input class="styled-checkbox" id="styled-checkbox-2" type="radio" value="value2">
</li> -->
<!-- <li>
<input class="styled-checkbox" id="styled-checkbox-2" type="radio" value="relevance" name="sort" (click)="setValue($event.target.value)">
<label for="styled-checkbox-2">Relevence</label>
</li>
</li> -->
<li>
<input class="styled-checkbox" id="styled-checkbox-3" type="radio" value="value3">
<input class="styled-checkbox" id="styled-checkbox-3" type="radio" value="low" name="sort" (click)="setValue($event.target.value)">
<label for="styled-checkbox-3">Price Low - High</label>
</li>
<li>
<input class="styled-checkbox" id="styled-checkbox-4" type="radio" value="value4">
<input class="styled-checkbox" id="styled-checkbox-4" type="radio" value="high" name="sort" (click)="setValue($event.target.value)">
<label for="styled-checkbox-4">Price High - Low</label>
</li>
<li>
<input class="styled-checkbox" id="styled-checkbox-5" type="radio" value="value5">
<!-- <li>
<input class="styled-checkbox" id="styled-checkbox-5" type="radio" value="rate" name="sort" (click)="setValue($event.target.value)">
<label for="styled-checkbox-5">Rating</label>
</li>
</li> -->
</ul>
<div class="sort_footer">
<button class="cancel floatLeft" (click)="istoggle()">CANCEL</button>
<button class="submit floatRight" (click)="istoggle()">SUBMIT</button>
<button class="submit floatRight" (click)="istoggle(); submit()">SUBMIT</button>
<div class="clear"></div>
</div>
</div>
......
......@@ -26,6 +26,7 @@ export class ProductlistPage implements OnInit {
onGrid = false;
isShow = false;
data: any;
sortValue: string;
constructor(
private router: Router,
......@@ -69,6 +70,8 @@ export class ProductlistPage implements OnInit {
changeFav(index) {
const state = this.prodService.fav.findIndex(x => x === index);
console.log(state);
console.log(this.prodService.fav);
if (state > -1) {
this.prodService.fav.splice(state, 1);
this.prodService.changeFav(index, 'yes');
......@@ -76,12 +79,22 @@ export class ProductlistPage implements OnInit {
this.prodService.fav.push(index);
this.prodService.changeFav(index, 'no');
}
return;
console.log(this.prodService.fav);
}
setValue(value) {
this.sortValue = value;
console.log(this.sortValue);
}
submit() {
console.log(this.sortValue);
this.prodService.filterSearch(this.sortValue);
}
checkFavStatus(index) {
const state = this.prodService.fav.findIndex(x => x === index);
console.log(state);
return state > -1 ? true : true;
return state > -1 ? 'fav_fill' : 'fav_icon';
}
}
import { Injectable } from '@angular/core';
import { AngularFirestore, AngularFirestoreCollection } from '@angular/fire/firestore';
import { AddressList, Address } from './services/address';
import { database } from 'firebase';
import { take } from 'rxjs/operators';
@Injectable({
providedIn: 'root'
})
export class AddressService {
addressList: AddressList[] = [];
constructor(
public afs: AngularFirestore
) {
}
public async addList(userId: string) {
const This = this;
const state = true;
const orderRef: AngularFirestoreCollection<any> = this.afs.collection('address', ref => ref.where('status', '==', state)
.where('uid', '==', userId));
orderRef.valueChanges().pipe(
take(1) // Here you can limit to only emit once, using the take operator
).subscribe((value) => {
this.addressList = [];
const res = value;
if (res.length > 0) {
res.forEach((item) => {
console.log(item);
const address: AddressList = {
address: item.address,
addressType: item.addressType,
latLng: item.latLng,
defaultVal: item.defaultVal,
building: item. building,
landmark: item.landmark,
addressId: item.addressId
};
this.addressList.push(address);
});
console.log(this.addressList);
} else {
// alert('No Orders Found');
}
});
}
addressCreate(data: Address) {
this.afs.collection('address').add({}).then((docRef) => {
data.addressId = docRef.id;
this.afs.collection('address').doc(data.addressId).set(data).then(() => {
console.log('Address created Successfully');
});
});
}
setDefaultAddress(addId: string, userId: string) {
this.afs.collection('address', ref => ref.where('uid', '==', userId)).get().forEach((item) => {
return item.docs.map(m => {
return this.afs.doc(`address/${m.id}`).update({defaultVal: 0});
});
});
this.afs.collection('address').doc(addId).update({defaultVal: 1}).then(() => {
console.log('Address updated Successfully');
});
}
}
......@@ -8,6 +8,7 @@ import * as firebase from 'firebase';
import { take } from 'rxjs/operators';
import { User } from './services/user';
import { from } from 'rxjs';
import undefined = require('firebase/empty-import');
@Injectable({
providedIn: 'root'
......@@ -27,8 +28,8 @@ export class CartsService {
public router: Router,
public service: ServiceService
) {
this.size = 'Small';
this.custId = '';
this.carts = [];
const users = this.service.get('user').then((data) => {
if (data) {
data = JSON.parse(data);
......@@ -44,18 +45,20 @@ export class CartsService {
this.prodId = product.prodId;
const prodRef = firebase.firestore().collection('products').doc(this.prodId);
this.size = this.size === undefined ? product.size[0] : this.size;
this.color = this.color === undefined ? product.color[0] : this.color;
const cartRef: AngularFirestoreCollection<any> = this.afs.collection('carts', ref => ref.where('size', '==', this.size)
.where('color', '==', Object.keys(product.color)[0])
.where('color', '==', this.color)
.where('custId', '==', this.custId)
.where('product', '==', prodRef)
);
;
cartRef.valueChanges().pipe(take(1)).subscribe((value) => {
console.log(value);
if (value.length === 0) {
product.image = product.image === undefined ? '../assets/[email protected]' : product.image;
const cart: Cart = {
color: Object.keys(product.color)[0],
color: this.color,
custId: this.custId,
shopperId: product.shopperId,
product: firebase.firestore().doc(`products/${this.prodId}`),
......@@ -87,7 +90,6 @@ export class CartsService {
console.log('Booking Successfully');
document.body.scrollTop = document.documentElement.scrollTop = 0;
});
}
});
}
......@@ -137,6 +139,10 @@ export class CartsService {
this.size = size;
}
choose_color(color: string) {
this.color = color;
}
removeCount(index) {
// tslint:disable-next-line:radix
const qty = this.carts[index].qty > 1 ? this.carts[index].qty - 1 : this.carts[index].qty;
......
......@@ -2,6 +2,7 @@ import { Injectable } from '@angular/core';
import { AngularFirestore, AngularFirestoreDocument, AngularFirestoreCollection } from '@angular/fire/firestore';
import { Products } from './services/product';
import { ServiceService } from './../config/service.service';
import { take } from 'rxjs/operators';
@Injectable({
providedIn: 'root'
......@@ -16,6 +17,8 @@ export class ProductsService {
public afs: AngularFirestore,
public service: ServiceService
) {
this.product = [];
this.fav = [];
this.service.get('user').then(data => {
this.user = JSON.parse(data);
this.getFavlist(this.user.uid);
......@@ -43,6 +46,68 @@ export class ProductsService {
brand: item.brand,
category: item.category,
shopperId: item.shopperId,
color: this.service.splitSep(item.color),
discount: item.discount,
featured: item.featured,
image: item.image,
price: item.price,
qty: item.qty,
shopper: item.shopper,
skuCode: item.skuCode,
status: item.status,
size: this.service.splitSep(item.size),
subCate: item.subCate,
tag: this.service.splitSep(item.tag)
};
this.product.push(prod);
});
console.log(this.product);
} else {
// alert('No Products Found');
}
});
}
public async filterSearch(sortValue: string) {
const This = this;
const state = true;
console.log(sortValue);
let field, order;
if (sortValue === 'low') {
field = 'price';
order = 'asc';
}
if (sortValue === 'high') {
field = 'price';
order = 'desc';
}
if (sortValue === 'rate') {
// field = 'price';
// order = 'desc';
}
// tslint:disable-next-line:max-line-length
const prodRef: AngularFirestoreCollection<any> = this.afs.collection(`products`, ref => ref.where('status', '==', state).orderBy(field, order));
prodRef.valueChanges().subscribe((value) => {
this.product = [];
const res = value;
if (res.length > 0) {
res.forEach((item) => {
console.log(item.size);
const prod: Products = {
prodId: item.prodId,
prodName: item.prodName,
prodCode: item.prodCode,
prodDesc: item.prodDesc,
prodStatus: item.prodStatus,
brand: item.brand,
category: item.category,
shopperId: item.shopperId,
color: item.color,
discount: item.discount,
featured: item.featured,
......@@ -65,6 +130,8 @@ export class ProductsService {
});
}
similarProd(shopperId, category, subCate, prodId) {
const This = this;
......@@ -117,24 +184,49 @@ export class ProductsService {
public async getFavlist(userId: string) {
const favRef: AngularFirestoreDocument<any> = this.afs.collection(`favourite`).doc(userId);
favRef.valueChanges().subscribe((value) => {
if (Object.keys(value).length > 0) {
this.fav = this.service.splitSep(value);
console.log(this.fav);
favRef.valueChanges().pipe(
take(1) // Here you can limit to only emit once, using the take operator
).subscribe((value) => {
if (value !== undefined) {
if (Object.keys(value).length > 0) {
this.fav = this.service.splitSep(value);
console.log(this.fav);
}
console.log(value);
}
console.log(value);
});
}
public async changeFav(index, type) {
console.log(index, type);
if (type === 'yes') {
this.afs.collection('favourite').doc(this.user.uid).update({
[index]: true
console.log(index, type, this.user.uid);
if (type === 'no') {
this.afs.collection('favourite').doc(this.user.uid).valueChanges().pipe(
take(1) // Here you can limit to only emit once, using the take operator
).subscribe((value) => {
if (value === undefined) {
this.afs.collection('favourite').doc(this.user.uid).set({
[index]: true
});
} else {
console.log(value);
value[index] = true;
console.log(value);
this.afs.collection('favourite').doc(this.user.uid).set(value);
}
});
} else {
this.afs.collection(`favourite`).doc(this.user.uid).update({
[index]: null
this.afs.collection('favourite').doc(this.user.uid).valueChanges().pipe(
take(1) // Here you can limit to only emit once, using the take operator
).subscribe((value) => {
console.log(value);
if (value !== undefined) {
value[index] = undefined;
Object.keys(value).forEach(key => value[key] === undefined ? delete value[key] : '');
console.log(value);
this.afs.collection('favourite').doc(this.user.uid).set(value);
} else {
console.log(value);
}
});
}
}
......
import { Injectable } from '@angular/core';
import { AngularFirestore, AngularFirestoreCollection } from '@angular/fire/firestore';
import { Search } from './services/search';
import { database } from 'firebase';
import { take } from 'rxjs/operators';
@Injectable({
providedIn: 'root'
})
export class SearchService {
searchList: Search[] = [];
constructor(
public afs: AngularFirestore
) {
}
public async search(inputText: string) {
if (inputText === '') {
this.searchList = [];
return;
}
const This = this;
const state = true;
this.searchList = [];
// tslint:disable-next-line:max-line-length
const orderRef: AngularFirestoreCollection<any> = this.afs.collection('shoppers', ref => ref.where('status', '==', state).orderBy('name').startAt(inputText).endAt(inputText + '\uf8ff').limit(5));
orderRef.valueChanges().subscribe((value) => {
const res = value;
if (res.length > 0) {
res.forEach((item) => {
console.log(item);
const shopper: Search = {
text: item.name,
data: item,
type: 'shopper'
};
this.searchList.push(shopper);
});
}
});
// tslint:disable-next-line:max-line-length
const prodRef: AngularFirestoreCollection<any> = this.afs.collection('products', ref => ref.where('status', '==', state).orderBy('prodName').startAt(inputText).endAt(inputText + '\uf8ff').limit(5));
prodRef.valueChanges().subscribe((values) => {
const result = values;
if (result.length > 0) {
result.forEach((item) => {
console.log(item);
const prod: Search = {
text: item.prodName,
data: item,
type: 'product'
};
this.searchList.push(prod);
});
console.log(this.searchList);
}
});
// tslint:disable-next-line:max-line-length
const feaRef: AngularFirestoreCollection<any> = this.afs.collection('category', ref => ref.where('status', '==', state).orderBy('catName').startAt(inputText).endAt(inputText + '\uf8ff').limit(5));
feaRef.valueChanges().subscribe((values) => {
const result = values;
if (result.length > 0) {
result.forEach((item) => {
console.log(item);
const prod: Search = {
text: item.catName,
data: item,
type: 'category'
};
this.searchList.push(prod);
});
console.log(this.searchList);
}
});
}
}
export class Address {
constructor(
public address: string,
public building: string,
public addressType: string,
public landmark: string,
public status: boolean,
public uid: string,
public defaultVal: number,
public latLng: any,
public addressId?: string,
) {
}
}
export interface AddressList {
addressId: string;
address: string;
addressType: string;
defaultVal: number;
building: string;
latLng: any;
landmark: string;
}
export interface Search {
type: string;
data: any;
text: any;
}
......@@ -505,6 +505,14 @@ app-deliverypop {
}
}
.nav_exit {
background-image: url("./assets/Group17_2.png");
img {
width: 25px;
display: none;
}
}
.nav_cart {
background-image: url("./assets/cart_icon.png");
img {
......
......@@ -2,7 +2,9 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/app",
"types": []
"types": [
"googlemaps"
]
},
"include": [
"src/**/*.ts"
......
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