|
@@ -12,8 +12,10 @@ Page({
|
|
|
activeTab:0,
|
|
|
showCart:false,
|
|
|
mask:true,
|
|
|
- series:[],
|
|
|
-
|
|
|
+ series:[],//商品分类
|
|
|
+ currentProductList:[],//商品
|
|
|
+ totalNum:0,//购物车总数
|
|
|
+ totalPrice:0.00//购物车总价格
|
|
|
},
|
|
|
|
|
|
|
|
@@ -31,7 +33,6 @@ Page({
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-
|
|
|
},
|
|
|
|
|
|
//商品分类列表
|
|
@@ -65,7 +66,8 @@ Page({
|
|
|
self.setData({
|
|
|
cartId:rs.id,
|
|
|
cartList:rs.list,
|
|
|
- cartListNum:rs.count?rs.count:0,
|
|
|
+ totalNum:rs.totalNum?rs.totalNum:0,
|
|
|
+ totalPrice:rs.totalPrice?rs.totalPrice:0.00,
|
|
|
})
|
|
|
},
|
|
|
|
|
@@ -89,7 +91,9 @@ Page({
|
|
|
// });
|
|
|
await this.updateCart(productId,type);
|
|
|
await this.getCart();
|
|
|
-
|
|
|
+ if(this.data.cartList.length ==0){
|
|
|
+ this.setData({showCart:false})
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
onLoad: async function (options) {
|
|
@@ -104,19 +108,31 @@ Page({
|
|
|
},
|
|
|
|
|
|
startOrder: function (e) {
|
|
|
-
|
|
|
if(this.data.cartList.length>0){
|
|
|
+ this.setData({showCart:false})
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/foodOrder/foodOrder?tableId='+this.data.tableId+"&storeId="+this.data.storeId+"&cartId="+this.data.cartId
|
|
|
})
|
|
|
}else{
|
|
|
- wx.showModal({
|
|
|
- content: '请选择产品',
|
|
|
+ wx.showToast({
|
|
|
+ title: '请选择产品',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 1000
|
|
|
})
|
|
|
+
|
|
|
}
|
|
|
|
|
|
},
|
|
|
-
|
|
|
+ handleTabClick: function (e) {
|
|
|
+ let index = e.currentTarget.dataset.index;
|
|
|
+ this.activeTab(index);
|
|
|
+ this.setData({ activeTab: index });
|
|
|
+ },
|
|
|
+ handleSwiperChange: function (e) {
|
|
|
+ var index = e.detail.current;
|
|
|
+ this.activeTab(index);
|
|
|
+ this.setData({ activeTab: index });
|
|
|
+ },
|
|
|
activeTab: function (_activeTab) {
|
|
|
var len = this.data.series.length;
|
|
|
if (len === 0) return;
|
|
@@ -148,7 +164,17 @@ Page({
|
|
|
openCartDialog: function(e){
|
|
|
let type = e.currentTarget.dataset.type;
|
|
|
if (type === 'open'){
|
|
|
- this.setData({showCart:true})
|
|
|
+ if(this.data.cartList.length==0){
|
|
|
+ wx.showToast({
|
|
|
+ title: '请选择产品',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 1000
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ this.setData({showCart:true})
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}else{
|
|
|
this.setData({showCart:false})
|
|
|
}
|