|
|
@ -110,7 +110,6 @@ Page({
|
|
|
|
this.cy_getStoreProduct();
|
|
|
|
this.cy_getStoreProduct();
|
|
|
|
mqttMessage.mqttSubscribe(5);
|
|
|
|
mqttMessage.mqttSubscribe(5);
|
|
|
|
mqttMessage.mqttOn(this);
|
|
|
|
mqttMessage.mqttOn(this);
|
|
|
|
this.cy_reloadData();
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
onMessage: function (top, message) {
|
|
|
|
onMessage: function (top, message) {
|
|
|
@ -147,10 +146,10 @@ Page({
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
wx.showToast({
|
|
|
|
/*wx.showToast({
|
|
|
|
title: data.message,
|
|
|
|
title: data.message,
|
|
|
|
icon: "none"
|
|
|
|
icon: "none"
|
|
|
|
})
|
|
|
|
})*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, function (err) {
|
|
|
|
}, function (err) {
|
|
|
|
wx.showToast({
|
|
|
|
wx.showToast({
|
|
|
@ -181,10 +180,10 @@ Page({
|
|
|
|
evaluateList: data.list,
|
|
|
|
evaluateList: data.list,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
wx.showToast({
|
|
|
|
/*wx.showToast({
|
|
|
|
title: data.message,
|
|
|
|
title: data.message,
|
|
|
|
icon: "none"
|
|
|
|
icon: "none"
|
|
|
|
})
|
|
|
|
})*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, function (err) {
|
|
|
|
}, function (err) {
|
|
|
|
|
|
|
|
|
|
|
@ -204,15 +203,9 @@ Page({
|
|
|
|
var ignores = ["programId", "storeId"]; // 不签名参数
|
|
|
|
var ignores = ["programId", "storeId"]; // 不签名参数
|
|
|
|
// app.globalData.serverUrl
|
|
|
|
// app.globalData.serverUrl
|
|
|
|
app.jsapi.api(app.globalData.appKey, app.globalData.appSecret, app.globalData.serverUrl).ajax(params, ignores, function (json) {
|
|
|
|
app.jsapi.api(app.globalData.appKey, app.globalData.appSecret, app.globalData.serverUrl).ajax(params, ignores, function (json) {
|
|
|
|
console.log(json);
|
|
|
|
|
|
|
|
var data = json.data;
|
|
|
|
var data = json.data;
|
|
|
|
if (data.status == 1) {
|
|
|
|
if (data.status == 1) {
|
|
|
|
that.cy_changeStoreProductData(data.data);
|
|
|
|
that.cy_changeStoreProductData(data.data);
|
|
|
|
} else {
|
|
|
|
|
|
|
|
wx.showToast({
|
|
|
|
|
|
|
|
title: data.message,
|
|
|
|
|
|
|
|
icon: "none"
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, function (err) {
|
|
|
|
}, function (err) {
|
|
|
|
wx.showToast({
|
|
|
|
wx.showToast({
|
|
|
@ -221,7 +214,57 @@ Page({
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* 查询沽清数据
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
cy_changeGuQing: function(param, type) {
|
|
|
|
|
|
|
|
var that = this;
|
|
|
|
|
|
|
|
var params = {
|
|
|
|
|
|
|
|
method: "saleclear.business.list",
|
|
|
|
|
|
|
|
storeId: app.orderTicket.storeId,
|
|
|
|
|
|
|
|
pageNumber: 1,
|
|
|
|
|
|
|
|
pageSize: 500
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
var ignores = ["pageNumber", "pageSize"]; // 不签名参数
|
|
|
|
|
|
|
|
app.jsapi.api(app.globalData.appKey, app.globalData.appSecret, app.globalData.serverUrl).ajax(params, ignores, function (json) {
|
|
|
|
|
|
|
|
var data = json.data;
|
|
|
|
|
|
|
|
if (data.status == 1) {
|
|
|
|
|
|
|
|
for(var i = 0; i < data.list.length; i++) {
|
|
|
|
|
|
|
|
if(param.productId == data.list[i].productId && data.list[i].quantity != 0) {
|
|
|
|
|
|
|
|
data.list[i].typeId = type
|
|
|
|
|
|
|
|
data.list[i].quantity = 1
|
|
|
|
|
|
|
|
//that.cy_updateGuQing(data.list[i]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}, function (err) {
|
|
|
|
|
|
|
|
wx.showToast({
|
|
|
|
|
|
|
|
title: '网络连接失败,请检查',
|
|
|
|
|
|
|
|
icon: "none"
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* 修改沽清数据
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
cy_updateGuQing: function(data) {
|
|
|
|
|
|
|
|
var params = {
|
|
|
|
|
|
|
|
method: "saleclear.business.updatekc",
|
|
|
|
|
|
|
|
storeId: app.orderTicket.storeId,
|
|
|
|
|
|
|
|
jsonString: JSON.stringify(data)
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
var ignores = ["jsonString"]; // 不签名参数
|
|
|
|
|
|
|
|
app.jsapi.api(app.globalData.appKey, app.globalData.appSecret, app.globalData.serverUrl).ajax(params, ignores, function (json) {
|
|
|
|
|
|
|
|
var data = json.data;
|
|
|
|
|
|
|
|
}, function (err) {
|
|
|
|
|
|
|
|
wx.showToast({
|
|
|
|
|
|
|
|
title: '网络连接失败,请检查',
|
|
|
|
|
|
|
|
icon: "none"
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 封装数据
|
|
|
|
* 封装数据
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -315,7 +358,6 @@ Page({
|
|
|
|
var tempList = mapSpec[keyId];
|
|
|
|
var tempList = mapSpec[keyId];
|
|
|
|
if (tempList.length > 1) {
|
|
|
|
if (tempList.length > 1) {
|
|
|
|
product.specFlag = true;
|
|
|
|
product.specFlag = true;
|
|
|
|
|
|
|
|
|
|
|
|
tempList.sort(function (temp1, temp2) {
|
|
|
|
tempList.sort(function (temp1, temp2) {
|
|
|
|
return temp1.price - temp2.price;
|
|
|
|
return temp1.price - temp2.price;
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -387,7 +429,6 @@ Page({
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//
|
|
|
|
|
|
|
|
this.setData({
|
|
|
|
this.setData({
|
|
|
|
categoryList: listCategory,
|
|
|
|
categoryList: listCategory,
|
|
|
|
productList: listProduct,
|
|
|
|
productList: listProduct,
|
|
|
@ -677,9 +718,15 @@ Page({
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else { // 做法多选
|
|
|
|
} else { // 做法多选
|
|
|
|
|
|
|
|
var total = 0;
|
|
|
|
|
|
|
|
for (var k = 0; k < list.list.length; k++){
|
|
|
|
|
|
|
|
if(list.list[k].checked) {
|
|
|
|
|
|
|
|
total++
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
for (var i = 0; i < list.list.length; i++) {
|
|
|
|
for (var i = 0; i < list.list.length; i++) {
|
|
|
|
var make = list.list[i];
|
|
|
|
var make = list.list[i];
|
|
|
|
if (make.makeId == selectMake.makeId) {
|
|
|
|
if (make.makeId == selectMake.makeId && total < 2) {
|
|
|
|
if (currentMultiMark >= 1) {
|
|
|
|
if (currentMultiMark >= 1) {
|
|
|
|
make.checked = !make.checked;
|
|
|
|
make.checked = !make.checked;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -688,6 +735,16 @@ Page({
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(make.makeId == selectMake.makeId && total == 2) {
|
|
|
|
|
|
|
|
if(!make.checked) {
|
|
|
|
|
|
|
|
wx.showToast({
|
|
|
|
|
|
|
|
title: '最多只能选两个',
|
|
|
|
|
|
|
|
icon: 'none'
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
make.checked = !make.checked;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -696,7 +753,6 @@ Page({
|
|
|
|
for (var j = 0; j < tempMakeList.list.length; j++) {
|
|
|
|
for (var j = 0; j < tempMakeList.list.length; j++) {
|
|
|
|
var makeTemp = tempMakeList.list[j];
|
|
|
|
var makeTemp = tempMakeList.list[j];
|
|
|
|
if (makeTemp.checked) {
|
|
|
|
if (makeTemp.checked) {
|
|
|
|
console.log(makeTemp);
|
|
|
|
|
|
|
|
if (idsName != "" && idsName != null) {
|
|
|
|
if (idsName != "" && idsName != null) {
|
|
|
|
idsName = idsName + "、" + makeTemp.showName;
|
|
|
|
idsName = idsName + "、" + makeTemp.showName;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -723,6 +779,13 @@ Page({
|
|
|
|
showSpec: idsName,
|
|
|
|
showSpec: idsName,
|
|
|
|
shopName: shopName
|
|
|
|
shopName: shopName
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
for (var i = 0; i < app.orderTicket.orderList.length; i++) {
|
|
|
|
|
|
|
|
var item = app.orderTicket.orderList[i];
|
|
|
|
|
|
|
|
if(item.productId == productMap.productId) {
|
|
|
|
|
|
|
|
item.showName = idsName;
|
|
|
|
|
|
|
|
app.orderTicket.orderList[i].makeList.push(selectMake);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -737,8 +800,16 @@ Page({
|
|
|
|
productMap.ids = myOrder.cy_getIds(productMap);
|
|
|
|
productMap.ids = myOrder.cy_getIds(productMap);
|
|
|
|
productMap.idsName = myOrder.cy_getIdsName(productMap);
|
|
|
|
productMap.idsName = myOrder.cy_getIdsName(productMap);
|
|
|
|
this.data.selectProduct = productMap;
|
|
|
|
this.data.selectProduct = productMap;
|
|
|
|
|
|
|
|
if(productMap.stock < 1 || productMap.sumCount == productMap.stock) {
|
|
|
|
myOrder.cy_addItem(productMap);
|
|
|
|
wx.showToast({
|
|
|
|
|
|
|
|
title: '菜品库存不足',
|
|
|
|
|
|
|
|
icon: 'none',
|
|
|
|
|
|
|
|
duration: 1500
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
myOrder.cy_addItem(productMap);
|
|
|
|
|
|
|
|
this.cy_changeGuQing(productMap, 'reduce');
|
|
|
|
|
|
|
|
}
|
|
|
|
this.cy_reloadData();
|
|
|
|
this.cy_reloadData();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
@ -760,6 +831,7 @@ Page({
|
|
|
|
}
|
|
|
|
}
|
|
|
|
myOrder.checkPromotionProduct();
|
|
|
|
myOrder.checkPromotionProduct();
|
|
|
|
this.cy_reloadData();
|
|
|
|
this.cy_reloadData();
|
|
|
|
|
|
|
|
this.cy_changeGuQing(productMap, 'add');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -779,8 +851,11 @@ Page({
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
console.error("-------------", app.orderTicket);*/
|
|
|
|
console.error("-------------", app.orderTicket);*/
|
|
|
|
this.cy_hide();
|
|
|
|
this.setData({
|
|
|
|
|
|
|
|
showSpec: this.data.showSpec
|
|
|
|
|
|
|
|
});
|
|
|
|
this.cy_reloadData();
|
|
|
|
this.cy_reloadData();
|
|
|
|
|
|
|
|
this.cy_hide();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -796,6 +871,7 @@ Page({
|
|
|
|
showSpec: this.data.showSpec
|
|
|
|
showSpec: this.data.showSpec
|
|
|
|
});
|
|
|
|
});
|
|
|
|
myOrder.checkPromotionProduct();
|
|
|
|
myOrder.checkPromotionProduct();
|
|
|
|
|
|
|
|
this.cy_changeGuQing(this.data.selectProduct, 'add');
|
|
|
|
this.cy_reloadData();
|
|
|
|
this.cy_reloadData();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
@ -803,14 +879,23 @@ Page({
|
|
|
|
* 多规格商品
|
|
|
|
* 多规格商品
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
cy_addSpecItem: function () {
|
|
|
|
cy_addSpecItem: function () {
|
|
|
|
myOrder.cy_addItem(this.data.selectProduct);
|
|
|
|
if(this.data.selectProduct.stock < 1 || this.data.productCount == this.data.selectProduct.stock) {
|
|
|
|
var productCount = myOrder.cy_getProductCount(this.data.selectProduct);
|
|
|
|
wx.showToast({
|
|
|
|
this.setData({
|
|
|
|
title: '菜品库存不足',
|
|
|
|
productCount: productCount,
|
|
|
|
icon: 'none',
|
|
|
|
shopName: this.data.shopName,
|
|
|
|
duration: 1500
|
|
|
|
specPrice: this.data.specPrice,
|
|
|
|
})
|
|
|
|
showSpec: this.data.showSpec
|
|
|
|
}else {
|
|
|
|
})
|
|
|
|
myOrder.cy_addItem(this.data.selectProduct);
|
|
|
|
|
|
|
|
var productCount = myOrder.cy_getProductCount(this.data.selectProduct);
|
|
|
|
|
|
|
|
this.setData({
|
|
|
|
|
|
|
|
productCount: productCount,
|
|
|
|
|
|
|
|
shopName: this.data.shopName,
|
|
|
|
|
|
|
|
specPrice: this.data.specPrice,
|
|
|
|
|
|
|
|
showSpec: this.data.showSpec
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
this.cy_changeGuQing(this.data.selectProduct, 'reduce');
|
|
|
|
|
|
|
|
}
|
|
|
|
this.cy_reloadData();
|
|
|
|
this.cy_reloadData();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
@ -822,7 +907,6 @@ Page({
|
|
|
|
hidden: false,
|
|
|
|
hidden: false,
|
|
|
|
msg: "处理中..."
|
|
|
|
msg: "处理中..."
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
var store = wx.getStorageSync("store");
|
|
|
|
var store = wx.getStorageSync("store");
|
|
|
|
var dateTime = app.utils.getFormatTime(new Date(), 5);
|
|
|
|
var dateTime = app.utils.getFormatTime(new Date(), 5);
|
|
|
|
var openTime = store.openTime;
|
|
|
|
var openTime = store.openTime;
|
|
|
@ -842,7 +926,6 @@ Page({
|
|
|
|
|
|
|
|
|
|
|
|
if (app.orderTicket.orderList) {
|
|
|
|
if (app.orderTicket.orderList) {
|
|
|
|
for (var product of app.orderTicket.orderList) { // 遍历订单列表计算商品金额
|
|
|
|
for (var product of app.orderTicket.orderList) { // 遍历订单列表计算商品金额
|
|
|
|
|
|
|
|
|
|
|
|
if (product.isSuit != 2) { // 套餐主菜不计算餐盒费
|
|
|
|
if (product.isSuit != 2) { // 套餐主菜不计算餐盒费
|
|
|
|
product.boxFee = product.boxPrice * product.count; // 单品餐盒费
|
|
|
|
product.boxFee = product.boxPrice * product.count; // 单品餐盒费
|
|
|
|
boxFee = boxFee + product.boxFee // 总餐盒费
|
|
|
|
boxFee = boxFee + product.boxFee // 总餐盒费
|
|
|
@ -919,7 +1002,6 @@ Page({
|
|
|
|
promotionMoney: app.orderTicket.promotionReceivable,
|
|
|
|
promotionMoney: app.orderTicket.promotionReceivable,
|
|
|
|
list: app.orderTicket.orderList
|
|
|
|
list: app.orderTicket.orderList
|
|
|
|
});
|
|
|
|
});
|
|
|
|
console.log(app.orderTicket);
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -1182,7 +1264,7 @@ Page({
|
|
|
|
})
|
|
|
|
})
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log(app.orderTicket.orderList);
|
|
|
|
if (app.orderTicket.orderList.length == 0) {
|
|
|
|
if (app.orderTicket.orderList.length == 0) {
|
|
|
|
wx.showToast({
|
|
|
|
wx.showToast({
|
|
|
|
title: '请您先点单',
|
|
|
|
title: '请您先点单',
|
|
|
@ -1208,7 +1290,6 @@ Page({
|
|
|
|
cy_cart: function () {
|
|
|
|
cy_cart: function () {
|
|
|
|
console.log("购物车", app.orderTicket);
|
|
|
|
console.log("购物车", app.orderTicket);
|
|
|
|
if (app.orderTicket.orderList.length > 0) {
|
|
|
|
if (app.orderTicket.orderList.length > 0) {
|
|
|
|
console.error(" app.orderTicket.orderList ", app.orderTicket.orderList)
|
|
|
|
|
|
|
|
this.setData({
|
|
|
|
this.setData({
|
|
|
|
cartFlag: false,
|
|
|
|
cartFlag: false,
|
|
|
|
list: app.orderTicket.orderList
|
|
|
|
list: app.orderTicket.orderList
|
|
|
@ -1265,6 +1346,7 @@ Page({
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
myOrder.checkPromotionProduct();
|
|
|
|
myOrder.checkPromotionProduct();
|
|
|
|
|
|
|
|
this.cy_changeGuQing(map, 'add');
|
|
|
|
this.cy_reloadData();
|
|
|
|
this.cy_reloadData();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
@ -1272,12 +1354,19 @@ Page({
|
|
|
|
* 购物车数量加一
|
|
|
|
* 购物车数量加一
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
cy_addCartItem: function (e) {
|
|
|
|
cy_addCartItem: function (e) {
|
|
|
|
console.error("eee", e)
|
|
|
|
|
|
|
|
var index = e.detail.dataset.index;
|
|
|
|
var index = e.detail.dataset.index;
|
|
|
|
var index = e.detail.dataset.index;
|
|
|
|
var index = e.detail.dataset.index;
|
|
|
|
var map = app.orderTicket.orderList[index];
|
|
|
|
var map = app.orderTicket.orderList[index];
|
|
|
|
map.count = map.count + 1;
|
|
|
|
if(map.stock < 1 || map.count == map.stock) {
|
|
|
|
|
|
|
|
wx.showToast({
|
|
|
|
|
|
|
|
title: '菜品库存不足',
|
|
|
|
|
|
|
|
icon: 'none',
|
|
|
|
|
|
|
|
duration: 1500
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
map.count = map.count + 1;
|
|
|
|
|
|
|
|
this.cy_changeGuQing(map, 'reduce');
|
|
|
|
|
|
|
|
}
|
|
|
|
this.cy_reloadData();
|
|
|
|
this.cy_reloadData();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
@ -1317,7 +1406,7 @@ Page({
|
|
|
|
cy_goto_productDetail: function (e) {
|
|
|
|
cy_goto_productDetail: function (e) {
|
|
|
|
var product = this.data.productList[e.currentTarget.dataset.index];
|
|
|
|
var product = this.data.productList[e.currentTarget.dataset.index];
|
|
|
|
wx.navigateTo({
|
|
|
|
wx.navigateTo({
|
|
|
|
url: '/pages/list/productDetail?detail=' + JSON.stringify(product),
|
|
|
|
url: '/pages/list/productDetail?detail=' + JSON.stringify(product) + '&random=' + Math.random(),
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|