购物车

This commit is contained in:
pplokijuhyg 2019-12-20 14:16:06 +08:00
parent 38280893bd
commit 487fee5b04
2 changed files with 73 additions and 46 deletions

View File

@ -33,6 +33,8 @@ Page({
this.setData({
list: res.data.result
})
this.num()
})
},
onLoad: function (options) {
@ -44,6 +46,7 @@ Page({
userid: res.data.data.user_id
})
this.getlist()
})
},
sub() {
@ -109,7 +112,7 @@ Page({
sel++
}
}
if(sel == this.data.list.length){
if (sel == this.data.list.length && this.data.list.length != 0) {
this.setData({
all: true
})
@ -147,5 +150,29 @@ Page({
}
this.num()
},
del() {
for (let i in this.data.list) {
// console.log(i)
if (this.data.select[i]) {
// num += parseFloat(this.data.list[i].goods_price)*100
// sel++
request({
url: "Cart/delCart",
urldata: {
id: this.data.list[i].id
}
}).then((res) => {
console.log('删除成功')
this.setData({
list: [],
select: [],
userid: 0,
price: "0.00"
})
this.onLoad()
})
}
}
}
})

View File

@ -18,7 +18,7 @@
<text class="pri">${{price}}</text>
</view>
<view class="right">
<text class="del">删除</text>
<text class="del" bind:tap="del">删除</text>
<text class="sub" bindtap="sub">结算</text>
</view>
</view>