|
|
const app = getApp();
|
|
|
const myOrder = require("../../utils/myOrder.js");
|
|
|
const log = require('../../utils/log.js');
|
|
|
const mqttMessage = require('../../utils/mqttMessage.js');
|
|
|
Page({
|
|
|
|
|
|
/**
|
|
|
* 页面的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
hidden: true,
|
|
|
isFlagImage: true,
|
|
|
msg: "加载中...",
|
|
|
isSpec: false,
|
|
|
cartFlag: true,
|
|
|
storeBusModes: "",
|
|
|
deliverFee: 0,
|
|
|
storeId: "",
|
|
|
pageSize: 15,
|
|
|
pageNumber: 1,
|
|
|
placeholder: "../../images/icon-placeholder.gif",
|
|
|
scrollTop: 0,
|
|
|
categoryIndex: 0,
|
|
|
categoryList: [],
|
|
|
productList: [],
|
|
|
evaluateList: [],
|
|
|
selectProduct: null,
|
|
|
selectNavIndex: 1,
|
|
|
num: 0,
|
|
|
defaultShopBanner: [{
|
|
|
"pictureUrl": "http://pos.juweiyun.cn/373001/file/wechatAppmemberdefault_store_banner.png"
|
|
|
}],
|
|
|
// defaultStoreVodiu: "http://photovideo.photo.qq.com/1075_0b53auslowyby4abqq3e25pdebiew54acika.f20.mp4?dis_k=1bca91d643b872f6e249164618f56df6&dis_t=1583748682&vuin=1529190013&save=1&d=1",
|
|
|
indicatorDots: false,
|
|
|
autoplay: true,
|
|
|
interval: 3000,
|
|
|
circular: true,
|
|
|
isSubmit: true,
|
|
|
promotionMoney: 0,
|
|
|
isMemberPrice:0,
|
|
|
memberPriceEnabled:0
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad: function (options) {
|
|
|
|
|
|
var that = this;
|
|
|
var store = wx.getStorageSync("store");
|
|
|
var storeName = store.storeName;
|
|
|
|
|
|
var title = "";
|
|
|
if (options.isDeliverKilometreWarn) {
|
|
|
wx.showToast({
|
|
|
title: options.warn,
|
|
|
icon: "none",
|
|
|
duration: 2000
|
|
|
})
|
|
|
}
|
|
|
if (app.orderTicket.busMode == 0 || app.orderTicket.busMode == 1) {
|
|
|
title = "到店:" + storeName;
|
|
|
}
|
|
|
|
|
|
if (app.orderTicket.busMode == 3) {
|
|
|
title = "外卖:" + storeName;
|
|
|
}
|
|
|
wx.setNavigationBarTitle({
|
|
|
title: title,
|
|
|
});
|
|
|
|
|
|
var evaluatehight = (app.systemInfo.windowHeight - Number(370 * app.percent));
|
|
|
var isMemberPrice = 0;
|
|
|
if(app.globalData.cardInfo){
|
|
|
isMemberPrice = app.globalData.cardInfo.memberPriceFlag;
|
|
|
}
|
|
|
|
|
|
console.log("------------- 会员信息", app.globalData.cardInfo);
|
|
|
log.info('菜品列表busMode: ', app.orderTicket.busMode)
|
|
|
that.setData({
|
|
|
evaluatehight: evaluatehight + "px",
|
|
|
openTime: store.openTime,
|
|
|
count: app.orderTicket.sumCount,
|
|
|
money: app.orderTicket.sumMoney,
|
|
|
storeId: app.orderTicket.storeId,
|
|
|
storeName: app.orderTicket.storeName,
|
|
|
distance: app.orderTicket.distance,
|
|
|
storeAddress: app.orderTicket.storeAddress,
|
|
|
busMode: app.orderTicket.busMode,
|
|
|
storeBusModes: store.busModes,
|
|
|
isBusiness: wx.getStorageSync('store').isOpen,
|
|
|
noticeInfo: store.noticeInfo,
|
|
|
color: app.globalData.color,
|
|
|
isMemberPrice:isMemberPrice,
|
|
|
memberPriceEnabled:app.globalData.memberPriceEnabled
|
|
|
})
|
|
|
|
|
|
that.cy_getProgramEvaluateDownload();
|
|
|
that.cy_getStoreBanner();
|
|
|
},
|
|
|
|
|
|
onUnload: function () {
|
|
|
mqttMessage.mqttunSubscribe(app.appTop3);
|
|
|
},
|
|
|
onHide: function () {
|
|
|
mqttMessage.mqttunSubscribe(app.appTop3);
|
|
|
},
|
|
|
|
|
|
onShow: function () {
|
|
|
this.cy_getStoreProduct();
|
|
|
mqttMessage.mqttSubscribe(5);
|
|
|
mqttMessage.mqttOn(this);
|
|
|
this.cy_reloadData();
|
|
|
},
|
|
|
|
|
|
onMessage: function (top, message) {
|
|
|
console.error("门店商品库存变更", top, "-----", message);
|
|
|
this.cy_getStoreProduct();
|
|
|
if (message.deliverStatus == 1) {
|
|
|
wx.showToast({
|
|
|
title: '骑手已接单',
|
|
|
icon: "none"
|
|
|
})
|
|
|
return;
|
|
|
} else if (message.deliverStatus == 14) {
|
|
|
wx.showToast({
|
|
|
title: '您的配送单已取消',
|
|
|
icon: "none"
|
|
|
})
|
|
|
return;
|
|
|
}
|
|
|
},
|
|
|
cy_getStoreBanner: function () {
|
|
|
var that = this;
|
|
|
var params = {
|
|
|
method: "program.store.picture",
|
|
|
storeId: app.orderTicket.storeId
|
|
|
};
|
|
|
var ignores = [];
|
|
|
app.jsapi.api(app.globalData.appKey, app.globalData.appSecret, app.globalData.serverUrl).ajax(params, ignores, function (json) {
|
|
|
console.log("门店轮播", json);
|
|
|
var data = json.data;
|
|
|
if (data.status == 1) {
|
|
|
if (data.data.pictures && data.data.pictures.length > 0) {
|
|
|
that.setData({
|
|
|
defaultShopBanner: data.data.pictures
|
|
|
})
|
|
|
}
|
|
|
} else {
|
|
|
wx.showToast({
|
|
|
title: data.message,
|
|
|
icon: "none"
|
|
|
})
|
|
|
}
|
|
|
}, function (err) {
|
|
|
wx.showToast({
|
|
|
title: "网络异常",
|
|
|
icon: "none"
|
|
|
})
|
|
|
});
|
|
|
},
|
|
|
/**
|
|
|
* 下载评价
|
|
|
*/
|
|
|
cy_getProgramEvaluateDownload: function () {
|
|
|
var that = this;
|
|
|
var params = {
|
|
|
method: "program.evaluate.download",
|
|
|
programId: app.globalData.programId,
|
|
|
openId: app.openId,
|
|
|
storeId: app.orderTicket.storeId,
|
|
|
pageNumber: 1,
|
|
|
pageSize: 15,
|
|
|
};
|
|
|
var ignores = ["storeId", "pageNumber", "pageSize"]; // 不签名参数
|
|
|
app.jsapi.api(app.globalData.appKey, app.globalData.appSecret, app.globalData.serverUrl).ajax(params, ignores, function (json) {
|
|
|
console.log("评价", json);
|
|
|
var data = json.data;
|
|
|
if (data.status == 1) {
|
|
|
that.setData({
|
|
|
evaluateList: data.list,
|
|
|
});
|
|
|
} else {
|
|
|
wx.showToast({
|
|
|
title: data.message,
|
|
|
icon: "none"
|
|
|
})
|
|
|
}
|
|
|
}, function (err) {
|
|
|
|
|
|
});
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 下载门店商品信息
|
|
|
*/
|
|
|
cy_getStoreProduct: function () {
|
|
|
var that = this;
|
|
|
var params = {
|
|
|
method: "program.product",
|
|
|
programId: app.globalData.programId,
|
|
|
storeId: app.orderTicket.storeId
|
|
|
}
|
|
|
var ignores = ["programId", "storeId"]; // 不签名参数
|
|
|
// app.globalData.serverUrl
|
|
|
app.jsapi.api(app.globalData.appKey, app.globalData.appSecret, app.globalData.serverUrl).ajax(params, ignores, function (json) {
|
|
|
console.log(json);
|
|
|
var data = json.data;
|
|
|
if (data.status == 1) {
|
|
|
that.cy_changeStoreProductData(data.data);
|
|
|
} else {
|
|
|
wx.showToast({
|
|
|
title: data.message,
|
|
|
icon: "none"
|
|
|
})
|
|
|
}
|
|
|
}, function (err) {
|
|
|
wx.showToast({
|
|
|
title: '网络连接失败,请检查',
|
|
|
icon: "none"
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 封装数据
|
|
|
*/
|
|
|
cy_changeStoreProductData: function (data) {
|
|
|
|
|
|
if (data) {
|
|
|
var listCategory = [];
|
|
|
var listProduct = [];
|
|
|
var mapSuit = {};
|
|
|
var mapSpec = {};
|
|
|
var mapMake = {};
|
|
|
|
|
|
data.listCategory.sort(function (item1, item2) { // 分类排序
|
|
|
return item1.orderNo - item2.orderNo;
|
|
|
});
|
|
|
|
|
|
data.listProduct.sort(function (item1, item2) { // 商品排序
|
|
|
return item1.orderNo - item2.orderNo;
|
|
|
});
|
|
|
|
|
|
data.listProductMake.sort(function (item1, item2) { // 做法排序
|
|
|
return item1.orderNo - item2.orderNo;
|
|
|
})
|
|
|
|
|
|
for (var productSuit of data.listProductSuit) { // 套餐明细
|
|
|
productSuit.list = [];
|
|
|
for (var productDetail of data.listProductSuitDetail) {
|
|
|
if (productSuit.id == productDetail.suitId) {
|
|
|
productSuit.list.push(productDetail);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
var key = productSuit.productId;
|
|
|
var tempList = mapSuit[key];
|
|
|
if (!tempList) {
|
|
|
var list = [];
|
|
|
list.push(productSuit);
|
|
|
mapSuit[key] = list;
|
|
|
} else {
|
|
|
tempList.push(productSuit);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
for (var productSpec of data.listProductSpec) { // 封装规格
|
|
|
var key = productSpec.productId + "|" + productSpec.typeId;
|
|
|
var tempList = mapSpec[key];
|
|
|
if (!tempList) {
|
|
|
var list = [];
|
|
|
list.push(productSpec);
|
|
|
mapSpec[key] = list;
|
|
|
} else {
|
|
|
tempList.push(productSpec);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
for (var productMake of data.listProductMake) { // 封装做法数据
|
|
|
productMake.checked = false;
|
|
|
var key = productMake.productId + "|" + productMake.typeId;
|
|
|
var tempList = mapMake[key];
|
|
|
if (!tempList) {
|
|
|
var list = [];
|
|
|
list.push(productMake);
|
|
|
mapMake[key] = list;
|
|
|
} else {
|
|
|
tempList.push(productMake);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
for (var i = 0; i < data.listCategory.length; i++) {
|
|
|
var category = data.listCategory[i];
|
|
|
category.productSize = 0;
|
|
|
category.select = false;
|
|
|
for (var j = 0; j < data.listProduct.length; j++) { // 循环商品信息
|
|
|
var product = data.listProduct[j];
|
|
|
product.scrollId = "s" + product.productId; // 设置滚动id
|
|
|
product.specFlag = false;
|
|
|
product.specList = []; // 规格列表
|
|
|
product.makeList = []; // 做法列表
|
|
|
|
|
|
product.isSuit = 1;
|
|
|
if (product.suitFlag == 1) { //判断是否是套餐
|
|
|
product.isSuit = 2;
|
|
|
product.specFlag = true;
|
|
|
if (mapSuit[product.productId]) { // 道菜明细列表
|
|
|
product.suitList = mapSuit[product.productId];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
for (var keyId in mapSpec) { // 规格分类
|
|
|
if (keyId.indexOf(product.productId) != -1) {
|
|
|
var tempList = mapSpec[keyId];
|
|
|
if (tempList.length > 1) {
|
|
|
product.specFlag = true;
|
|
|
|
|
|
tempList.sort(function (temp1, temp2) {
|
|
|
return temp1.price - temp2.price;
|
|
|
});
|
|
|
}
|
|
|
product.specList = tempList;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
for (var keyId in mapMake) { // 做法分类
|
|
|
if (keyId.indexOf(product.productId) != -1) {
|
|
|
var tempMap = {};
|
|
|
var tempList = mapMake[keyId];
|
|
|
tempMap.typeName = tempList[0].typeName;
|
|
|
tempMap.list = tempList;
|
|
|
if (tempList.length >= 1) {
|
|
|
product.specFlag = true;
|
|
|
}
|
|
|
product.makeList.push(tempMap);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (category.id == product.categoryId) {
|
|
|
product.categoryName = category.name;
|
|
|
if (category.productSize == 0) { // 商品数量不为零
|
|
|
category.scrollId = "s" + product.productId; // 设置父类滚动id
|
|
|
}
|
|
|
category.productSize++;
|
|
|
product.isSearch = true;
|
|
|
listProduct.push(product)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (category.productSize != 0) {
|
|
|
if (listCategory.length == 0) {
|
|
|
category.select = true;
|
|
|
}
|
|
|
listCategory.push(category);
|
|
|
}
|
|
|
}
|
|
|
for (var productItem of listProduct) {
|
|
|
if (productItem.isOnlyMember == 1) {
|
|
|
if (!wx.getStorageSync('cardNo')) {
|
|
|
productItem.discountRule = "";
|
|
|
}
|
|
|
}
|
|
|
if (productItem.specList) {
|
|
|
if (productItem.specList.length >= 1) {
|
|
|
var isSellOut = false;
|
|
|
var specSize = productItem.specList.length;
|
|
|
var flag = 0;
|
|
|
for (var specItem of productItem.specList) {
|
|
|
//判断是否会员专享
|
|
|
if (productItem.isOnlyMember == 1) {
|
|
|
if (!wx.getStorageSync('cardNo')) {
|
|
|
specItem.discountRule = "";
|
|
|
}
|
|
|
}
|
|
|
specItem.count = 1;
|
|
|
myOrder.promotionComputePrice(specItem);
|
|
|
if (specItem.stock <= 0) {
|
|
|
flag++;
|
|
|
}
|
|
|
}
|
|
|
if (flag == specSize) {
|
|
|
productItem.isSellOut = true;
|
|
|
} else {
|
|
|
productItem.isSellOut = false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//
|
|
|
this.setData({
|
|
|
categoryList: listCategory,
|
|
|
productList: listProduct,
|
|
|
})
|
|
|
this.cy_reloadData();
|
|
|
} else {
|
|
|
wx.showToast({
|
|
|
title: '商品信息配置错误',
|
|
|
icon: 'none'
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 选择规格
|
|
|
*/
|
|
|
cy_selectProductSpec: function (e) {
|
|
|
if (this.data.isBusiness == '0') {
|
|
|
return;
|
|
|
}
|
|
|
var index = e.currentTarget.dataset.index;
|
|
|
var productMap = this.data.productList[index];
|
|
|
this.setData({
|
|
|
color: app.globalData.color,
|
|
|
selectProduct: productMap
|
|
|
});
|
|
|
if (productMap.suitFlag == 0) { // 单品选择规格
|
|
|
this.cy_showSpecAndMake();
|
|
|
} else { // 套餐选择(随心配)
|
|
|
var suitList = productMap.suitList;
|
|
|
for (var suitItem of suitList) { // 套餐主菜
|
|
|
for (var item of suitItem.list) { // 套餐明细菜
|
|
|
suitItem.des = ""; // 套餐描述
|
|
|
if (suitItem.list.length > 1) {
|
|
|
suitItem.des = "(" + suitItem.list.length + "选" + suitItem.quantity + ")";
|
|
|
}
|
|
|
|
|
|
for (var product of this.data.productList) {
|
|
|
if (item.productId == product.productId) {
|
|
|
console.log(item);
|
|
|
console.log(product);
|
|
|
|
|
|
product.suitProductId = productMap.productId
|
|
|
product.suitId = item.suitId;
|
|
|
item.product = JSON.parse(JSON.stringify(product));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
if (!item.product) {
|
|
|
wx.showToast({
|
|
|
title: '套餐商品错误',
|
|
|
icon: "none",
|
|
|
})
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
for (var spec of item.product.specList) {
|
|
|
if (item.specId == spec.specId) {
|
|
|
var specList = [spec];
|
|
|
item.product.specId = spec.specId;
|
|
|
item.product.specName = spec.specName;
|
|
|
item.product.specList = specList;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
item.select = false;
|
|
|
if (item.defaultflag == 1) {
|
|
|
suitItem.selectName = item.product.productName;
|
|
|
suitItem.selectSpecName = item.product.specName;
|
|
|
suitItem.quantity = item.quantity;
|
|
|
item.select = true;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
wx.setStorageSync("suitProduct", productMap);
|
|
|
wx.navigateTo({
|
|
|
url: 'shopMeal',
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 展示默认规格和做法
|
|
|
*/
|
|
|
cy_showSpecAndMake: function () {
|
|
|
var productMap = this.data.selectProduct;
|
|
|
//
|
|
|
var mustMakePrice = 0;
|
|
|
var makeStr = "";
|
|
|
for (var i = 0; i < productMap.makeList.length; i++) {
|
|
|
var makeListTemp = productMap.makeList[i];
|
|
|
var mustMakePriceItem = 0;
|
|
|
var mustMakeName = "";
|
|
|
for (var j = 0; j < makeListTemp.list.length; j++) {
|
|
|
var make = makeListTemp.list[j];
|
|
|
make.checked = false;
|
|
|
if (make.isMustMake == 1) {
|
|
|
makeListTemp.list[0].checked = true;
|
|
|
if (mustMakeName == "") {
|
|
|
mustMakeName = makeListTemp.list[0].makeName
|
|
|
}
|
|
|
mustMakePriceItem = makeListTemp.list[0].addPrice;
|
|
|
}
|
|
|
}
|
|
|
if (mustMakeName != "") {
|
|
|
if (makeStr == "") {
|
|
|
makeStr = mustMakeName
|
|
|
} else {
|
|
|
makeStr = makeStr + "、" + mustMakeName
|
|
|
}
|
|
|
}
|
|
|
mustMakePrice = mustMakePrice + mustMakePriceItem;
|
|
|
}
|
|
|
|
|
|
|
|
|
productMap.ids = myOrder.cy_getIds(productMap);
|
|
|
productMap.idsName = myOrder.cy_getIdsName(productMap);
|
|
|
var productCount = myOrder.cy_getProductCount(productMap);
|
|
|
|
|
|
|
|
|
var specPrice = 0;
|
|
|
var promotionPrice = 0;
|
|
|
var defaultSpesFlag = true;
|
|
|
for (var specItem of productMap.specList) {
|
|
|
if (specItem.stock > 0) {
|
|
|
if (defaultSpesFlag) {
|
|
|
specItem.checked = true;
|
|
|
defaultSpesFlag = false;
|
|
|
specPrice = specItem.price;
|
|
|
if (specItem.promotionPrice) {
|
|
|
promotionPrice = specItem.promotionPrice;
|
|
|
}
|
|
|
} else specItem.checked = false;
|
|
|
// break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
var memberPrice = parseFloat(parseFloat(productMap.specList[0].memberPrice + mustMakePrice).toFixed(2));
|
|
|
var wmemberPrice = parseFloat(parseFloat(productMap.specList[0].wmemberPrice + mustMakePrice).toFixed(2));
|
|
|
specPrice = parseFloat(parseFloat(specPrice + mustMakePrice).toFixed(2));
|
|
|
if (promotionPrice > 0) {
|
|
|
promotionPrice = parseFloat(parseFloat(promotionPrice + mustMakePrice).toFixed(2));
|
|
|
}
|
|
|
if (makeStr != "") {
|
|
|
productMap.idsName = productMap.idsName + "、" + makeStr;
|
|
|
}
|
|
|
this.setData({
|
|
|
isSpec: productMap.specFlag,
|
|
|
shopName: productMap.productName, // 商品名称
|
|
|
showSpec: productMap.idsName, // 规格做法名称
|
|
|
spec: productMap.specList.length > 1, // 是否是多规格
|
|
|
specPrice: specPrice, // 单价
|
|
|
promotionPrice: parseFloat(promotionPrice),
|
|
|
specList: productMap.specList, // 规格列表
|
|
|
makeList: productMap.makeList, // 做法列表
|
|
|
productCount: productCount, //
|
|
|
memberPrice: memberPrice, //会员价
|
|
|
wmemberPrice: wmemberPrice //外卖会员价
|
|
|
})
|
|
|
},
|
|
|
cy_changeSpecSellOut: function () {
|
|
|
wx.showToast({
|
|
|
title: '该规格已售罄,请选择其他规格',
|
|
|
icon: "none"
|
|
|
})
|
|
|
return;
|
|
|
},
|
|
|
cy_changeProductSellOut: function () {
|
|
|
wx.showToast({
|
|
|
title: '该商品已售罄,请选择其他商品',
|
|
|
icon: "none"
|
|
|
})
|
|
|
return;
|
|
|
},
|
|
|
/**
|
|
|
* 修改规格
|
|
|
*/
|
|
|
cy_changeSpec: function (e) {
|
|
|
var index = e.detail.currentTarget.dataset.index;
|
|
|
var productMap = this.data.selectProduct;
|
|
|
var specList = this.data.selectProduct.specList;
|
|
|
var selectSpec = specList[index];
|
|
|
var specPrice = 0;
|
|
|
var promotionPrice = 0;
|
|
|
var ids = "";
|
|
|
var idsName = "";
|
|
|
if (selectSpec.stock <= 0) {
|
|
|
wx.showToast({
|
|
|
title: '该规格已售罄,请选择其他规格',
|
|
|
icon: "none"
|
|
|
})
|
|
|
return;
|
|
|
}
|
|
|
// 遍历规格
|
|
|
for (var i = 0; i < specList.length; i++) {
|
|
|
var spec = specList[i];
|
|
|
spec.checked = false;
|
|
|
if (spec.specId == selectSpec.specId) {
|
|
|
ids = ids + selectSpec.specId;
|
|
|
idsName = idsName + selectSpec.specName;
|
|
|
spec.checked = true;
|
|
|
specPrice = spec.price;
|
|
|
promotionPrice = spec.promotionPrice;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 遍历做法
|
|
|
for (var i = 0; i < productMap.makeList.length; i++) {
|
|
|
var makeListTemp = productMap.makeList[i];
|
|
|
for (var j = 0; j < makeListTemp.list.length; j++) {
|
|
|
var make = makeListTemp.list[j];
|
|
|
if (make.checked) {
|
|
|
ids = ids + "|" + make.makeId;
|
|
|
idsName = idsName + "、" + make.showName;
|
|
|
specPrice += make.addPrice;
|
|
|
promotionPrice += specPrice;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
var productCount = myOrder.cy_getProductCount(this.data.selectProduct);
|
|
|
this.setData({
|
|
|
specPrice: specPrice,
|
|
|
specList: specList,
|
|
|
productCount: productCount,
|
|
|
showSpec: idsName,
|
|
|
promotionPrice: promotionPrice
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 修改做法
|
|
|
*/
|
|
|
cy_changeMake: function (e) {
|
|
|
var x = e.detail.currentTarget.dataset.x;
|
|
|
var y = e.detail.currentTarget.dataset.y;
|
|
|
var productMap = this.data.selectProduct;
|
|
|
var makeList = productMap.makeList; // 做法分类
|
|
|
var list = makeList[x]; // 做法明细
|
|
|
var selectMake = list.list[y];
|
|
|
|
|
|
var specPrice = 0;
|
|
|
var memberPrice = 0;
|
|
|
var wmemberPrice = 0;
|
|
|
var sprcPromotionPrice = 0;
|
|
|
var ids = "";
|
|
|
var idsName = "";
|
|
|
|
|
|
// 遍历规格
|
|
|
for (var spec of productMap.specList) {
|
|
|
if (spec.checked) {
|
|
|
specPrice = parseFloat(spec.price);
|
|
|
sprcPromotionPrice = parseFloat(spec.promotionPrice);
|
|
|
ids = spec.specId;
|
|
|
idsName = spec.specName;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
var currentMultiMark = 0;
|
|
|
//当前做法多选选择做法的数量
|
|
|
var oldMakeId="";
|
|
|
// if(selectMake.isRadio !=1){
|
|
|
for (var i = 0; i < list.list.length; i++) {
|
|
|
var make = list.list[i];
|
|
|
if (make.checked) {
|
|
|
currentMultiMark++;
|
|
|
oldMakeId=make.makeId;
|
|
|
}
|
|
|
}
|
|
|
// }
|
|
|
|
|
|
if (selectMake.isRadio == 1) { // 做法互斥
|
|
|
for (var i = 0; i < list.list.length; i++) {
|
|
|
var makeTemp = list.list[i];
|
|
|
if (makeTemp.makeId == selectMake.makeId) {
|
|
|
if (makeTemp.isMustMake != 1) {
|
|
|
makeTemp.checked = !makeTemp.checked;
|
|
|
}else{
|
|
|
if(oldMakeId!=makeTemp.id){
|
|
|
makeTemp.checked =true;
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
makeTemp.checked = false;
|
|
|
}
|
|
|
}
|
|
|
} else { // 做法多选
|
|
|
for (var i = 0; i < list.list.length; i++) {
|
|
|
var make = list.list[i];
|
|
|
if (make.makeId == selectMake.makeId) {
|
|
|
if (currentMultiMark >= 1) {
|
|
|
make.checked = !make.checked;
|
|
|
} else {
|
|
|
if (!make.checked) {
|
|
|
make.checked = !make.checked;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
for (var i = 0; i < productMap.makeList.length; i++) {
|
|
|
var tempMakeList = productMap.makeList[i];
|
|
|
for (var j = 0; j < tempMakeList.list.length; j++) {
|
|
|
var makeTemp = tempMakeList.list[j];
|
|
|
if (makeTemp.checked) {
|
|
|
console.log(makeTemp);
|
|
|
if (idsName != "" && idsName != null) {
|
|
|
idsName = idsName + "、" + makeTemp.showName;
|
|
|
} else {
|
|
|
idsName = makeTemp.showName;
|
|
|
}
|
|
|
|
|
|
ids = ids + "|" + makeTemp.makeId;
|
|
|
specPrice += makeTemp.addPrice;
|
|
|
sprcPromotionPrice += makeTemp.addPrice;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
var productCount = myOrder.cy_getProductCount(this.data.selectProduct);
|
|
|
|
|
|
console.log("修改做法", productCount);
|
|
|
specPrice = parseFloat(specPrice.toFixed(2));
|
|
|
var shopName = this.data.shopName
|
|
|
this.setData({
|
|
|
specPrice: specPrice,
|
|
|
promotionPrice: sprcPromotionPrice,
|
|
|
makeList: makeList,
|
|
|
productCount: productCount,
|
|
|
showSpec: idsName,
|
|
|
shopName: shopName
|
|
|
})
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 单规格商品加一
|
|
|
*/
|
|
|
cy_addItem: function (e) {
|
|
|
if (this.data.isBusiness == '0' && this.data.busMode == 0) {
|
|
|
return;
|
|
|
}
|
|
|
var index = e.currentTarget.dataset.index;
|
|
|
var productMap = this.data.productList[index];
|
|
|
productMap.ids = myOrder.cy_getIds(productMap);
|
|
|
productMap.idsName = myOrder.cy_getIdsName(productMap);
|
|
|
this.data.selectProduct = productMap;
|
|
|
|
|
|
myOrder.cy_addItem(productMap);
|
|
|
this.cy_reloadData();
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 单规格商品减一
|
|
|
*/
|
|
|
cy_subItem: function (e) {
|
|
|
var index = e.currentTarget.dataset.index;
|
|
|
var productMap = this.data.productList[index];
|
|
|
for (var i = 0; i < app.orderTicket.orderList.length; i++) {
|
|
|
var map = app.orderTicket.orderList[i];
|
|
|
if (map.productId == productMap.productId) {
|
|
|
map.count = map.count - 1;
|
|
|
if (map.count == 0) {
|
|
|
app.orderTicket.orderList.remove(i);
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
myOrder.checkPromotionProduct();
|
|
|
this.cy_reloadData();
|
|
|
},
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 多规格加入购物车
|
|
|
*/
|
|
|
cy_addCart: function () {
|
|
|
/*console.log("多规格商品加入购物车");
|
|
|
myOrder.cy_addItem(this.data.selectProduct);
|
|
|
var productCount = myOrder.cy_getProductCount(this.data.selectProduct);
|
|
|
console.log(productCount);
|
|
|
this.setData({
|
|
|
productCount: productCount,
|
|
|
shopName: this.data.shopName,
|
|
|
specPrice: this.data.specPrice,
|
|
|
showSpec: this.data.showSpec
|
|
|
});
|
|
|
|
|
|
console.error("-------------", app.orderTicket);*/
|
|
|
this.cy_hide();
|
|
|
this.cy_reloadData();
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 多规格商品减
|
|
|
*/
|
|
|
cy_subSpecItem: function () {
|
|
|
myOrder.cy_subItem(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
|
|
|
});
|
|
|
myOrder.checkPromotionProduct();
|
|
|
this.cy_reloadData();
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 多规格商品
|
|
|
*/
|
|
|
cy_addSpecItem: function () {
|
|
|
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_reloadData();
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 刷新数据
|
|
|
*/
|
|
|
cy_reloadData: function () {
|
|
|
this.setData({
|
|
|
hidden: false,
|
|
|
msg: "处理中..."
|
|
|
});
|
|
|
|
|
|
var store = wx.getStorageSync("store");
|
|
|
var dateTime = app.utils.getFormatTime(new Date(), 5);
|
|
|
var openTime = store.openTime;
|
|
|
var isOpen = app.utils.isOpen(dateTime, openTime);
|
|
|
var isOpen = false;
|
|
|
|
|
|
var count = 0; // 数量
|
|
|
var amount = 0.0; // 消费金额
|
|
|
var discountTotal = 0.0; // 优惠金额
|
|
|
var receivable = 0.0; // 应收金额
|
|
|
var promotionReceivable = 0.0; //促销应收
|
|
|
var maling = 0.0; // 抹零金额
|
|
|
var paid = 0.0; // 实收金额
|
|
|
var boxFee = 0.0; // 餐盒费
|
|
|
var deliverFee = 0.0; // 配送费
|
|
|
var flag = false; //是否有促销标识
|
|
|
|
|
|
if (app.orderTicket.orderList) {
|
|
|
for (var product of app.orderTicket.orderList) { // 遍历订单列表计算商品金额
|
|
|
|
|
|
if (product.isSuit != 2) { // 套餐主菜不计算餐盒费
|
|
|
product.boxFee = product.boxPrice * product.count; // 单品餐盒费
|
|
|
boxFee = boxFee + product.boxFee // 总餐盒费
|
|
|
}
|
|
|
|
|
|
if (product.isSuit == 3) { // 套餐明细不参与商品金额计算
|
|
|
/**修改套餐做法信息 */
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
|
|
|
var addReceivable = 0; // 加价应收金额
|
|
|
// 计算做法的价格
|
|
|
if (product.isSuit == 1) {
|
|
|
if (product.makeList) {
|
|
|
for (var make of product.makeList) {
|
|
|
make.count = product.count;
|
|
|
addReceivable += make.addPrice * make.count;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**修改套餐的做法加价 */
|
|
|
if (product.isSuit == 2) {
|
|
|
addReceivable = product.addPriceTotal;
|
|
|
}
|
|
|
|
|
|
var spec = product.specList[0]; // 商品规格
|
|
|
product.amount = parseFloat((spec.price * product.count + addReceivable).toFixed(2)); // 总金额
|
|
|
product.receivable = product.amount; // 应收金额
|
|
|
count += product.count;
|
|
|
amount = amount + product.amount;
|
|
|
var oldReceivable = receivable;
|
|
|
receivable += product.receivable;
|
|
|
//判断是否促销商品 是的话给订单一个标识
|
|
|
if (spec.discountRule) {
|
|
|
flag = true;
|
|
|
product.promotionTotalPrice = parseFloat((spec.promotionPrice * product.count + addReceivable).toFixed(2)); // 促销总金额
|
|
|
if (promotionReceivable > 0) {
|
|
|
promotionReceivable = parseFloat((parseFloat(product.promotionTotalPrice) + parseFloat(promotionReceivable)).toFixed(2));
|
|
|
} else {
|
|
|
promotionReceivable = parseFloat((parseFloat(product.promotionTotalPrice) + parseFloat(oldReceivable)).toFixed(2));
|
|
|
}
|
|
|
} else {
|
|
|
if (promotionReceivable > 0) {
|
|
|
promotionReceivable = parseFloat(parseFloat(promotionReceivable) + parseFloat(product.amount)).toFixed(2);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (flag) {
|
|
|
app.orderTicket.promotionFlag = 1;
|
|
|
} else {
|
|
|
app.orderTicket.promotionFlag = 0;
|
|
|
}
|
|
|
paid = receivable;
|
|
|
app.orderTicket.count = count;
|
|
|
app.orderTicket.amount = parseFloat(amount).toFixed(2);
|
|
|
app.orderTicket.discountTotal = parseFloat(discountTotal).toFixed(2);
|
|
|
app.orderTicket.receivable = parseFloat(receivable).toFixed(2);
|
|
|
app.orderTicket.promotionReceivable = parseFloat(promotionReceivable).toFixed(2);
|
|
|
app.orderTicket.maling = parseFloat(maling).toFixed(2);
|
|
|
app.orderTicket.paid = parseFloat(paid).toFixed(2);
|
|
|
app.orderTicket.boxFee = boxFee;
|
|
|
|
|
|
// 统计数量的合计
|
|
|
myOrder.cy_getProductList(this.data.productList);
|
|
|
this.setData({
|
|
|
hidden: true,
|
|
|
isOpen: isOpen,
|
|
|
productList: this.data.productList,
|
|
|
count: app.orderTicket.count,
|
|
|
money: app.orderTicket.receivable,
|
|
|
promotionMoney: app.orderTicket.promotionReceivable,
|
|
|
list: app.orderTicket.orderList
|
|
|
});
|
|
|
console.log(app.orderTicket);
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 选择分类
|
|
|
*/
|
|
|
cy_selectCategory: function (e) {
|
|
|
var index = e.currentTarget.dataset.index;
|
|
|
var category = this.data.categoryList[index];
|
|
|
if (category.select) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
for (var tempCategory of this.data.categoryList) {
|
|
|
tempCategory.select = false;
|
|
|
}
|
|
|
|
|
|
category.select = true;
|
|
|
this.setData({
|
|
|
scrollId: category.scrollId,
|
|
|
categoryList: this.data.categoryList,
|
|
|
})
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 商品详情
|
|
|
*/
|
|
|
cy_productDetail: function (e) {
|
|
|
var index = e.currentTarget.dataset.index;
|
|
|
var productMap = this.data.productList[index];
|
|
|
this.data.selectProduct = productMap;
|
|
|
wx.navigateTo({
|
|
|
url: 'shopDetail?product=' + JSON.stringify(productMap),
|
|
|
})
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 选择门店信息
|
|
|
*/
|
|
|
cy_getLookInfo: function (e) {
|
|
|
var index = e.currentTarget.dataset.index;
|
|
|
if (index == 2 && this.data.evaluateList.length == 0) {
|
|
|
wx.showToast({
|
|
|
title: '暂无评论记录',
|
|
|
icon: "none"
|
|
|
})
|
|
|
}
|
|
|
this.setData({
|
|
|
selectNavIndex: index
|
|
|
});
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 搜索
|
|
|
*/
|
|
|
cy_search: function (e) {
|
|
|
var content = e.detail.value;
|
|
|
for (var product of this.data.productList) {
|
|
|
product.isSearch = false;
|
|
|
if (product.productName.indexOf(content) != -1) {
|
|
|
product.isSearch = true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
this.setData({
|
|
|
productList: this.data.productList
|
|
|
})
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 监听left-scroll的滚动距离
|
|
|
*/
|
|
|
cy_bindScroll: function (e) {
|
|
|
var that = this;
|
|
|
var search_hight = Number(120 * app.percent);
|
|
|
var scrollHeight = e.detail.scrollTop;
|
|
|
var productHeight = Number(190 * app.percent);
|
|
|
var scrollIndex = Math.round(scrollHeight / productHeight);
|
|
|
if (scrollIndex < 0 && scrollIndex > this.data.productList.length) {
|
|
|
scrollIndex = 0;
|
|
|
}
|
|
|
|
|
|
if (scrollIndex > this.data.productList.length) {
|
|
|
scrollIndex = this.data.productList.length - 1;
|
|
|
}
|
|
|
|
|
|
var tempCategory = null;
|
|
|
var tempSelectCategory = null;
|
|
|
var product = that.data.productList[scrollIndex];
|
|
|
|
|
|
for (var i = 0; i < that.data.categoryList.length; i++) {
|
|
|
var category = that.data.categoryList[i];
|
|
|
if (category.select && !tempCategory) {
|
|
|
tempCategory = category;
|
|
|
}
|
|
|
|
|
|
category.select = false;
|
|
|
if (category.id == product.categoryId) {
|
|
|
that.data.categoryIndex = i;
|
|
|
tempSelectCategory = category;
|
|
|
category.select = true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (tempCategory.id != tempSelectCategory.id) {
|
|
|
var index = that.data.categoryIndex;
|
|
|
var scrollTop = Number(index * 120 * app.percent);
|
|
|
that.setData({
|
|
|
scrollTop: scrollTop,
|
|
|
categoryList: that.data.categoryList
|
|
|
});
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 商家电话
|
|
|
*/
|
|
|
cy_callPhone: function () {
|
|
|
var store = wx.getStorageSync("store");
|
|
|
if (store.orderTel) {
|
|
|
wx.makePhoneCall({
|
|
|
phoneNumber: store.orderTel,
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 导航
|
|
|
*/
|
|
|
cy_storeLocation: function () {
|
|
|
/*var store = wx.getStorageSync("store");
|
|
|
wx.openLocation({
|
|
|
latitude: store.latitude,
|
|
|
longitude: store.longitude,
|
|
|
})*/
|
|
|
wx.navigateTo({
|
|
|
url: '../mine/myOrders',
|
|
|
})
|
|
|
},
|
|
|
|
|
|
/********************************************************************************** */
|
|
|
|
|
|
/**
|
|
|
* mqtt消息售罄接受
|
|
|
*/
|
|
|
// onMessage: function (top, message) {
|
|
|
// if (top == app.appTop2) {
|
|
|
// var productIds = message.productIds;
|
|
|
// var storeId = message.storeId;
|
|
|
// var type = message.type;
|
|
|
// if (storeId == this.data.storeId) {
|
|
|
// for (var i = 0; i < this.data.productList.length; i++) {
|
|
|
// var good = this.data.productList[i];
|
|
|
// var productId = good.productId;
|
|
|
// if (productIds == "") { //全部
|
|
|
// if (type == 1) { // 停售
|
|
|
// good.saleStatus = true;
|
|
|
// } else {
|
|
|
// good.saleStatus = false;
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
// if (productIds.indexOf(productId) != -1) { // 单品
|
|
|
// if (type == 1) {
|
|
|
// good.saleStatus = true;
|
|
|
// } else {
|
|
|
// good.saleStatus = false;
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// this.setData({
|
|
|
// productList: this.data.productList,
|
|
|
// });
|
|
|
// }
|
|
|
// }
|
|
|
// },
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 封装下载数据
|
|
|
* 在原有数据中添加 属性sumCount、count、specFlag、ids、idsName
|
|
|
* 设置默认规格 checked、数量 count
|
|
|
*/
|
|
|
cy_changeProduct: function () {
|
|
|
for (var product of this.data.productList) {
|
|
|
product.sumCount = 0;
|
|
|
product.count = 0;
|
|
|
product.specFlag = false;
|
|
|
product.specList[0].checked = true;
|
|
|
product.specList[0].count = 0;
|
|
|
product.imgUrl = product.dfsAccessDomain + "/" + product.groupName + "/" + product.picture;
|
|
|
var ids = product.specList[0].specId;
|
|
|
var idsName = product.specList[0].specName;
|
|
|
// 多规格或者做法
|
|
|
if (product.specList.length > 1 || product.makeList.length > 1 || product.suitFlag != 0) {
|
|
|
product.specFlag = true;
|
|
|
}
|
|
|
// 做法
|
|
|
for (var make of product.makeList) {
|
|
|
|
|
|
console.log(make);
|
|
|
// 2020-03-04 修改适配做法多选
|
|
|
make.detailList[0].checked = true;
|
|
|
make.detailList[0].count = 0;
|
|
|
ids = ids + (ids != "" ? "|" : "") + make.detailList[0].id;
|
|
|
idsName = idsName + (idsName != "" ? "," : "") + make.detailList[0].name;
|
|
|
if (make.detailList.length > 1) {
|
|
|
product.specFlag = true;
|
|
|
}
|
|
|
}
|
|
|
product.ids = ids;
|
|
|
product.idsName = idsName;
|
|
|
//
|
|
|
for (var order of app.orderTicket.orderList) {
|
|
|
if (product.productId == order.productId) {
|
|
|
product.sumCount = product.sumCount + order.count;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
this.setData({
|
|
|
hidden: true,
|
|
|
productList: this.data.productList,
|
|
|
})
|
|
|
},
|
|
|
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
*/
|
|
|
cy_hide: function () {
|
|
|
this.setData({
|
|
|
isSpec: false,
|
|
|
cartFlag: true,
|
|
|
isFlagImage: true
|
|
|
});
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 确定下单
|
|
|
*/
|
|
|
cy_placeOrder: function (e) {
|
|
|
if (this.data.isSubmit) {
|
|
|
this.data.isSubmit = false;
|
|
|
var store = wx.getStorageSync("store");
|
|
|
var dateTime = app.utils.getFormatTime(new Date(), 5);
|
|
|
var openTime = store.openTime;
|
|
|
|
|
|
var isOpen = app.utils.isOpen(dateTime, openTime);
|
|
|
|
|
|
var that = this;
|
|
|
var int = setTimeout(function () {
|
|
|
that.data.isSubmit = true;
|
|
|
}, 1500);
|
|
|
|
|
|
if (!isOpen && app.orderTicket.busMode == 0) {
|
|
|
wx.showToast({
|
|
|
title: '门店休息中,暂时无法下单',
|
|
|
icon: "none"
|
|
|
})
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (app.orderTicket.orderList.length == 0) {
|
|
|
wx.showToast({
|
|
|
title: '请您先点单',
|
|
|
icon: "none"
|
|
|
})
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
that.setData({
|
|
|
cartFlag: true,
|
|
|
});
|
|
|
var url = "../order/balance/submitOrder?storeBusModes=" + that.data.storeBusModes;
|
|
|
|
|
|
wx.navigateTo({
|
|
|
url: url,
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 点击购物车
|
|
|
*/
|
|
|
cy_cart: function () {
|
|
|
console.log("购物车", app.orderTicket);
|
|
|
if (app.orderTicket.orderList.length > 0) {
|
|
|
console.error(" app.orderTicket.orderList ", app.orderTicket.orderList)
|
|
|
this.setData({
|
|
|
cartFlag: false,
|
|
|
list: app.orderTicket.orderList
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
*/
|
|
|
cy_clearCart: function () {
|
|
|
var that = this;
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
|
|
content: '清空购物车商品',
|
|
|
success: function (res) {
|
|
|
if (res.confirm) {
|
|
|
that.setData({
|
|
|
cartFlag: true,
|
|
|
})
|
|
|
app.orderTicket.orderList = [];
|
|
|
that.cy_reloadData();
|
|
|
app.orderTicket.promotionFlag = 0;
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
*/
|
|
|
cy_subCartItem: function (e) {
|
|
|
var index = e.detail.dataset.index;
|
|
|
var map = app.orderTicket.orderList[index];
|
|
|
map.count = map.count - 1;
|
|
|
|
|
|
if (map.isSuit == 2 && map.count == 0) { // 套餐主菜
|
|
|
for (var suit of map.suitList) {
|
|
|
for (var i = 0; i < app.orderTicket.orderList.length; i++) {
|
|
|
var item = app.orderTicket.orderList[i];
|
|
|
if (item.isSuit == 3 && map.itemId == item.parentItemId) {
|
|
|
app.orderTicket.orderList.remove(i);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (map.count == 0) {
|
|
|
app.orderTicket.orderList.remove(index);
|
|
|
}
|
|
|
if (app.orderTicket.orderList.length == 0) {
|
|
|
this.setData({
|
|
|
cartFlag: true,
|
|
|
})
|
|
|
}
|
|
|
myOrder.checkPromotionProduct();
|
|
|
this.cy_reloadData();
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 购物车数量加一
|
|
|
*/
|
|
|
cy_addCartItem: function (e) {
|
|
|
console.error("eee", e)
|
|
|
var index = e.detail.dataset.index;
|
|
|
var index = e.detail.dataset.index;
|
|
|
var map = app.orderTicket.orderList[index];
|
|
|
map.count = map.count + 1;
|
|
|
|
|
|
this.cy_reloadData();
|
|
|
},
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 创建订单数据
|
|
|
*/
|
|
|
cy_orderCreate: function () {
|
|
|
var order = myOrder.getOrder();
|
|
|
return order;
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 显示大图
|
|
|
*/
|
|
|
cy_showBigImage: function (e) {
|
|
|
var current = e.currentTarget.dataset.src + "!w500h500";
|
|
|
console.error(" current ", current)
|
|
|
if (current) {
|
|
|
var imglist = [current];
|
|
|
wx.previewImage({
|
|
|
current: current, // 当前显示图片的http链接
|
|
|
urls: imglist // 需要预览的图片http链接列表
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
payVideo: function () {
|
|
|
this.setData({
|
|
|
autoplay: false
|
|
|
})
|
|
|
},
|
|
|
pauseVideo: function () {
|
|
|
this.setData({
|
|
|
autoplay: true
|
|
|
})
|
|
|
},
|
|
|
cy_goto_productDetail: function (e) {
|
|
|
var product = this.data.productList[e.currentTarget.dataset.index];
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/list/productDetail?detail=' + JSON.stringify(product),
|
|
|
})
|
|
|
}
|
|
|
}) |