|
@@ -31,8 +31,14 @@ Page({
|
|
|
let free_info = res.datas.free_info;
|
|
|
let summary_datas = res.datas.summary;
|
|
|
let cart_list = res.datas.cart_list;
|
|
|
- let lastCartListId = cart_list[cart_list.length - 1].cart_id;
|
|
|
let summary = [];
|
|
|
+ if (cart_list.length <= 0) {
|
|
|
+ self.setData({
|
|
|
+ free_info: free_info || self.data.free_info
|
|
|
+ });
|
|
|
+ wx.hideLoading();
|
|
|
+ return;
|
|
|
+ }
|
|
|
for (let item of cart_list) {
|
|
|
item.checked = false;
|
|
|
}
|
|
@@ -45,6 +51,7 @@ Page({
|
|
|
}
|
|
|
}
|
|
|
if (hasmore) {
|
|
|
+ let lastCartListId = cart_list[cart_list.length - 1].cart_id;
|
|
|
self.setData({
|
|
|
hasmore: true,
|
|
|
curpage: lastCartListId
|
|
@@ -52,8 +59,7 @@ Page({
|
|
|
}
|
|
|
else {
|
|
|
self.setData({
|
|
|
- hasmore: false,
|
|
|
- curpage: lastCartListId
|
|
|
+ hasmore: false
|
|
|
})
|
|
|
}
|
|
|
let localSummary = self.data.summary;
|
|
@@ -155,17 +161,7 @@ Page({
|
|
|
else {
|
|
|
quantity = num - quantity;
|
|
|
if (quantity <= 0) {
|
|
|
- wx.showModal({
|
|
|
- title: "提示",
|
|
|
- content: "确定要删除吗?",
|
|
|
- success: function (res) {
|
|
|
- if (res.confirm) {
|
|
|
- self.req_goods_num(cart_id, quantity, self.del_cart(cart_id, goods_id));
|
|
|
- } else if (res.cancel) {
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
+ this.cancal_cart(e,goods_id, cart_id);
|
|
|
}
|
|
|
else {
|
|
|
self.req_goods_num(cart_id, quantity);
|
|
@@ -190,6 +186,22 @@ Page({
|
|
|
cart_list
|
|
|
})
|
|
|
},
|
|
|
+ cancal_cart(e,goodsid,cartid){
|
|
|
+ let self = this;
|
|
|
+ let goods_id = e.target.dataset.goodsid || goodsid;
|
|
|
+ let cart_id = e.target.dataset.cartid || cartid;
|
|
|
+ wx.showModal({
|
|
|
+ title: "提示",
|
|
|
+ content: "确定要删除吗?",
|
|
|
+ success: function (res) {
|
|
|
+ if (res.confirm) {
|
|
|
+ self.req_goods_num(cart_id, 0, self.del_cart(cart_id, goods_id));
|
|
|
+ } else if (res.cancel) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
total(){
|
|
|
let self = this;
|
|
|
let cart_item = [];
|