From 6183a69cb22d9a0cb1e01bf07d352f54ab90d8e8 Mon Sep 17 00:00:00 2001 From: Jansa Jose <jansa@techware.in> Date: Mon, 3 Jun 2019 16:57:35 +0530 Subject: [PATCH] cart --- src/app/purchase/address/address.component.ts | 2 +- src/app/purchase/cart/cart.component.html | 604 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ src/app/purchase/cart/cart.component.scss | 3 +++ src/app/purchase/cart/cart.component.ts | 172 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------- src/app/purchase/orders/orders.component.html | 28 ++++++++++++++++++++++++++-- src/app/purchase/orders/orders.component.ts | 44 ++++++++++++++++++++++++++++++++++++++------ src/app/purchase/productdetails/productdetails.component.html | 4 ++-- src/app/purchase/productdetails/productdetails.component.ts | 23 +++++++++++++++++++++++ src/app/purchase/productlist/productlist.component.ts | 2 +- 9 files changed, 353 insertions(+), 529 deletions(-) diff --git a/src/app/purchase/address/address.component.ts b/src/app/purchase/address/address.component.ts index c1a5a3e..2b6d77d 100644 --- a/src/app/purchase/address/address.component.ts +++ b/src/app/purchase/address/address.component.ts @@ -42,7 +42,7 @@ export class AddressComponent implements OnInit { checkProductId(){ this.prdtData = JSON.parse(this.webService.getLocalStorageItem('productDetails')); - + console.log(this.prdtData) if(this.prdtData && this.prdtData['product_id'] > 0){ this.product_id = this.prdtData['product_id']; }else{ diff --git a/src/app/purchase/cart/cart.component.html b/src/app/purchase/cart/cart.component.html index 65a6d0b..21a8ff4 100644 --- a/src/app/purchase/cart/cart.component.html +++ b/src/app/purchase/cart/cart.component.html @@ -1,514 +1,110 @@ <div class="purchase_wrapper"> - <div class="container-fluid"> - <app-searchbar> - </app-searchbar> - <div class="myorder_wrapper"> - <ul> - <li> - <div class="row"> - <div class="col-md-6"> - <div class="auto_part_container"> - <img src="/assets/images/asset_product.png"> - </div> - <div class="auto_part_detail"> - <h2>Apollo Amazer 4G Tubeless 4 Wheeler</h2> - <h3>Audi Q7</h3> - <div class="others"> - <h4><div>Color</div><span>Black</span></h4> - <h4><div>Quantity</div><span>1</span></h4> - </div> - <h4>Quantity</h4> - <div class="counter_wrapper"> - <div class="count_btn" (click)="minus()">-</div> - <div class="counter_value">{{this.count}}</div> - <div class="count_btn" (click)="add()">+</div> - </div> - </div> - <div class="clear"></div> - </div> - <div class="col-md-6"> - <div class="price_details"> - <div class="remove">Remove</div> - <h5>$ 3,200</h5> - <h4>Delivery expected by Thu, Apr 25th 2019<br> - </h4><br> - <button class="purchase_btn">Purchase</button> - <div class="clear"></div> - - </div> - </div> + <div class="container-fluid"> + <app-searchbar> + </app-searchbar> + <div class="loader_overlay" *ngIf="loader"></div> + <div class="myorder_wrapper"> + <ul *ngIf="cartData;else noCart" infiniteScroll [infiniteScrollDistance]="2" [infiniteScrollThrottle]="50" (scrolled)="onScroll()" [scrollWindow]="false" style="max-height: 700px; overflow: scroll"> + <li *ngFor="let cart of cartData"> + <div class="row"> + <div class="col-md-6"> + <div class="auto_part_container"> + <img src="{{imageServer + cart.product_image}}" onerror="this.src='assets/images/user_avatar.jpg'"> </div> - </li> - <li> - <div class="row"> - <div class="col-md-6"> - <div class="auto_part_container"> - <img src="/assets/images/asset_product.png"> - </div> - <div class="auto_part_detail"> - <h2>Apollo Amazer 4G Tubeless 4 Wheeler</h2> - <h3>Audi Q7</h3> - <div class="others"> - <h4><div>Color</div><span>Black</span></h4> - <h4><div>Quantity</div><span>1</span></h4> - </div> - <h4>Quantity</h4> - <div class="counter_wrapper"> - <div class="count_btn" (click)="minus()">-</div> - <div class="counter_value">{{this.count}}</div> - <div class="count_btn" (click)="add()">+</div> - </div> - </div> - <div class="clear"></div> - </div> - <div class="col-md-6"> - <div class="price_details"> - <div class="remove">Remove</div> - <h5>$ 3,200</h5> - <h4>Delivery expected by Thu, Apr 25th 2019<br> - </h4><br> - <button class="purchase_btn">Purchase</button> - <div class="clear"></div> - - </div> - </div> - </div> - </li> - <li> - <div class="row"> - <div class="col-md-6"> - <div class="auto_part_container"> - <img src="/assets/images/asset_product.png"> - </div> - <div class="auto_part_detail"> - <h2>Apollo Amazer 4G Tubeless 4 Wheeler</h2> - <h3>Audi Q7</h3> - <div class="others"> - <h4><div>Color</div><span>Black</span></h4> - <h4><div>Quantity</div><span>1</span></h4> - </div> - <h4>Quantity</h4> - <div class="counter_wrapper"> - <div class="count_btn" (click)="minus()">-</div> - <div class="counter_value">{{this.count}}</div> - <div class="count_btn" (click)="add()">+</div> - </div> - </div> - <div class="clear"></div> - </div> - <div class="col-md-6"> - <div class="price_details"> - <div class="remove">Remove</div> - <h5>$ 3,200</h5> - <h4>Delivery expected by Thu, Apr 25th 2019<br> - </h4><br> - <button class="purchase_btn">Purchase</button> - <div class="clear"></div> - - </div> - </div> - </div> - </li> - </ul> - </div> - </div> - <div class="bottom_product_list"> - <h4>Audi Q7 <span>( Similar Results )</span></h4> - <ngx-carousel [inputs]="carouselTile" (carouselLoad)="carouselTileLoad()"> - <ngx-tile NgxCarouselItem> - <li (click)="goToPage('productdetails')"> - <div class="inner_div_product"> - <div class="product_wrapper"> - <img src="/assets/images/asset_product.png"> - </div> - <h5>JK Victory Wheelers type</h5> - <p>265/65 R17, Tubeless</p> - <div class="star_ratting"> - <fieldset class="rating"> - <input type="radio" id="star5" name="rating" value="5" /><label class = "full" for="star5" title="Awesome - 5 stars"></label> - <input type="radio" id="star4half" name="rating" value="4 and a half" /><label class="half" for="star4half" title="Pretty good - 4.5 stars"></label> - <input type="radio" id="star4" name="rating" value="4" /><label class = "full" for="star4" title="Pretty good - 4 stars"></label> - <input type="radio" id="star3half" name="rating" value="3 and a half" /><label class="half" for="star3half" title="Meh - 3.5 stars"></label> - <input type="radio" id="star3" name="rating" value="3" /><label class = "full" for="star3" title="Meh - 3 stars"></label> - <input type="radio" id="star2half" name="rating" value="2 and a half" /><label class="half" for="star2half" title="Kinda bad - 2.5 stars"></label> - <input type="radio" id="star2" name="rating" value="2" /><label class = "full" for="star2" title="Kinda bad - 2 stars"></label> - <input type="radio" id="star1half" name="rating" value="1 and a half" /><label class="half" for="star1half" title="Meh - 1.5 stars"></label> - <input type="radio" id="star1" name="rating" value="1" /><label class = "full" for="star1" title="Sucks big time - 1 star"></label> - <input type="radio" id="starhalf" name="rating" value="half" /><label class="half" for="starhalf" title="Sucks big time - 0.5 stars"></label> - </fieldset> - <span class="floatRight">$320</span> - <div class="clear"></div> - <p>21 Reviews</p> - </div> - </div> - </li> - </ngx-tile> - <ngx-tile NgxCarouselItem> - <li (click)="goToPage('productdetails')"> - <div class="inner_div_product"> - <div class="product_wrapper"> - <img src="/assets/images/asset_product.png"> - </div> - <h5>JK Victory Wheelers type</h5> - <p>265/65 R17, Tubeless</p> - <div class="star_ratting"> - <fieldset class="rating"> - <input type="radio" id="star5" name="rating" value="5" /><label class = "full" for="star5" title="Awesome - 5 stars"></label> - <input type="radio" id="star4half" name="rating" value="4 and a half" /><label class="half" for="star4half" title="Pretty good - 4.5 stars"></label> - <input type="radio" id="star4" name="rating" value="4" /><label class = "full" for="star4" title="Pretty good - 4 stars"></label> - <input type="radio" id="star3half" name="rating" value="3 and a half" /><label class="half" for="star3half" title="Meh - 3.5 stars"></label> - <input type="radio" id="star3" name="rating" value="3" /><label class = "full" for="star3" title="Meh - 3 stars"></label> - <input type="radio" id="star2half" name="rating" value="2 and a half" /><label class="half" for="star2half" title="Kinda bad - 2.5 stars"></label> - <input type="radio" id="star2" name="rating" value="2" /><label class = "full" for="star2" title="Kinda bad - 2 stars"></label> - <input type="radio" id="star1half" name="rating" value="1 and a half" /><label class="half" for="star1half" title="Meh - 1.5 stars"></label> - <input type="radio" id="star1" name="rating" value="1" /><label class = "full" for="star1" title="Sucks big time - 1 star"></label> - <input type="radio" id="starhalf" name="rating" value="half" /><label class="half" for="starhalf" title="Sucks big time - 0.5 stars"></label> - </fieldset> - <span class="floatRight">$320</span> - <div class="clear"></div> - <p>21 Reviews</p> - </div> - </div> - </li> - </ngx-tile> - <ngx-tile NgxCarouselItem> - <li (click)="goToPage('productdetails')"> - <div class="inner_div_product"> - <div class="product_wrapper"> - <img src="/assets/images/asset_product.png"> - </div> - <h5>JK Victory Wheelers type</h5> - <p>265/65 R17, Tubeless</p> - <div class="star_ratting"> - <fieldset class="rating"> - <input type="radio" id="star5" name="rating" value="5" /><label class = "full" for="star5" title="Awesome - 5 stars"></label> - <input type="radio" id="star4half" name="rating" value="4 and a half" /><label class="half" for="star4half" title="Pretty good - 4.5 stars"></label> - <input type="radio" id="star4" name="rating" value="4" /><label class = "full" for="star4" title="Pretty good - 4 stars"></label> - <input type="radio" id="star3half" name="rating" value="3 and a half" /><label class="half" for="star3half" title="Meh - 3.5 stars"></label> - <input type="radio" id="star3" name="rating" value="3" /><label class = "full" for="star3" title="Meh - 3 stars"></label> - <input type="radio" id="star2half" name="rating" value="2 and a half" /><label class="half" for="star2half" title="Kinda bad - 2.5 stars"></label> - <input type="radio" id="star2" name="rating" value="2" /><label class = "full" for="star2" title="Kinda bad - 2 stars"></label> - <input type="radio" id="star1half" name="rating" value="1 and a half" /><label class="half" for="star1half" title="Meh - 1.5 stars"></label> - <input type="radio" id="star1" name="rating" value="1" /><label class = "full" for="star1" title="Sucks big time - 1 star"></label> - <input type="radio" id="starhalf" name="rating" value="half" /><label class="half" for="starhalf" title="Sucks big time - 0.5 stars"></label> - </fieldset> - <span class="floatRight">$320</span> - <div class="clear"></div> - <p>21 Reviews</p> - </div> - </div> - </li> - </ngx-tile> - <ngx-tile NgxCarouselItem> - <li (click)="goToPage('productdetails')"> - <div class="inner_div_product"> - <div class="product_wrapper"> - <img src="/assets/images/asset_product.png"> - </div> - <h5>JK Victory Wheelers type</h5> - <p>265/65 R17, Tubeless</p> - <div class="star_ratting"> - <fieldset class="rating"> - <input type="radio" id="star5" name="rating" value="5" /><label class = "full" for="star5" title="Awesome - 5 stars"></label> - <input type="radio" id="star4half" name="rating" value="4 and a half" /><label class="half" for="star4half" title="Pretty good - 4.5 stars"></label> - <input type="radio" id="star4" name="rating" value="4" /><label class = "full" for="star4" title="Pretty good - 4 stars"></label> - <input type="radio" id="star3half" name="rating" value="3 and a half" /><label class="half" for="star3half" title="Meh - 3.5 stars"></label> - <input type="radio" id="star3" name="rating" value="3" /><label class = "full" for="star3" title="Meh - 3 stars"></label> - <input type="radio" id="star2half" name="rating" value="2 and a half" /><label class="half" for="star2half" title="Kinda bad - 2.5 stars"></label> - <input type="radio" id="star2" name="rating" value="2" /><label class = "full" for="star2" title="Kinda bad - 2 stars"></label> - <input type="radio" id="star1half" name="rating" value="1 and a half" /><label class="half" for="star1half" title="Meh - 1.5 stars"></label> - <input type="radio" id="star1" name="rating" value="1" /><label class = "full" for="star1" title="Sucks big time - 1 star"></label> - <input type="radio" id="starhalf" name="rating" value="half" /><label class="half" for="starhalf" title="Sucks big time - 0.5 stars"></label> - </fieldset> - <span class="floatRight">$320</span> - <div class="clear"></div> - <p>21 Reviews</p> - </div> - </div> - </li> - </ngx-tile> - <ngx-tile NgxCarouselItem> - <li (click)="goToPage('productdetails')"> - <div class="inner_div_product"> - <div class="product_wrapper"> - <img src="/assets/images/asset_product.png"> - </div> - <h5>JK Victory Wheelers type</h5> - <p>265/65 R17, Tubeless</p> - <div class="star_ratting"> - <fieldset class="rating"> - <input type="radio" id="star5" name="rating" value="5" /><label class = "full" for="star5" title="Awesome - 5 stars"></label> - <input type="radio" id="star4half" name="rating" value="4 and a half" /><label class="half" for="star4half" title="Pretty good - 4.5 stars"></label> - <input type="radio" id="star4" name="rating" value="4" /><label class = "full" for="star4" title="Pretty good - 4 stars"></label> - <input type="radio" id="star3half" name="rating" value="3 and a half" /><label class="half" for="star3half" title="Meh - 3.5 stars"></label> - <input type="radio" id="star3" name="rating" value="3" /><label class = "full" for="star3" title="Meh - 3 stars"></label> - <input type="radio" id="star2half" name="rating" value="2 and a half" /><label class="half" for="star2half" title="Kinda bad - 2.5 stars"></label> - <input type="radio" id="star2" name="rating" value="2" /><label class = "full" for="star2" title="Kinda bad - 2 stars"></label> - <input type="radio" id="star1half" name="rating" value="1 and a half" /><label class="half" for="star1half" title="Meh - 1.5 stars"></label> - <input type="radio" id="star1" name="rating" value="1" /><label class = "full" for="star1" title="Sucks big time - 1 star"></label> - <input type="radio" id="starhalf" name="rating" value="half" /><label class="half" for="starhalf" title="Sucks big time - 0.5 stars"></label> - </fieldset> - <span class="floatRight">$320</span> - <div class="clear"></div> - <p>21 Reviews</p> - </div> - </div> - </li> - </ngx-tile> - <ngx-tile NgxCarouselItem> - <li (click)="goToPage('productdetails')"> - <div class="inner_div_product"> - <div class="product_wrapper"> - <img src="/assets/images/asset_product.png"> - </div> - <h5>JK Victory Wheelers type</h5> - <p>265/65 R17, Tubeless</p> - <div class="star_ratting"> - <fieldset class="rating"> - <input type="radio" id="star5" name="rating" value="5" /><label class = "full" for="star5" title="Awesome - 5 stars"></label> - <input type="radio" id="star4half" name="rating" value="4 and a half" /><label class="half" for="star4half" title="Pretty good - 4.5 stars"></label> - <input type="radio" id="star4" name="rating" value="4" /><label class = "full" for="star4" title="Pretty good - 4 stars"></label> - <input type="radio" id="star3half" name="rating" value="3 and a half" /><label class="half" for="star3half" title="Meh - 3.5 stars"></label> - <input type="radio" id="star3" name="rating" value="3" /><label class = "full" for="star3" title="Meh - 3 stars"></label> - <input type="radio" id="star2half" name="rating" value="2 and a half" /><label class="half" for="star2half" title="Kinda bad - 2.5 stars"></label> - <input type="radio" id="star2" name="rating" value="2" /><label class = "full" for="star2" title="Kinda bad - 2 stars"></label> - <input type="radio" id="star1half" name="rating" value="1 and a half" /><label class="half" for="star1half" title="Meh - 1.5 stars"></label> - <input type="radio" id="star1" name="rating" value="1" /><label class = "full" for="star1" title="Sucks big time - 1 star"></label> - <input type="radio" id="starhalf" name="rating" value="half" /><label class="half" for="starhalf" title="Sucks big time - 0.5 stars"></label> - </fieldset> - <span class="floatRight">$320</span> - <div class="clear"></div> - <p>21 Reviews</p> - </div> - </div> - </li> - </ngx-tile> - <ngx-tile NgxCarouselItem> - <li (click)="goToPage('productdetails')"> - <div class="inner_div_product"> - <div class="product_wrapper"> - <img src="/assets/images/asset_product.png"> - </div> - <h5>JK Victory Wheelers type</h5> - <p>265/65 R17, Tubeless</p> - <div class="star_ratting"> - <fieldset class="rating"> - <input type="radio" id="star5" name="rating" value="5" /><label class = "full" for="star5" title="Awesome - 5 stars"></label> - <input type="radio" id="star4half" name="rating" value="4 and a half" /><label class="half" for="star4half" title="Pretty good - 4.5 stars"></label> - <input type="radio" id="star4" name="rating" value="4" /><label class = "full" for="star4" title="Pretty good - 4 stars"></label> - <input type="radio" id="star3half" name="rating" value="3 and a half" /><label class="half" for="star3half" title="Meh - 3.5 stars"></label> - <input type="radio" id="star3" name="rating" value="3" /><label class = "full" for="star3" title="Meh - 3 stars"></label> - <input type="radio" id="star2half" name="rating" value="2 and a half" /><label class="half" for="star2half" title="Kinda bad - 2.5 stars"></label> - <input type="radio" id="star2" name="rating" value="2" /><label class = "full" for="star2" title="Kinda bad - 2 stars"></label> - <input type="radio" id="star1half" name="rating" value="1 and a half" /><label class="half" for="star1half" title="Meh - 1.5 stars"></label> - <input type="radio" id="star1" name="rating" value="1" /><label class = "full" for="star1" title="Sucks big time - 1 star"></label> - <input type="radio" id="starhalf" name="rating" value="half" /><label class="half" for="starhalf" title="Sucks big time - 0.5 stars"></label> - </fieldset> - <span class="floatRight">$320</span> - <div class="clear"></div> - <p>21 Reviews</p> - </div> - </div> - </li> - </ngx-tile> - <ngx-tile NgxCarouselItem> - <li (click)="goToPage('productdetails')"> - <div class="inner_div_product"> - <div class="product_wrapper"> - <img src="/assets/images/asset_product.png"> - </div> - <h5>JK Victory Wheelers type</h5> - <p>265/65 R17, Tubeless</p> - <div class="star_ratting"> - <fieldset class="rating"> - <input type="radio" id="star5" name="rating" value="5" /><label class = "full" for="star5" title="Awesome - 5 stars"></label> - <input type="radio" id="star4half" name="rating" value="4 and a half" /><label class="half" for="star4half" title="Pretty good - 4.5 stars"></label> - <input type="radio" id="star4" name="rating" value="4" /><label class = "full" for="star4" title="Pretty good - 4 stars"></label> - <input type="radio" id="star3half" name="rating" value="3 and a half" /><label class="half" for="star3half" title="Meh - 3.5 stars"></label> - <input type="radio" id="star3" name="rating" value="3" /><label class = "full" for="star3" title="Meh - 3 stars"></label> - <input type="radio" id="star2half" name="rating" value="2 and a half" /><label class="half" for="star2half" title="Kinda bad - 2.5 stars"></label> - <input type="radio" id="star2" name="rating" value="2" /><label class = "full" for="star2" title="Kinda bad - 2 stars"></label> - <input type="radio" id="star1half" name="rating" value="1 and a half" /><label class="half" for="star1half" title="Meh - 1.5 stars"></label> - <input type="radio" id="star1" name="rating" value="1" /><label class = "full" for="star1" title="Sucks big time - 1 star"></label> - <input type="radio" id="starhalf" name="rating" value="half" /><label class="half" for="starhalf" title="Sucks big time - 0.5 stars"></label> - </fieldset> - <span class="floatRight">$320</span> - <div class="clear"></div> - <p>21 Reviews</p> - </div> - </div> - </li> - </ngx-tile> - <ngx-tile NgxCarouselItem> - <li (click)="goToPage('productdetails')"> - <div class="inner_div_product"> - <div class="product_wrapper"> - <img src="/assets/images/asset_product.png"> - </div> - <h5>JK Victory Wheelers type</h5> - <p>265/65 R17, Tubeless</p> - <div class="star_ratting"> - <fieldset class="rating"> - <input type="radio" id="star5" name="rating" value="5" /><label class = "full" for="star5" title="Awesome - 5 stars"></label> - <input type="radio" id="star4half" name="rating" value="4 and a half" /><label class="half" for="star4half" title="Pretty good - 4.5 stars"></label> - <input type="radio" id="star4" name="rating" value="4" /><label class = "full" for="star4" title="Pretty good - 4 stars"></label> - <input type="radio" id="star3half" name="rating" value="3 and a half" /><label class="half" for="star3half" title="Meh - 3.5 stars"></label> - <input type="radio" id="star3" name="rating" value="3" /><label class = "full" for="star3" title="Meh - 3 stars"></label> - <input type="radio" id="star2half" name="rating" value="2 and a half" /><label class="half" for="star2half" title="Kinda bad - 2.5 stars"></label> - <input type="radio" id="star2" name="rating" value="2" /><label class = "full" for="star2" title="Kinda bad - 2 stars"></label> - <input type="radio" id="star1half" name="rating" value="1 and a half" /><label class="half" for="star1half" title="Meh - 1.5 stars"></label> - <input type="radio" id="star1" name="rating" value="1" /><label class = "full" for="star1" title="Sucks big time - 1 star"></label> - <input type="radio" id="starhalf" name="rating" value="half" /><label class="half" for="starhalf" title="Sucks big time - 0.5 stars"></label> - </fieldset> - <span class="floatRight">$320</span> - <div class="clear"></div> - <p>21 Reviews</p> - </div> - </div> - </li> - </ngx-tile> - <ngx-tile NgxCarouselItem> - <li (click)="goToPage('productdetails')"> - <div class="inner_div_product"> - <div class="product_wrapper"> - <img src="/assets/images/asset_product.png"> - </div> - <h5>JK Victory Wheelers type</h5> - <p>265/65 R17, Tubeless</p> - <div class="star_ratting"> - <fieldset class="rating"> - <input type="radio" id="star5" name="rating" value="5" /><label class = "full" for="star5" title="Awesome - 5 stars"></label> - <input type="radio" id="star4half" name="rating" value="4 and a half" /><label class="half" for="star4half" title="Pretty good - 4.5 stars"></label> - <input type="radio" id="star4" name="rating" value="4" /><label class = "full" for="star4" title="Pretty good - 4 stars"></label> - <input type="radio" id="star3half" name="rating" value="3 and a half" /><label class="half" for="star3half" title="Meh - 3.5 stars"></label> - <input type="radio" id="star3" name="rating" value="3" /><label class = "full" for="star3" title="Meh - 3 stars"></label> - <input type="radio" id="star2half" name="rating" value="2 and a half" /><label class="half" for="star2half" title="Kinda bad - 2.5 stars"></label> - <input type="radio" id="star2" name="rating" value="2" /><label class = "full" for="star2" title="Kinda bad - 2 stars"></label> - <input type="radio" id="star1half" name="rating" value="1 and a half" /><label class="half" for="star1half" title="Meh - 1.5 stars"></label> - <input type="radio" id="star1" name="rating" value="1" /><label class = "full" for="star1" title="Sucks big time - 1 star"></label> - <input type="radio" id="starhalf" name="rating" value="half" /><label class="half" for="starhalf" title="Sucks big time - 0.5 stars"></label> - </fieldset> - <span class="floatRight">$320</span> - <div class="clear"></div> - <p>21 Reviews</p> - </div> - </div> - </li> - </ngx-tile> - <ngx-tile NgxCarouselItem> - <li (click)="goToPage('productdetails')"> - <div class="inner_div_product"> - <div class="product_wrapper"> - <img src="/assets/images/asset_product.png"> - </div> - <h5>JK Victory Wheelers type</h5> - <p>265/65 R17, Tubeless</p> - <div class="star_ratting"> - <fieldset class="rating"> - <input type="radio" id="star5" name="rating" value="5" /><label class = "full" for="star5" title="Awesome - 5 stars"></label> - <input type="radio" id="star4half" name="rating" value="4 and a half" /><label class="half" for="star4half" title="Pretty good - 4.5 stars"></label> - <input type="radio" id="star4" name="rating" value="4" /><label class = "full" for="star4" title="Pretty good - 4 stars"></label> - <input type="radio" id="star3half" name="rating" value="3 and a half" /><label class="half" for="star3half" title="Meh - 3.5 stars"></label> - <input type="radio" id="star3" name="rating" value="3" /><label class = "full" for="star3" title="Meh - 3 stars"></label> - <input type="radio" id="star2half" name="rating" value="2 and a half" /><label class="half" for="star2half" title="Kinda bad - 2.5 stars"></label> - <input type="radio" id="star2" name="rating" value="2" /><label class = "full" for="star2" title="Kinda bad - 2 stars"></label> - <input type="radio" id="star1half" name="rating" value="1 and a half" /><label class="half" for="star1half" title="Meh - 1.5 stars"></label> - <input type="radio" id="star1" name="rating" value="1" /><label class = "full" for="star1" title="Sucks big time - 1 star"></label> - <input type="radio" id="starhalf" name="rating" value="half" /><label class="half" for="starhalf" title="Sucks big time - 0.5 stars"></label> - </fieldset> - <span class="floatRight">$320</span> - <div class="clear"></div> - <p>21 Reviews</p> - </div> + <div class="auto_part_detail"> + <h2>{{cart.product_name}}</h2> + <h3>{{cart.short_description}}</h3> + <div class="others"> + <h4><div>Brand</div><span>{{cart.brand_name}}</span></h4> + <!-- <h4><div>Quantity</div><span>1</span></h4> --> + </div> + <h4>Quantity</h4> + <div class="counter_wrapper"> + <div class="count_btn" (click)="minus(cart.cart_id)">-</div> + <!-- <div class="counter_value">{{this.count}}</div> --> + <div class="counter_value">{{cartQuantity[cart.cart_id]['quantity']}}</div> + <div class="count_btn" (click)="add(cart.cart_id)">+</div> + </div> + </div> + <div class="clear"></div> </div> - </li> - </ngx-tile> - <ngx-tile NgxCarouselItem> - <li (click)="goToPage('productdetails')"> - <div class="inner_div_product"> - <div class="product_wrapper"> - <img src="/assets/images/asset_product.png"> - </div> - <h5>JK Victory Wheelers type</h5> - <p>265/65 R17, Tubeless</p> - <div class="star_ratting"> - <fieldset class="rating"> - <input type="radio" id="star5" name="rating" value="5" /><label class = "full" for="star5" title="Awesome - 5 stars"></label> - <input type="radio" id="star4half" name="rating" value="4 and a half" /><label class="half" for="star4half" title="Pretty good - 4.5 stars"></label> - <input type="radio" id="star4" name="rating" value="4" /><label class = "full" for="star4" title="Pretty good - 4 stars"></label> - <input type="radio" id="star3half" name="rating" value="3 and a half" /><label class="half" for="star3half" title="Meh - 3.5 stars"></label> - <input type="radio" id="star3" name="rating" value="3" /><label class = "full" for="star3" title="Meh - 3 stars"></label> - <input type="radio" id="star2half" name="rating" value="2 and a half" /><label class="half" for="star2half" title="Kinda bad - 2.5 stars"></label> - <input type="radio" id="star2" name="rating" value="2" /><label class = "full" for="star2" title="Kinda bad - 2 stars"></label> - <input type="radio" id="star1half" name="rating" value="1 and a half" /><label class="half" for="star1half" title="Meh - 1.5 stars"></label> - <input type="radio" id="star1" name="rating" value="1" /><label class = "full" for="star1" title="Sucks big time - 1 star"></label> - <input type="radio" id="starhalf" name="rating" value="half" /><label class="half" for="starhalf" title="Sucks big time - 0.5 stars"></label> - </fieldset> - <span class="floatRight">$320</span> - <div class="clear"></div> - <p>21 Reviews</p> - </div> + <div class="col-md-6"> + <div class="price_details"> + <div class="remove" (click)="cnfRemoveProduct(cart.cart_id)">Remove</div> + <h5>$ {{cartQuantity[cart.cart_id]['total_amount']}}</h5> + <!-- <h4>Delivery expected by Thu, Apr 25th 2019<br> + </h4> --><br> + <button class="purchase_btn" (click)="buyProduct(cart.product_id,cartQuantity[cart.cart_id]['total_amount'],cart.cart_id,cartQuantity[cart.cart_id]['quantity'],cart.amount)">Purchase</button> + <div class="clear"></div> + + </div> </div> + </div> </li> - </ngx-tile> - <ngx-tile NgxCarouselItem> - <li (click)="goToPage('productdetails')"> - <div class="inner_div_product"> - <div class="product_wrapper"> - <img src="/assets/images/asset_product.png"> - </div> - <h5>JK Victory Wheelers type</h5> - <p>265/65 R17, Tubeless</p> - <div class="star_ratting"> - <fieldset class="rating"> - <input type="radio" id="star5" name="rating" value="5" /><label class = "full" for="star5" title="Awesome - 5 stars"></label> - <input type="radio" id="star4half" name="rating" value="4 and a half" /><label class="half" for="star4half" title="Pretty good - 4.5 stars"></label> - <input type="radio" id="star4" name="rating" value="4" /><label class = "full" for="star4" title="Pretty good - 4 stars"></label> - <input type="radio" id="star3half" name="rating" value="3 and a half" /><label class="half" for="star3half" title="Meh - 3.5 stars"></label> - <input type="radio" id="star3" name="rating" value="3" /><label class = "full" for="star3" title="Meh - 3 stars"></label> - <input type="radio" id="star2half" name="rating" value="2 and a half" /><label class="half" for="star2half" title="Kinda bad - 2.5 stars"></label> - <input type="radio" id="star2" name="rating" value="2" /><label class = "full" for="star2" title="Kinda bad - 2 stars"></label> - <input type="radio" id="star1half" name="rating" value="1 and a half" /><label class="half" for="star1half" title="Meh - 1.5 stars"></label> - <input type="radio" id="star1" name="rating" value="1" /><label class = "full" for="star1" title="Sucks big time - 1 star"></label> - <input type="radio" id="starhalf" name="rating" value="half" /><label class="half" for="starhalf" title="Sucks big time - 0.5 stars"></label> - </fieldset> - <span class="floatRight">$320</span> - <div class="clear"></div> - <p>21 Reviews</p> - </div> + </ul> + <ng-template #noCart> + No Data Found + </ng-template> + </div> + </div> + <div class="bottom_product_list"> + <div class="loader_overlay" *ngIf="trend_loader"></div> + <h4>Trending Products</h4> + <ngx-carousel [inputs]="carouselTile" (carouselLoad)="carouselTileLoad()" *ngIf="trendingProductData"> + <ngx-tile NgxCarouselItem *ngFor="let prdt of trendingProductData"> + <li (click)="latestPrdtDtls(prdt.product_id)"> + <div class="inner_div_product"> + <div class="product_wrapper"> + <img src="{{imageServer + prdt.product_image}}" onerror="this.src='assets/images/user_avatar.jpg'"> </div> - </li> - </ngx-tile> - <ngx-tile NgxCarouselItem> - <li (click)="goToPage('productdetails')"> - <div class="inner_div_product"> - <div class="product_wrapper"> - <img src="/assets/images/asset_product.png"> - </div> - <h5>JK Victory Wheelers type</h5> - <p>265/65 R17, Tubeless</p> - <div class="star_ratting"> - <fieldset class="rating"> - <input type="radio" id="star5" name="rating" value="5" /><label class = "full" for="star5" title="Awesome - 5 stars"></label> - <input type="radio" id="star4half" name="rating" value="4 and a half" /><label class="half" for="star4half" title="Pretty good - 4.5 stars"></label> - <input type="radio" id="star4" name="rating" value="4" /><label class = "full" for="star4" title="Pretty good - 4 stars"></label> - <input type="radio" id="star3half" name="rating" value="3 and a half" /><label class="half" for="star3half" title="Meh - 3.5 stars"></label> - <input type="radio" id="star3" name="rating" value="3" /><label class = "full" for="star3" title="Meh - 3 stars"></label> - <input type="radio" id="star2half" name="rating" value="2 and a half" /><label class="half" for="star2half" title="Kinda bad - 2.5 stars"></label> - <input type="radio" id="star2" name="rating" value="2" /><label class = "full" for="star2" title="Kinda bad - 2 stars"></label> - <input type="radio" id="star1half" name="rating" value="1 and a half" /><label class="half" for="star1half" title="Meh - 1.5 stars"></label> - <input type="radio" id="star1" name="rating" value="1" /><label class = "full" for="star1" title="Sucks big time - 1 star"></label> - <input type="radio" id="starhalf" name="rating" value="half" /><label class="half" for="starhalf" title="Sucks big time - 0.5 stars"></label> - </fieldset> - <span class="floatRight">$320</span> - <div class="clear"></div> - <p>21 Reviews</p> - </div> + <h5>{{prdt.product_name}}</h5> + <p>{{prdt.short_description}}</p> + <div class="star_ratting prevent-click"> + <fieldset class="rating"> + <input type="radio" [checked]="(prdt.rating >= 4.75) ? 'true':''" [attr.id]="'thirdStar_'+prdt.product_id+'_5'" [attr.name]="'thirdStarName_'+prdt.product_id" value="5" /><label class = "full" for="thirdStar5"></label> + <input type="radio" [checked]="(prdt.rating >= 4.25 && prdt.rating < 4.75) ? 'true':''" [attr.id]="'thirdStar_'+prdt.product_id+'_4half'" [attr.name]="'thirdStarName_'+prdt.product_id" value="4.5" /><label class="half" for="thirdStar4half"></label> + <input type="radio" [checked]="(prdt.rating >= 3.75 && prdt.rating < 4.25) ? 'true':''" [attr.id]="'thirdStar_'+prdt.product_id+'_4'" [attr.name]="'thirdStarName_'+prdt.product_id" value="4" /><label class = "full" for="thirdStar4"></label> + <input type="radio" [checked]="(prdt.rating >= 3.25 && prdt.rating < 3.75) ? 'true':''" [attr.id]="'thirdStar_'+prdt.product_id+'_3half'" [attr.name]="'thirdStarName_'+prdt.product_id" value="3.5" /><label class="half" for="thirdStar3half"></label> + <input type="radio" [checked]="(prdt.rating >= 2.75 && prdt.rating < 3.25) ? 'true':''" [attr.id]="'thirdStar_'+prdt.product_id+'_3'" [attr.name]="'thirdStarName_'+prdt.product_id" value="3" /><label class = "full" for="thirdStar3"></label> + <input type="radio" [checked]="(prdt.rating >= 2.25 && prdt.rating < 2.75) ? 'true':''" [attr.id]="'thirdStar_'+prdt.product_id+'_2half'" [attr.name]="'thirdStarName_'+prdt.product_id" value="2.5" /><label class="half" for="thirdStar2half"></label> + <input type="radio" [checked]="(prdt.rating >= 1.75 && prdt.rating < 2.25) ? 'true':''" [attr.id]="'thirdStar_'+prdt.product_id+'_2'" [attr.name]="'thirdStarName_'+prdt.product_id" value="2" /><label class = "full" for="thirdStar2"></label> + <input type="radio" [checked]="(prdt.rating >= 1.25 && prdt.rating < 1.75) ? 'true':''" [attr.id]="'thirdStar_'+prdt.product_id+'_1half'" [attr.name]="'thirdStarName_'+prdt.product_id" value="1.5" /><label class="half" for="thirdStar1half"></label> + <input type="radio" [checked]="(prdt.rating >= 0.75 && prdt.rating < 1.25) ? 'true':''" [attr.id]="'thirdStar_'+prdt.product_id+'_1'" [attr.name]="'thirdStarName_'+prdt.product_id" value="1" /><label class = "full" for="thirdStar1"></label> + <input type="radio" [checked]="(prdt.rating < 0.75 && prdt.rating >= 0.25) ? 'true':''" [attr.id]="'thirdStar_'+prdt.product_id+'_half'" [attr.name]="'thirdStarName_'+prdt.product_id" value="0.5" /><label class="half" for="thirdStarhalf"></label> + </fieldset> + <span class="floatRight">$ {{prdt.amount}}</span> + <div class="clear"></div> + <p>{{(prdt.reviews > 0)?prdt.reviews+' Reviews':'Be the first one to review.'}}</p> </div> + </div> </li> - </ngx-tile> - <button NgxCarouselPrev class='leftRs'><</button> - <button NgxCarouselNext class='rightRs'>></button> + </ngx-tile> + <button NgxCarouselPrev class='leftRs'><</button> + <button NgxCarouselNext class='rightRs'>></button> </ngx-carousel> + </div> +</div> + +<!-- Confirm Modal PopUp--> +<button #confirmModal class="hide" data-toggle="modal" data-target="#confirm">Add Vehicle</button> +<div class="modal" id="confirm" > + <div class="modal-dialog modal-full"> + <div class="modal-content background_transparent"> + <div class="modal-body quote_modal"> + <div class="confirm_modal_content"> + <div class="login_modal_inner"> + <div class="login_success"> + <h4>Do You Want to Confirm ?</h4> + </div> + <div class="row"> + <div class="col-md-12 textCenter"> + <button class="btn btn-success" data-dismiss="modal" (click)="confirmCallBack(confirmCallBak,confirmParam)">Yes</button> + <button class="btn btn-danger" data-dismiss="modal">No</button> + </div> + </div> + </div> + </div> + </div> + </div> </div> - </div> \ No newline at end of file +</div> \ No newline at end of file diff --git a/src/app/purchase/cart/cart.component.scss b/src/app/purchase/cart/cart.component.scss index 2a013c4..ceb4365 100644 --- a/src/app/purchase/cart/cart.component.scss +++ b/src/app/purchase/cart/cart.component.scss @@ -3,6 +3,9 @@ width:100%; ul{ padding:0px; + &::-webkit-scrollbar { + display: none; + } li{ list-style: none; background: #fff; diff --git a/src/app/purchase/cart/cart.component.ts b/src/app/purchase/cart/cart.component.ts index 4acaa6a..981d860 100644 --- a/src/app/purchase/cart/cart.component.ts +++ b/src/app/purchase/cart/cart.component.ts @@ -1,6 +1,9 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, ViewChild, ElementRef } from '@angular/core'; import { NgxCarousel } from 'ngx-carousel'; +import { WebService } from '../../provider/web.service'; +import { ImageStorage } from '../../../environments/server.config'; import { Router,ActivatedRoute } from '@angular/router'; +import { exists } from 'fs'; @Component({ selector: 'app-cart', @@ -9,33 +12,176 @@ import { Router,ActivatedRoute } from '@angular/router'; }) export class CartComponent implements OnInit { count:any; + loginDetails:any; + loader:boolean; + cartData:any; + page :number = 1; + total_page :number = 1; + imageServer: any; + trend_loader:boolean; + trendingProductData:any; + product_data:any; + cartQuantity :any[] = new Array(); + confirmParam: string = ''; + confirmCallBak: string = ''; + + @ViewChild("confirmModal") public confirmModalRef: ElementRef; + public carouselTile: NgxCarousel; constructor( private router : Router, - private route : ActivatedRoute + private route : ActivatedRoute, + public webService : WebService ) { - this.count = 0; + this.count = 1; + this.loader = true; + this.imageServer = ImageStorage; + this.trend_loader = true; } - add(){ - this.count = this.count + 1; + add(cart_id: number){ + if(this.cartQuantity[cart_id] && this.cartQuantity[cart_id]['quantity'] < 15){ + this.cartQuantity[cart_id]['quantity'] = this.cartQuantity[cart_id]['quantity']+1; + this.cartQuantity[cart_id]['total_amount'] = this.cartQuantity[cart_id]['amount']*this.cartQuantity[cart_id]['quantity']; + } } - - minus(){ - this.count = this.count - 1; - if(this.count < 0){ - this.count = 0; + + minus(cart_id: number){ + if(this.cartQuantity[cart_id] && this.cartQuantity[cart_id]['quantity'] > 1){ + this.cartQuantity[cart_id]['quantity'] = this.cartQuantity[cart_id]['quantity']-1; + this.cartQuantity[cart_id]['total_amount'] = this.cartQuantity[cart_id]['amount']*this.cartQuantity[cart_id]['quantity']; } } - ngOnInit() { + this.checkUserLogin(); + this.getCartData(); + this.trendingProducts(); this.carouselTile = {grid: {xs: 1, sm: 2 , md: 4, lg: 8, all: 0},slide: 1, speed: 400,point: { visible: false },load: 2, touch: true, easing: 'ease'} } + checkUserLogin(){ + this.loginDetails = JSON.parse(this.webService.getLocalStorageItem('userData')); + if(!this.loginDetails){ + this.goToPage('purchaseHome',''); + } + } + + getCartData(){ + if(!this.loginDetails || !this.loginDetails.customer_id){ + return false; + } + this.loader = true; + this.webService.post_data('getCartData',{'customer_id':this.loginDetails.customer_id,'page':this.page}).subscribe(response => { + if(response.status == 'success'){ + this.cartData = response.data; + const thisObj = this; + let tempArr:any = Array(); + this.cartData.forEach(function(data,key) { + tempArr[data.cart_id] = {'quantity':+data.quantity,'amount':data.amount,'total_amount':data.quantity*data.amount}; + }); + thisObj.cartQuantity = tempArr; + }else{ + this.cartData = false; + } + this.loader = false; + }) + } + + trendingProducts(){ + this.trend_loader = true; + this.webService.post_data('getTrendingPrdts',{'page':this.page}).subscribe(response => { + if(response.status == 'success'){ + this.trendingProductData = response.data; + } else { + this.trendingProductData = false; + } + this.trend_loader = false; + }); + } + + removeProduct(params){ + this.page= 1; + this.loader = true; + this.webService.post_data('removeCartPrdt',params).subscribe(response => { + if(response.status == 'success'){ + this.getCartData(); + } + this.trend_loader = false; + }); + } + + cnfRemoveProduct(cartId){ + if(cartId < 0){ + return false; + } + this.showConfirmPopUp('removeProduct',{'cart_id':cartId}); + } + + showConfirmPopUp(fn_name: string, param: any){ + if(fn_name === ''){ + return false; + } + if(param){ + param = JSON.stringify(param); + } + this.confirmParam = param; + this.confirmCallBak = fn_name; + this.confirmModalRef.nativeElement.click(); + } + + confirmCallBack(fn_name: string,param: string){ + if(fn_name === '' || !this[fn_name]){ + return false; + } + if(param !== ''){ + param = JSON.parse(param); + this[fn_name](param); + } else { + this[fn_name](); + } + } + + onScroll(){ + if(this.total_page < this.page){ + return false; + } + + this.page += 1; + this.loader = true; + this.webService.post_data('getCartData',{'customer_id':this.loginDetails.customer_id,'page':this.page}).subscribe(response => { + if(response.status == 'success'){ + let thisObj = this; + response.data.forEach(function(cartData,key) { + thisObj.cartData.push(cartData); + }); + } + this.loader = false; + }); + } + + latestPrdtDtls(prdt_id){ + this.goToPage('productdetails',{"product_id":prdt_id}); + } + + buyProduct(product_id,total_amount,cartId,quantity,amount){ + if(cartId <= 0 || product_id <= 0 || total_amount <= 0 || quantity <= 0 || amount <= 0){ + return false; + } + this.loader = true; + this.webService.post_data('removeCartPrdt',{'cart_id':cartId}).subscribe(response => { + if(response.status == 'success'){ + this.product_data = {amount:amount,product_id:product_id,quantity:quantity,total_amount:total_amount}; + this.webService.setLocalStorageItem('productDetails', JSON.stringify(this.product_data)); + this.goToPage('address',''); + } + this.loader = false; + }); + } + goToPage(path,data=null){ - this.router.navigateByUrl(path,{queryParams:data}); - document.body.scrollTop = document.documentElement.scrollTop = 0; + this.router.navigate([path],{queryParams: data}); + document.body.scrollTop = document.documentElement.scrollTop = 0; } carouselTileLoad(){ return ''; } diff --git a/src/app/purchase/orders/orders.component.html b/src/app/purchase/orders/orders.component.html index c87a152..89a5bb7 100644 --- a/src/app/purchase/orders/orders.component.html +++ b/src/app/purchase/orders/orders.component.html @@ -18,7 +18,7 @@ <!-- <h4><div>Color</div><span>Black</span></h4> --> <h4><div>Quantity</div><span>{{book.quantity}}</span></h4> </div> - <h4><span>{{book.format_order_id}}</span><strong (click)="trackOrder(book.transId)" *ngIf="(book.status == '2' || book.status == '3' || book.status == '4' || book.status == '5')">Track Order</strong></h4> + <h4 class="cpoint"><span>{{book.format_order_id}}</span><strong (click)="trackOrder(book.transId)" *ngIf="(book.status == '2' || book.status == '3' || book.status == '4' || book.status == '5')">Track Order</strong></h4> <h4><div style="width:auto !important;">Ordered On</div><span>{{book.datetime | date: "EEE, MMMM dd, yyyy"}}</span></h4> </div> <div class="clear"></div> @@ -38,7 +38,7 @@ <h4 *ngIf = "book.status == '7'"> <div *ngIf="book.status == '7'">This item is Canceled</div> </h4> - <div class="cancel" *ngIf="(book.status == '2' || book.status == '3'|| book.status == '4')" (click)="cancelOrder(book.order_id)">Cancel Item</div> + <div class="cancel cpoint" *ngIf="(book.status == '2' || book.status == '3'|| book.status == '4')" (click)="cnfCancelOrder(book.order_id)">Cancel Item</div> <div class="clear"></div> </div> </div> @@ -83,4 +83,28 @@ <button NgxCarouselNext class='rightRs'>></button> </ngx-carousel> </div> +</div> + +<!-- Confirm Modal PopUp--> +<button #confirmModal class="hide" data-toggle="modal" data-target="#confirm">Add Vehicle</button> +<div class="modal" id="confirm" > + <div class="modal-dialog modal-full"> + <div class="modal-content background_transparent"> + <div class="modal-body quote_modal"> + <div class="confirm_modal_content"> + <div class="login_modal_inner"> + <div class="login_success"> + <h4>Do You Want to Confirm ?</h4> + </div> + <div class="row"> + <div class="col-md-12 textCenter"> + <button class="btn btn-success" data-dismiss="modal" (click)="confirmCallBack(confirmCallBak,confirmParam)">Yes</button> + <button class="btn btn-danger" data-dismiss="modal">No</button> + </div> + </div> + </div> + </div> + </div> + </div> + </div> </div> \ No newline at end of file diff --git a/src/app/purchase/orders/orders.component.ts b/src/app/purchase/orders/orders.component.ts index 4695875..3dc5bd3 100644 --- a/src/app/purchase/orders/orders.component.ts +++ b/src/app/purchase/orders/orders.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, ViewChild, ElementRef } from '@angular/core'; import { NgxCarousel } from 'ngx-carousel'; import { WebService } from '../../provider/web.service'; import { ImageStorage } from '../../../environments/server.config'; @@ -19,6 +19,10 @@ export class OrdersComponent implements OnInit { imageServer: string; trend_loader:boolean; trendingProductData:any; + confirmParam: string = ''; + confirmCallBak: string = ''; + + @ViewChild("confirmModal") public confirmModalRef: ElementRef; public carouselTile: NgxCarousel; @@ -84,12 +88,9 @@ export class OrdersComponent implements OnInit { }); } - cancelOrder(odrId){ - if(odrId < 0){ - return false; - } + cancelOrder(params){ this.loader = true; - this.webService.post_data('cancelOrder',{"order_id":odrId}).subscribe(response => { + this.webService.post_data('cancelOrder',params).subscribe(response => { if(response.status == 'success'){ this.getMyOrders(); } @@ -97,6 +98,37 @@ export class OrdersComponent implements OnInit { }) } + cnfCancelOrder(odrId){ + if(odrId < 0){ + return false; + } + this.showConfirmPopUp('cancelOrder',{"order_id":odrId}); + } + + showConfirmPopUp(fn_name: string, param: any){ + if(fn_name === ''){ + return false; + } + if(param){ + param = JSON.stringify(param); + } + this.confirmParam = param; + this.confirmCallBak = fn_name; + this.confirmModalRef.nativeElement.click(); + } + + confirmCallBack(fn_name: string,param: string){ + if(fn_name === '' || !this[fn_name]){ + return false; + } + if(param !== ''){ + param = JSON.parse(param); + this[fn_name](param); + } else { + this[fn_name](); + } + } + trendingProducts(){ this.trend_loader = true; this.webService.get_data('getTrendingPrdts').subscribe(response => { diff --git a/src/app/purchase/productdetails/productdetails.component.html b/src/app/purchase/productdetails/productdetails.component.html index d6e3be8..2300dbf 100644 --- a/src/app/purchase/productdetails/productdetails.component.html +++ b/src/app/purchase/productdetails/productdetails.component.html @@ -46,8 +46,8 @@ <div class="count_btn" (click)="add()">+</div> </div> <div class="btn_bay"> - <button class="btn_cart btn">Add to Cart</button> - <!-- <button class="btn_buy btn" (click)="goToPage('address')">Buy Now</button> --> + <button class="btn_cart btn" (click)="addToCart(productDetails.amount)" *ngIf="loginDetails && cartValue == '1'">Add to Cart</button> + <button class="btn_cart btn" (click)="goCart()" *ngIf="loginDetails && cartValue == '2'">Go to Cart</button> <button class="btn_buy btn" (click)="buyProduct(productDetails.amount)">{{loginDetails?'Buy Now':'Login And Continue'}}</button> </div> </div> diff --git a/src/app/purchase/productdetails/productdetails.component.ts b/src/app/purchase/productdetails/productdetails.component.ts index a4d957f..17a1c0e 100644 --- a/src/app/purchase/productdetails/productdetails.component.ts +++ b/src/app/purchase/productdetails/productdetails.component.ts @@ -29,6 +29,7 @@ export class ProductdetailsComponent implements OnInit { page: number = 1; reviewArray:any = new Array(); total_page: number = 1; + cartValue :number = 1; @ViewChild("indexLoginModal") loginModalRef: ElementRef; @@ -88,6 +89,7 @@ export class ProductdetailsComponent implements OnInit { this.productDetails = response.data; this.reviewArray = response.data.reviews.data; this.total_page = response.data.reviews.meta.total_pages; + this.cartValue = (this.productDetails.cart_id > 0) ? 2 : 1; if(this.productDetails.images.length > 0){ thisObj.productDetails.images.forEach(function (data) { image = thisObj.imageServer + data.image; @@ -145,6 +147,27 @@ export class ProductdetailsComponent implements OnInit { this.goToPage('address',''); } + addToCart(amount){ + if(!this.loginDetails){ + this.loginModalRef.nativeElement.click(); + return false; + } + this.loader=true; + this.product_data = {product_id:this.product_id,quantity:this.count,amount:this.count*amount,customer_id:this.loginDetails.customer_id}; + this.webService.post_data('addToCart',this.product_data).subscribe(response => { + if(response.status == 'success'){ + if(response.data > 0){ + this.cartValue = 2; + } + } + this.loader = false; + }); + } + + goCart(){ + this.goToPage('cart',''); + } + latestPrdtDtls(prdt_id){ this.goToPage('productdetails',{"product_id":prdt_id}); } diff --git a/src/app/purchase/productlist/productlist.component.ts b/src/app/purchase/productlist/productlist.component.ts index 26ab2c9..fb4a642 100644 --- a/src/app/purchase/productlist/productlist.component.ts +++ b/src/app/purchase/productlist/productlist.component.ts @@ -31,8 +31,8 @@ export class ProductlistComponent implements OnInit { this.loader = true; this.productArray = []; this.filterParam = {"key":'',"brand_id":Array(),"minPrice":'',"maxPrice":'','page':1}; - this.imageServer = ImageStorage; + route.params.subscribe(val => { this.route.queryParams.subscribe(params => { this.searchKey = params['key']; -- libgit2 0.27.1