From 21f8932b9459ec6cf306ad2b7b3e341e3fa1e7dc Mon Sep 17 00:00:00 2001 From: Le Deng Date: Fri, 10 Mar 2017 13:45:53 -0500 Subject: [PATCH] latet --- bookstore-api/.idea/workspace.xml | 4 +- store-front/src/app/app.routing.ts | 6 +- .../app/components/order/order.component.html | 357 +++++++++++++++++- .../app/components/order/order.component.ts | 53 ++- .../shopping-cart.component.html | 4 +- 5 files changed, 415 insertions(+), 9 deletions(-) diff --git a/bookstore-api/.idea/workspace.xml b/bookstore-api/.idea/workspace.xml index f96979b..72252bf 100644 --- a/bookstore-api/.idea/workspace.xml +++ b/bookstore-api/.idea/workspace.xml @@ -1036,12 +1036,12 @@ - + - diff --git a/store-front/src/app/app.routing.ts b/store-front/src/app/app.routing.ts index 4b660a2..65eb5dc 100644 --- a/store-front/src/app/app.routing.ts +++ b/store-front/src/app/app.routing.ts @@ -10,7 +10,7 @@ import {MyProfileComponent} from './components/my-profile/my-profile.component'; import {BookListComponent} from './components/book-list/book-list.component'; import {BookDetailComponent} from './components/book-detail/book-detail.component'; import {ShoppingCartComponent} from './components/shopping-cart/shopping-cart.component'; - +import {OrderComponent} from './components/order/order.component'; const appRoutes: Routes = [ { @@ -41,6 +41,10 @@ const appRoutes: Routes = [ { path: 'shoppingCart', component: ShoppingCartComponent + }, + { + path: 'order', + component: OrderComponent } ]; diff --git a/store-front/src/app/components/order/order.component.html b/store-front/src/app/components/order/order.component.html index c1bb21d..8c49296 100644 --- a/store-front/src/app/components/order/order.component.html +++ b/store-front/src/app/components/order/order.component.html @@ -1,3 +1,354 @@ -

- order works! -

+
+
+
+

Shopping Cart

+
+
+ +
+
+
+ +
+
+
+
+
+ +

By placing your order, you agree to Le's Bookstore privacy notice and + conditions of use.

+
+

Order Summary

+
+
+ Total before tax: +
+
+ $ + {{shoppingCart.grandTotal}} +
+
+
+
+ Estimated tax: +
+
+ ${{shoppingCart.grandTotal*0.06 | number : '1.2-2'}} +
+
+
+
+
+

Order total:

+
+
+

${{shoppingCart.grandTotal*1.06 | number : '1.2-2'}} +

+
+
+ +
+
+
+
+
+
There are some fields missing. Field with * is required.
+
+ + + +
+
+

+ 1. Shipping Address +

+
+
+ + + + + + + + + + + + + +
Available Shipping AddressOperations
+ {{userShipping.userShippingStreet1}}, {{userShipping.userShippingStreet2}}, {{userShipping.userShippingCity}}, {{userShipping.userShippingState}} + + use + this address +
+
+ + +
+
+ + +
+
+ +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+ +
+
+
+ + +
+
+

+ 2. Payment Information +

+
+
+ + + + + + + + + + + + + +
Available Credit CardOperations
+ {{userPayment.cardName}} + + use this address + +
+ +
+
+ +
+
+ + +
+
+ + +
+
+ +
+ + +
+
+
+
+
+
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+ + +
+
+
+ +
+ +
+
+ + +
+
+ + +
+
+ +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+ Next +
+
+
+ + +
+
+

+ 3. Review Items and Shipping +

+
+
+

Choose your shipping method:

+
+ +
+
+ +
+
+
+

Products

+
+

Price

+
+

Qty

+
+ +
+
+
+ +
+
+

{{cartItem.book.title}}

+

In Stock

+

Only {{cartItem.book.inStockNumber}} In Stock +

+

Product Unavailable

+ delete +
+
+
${{cartItem.book.ourPrice}} +
+
+
+
{{cartItem.qty}}
+
+
+
+

Total Price ({{cartItemNumber}} items): ${{shoppingCart.grandTotal}}

+
+
+ +

By placing your order, you agree to Le's Bookstore privacy notice and + conditions of use.

+
+
+
+
+
+
+
+
diff --git a/store-front/src/app/components/order/order.component.ts b/store-front/src/app/components/order/order.component.ts index f0fbd72..bbfd19d 100644 --- a/store-front/src/app/components/order/order.component.ts +++ b/store-front/src/app/components/order/order.component.ts @@ -1,4 +1,15 @@ import { Component, OnInit } from '@angular/core'; +import {AppConst} from '../../constants/app-const'; +import {Book} from '../../models/book'; +import {Router} from "@angular/router"; +import {CartService} from '../../services/cart.service'; +import {CartItem} from '../../models/cart-item'; +import {ShoppingCart} from '../../models/shopping-cart'; +import {ShippingAddress} from '../../models/shipping-address'; +import {BillingAddress} from '../../models/billing-address'; +import {UserPayment} from '../../models/user-payment'; +import {UserBilling} from '../../models/user-billing'; +import {UserShipping} from '../../models/user-shipping'; @Component({ selector: 'app-order', @@ -6,10 +17,50 @@ import { Component, OnInit } from '@angular/core'; styleUrls: ['./order.component.css'] }) export class OrderComponent implements OnInit { + private serverPath = AppConst.serverPath; + private selectedBook: Book; + private cartItemList: CartItem[] = []; + private cartItemNumber: number; + private shoppingCart: ShoppingCart = new ShoppingCart(); + private cartItemUpdated:boolean; + private shippingAddress:ShippingAddress=new ShippingAddress(); + private billingAddress:BillingAddress = new BillingAddress(); + private userPayment:UserPayment = new UserPayment(); + private userShipping:UserShipping = new UserShipping(); + private userBilling: UserBilling = new UserBilling(); - constructor() { } + constructor(private router:Router, private cartService: CartService) { } + + onSelect(book:Book) { + this.selectedBook = book; + this.router.navigate(['/bookDetail', this.selectedBook.id]); + } + + getCartItemList(){ + this.cartService.getCartItemList().subscribe( + res=>{ + this.cartItemList = res.json(); + this.cartItemNumber = this.cartItemList.length; + }, + error=>{ + console.log(error.text()); + } + ); + } ngOnInit() { + this.getCartItemList(); + + + this.cartService.getShoppingCart().subscribe( + res=>{ + console.log(res.json()); + this.shoppingCart=res.json(); + }, + error=>{ + console.log(error.text()); + } + ); } } diff --git a/store-front/src/app/components/shopping-cart/shopping-cart.component.html b/store-front/src/app/components/shopping-cart/shopping-cart.component.html index d24cf0e..71df3bd 100644 --- a/store-front/src/app/components/shopping-cart/shopping-cart.component.html +++ b/store-front/src/app/components/shopping-cart/shopping-cart.component.html @@ -1,7 +1,7 @@
-

Shopping Cart

+

Checkout

@@ -17,7 +17,7 @@