diff --git a/app.js b/app.js index f149948..a671cca 100644 --- a/app.js +++ b/app.js @@ -233,7 +233,6 @@ App({ }, success: res => { var data = res.data; - console.log("----------------------", data); if (data.status == 1) { var cardApi = data.data.cardApi; var cyApi = data.data.cyApi; @@ -278,7 +277,6 @@ App({ } that.globalData.memberWid = wxBoday.mWid; - that.checkSession(); } else { wx.showToast({ @@ -303,7 +301,8 @@ App({ if (!that.loginKey || that.loginKey == "") { that.login(); } else { - // + wx.setStorageSync("loginKey", that.loginKey) + wx.setStorageSync("openId", that.openId) that.cy_userInfoReadyCallback(true); } }, diff --git a/pages/list/productDetail.js b/pages/list/productDetail.js index 90c23e1..2447cf5 100644 --- a/pages/list/productDetail.js +++ b/pages/list/productDetail.js @@ -314,6 +314,13 @@ Page({ showSpec: idsName, 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); + } + } }, cy_changeSpecSellOut: function () { wx.showToast({ @@ -333,17 +340,18 @@ Page({ * 多规格加入购物车 */ cy_addCart: function () { - console.log("多规格商品加入购物车"); + /*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 + });*/ + this.setData({ + showSpec: this.data.showSpec }); - console.error("-------------", app.orderTicket); this.cy_hide(); this.cy_reloadData(); @@ -362,6 +370,7 @@ Page({ showSpec: this.data.showSpec }); myOrder.checkPromotionProduct(); + this.cy_changeGuQing(this.data.detail, 'add'); this.cy_reloadData(); }, @@ -369,14 +378,23 @@ Page({ * 多规格商品 */ cy_addSpecItem: function () { - myOrder.cy_addItem(this.data.detail); - var productCount = myOrder.cy_getProductCount(this.data.detail); - this.setData({ - productCount: productCount, - shopName: this.data.shopName, - specPrice: this.data.specPrice, - showSpec: this.data.showSpec - }) + if(this.data.detail.stock < 1 || this.data.productCount == this.data.detail.stock) { + wx.showToast({ + title: '菜品库存不足', + icon: 'none', + duration: 1500 + }) + }else { + myOrder.cy_addItem(this.data.detail); + var productCount = myOrder.cy_getProductCount(this.data.detail); + this.setData({ + productCount: productCount, + shopName: this.data.shopName, + specPrice: this.data.specPrice, + showSpec: this.data.showSpec + }) + this.cy_changeGuQing(this.data.detail, 'reduce'); + } this.cy_reloadData(); }, /** @@ -439,6 +457,7 @@ Page({ }) } myOrder.checkPromotionProduct(); + this.cy_changeGuQing(map, 'add'); this.cy_reloadData(); }, @@ -450,8 +469,16 @@ Page({ var index = e.detail.dataset.index; var index = e.detail.dataset.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(); }, /** @@ -551,9 +578,7 @@ Page({ app.orderTicket.maling = parseFloat(maling).toFixed(2); app.orderTicket.paid = parseFloat(paid).toFixed(2); app.orderTicket.boxFee = boxFee; - console.error(" promotionReceivable ", promotionReceivable) app.orderTicket.promotionReceivable = parseFloat(promotionReceivable).toFixed(2); - console.error(" promotionReceivable ", promotionReceivable) var productList = []; productList.push(this.data.detail); // 统计数量的合计 @@ -589,6 +614,70 @@ Page({ } this.cy_reloadData(); }, + /** + * + * 查询沽清数据 + */ + 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].typeId = type + data.list[i].quantity = 1 + //that.cy_updateGuQing(data.list[i]); + } + } + } else { + wx.showToast({ + title: data.message, + icon: "none" + }) + } + }, 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; + if (data.status == 1) { + + } else { + wx.showToast({ + title: data.message, + icon: "none" + }) + } + }, function (err) { + wx.showToast({ + title: '网络连接失败,请检查', + icon: "none" + }) + }) + }, /** * 单规格商品加一 */ @@ -602,8 +691,16 @@ Page({ productMap.ids = myOrder.cy_getIds(productMap); productMap.idsName = myOrder.cy_getIdsName(productMap); this.data.selectProduct = productMap; - - myOrder.cy_addItem(productMap); + if(productMap.stock < 1 || productMap.sumCount == productMap.stock) { + wx.showToast({ + title: '菜品库存不足', + icon: 'none', + duration: 1500 + }) + }else { + myOrder.cy_addItem(productMap); + this.cy_changeGuQing(productMap, 'reduce'); + } this.cy_reloadData(); }, @@ -642,7 +739,7 @@ Page({ var int = setTimeout(function () { that.data.isSubmit = true; }, 1500); - if (!isOpen && app.orderTicket.busMode == 0) { + if (!isOpen) { wx.showToast({ title: '门店休息中,暂时无法下单', icon: "none" diff --git a/pages/list/productDetail.wxml b/pages/list/productDetail.wxml index 8cd56ce..4ef123d 100644 --- a/pages/list/productDetail.wxml +++ b/pages/list/productDetail.wxml @@ -34,11 +34,11 @@ 会员价¥{{detail.memberPrice}} 会员价¥{{detail.wmemberPrice}} - 剩余{{detail.specList[0].stock}}份 + 剩余{{detail.stock}}份 - 已售罄 + 已售罄 加入购物车 {{detail.sumCount}} diff --git a/pages/list/shopList.js b/pages/list/shopList.js index 0996c76..701c178 100644 --- a/pages/list/shopList.js +++ b/pages/list/shopList.js @@ -110,7 +110,6 @@ Page({ this.cy_getStoreProduct(); mqttMessage.mqttSubscribe(5); mqttMessage.mqttOn(this); - this.cy_reloadData(); }, onMessage: function (top, message) { @@ -147,10 +146,10 @@ Page({ }) } } else { - wx.showToast({ + /*wx.showToast({ title: data.message, icon: "none" - }) + })*/ } }, function (err) { wx.showToast({ @@ -181,10 +180,10 @@ Page({ evaluateList: data.list, }); } else { - wx.showToast({ + /*wx.showToast({ title: data.message, icon: "none" - }) + })*/ } }, function (err) { @@ -204,15 +203,9 @@ Page({ 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({ @@ -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" + }) + }) + }, /** * 封装数据 */ @@ -245,7 +288,7 @@ Page({ 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) { @@ -315,7 +358,6 @@ Page({ var tempList = mapSpec[keyId]; if (tempList.length > 1) { product.specFlag = true; - tempList.sort(function (temp1, temp2) { return temp1.price - temp2.price; }); @@ -387,7 +429,6 @@ Page({ } } } - // this.setData({ categoryList: listCategory, productList: listProduct, @@ -677,9 +718,15 @@ Page({ } } } 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++) { var make = list.list[i]; - if (make.makeId == selectMake.makeId) { + if (make.makeId == selectMake.makeId && total < 2) { if (currentMultiMark >= 1) { make.checked = !make.checked; } 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++) { var makeTemp = tempMakeList.list[j]; if (makeTemp.checked) { - console.log(makeTemp); if (idsName != "" && idsName != null) { idsName = idsName + "、" + makeTemp.showName; } else { @@ -723,6 +779,13 @@ Page({ showSpec: idsName, 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.idsName = myOrder.cy_getIdsName(productMap); this.data.selectProduct = productMap; - - myOrder.cy_addItem(productMap); + if(productMap.stock < 1 || productMap.sumCount == productMap.stock) { + wx.showToast({ + title: '菜品库存不足', + icon: 'none', + duration: 1500 + }) + }else { + myOrder.cy_addItem(productMap); + this.cy_changeGuQing(productMap, 'reduce'); + } this.cy_reloadData(); }, @@ -760,6 +831,7 @@ Page({ } myOrder.checkPromotionProduct(); this.cy_reloadData(); + this.cy_changeGuQing(productMap, 'add'); }, @@ -779,8 +851,11 @@ Page({ }); console.error("-------------", app.orderTicket);*/ - this.cy_hide(); + this.setData({ + showSpec: this.data.showSpec + }); this.cy_reloadData(); + this.cy_hide(); }, /** @@ -796,6 +871,7 @@ Page({ showSpec: this.data.showSpec }); myOrder.checkPromotionProduct(); + this.cy_changeGuQing(this.data.selectProduct, 'add'); this.cy_reloadData(); }, @@ -803,14 +879,23 @@ Page({ * 多规格商品 */ 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 - }) + if(this.data.selectProduct.stock < 1 || this.data.productCount == this.data.selectProduct.stock) { + wx.showToast({ + title: '菜品库存不足', + icon: 'none', + duration: 1500 + }) + }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(); }, @@ -822,7 +907,6 @@ Page({ hidden: false, msg: "处理中..." }); - var store = wx.getStorageSync("store"); var dateTime = app.utils.getFormatTime(new Date(), 5); var openTime = store.openTime; @@ -842,7 +926,6 @@ Page({ 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 // 总餐盒费 @@ -919,7 +1002,6 @@ Page({ promotionMoney: app.orderTicket.promotionReceivable, list: app.orderTicket.orderList }); - console.log(app.orderTicket); }, /** @@ -1182,7 +1264,7 @@ Page({ }) return; } - + console.log(app.orderTicket.orderList); if (app.orderTicket.orderList.length == 0) { wx.showToast({ title: '请您先点单', @@ -1208,7 +1290,6 @@ Page({ 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 @@ -1265,6 +1346,7 @@ Page({ }) } myOrder.checkPromotionProduct(); + this.cy_changeGuQing(map, 'add'); this.cy_reloadData(); }, @@ -1272,12 +1354,19 @@ Page({ * 购物车数量加一 */ 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; - + 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(); }, @@ -1317,7 +1406,7 @@ Page({ cy_goto_productDetail: function (e) { var product = this.data.productList[e.currentTarget.dataset.index]; wx.navigateTo({ - url: '/pages/list/productDetail?detail=' + JSON.stringify(product), + url: '/pages/list/productDetail?detail=' + JSON.stringify(product) + '&random=' + Math.random(), }) } }) \ No newline at end of file diff --git a/pages/list/shopList.wxml b/pages/list/shopList.wxml index 83a10ba..410b696 100644 --- a/pages/list/shopList.wxml +++ b/pages/list/shopList.wxml @@ -1,7 +1,6 @@ - @@ -164,6 +163,9 @@ + + 剩余{{item.stock}} + @@ -197,9 +199,17 @@ + + + {{item.sumCount}} + + + + + @@ -221,7 +231,7 @@ - + @@ -247,7 +257,7 @@ - + 本店已休息 ({{openTime}} 营业) diff --git a/pages/list/shopList.wxss b/pages/list/shopList.wxss index f4acbac..7a200e8 100644 --- a/pages/list/shopList.wxss +++ b/pages/list/shopList.wxss @@ -404,6 +404,22 @@ justify-content: center; } +.cy-product-surplus{ + position: absolute; + left: 15rpx; + bottom: 18rpx; + width: 150rpx; + height: 48rpx; + background: rgba(0, 0, 0, 0.5); + color: #ffffff; + display: flex; + justify-content: center; + align-items: center; + font-size: 24rpx; + border-top-left-radius: 16rpx; + border-top-right-radius: 16rpx; +} + .cy-product-image { /* margin: 0rpx 10rpx 15rpx 20rpx; */ width: 150rpx; @@ -459,7 +475,7 @@ } .cy-product-price { - width: 180rpx; + width: 100rpx; height: 100%; font-weight: 450; color: #ff4949; @@ -474,12 +490,25 @@ color: white; } +.product-add{ + width: auto; + height: auto; + position: absolute; + right: 128rpx; + display: flex; + align-items: center; + margin-bottom: 4rpx; +} + .cy-product-sym { position: relative; width: 40rpx; height: 40rpx; border-radius: 40rpx; margin-bottom: 10rpx; + display: flex; + align-items: center; + justify-content: center; } .cy-product-sym .mykd{ @@ -487,7 +516,6 @@ position: relative; height: 28rpx; width: 4rpx; - margin: 10rpx auto; } .cy-product-sym .mykd:after{ @@ -541,7 +569,7 @@ .cy-product-spec { padding-left: 20rpx; padding-right: 20rpx; - margin-bottom: 13rpx; + margin-bottom: 10rpx; width: auto; height: 48rpx; line-height: 48rpx; diff --git a/pages/mine/memberRegister.js b/pages/mine/memberRegister.js index 8578f26..e5ba468 100644 --- a/pages/mine/memberRegister.js +++ b/pages/mine/memberRegister.js @@ -13,7 +13,6 @@ Page({ * 生命周期函数--监听页面加载 */ onLoad: function (options) { - console.log(app.globalData.user); }, diff --git a/pages/order/balance/submitOrder.js b/pages/order/balance/submitOrder.js index 82ac2d7..6a6a312 100644 --- a/pages/order/balance/submitOrder.js +++ b/pages/order/balance/submitOrder.js @@ -84,7 +84,6 @@ Page({ } this.computePromotion(); - log.info('busMode的值: ' + app.orderTicket.busMode); this.setData({ busMode: app.orderTicket.busMode, busModes: options.storeBusModes, @@ -534,130 +533,154 @@ Page({ */ cy_tapGoPay: function (e) { console.error(" app.orderTicket.order ", app.orderTicket) + var that = this; this.data.formId = e.detail.formId; var tenantId = app.globalData.tenantId; - - if ("0|1".indexOf(app.orderTicket.busMode) != -1) { // 堂食和外带 - if (tenantId != "571022") { - if (this.data.isTables) { - if (app.orderTicket.busMode == 0 && app.orderTicket.tableName == "选择餐桌") { - wx.showToast({ - title: '请选择餐桌', - icon: "none" - }) - return; - } - } - } - /*if (app.orderTicket.busMode == 1 && app.orderTicket.phone.length != 11) { - var title = '手机号码格式错误'; - if (app.orderTicket.phone.length == 0) { - title = '请填写联系方式'; - } - wx.showToast({ - title: title, - icon: "none" - }) - return; - }*/ - console.log("堂食和外带"); - } - - if (app.orderTicket.busMode == 3) { // 外卖 - console.log("外卖"); - if (!this.data.address) { - wx.showToast({ - title: '请选择收货地址', - icon: "none" - }) - return; - } - app.orderTicket.reserveTime = this.data.outTime; - var ticket_deliver = {}; - ticket_deliver.id = ""; - ticket_deliver.orderTel = this.data.receiveMobile; - ticket_deliver.name = this.data.receiveName; - ticket_deliver.address = this.data.receiveAddress; - ticket_deliver.latitude = this.data.address.latitude; - ticket_deliver.longitude = this.data.address.longitude; - ticket_deliver.deliverType = this.data.deliverType; - ticket_deliver.deliverFee = this.data.deliverFee; - app.orderTicket.ticket_deliver = ticket_deliver; + var params = { + method: "program.product", + programId: app.globalData.programId, + storeId: app.orderTicket.storeId } - - if (this.data.sumMoney == 0) { - var that = this; - if (app.globalData.deliverMoney > 0 && app.orderTicket.busMode == 3) { + var ignores = ["programId", "storeId"]; // 不签名参数 + 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(let i = 0; i < data.data.listProduct.length; i++) { + for(let j = 0; j < app.orderTicket.orderList; j++) { + if(data.data.listProduct[i].productId == app.orderTicket.orderList[j].productId && data.data.listProduct[i].stock < app.orderTicket.orderList[j].count) { + wx.showToast({ + title: app.orderTicket.orderList[j].productName + '库存不足', + icon: "none" + }) + return; + } + } + } + if ("0|1".indexOf(app.orderTicket.busMode) != -1) { // 堂食和外带 + if (tenantId != "571022") { + if (that.data.isTables) { + if (app.orderTicket.busMode == 0 && app.orderTicket.tableName == "选择餐桌") { + wx.showToast({ + title: '请选择餐桌', + icon: "none" + }) + return; + } + } + } + /*if (app.orderTicket.busMode == 1 && app.orderTicket.phone.length != 11) { + var title = '手机号码格式错误'; + if (app.orderTicket.phone.length == 0) { + title = '请填写联系方式'; + } + wx.showToast({ + title: title, + icon: "none" + }) + return; + }*/ + } + + if (app.orderTicket.busMode == 3) { // 外卖 + console.log("外卖"); + if (!that.data.address) { + wx.showToast({ + title: '请选择收货地址', + icon: "none" + }) + return; + } + app.orderTicket.reserveTime = that.data.outTime; + var ticket_deliver = {}; + ticket_deliver.id = ""; + ticket_deliver.orderTel = that.data.receiveMobile; + ticket_deliver.name = that.data.receiveName; + ticket_deliver.address = that.data.receiveAddress; + ticket_deliver.latitude = that.data.address.latitude; + ticket_deliver.longitude = that.data.address.longitude; + ticket_deliver.deliverType = that.data.deliverType; + ticket_deliver.deliverFee = that.data.deliverFee; + app.orderTicket.ticket_deliver = ticket_deliver; + } + + if (that.data.sumMoney == 0) { + if (app.globalData.deliverMoney > 0 && app.orderTicket.busMode == 3) { + wx.showToast({ + title: '不满足外卖起送金额 ¥' + app.globalData.deliverMoney + ' 元 ', + icon: "none" + }) + return; + } + that.cy_tapWxPay(); + } else { + //计算会员卡支付优惠价格 + var memberPayDiscountsAmount = 0; + var wechatPayDisCountsAmount = 0; + var discountsAmount = 0; + var jsonString = myOrder.getMemberCreateOrder(); + console.error("jsonString ",jsonString) + + if (that.data.memberPriceEnabled == 1) { + for (var map of jsonString.ticket_info) { + if (map.type == 3) { + discountsAmount = parseFloat(map.discountMoney); + } + } + if (app.globalData.deliverMoney > 0 && app.orderTicket.busMode == 3) { + if (app.globalData.deliverMoney > (that.data.orgPrice - that.data.deliverFee)) { + wx.showToast({ + title: '不满足外卖起送金额 ¥' + app.globalData.deliverMoney + ' 元 ', + icon: "none" + }) + return; + } + } + } else { + if (app.globalData.deliverMoney > 0 && app.orderTicket.busMode == 3) { + if (app.globalData.deliverMoney > (that.data.orgPrice - that.data.deliverFee)) { + wx.showToast({ + title: '不满足外卖起送金额 ¥' + app.globalData.deliverMoney + ' 元 ', + icon: "none" + }) + return; + } + } + } + var actualAmount = 0; + if (that.data.promotionReceivable > 0) { + //判断优惠为0元的情况 + if (discountsAmount >= that.data.promotionReceivable) { + //判断是否是堂食打包 + if (that.data.busMode == 1 && that.data.isBoxFee == 1) { + actualAmount = parseFloat(app.orderTicket.boxFee); + } + //判断是否是外卖 + if (that.data.busMode == 3) { + actualAmount = (parseFloat(app.orderTicket.boxFee) + parseFloat(app.orderTicket.deliverFee)).toFixed(2); + } + } else { + actualAmount = (parseFloat(that.data.promotionReceivable) - parseFloat(discountsAmount)).toFixed(2) + } + } else { + actualAmount = parseFloat(that.data.sumMoney - discountsAmount).toFixed(2); + } + that.setData({ + payFlag: false, + discountsAmount: parseFloat(discountsAmount).toFixed(2), + actualAmount: actualAmount, + }); + } + if (that.data.is_member_pay == "1") { + app.orderTicket.isMember = 1; + } + app.globalData.isEnablePromotion = that.data.isEnablePromotion; + } + }, function (err) { wx.showToast({ - title: '不满足外卖起送金额 ¥' + app.globalData.deliverMoney + ' 元 ', + title: '网络连接失败,请检查', icon: "none" }) - return; - } - that.cy_tapWxPay(); - } else { - //计算会员卡支付优惠价格 - var memberPayDiscountsAmount = 0; - var wechatPayDisCountsAmount = 0; - var discountsAmount = 0; - var jsonString = myOrder.getMemberCreateOrder(); - console.error("jsonString ",jsonString) - - if (this.data.memberPriceEnabled == 1) { - for (var map of jsonString.ticket_info) { - if (map.type == 3) { - discountsAmount = parseFloat(map.discountMoney); - } - } - if (app.globalData.deliverMoney > 0 && app.orderTicket.busMode == 3) { - if (app.globalData.deliverMoney > (this.data.orgPrice - this.data.deliverFee)) { - wx.showToast({ - title: '不满足外卖起送金额 ¥' + app.globalData.deliverMoney + ' 元 ', - icon: "none" - }) - return; - } - } - } else { - if (app.globalData.deliverMoney > 0 && app.orderTicket.busMode == 3) { - if (app.globalData.deliverMoney > (this.data.orgPrice - this.data.deliverFee)) { - wx.showToast({ - title: '不满足外卖起送金额 ¥' + app.globalData.deliverMoney + ' 元 ', - icon: "none" - }) - return; - } - } - } - var actualAmount = 0; - if (this.data.promotionReceivable > 0) { - //判断优惠为0元的情况 - if (discountsAmount >= this.data.promotionReceivable) { - //判断是否是堂食打包 - if (this.data.busMode == 1 && this.data.isBoxFee == 1) { - actualAmount = parseFloat(app.orderTicket.boxFee); - } - //判断是否是外卖 - if (this.data.busMode == 3) { - actualAmount = (parseFloat(app.orderTicket.boxFee) + parseFloat(app.orderTicket.deliverFee)).toFixed(2); - } - } else { - actualAmount = (parseFloat(this.data.promotionReceivable) - parseFloat(discountsAmount)).toFixed(2) - } - } else { - actualAmount = parseFloat(this.data.sumMoney - discountsAmount).toFixed(2); - } - this.setData({ - payFlag: false, - discountsAmount: parseFloat(discountsAmount).toFixed(2), - actualAmount: actualAmount, - }); - } - - if (this.data.is_member_pay == "1") { - app.orderTicket.isMember = 1; - } - app.globalData.isEnablePromotion = this.data.isEnablePromotion; + }); }, /** diff --git a/pages/order/balance/submitOrder.wxml b/pages/order/balance/submitOrder.wxml index 96eafb3..984d74d 100644 --- a/pages/order/balance/submitOrder.wxml +++ b/pages/order/balance/submitOrder.wxml @@ -86,9 +86,9 @@ 联系方式 - + @@ -154,12 +154,12 @@ - + diff --git a/pages/order/balance/userComment.js b/pages/order/balance/userComment.js index 1c7e117..9422578 100644 --- a/pages/order/balance/userComment.js +++ b/pages/order/balance/userComment.js @@ -84,9 +84,9 @@ Page({ */ cy_selectType: function(e) { var name = e.currentTarget.dataset.name; - if ((this.data.content.length + name.length + 1) > 32) { + if ((this.data.content.length + name.length + 1) > 7) { wx.showToast({ - title: '最多32个字!', + title: '最多7个字!', icon: "none" }) return; diff --git a/pages/store/store.js b/pages/store/store.js index e3a0104..8a76b86 100644 --- a/pages/store/store.js +++ b/pages/store/store.js @@ -224,12 +224,10 @@ Page({ app.globalData.memberPriceEnabled = store.memberPriceEnabled; app.globalData.memberPayEnabled=store.memberPayEnabled; app.globalData.takeOutBoxFeeFlag=store.takeOutBoxFeeFlag; - console.error(" takeOutBoxFeeFlag ",store.takeOutBoxFeeFlag) var url = "../list/shopList?shopRate=" + store.deductionRate; if (this.data.busMode == '3') { app.globalData.deliverMoney = store.deliverMoney; var distance = app.utils.getDistance(store.latitude, store.longitude, this.data.latitude, this.data.longitude); - var deliverKilometre = 5; if (store.deliverKilometre) { deliverKilometre = parseFloat(store.deliverKilometre); diff --git a/pages/tabbar/index.js b/pages/tabbar/index.js index 2d51b9c..b477ee4 100644 --- a/pages/tabbar/index.js +++ b/pages/tabbar/index.js @@ -278,7 +278,6 @@ Page({ var ignores = ["orderType"]; 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) { wx.setStorageSync("ads", data.list); diff --git a/pages/tabbar/launch.js b/pages/tabbar/launch.js index eed1608..32c8362 100644 --- a/pages/tabbar/launch.js +++ b/pages/tabbar/launch.js @@ -41,7 +41,6 @@ Page({ app.qqmapsdk = new QQMapWX({ key:key, }); - console.log(app.qqmapsdk); } clearInterval(inter); } @@ -80,7 +79,6 @@ Page({ } app.userInfoReadyCallback = res => { - console.log(res); if (res) { that.cy_getMemberInfo(); } @@ -328,6 +326,7 @@ Page({ } }, function(err) { + console.log(err) that.setData({ hidden: true, }) diff --git a/style/index.wxss b/style/index.wxss index ac0c4bc..652d092 100644 --- a/style/index.wxss +++ b/style/index.wxss @@ -23,4 +23,6 @@ overflow: hidden; text-overflow: ellipsis; white-space: nowrap; -} \ No newline at end of file +} + + diff --git a/utils/mqttMessage.js b/utils/mqttMessage.js index 577f20c..61d78b8 100644 --- a/utils/mqttMessage.js +++ b/utils/mqttMessage.js @@ -21,7 +21,7 @@ var mqttClient = function() { }); app.client.on('connect', function(err) { - console.log("监听连接状态", err); + //console.log("监听连接状态", err); }); app.client.on('close', function(res) { diff --git a/utils/myOrder.js b/utils/myOrder.js index 6d1bd92..f5f1cd3 100644 --- a/utils/myOrder.js +++ b/utils/myOrder.js @@ -4,7 +4,6 @@ var utils = require('utils.js'); * */ var cy_addItem = function (product) { - var tempSpec = []; // 规格 var makeList = []; // 做法 var ids = ""; @@ -19,7 +18,6 @@ var cy_addItem = function (product) { tempSpec.push(spec); ids = spec.specId; idsName = spec.specName; - break; } } @@ -42,14 +40,14 @@ var cy_addItem = function (product) { // for (var item of app.orderTicket.orderList) { var tempIds = item.ids; // 规格id - if (tempIds == ids) { + if (tempIds == ids || tempIds == ids.split('|')[0]) { item.count = item.count + 1; isContain = true; } } - // + if (!isContain) { product.ids = ids; var tempProduct = JSON.parse(JSON.stringify(product)); @@ -88,10 +86,11 @@ var cy_subItem = function (product) { } } } + for (var i = 0; i < app.orderTicket.orderList.length; i++) { var item = app.orderTicket.orderList[i]; var ids = item.ids; // 规格id - if (tempIds == ids) { + if ((tempIds == ids || tempIds.split('|')[0] == ids || tempIds.split('|')[0] == ids.split('|')[0]) && i == app.orderTicket.orderList.length - 1) { item.count = item.count - 1; if (item.count == 0) { app.orderTicket.orderList.remove(i); @@ -142,10 +141,11 @@ var cy_getProductCount = function (product) { } var productCount = 0; + console.log(app.orderTicket.orderList, ids) for (var item of app.orderTicket.orderList) { - if (item.ids == ids) { + if (item.ids == ids || item.ids == ids.split('|')[0] || item.ids.split('|')[0] == ids.split('|')[0] || item.ids.indexOf(ids) != -1) { if (item.isSuit != 3) { - productCount = item.count; + productCount = productCount + item.count } } }