小程序代码

main
lihao 2 months ago
parent 7f9e523e5a
commit 237708ec0e

@ -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);
}
},

@ -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"

@ -34,11 +34,11 @@
<block wx:if="{{busMode==0}}">会员价¥{{detail.memberPrice}} </block>
<block wx:if="{{busMode==3}}">会员价¥{{detail.wmemberPrice}} </block>
</text>
<text style="padding-left:30rpx;">剩余{{detail.specList[0].stock}}份</text>
<text style="padding-left:30rpx;">剩余{{detail.stock}}份</text>
</view>
<view class="cy-product-add-shop {{detail.specList.length<=1 && detail.specList[0].stock<=0?'cy-product-sell-out':'' }}" bindtap="{{detail.specList.length<=1 && detail.specList[0].stock<=0?'cy_changeSpecSellOut':'cy_selectProductSpec' }}">
<image src="/images/icon-add.png" class="cy-add-shop"></image>
<view class="cy-add-shop-text" wx:if="{{detail.specList.length<=1 && detail.specList[0].stock<=0 }}">已售罄</view>
<view class="cy-add-shop-text" wx:if="{{detail.specList.length <= 1 && detail.specList[0].stock <= 0 }}">已售罄</view>
<view class="cy-add-shop-text" wx:else>加入购物车</view>
<view class="cy-cart-count" style="margin-top:-20rpx;width:10rpx;" wx:if="{{detail.sumCount!='' && detail.sumCount >0 }}"> {{detail.sumCount}}</view>
</view>

@ -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"
})
})
},
/**
* 封装数据
*/
@ -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(),
})
}
})

@ -1,7 +1,6 @@
<view style='--color--:{{color}}'>
<loading hidden="{{hidden}}">{{msg}}</loading>
<view class='container'>
<view class='cy-view-top flex-display {{noticeInfo?"":"heigth" }}'>
<view class='cy-title-item'>
<view class='cy-title-row down-bottom cy-ellipsis'>
@ -164,6 +163,9 @@
<!-- bindtap='cy_showBigImage' -->
<image class='cy-product-image' src='{{item.linkUrl}}'></image>
<image wx:if='{{item.saleStatus}}' mode='aspectFit' src='../../images/sellOut.png'></image>
<view class="cy-product-surplus" wx:if="{{item.stock < 199}}">
<text>剩余{{item.stock}}</text>
</view>
</view>
<view class='cy-product-row' data-index='{{index}}' bindtap=''>
<view class="cy-product-title">
@ -197,9 +199,17 @@
</view>
<block wx:if="{{item.specFlag}}">
<view class="product-add">
<image wx:if="{{item.sumCount>0}}" src='../../images/icon-sub.png' data-index="{{index}}" class='cy-product-sym' catchtap='cy_subItem' />
<view wx:if="{{item.sumCount>0}}" class='cy-product-count content-center' style="color:black;">{{item.sumCount}}</view>
<view wx:if="{{!item.isSellOut}}" class='cy-product-sym' style='background: {{color}};' data-index="{{index}}" catchtap='cy_addItem'>
<!--<image class="iconfont iconjiahao"></image>-->
<view class="mykd"></view>
</view>
</view>
<view hidden='{{item.saleStatus}}' class='cy-product-width flex-display' catchtap='{{item.isSellOut?"cy_changeProductSellOut":"cy_selectProductSpec"}}' data-index="{{index}}">
<view wx:if="{{item.sumCount > 0}}" class='cy-product-position'>{{item.sumCount}}</view>
<view class='cy-product-spec cy-global-bg-color' wx:if="{{!item.isSellOut}}">{{item.suitFlag == 0 ? "选规格" : "随心配"}}</view>
<view class='cy-product-spec cy-global-bg-color' wx:if="{{!item.isSellOut}}">{{item.suitFlag == 0 ? "规格" : "随心配"}}</view>
<view class='cy-product-sell_out' wx:if="{{item.isSellOut}}">已售罄</view>
</view>
</block>
@ -221,7 +231,7 @@
</scroll-view>
<view class='cy-content-cart flex-display' wx:if="{{isBusiness=='1' || busMode==1}}">
<view class='cy-content-cart flex-display' wx:if="{{isBusiness=='1'}}">
<view class='cy-content-cart-image'>
<view class='cy-cart-image cy-global-bg-color' bindtap='cy_cart'>
<image class='cy-cart-view-image' src='http://pos.juweiyun.cn/373001/file/wechatAppicon_shopping%20cart%402x.png'></image>
@ -247,7 +257,7 @@
</view>
</view>
</view>
<view class="cy-content-no-cart" wx:if="{{isBusiness=='0' && busMode==0}}">
<view class="cy-content-no-cart" wx:if="{{isBusiness=='0'}}">
本店已休息 ({{openTime}} 营业)
</view>
</view>

@ -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;

@ -13,7 +13,6 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
console.log(app.globalData.user);
},

@ -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("堂食和外带");
var params = {
method: "program.product",
programId: app.globalData.programId,
storeId: app.orderTicket.storeId
}
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 (!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;
}
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 (this.data.sumMoney == 0) {
var that = this;
if (app.globalData.deliverMoney > 0 && app.orderTicket.busMode == 3) {
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;
});
},
/**

@ -86,9 +86,9 @@
<view wx:if="{{busMode==1}}" class='cy-store-address-view down-center' style='margin-top:30rpx;'>
<text style='width:150rpx; color:#666; font-size:30rpx;'>联系方式</text>
<input bindblur="cy_bindblur" maxlength="11" class='cy-eat-mobile' type='number' placeholder='请输入手机号' value='{{phone}}'></input>
<!--<block wx:if="{{isShowPhone}}">
<block wx:if="{{isShowPhone}}">
<button open-type="getPhoneNumber" bindgetphonenumber="cy_getPhoneNumber" class='cy-eat-time-view content-center' style='color:white; font-size:24rpx; right:30rpx;'>点击获取</button>
</block>-->
</block>
</view>
</view>
@ -154,12 +154,12 @@
</view>
</view>
<!--<view class='cy-order-comment down-center'>
<view class='cy-order-comment down-center'>
<view class='cy-store-address-view down-center' bindtap='cy_tapInputCommont'>
<text style='width:120rpx;'>备注</text>
<input class='cy-ellipsis' disabled='false' placeholder='备注信息' value="{{comment}}"></input>
</view>
</view>-->
</view>
<view style='width:100%; height:220rpx;'></view>
</view>

@ -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;

@ -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);

@ -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);

@ -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,
})

@ -24,3 +24,5 @@
text-overflow: ellipsis;
white-space: nowrap;
}

@ -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) {

@ -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
}
}
}

Loading…
Cancel
Save