item.js
2.14 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
const tagTypeList = ['price_gift', 'gift', 'ticket', 'advance'];
Component({
properties: {
item: {
type: Object,
value: {},
observer: '_itemChange'
},
index: {
type: Number,
value: 0
},
isEditing: {
type: Boolean,
value: false,
observer: '_editChange'
},
isInvalid: {
type: Boolean,
value: false
}
},
methods: {
_itemChange(item) {
if (item) {
this.selected = item.selected;
item.mark_price = item.sales_price;
switch (item.goods_type) {
case 'price_gift':
item.sales_price = +item.last_price;
if (item.storage_number > 1) {
item.storage_number = 1;
}
break;
case 'gift':
item.sales_price = 0;
if (item.storage_number > 1) {
item.storage_number = 1;
}
break;
default:
if (item.last_vip_price < item.sales_price) {
item.sales_price = item.last_vip_price;
}
break;
}
if (item.mark_price <= item.sales_price) {
delete item.mark_price;
}
if (tagTypeList.indexOf(item.goods_type) < 0 && item.buy_number > item.storage_number) {
item.goods_type = 'lowStorage';
}
item.isVipPrice = item.vip_discount_money > 0;
this.setData({item});
}
},
_editChange(isEdit) {
let item = {...this.data.item};
if (isEdit) {
if (item.selected === 'Y') {
this.triggerEvent('removeGoodsListInEdit', item);
}
} else if (this.selected) {
item.selected = this.selected;
this.setData({item: item});
}
},
chooseItemAction() {
let item = {...this.data.item};
if (this.data.isEditing) {
item.selected = item.selected === 'Y' ? 'N' : 'Y';
this.triggerEvent('removeGoodsListInEdit', item);
this.setData({item});
} else {
this.triggerEvent('chooseGoodsItem', item);
}
},
editGoodsNum(e) {
this.triggerEvent('editGoodsNum', e.detail);
}
}
});