box.js
1.2 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
import App from '../../utils/api.js'
import util from '../../utils/util.js'
Component({
properties:{
seller:Object
},
data:{
boxhidden:true,
},
attached(){
console.log(this.data.seller)
},
methods:{
getcartlist(){
App.Orders.GetCartByOpenid({sellerid:this.data.seller.id,openid:util.cache('openid')}).then((json)=>{
console.log(json,'yyyyyyy')
if(json.ret==200){
json.data.forEach((v,i)=>{
v.price=Number(v.price);
v.member_price=Number(v.member_price);
v.count=Number(v.count);
})
this.setData({
cartlist:json.data
})
}
})
},
showbox(){
this.setData({
boxhidden:false
})
this.getcartlist();
},
hidebox(){
this.setData({
boxhidden:true
})
},
tellfood(e){
this.triggerEvent('tellfood',e.detail);
if(e.detail.count==0){
this.getcartlist();
}
},
clearfood(){
App.Orders.ClearCar({sellerid:this.data.seller.id,openid:util.cache('openid')}).then((json)=>{
if(json.ret==200){
wx.showToast({
title:'购物车已清空',
icon:'none',
duration:1500,
mask:true
})
this.getcartlist();
this.hidebox();
this.triggerEvent('refresh')
}
})
}
}
})