Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import {Component} from '@angular/core';
import {IonicPage, ModalController, NavController, NavParams} from 'ionic-angular';
import {ServeService} from "../../serve.service";
import {GoodsOrderPage} from "../goods-order/goods-order";
import {SpcesComponent} from "../../../../components/spces/spces";
import {CommonService} from "../../../../provide/common.service";
@Component({
selector: 'page-goods-cart',
templateUrl: 'goods-cart.html',
})
export class GoodsCartPage {
cartList = [];
footerView = false;
chooseObj = [];
checkAll;
constructor(public navCtrl: NavController, public navParams: NavParams,
private serveSer: ServeService, private modalCtrl: ModalController,
private commonSer: CommonService) {
}
ionViewDidEnter() {
this.footerView = true;
this.getCart();
}
ionViewWillLeave() {
this.footerView = false;
}
changeCheck(goods) {
const data = {
id: goods.id,
amount: goods.amount,
brand: goods.brand,
officeId: goods.officeId,
model: goods.model,
specs1: goods.specs1,
specs2: goods.specs2,
specs3: goods.specs3,
specs4: goods.specs4,
specs5: goods.specs5,
};
let get = 0;
let number;
this.chooseObj.forEach((e, index) => {
if (e.id == goods.id) {
get = 1;
number = index;
}
});
if (get == 0) this.chooseObj.push(data);
if (get == 1) this.chooseObj.splice(number, 1);
}
//获取购物车列表
getCart() {
const data = {
P_pageNumber: '1',
P_pageSize: '100',
status: 1
};
this.serveSer.shoppingCar(data).subscribe(
(res) => {
this.cartList = res.list;
this.cartList.forEach(e => {
e.checkbox = false;
})
}
)
}
//选择规格 数量
choose(item) {
const data = {
amount:item.amount,
specs1:item.specs1,
specs2:item.specs2,
specs3:item.specs3,
specs4:item.specs4,
specs5:item.specs5,
}
let modal = this.modalCtrl.create(SpcesComponent, {goodsId: item.officeId,data:data});
updateCart(data){
this.serveSer.saveOrderSuppy(data).subscribe(
(res)=>{
this.getCart();
}
)
}
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
//全选
selectAll(e) {
this.chooseObj = [];
if (e == false) {
this.cartList.forEach(e => {
e.checkbox = false;
})
} else {
this.cartList.forEach(e => {
e.checkbox = true;
this.chooseObj.push(e);
})
}
}
//提交订单
submit() {
if (this.chooseObj.length == 0) {
this.commonSer.toast('请选择申请物品')
return false;
}
const data = {
"status": 2,
"orderSuppies": this.chooseObj
};
this.commonSer.alert('确定申请所选物品?', () => {
this.serveSer.saveOrder(data).subscribe(
(res) => {
if (res.errcode == 1000) {
this.commonSer.toast("提交申请成功");
this.getCart();
} else {
this.commonSer.toast(res.errmsg);
}
}
)
});
}
//前往订单
goOrder() {
this.navCtrl.push(GoodsOrderPage);
}
}