Commit d46d29b8 authored by wangqinghua's avatar wangqinghua

购物车优化

parent be643688
...@@ -70,23 +70,23 @@ export class SpcesComponent { ...@@ -70,23 +70,23 @@ export class SpcesComponent {
this.choose.id = this.goods.id; this.choose.id = this.goods.id;
this.choose.model = this.goods.model; this.choose.model = this.goods.model;
console.log(this.choose); console.log(this.choose);
if(this.goods.specs1List.length > 0 && !this.choose.specs1){ if(this.goods.specs1List && this.goods.specs1List.length > 0 && !this.choose.specs1){
this.commonSer.toast('请选择规格!'); this.commonSer.toast('请选择规格!');
return false; return false;
} }
if(this.goods.specs2List.length > 0 && !this.choose.specs2){ if(this.goods.specs2List && this.goods.specs2List.length > 0 && !this.choose.specs2){
this.commonSer.toast('请选择规格!'); this.commonSer.toast('请选择规格!');
return false; return false;
} }
if(this.goods.specs3List.length > 0 && !this.choose.specs3){ if(this.goods.specs3List && this.goods.specs3List.length > 0 && !this.choose.specs3){
this.commonSer.toast('请选择规格!'); this.commonSer.toast('请选择规格!');
return false; return false;
} }
if(this.goods.specs4List.length > 0 && !this.choose.specs4){ if(this.goods.specs4List && this.goods.specs4List.length > 0 && !this.choose.specs4){
this.commonSer.toast('请选择规格!'); this.commonSer.toast('请选择规格!');
return false; return false;
} }
if(this.goods.specs5List.length > 0 && !this.choose.specs5){ if(this.goods.specs5List && this.goods.specs5List.length > 0 && !this.choose.specs5){
this.commonSer.toast('请选择规格!'); this.commonSer.toast('请选择规格!');
return false; return false;
} }
......
...@@ -12,35 +12,43 @@ ...@@ -12,35 +12,43 @@
<ion-content> <ion-content>
<div class="goodsItem" *ngFor="let goods of cartList"> <div class="cart">
<ion-row class="cart-item"> <div class="goodsItem" *ngFor="let goods of cartList">
<ion-col col-2 class="center"> <ion-row class="cart-item">
<ion-checkbox [(ngModel)]="goods.checkbox" color="danger" <ion-col col-2 class="center">
(ngModelChange)="changeCheck(goods)"></ion-checkbox> <ion-checkbox [(ngModel)]="goods.checkbox" color="danger"
</ion-col> (ngModelChange)="changeCheck(goods)"></ion-checkbox>
<ion-col col-6> </ion-col>
<p class="model"> <ion-col col-6>
{{goods.model}} <p class="model">
</p> {{goods.model}}
<p> </p>
<span class="amount">数量:{{goods.amount}}</span> <p>
<span class="specs">规格: <span class="amount">数量:{{goods.amount}}</span>
<span class="specs">规格:
<span>{{goods.specs1}}</span> <span>{{goods.specs1}}</span>
<span>{{goods.specs2}}</span> <span>{{goods.specs2}}</span>
<span>{{goods.specs3}}</span> <span>{{goods.specs3}}</span>
<span>{{goods.specs4}}</span> <span>{{goods.specs4}}</span>
<span>{{goods.specs5}}</span> <span>{{goods.specs5}}</span>
</span> </span>
</p> </p>
</ion-col> </ion-col>
<ion-col col-2 class="center" (click)="deletI(goods)"> <ion-col col-2 class="center" (click)="deletI(goods)">
<span class="icon iconfont icon-round-delete"></span> <span class="icon iconfont icon-round-delete"></span>
</ion-col> </ion-col>
<ion-col col-2 class="center" (click)="choose(goods)"> <ion-col col-2 class="center" (click)="choose(goods)">
<span class="icon iconfont icon-fabu"></span> <span class="icon iconfont icon-fabu"></span>
</ion-col> </ion-col>
</ion-row> </ion-row>
</div>
</div> </div>
<ion-list text-center style="margin-top: 10rem;color: #666666" *ngIf="!isLoad && cartList.length == 0">
<img style="width: 20%;" src="./assets/imgs/no-info.png" alt="">
<p text-center>
购物车空空如也
</p>
</ion-list>
</ion-content> </ion-content>
<div *ngIf="footerView" class="stuff-footer"> <div *ngIf="footerView" class="stuff-footer">
<div class="footer-flex"> <div class="footer-flex">
......
page-goods-cart { page-goods-cart {
.cart{
margin-bottom: 8rem;
}
.stuff-footer { .stuff-footer {
position: fixed; position: fixed;
bottom: 0; bottom: 0;
height: 4rem; height: 5rem;
width: 100%; width: 100%;
text-align: center; text-align: center;
border-top: 1px solid #eeeeee; border-top: 1px solid #eeeeee;
z-index: 9; z-index: 9;
background-color: #fff;
.item-ios.item-block .item-inner {
border: none;
}
.button-small-ios {
height: 2.6rem;
}
img { img {
margin-top: .5rem; margin-top: .5rem;
...@@ -49,7 +61,8 @@ page-goods-cart { ...@@ -49,7 +61,8 @@ page-goods-cart {
border-bottom: 1px solid #ddd; border-bottom: 1px solid #ddd;
margin-bottom: 5px; margin-bottom: 5px;
padding: 5px; padding: 5px;
.model{
.model {
padding: 5px 0; padding: 5px 0;
font-size: 1.4rem; font-size: 1.4rem;
} }
...@@ -69,18 +82,20 @@ page-goods-cart { ...@@ -69,18 +82,20 @@ page-goods-cart {
} }
} }
.center{ .center {
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
} }
} }
.footer-flex{
.footer-flex {
display: flex; display: flex;
} }
.footer-flex > div{
.footer-flex > div {
width: 50%; width: 50%;
line-height: 3rem; line-height: 4rem;
padding: 0 20px; padding: 0 20px;
} }
......
...@@ -16,6 +16,7 @@ export class GoodsCartPage { ...@@ -16,6 +16,7 @@ export class GoodsCartPage {
chooseObj = []; chooseObj = [];
checkAll; checkAll;
isLoad = true;
constructor(public navCtrl: NavController, public navParams: NavParams, constructor(public navCtrl: NavController, public navParams: NavParams,
private serveSer: ServeService, private modalCtrl: ModalController, private serveSer: ServeService, private modalCtrl: ModalController,
...@@ -66,6 +67,7 @@ export class GoodsCartPage { ...@@ -66,6 +67,7 @@ export class GoodsCartPage {
this.serveSer.shoppingCar(data).subscribe( this.serveSer.shoppingCar(data).subscribe(
(res) => { (res) => {
this.cartList = res.list; this.cartList = res.list;
this.isLoad = false;
this.cartList.forEach(e => { this.cartList.forEach(e => {
e.checkbox = false; e.checkbox = false;
}) })
......
...@@ -45,12 +45,12 @@ export class GoodsCollectPage { ...@@ -45,12 +45,12 @@ export class GoodsCollectPage {
this.getTypeList(); this.getTypeList();
} }
search(){ search() {
this.pageNumber = 1; this.pageNumber = 1;
this.getList(); this.getList();
} }
filterType(item){ filterType(item) {
this.obj.type = item; this.obj.type = item;
this.getList(); this.getList();
} }
...@@ -82,12 +82,14 @@ export class GoodsCollectPage { ...@@ -82,12 +82,14 @@ export class GoodsCollectPage {
//打开过滤条件 //打开过滤条件
fliter() { fliter() {
let modal = this.modalCtrl.create(FilterComponent, {list: this.typeList,choose:this.obj.type}, { let modal = this.modalCtrl.create(FilterComponent, {list: this.typeList, choose: this.obj.type}, {
enterAnimation: 'modal-from-right-enter', enterAnimation: 'modal-from-right-enter',
leaveAnimation: 'modal-from-right-leave' leaveAnimation: 'modal-from-right-leave'
}); });
modal.onDidDismiss(data => { modal.onDidDismiss(data => {
this.filterType(data.choose); if (data) {
this.filterType(data.choose);
}
}); });
modal.present(); modal.present();
} }
...@@ -142,7 +144,7 @@ export class GoodsCollectPage { ...@@ -142,7 +144,7 @@ export class GoodsCollectPage {
} }
//选择规格 数量 //选择规格 数量
choose(item){ choose(item) {
let modal = this.modalCtrl.create(SpcesComponent, {goodsId: item.id}); let modal = this.modalCtrl.create(SpcesComponent, {goodsId: item.id});
modal.onDidDismiss(res => { modal.onDidDismiss(res => {
if (res) { if (res) {
...@@ -154,20 +156,20 @@ export class GoodsCollectPage { ...@@ -154,20 +156,20 @@ export class GoodsCollectPage {
} }
//添加到购物车 //添加到购物车
addCart(){ addCart() {
const data = { const data = {
"status":1, "status": 1,
"orderSuppies":[this.chooseObj] "orderSuppies": [this.chooseObj]
}; };
this.serveSer.saveOrder(data).subscribe( this.serveSer.saveOrder(data).subscribe(
(res)=>{ (res) => {
this.commonSer.toast('添加成功!') this.commonSer.toast('添加成功!')
} }
) )
} }
//购物车 //购物车
goCart(){ goCart() {
this.navCtrl.push(GoodsCartPage); this.navCtrl.push(GoodsCartPage);
} }
......
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