代客下单逻辑修改
This commit is contained in:
@@ -273,7 +273,11 @@
|
||||
<!-- 登录弹窗 -->
|
||||
<my-login v-model="modal.login" @loginSuccess="loginSuccess"></my-login>
|
||||
<!-- 称重 -->
|
||||
<weigh-item ref="refweighitem" @weighgoodsUpdate="goodsUpdate"></weigh-item>
|
||||
<weigh-item
|
||||
ref="refweighitem"
|
||||
@weighgoodsUpdate="goodsUpdate"
|
||||
:limitTimeDiscount="data.limitTimeDiscount"
|
||||
></weigh-item>
|
||||
<up-modal
|
||||
title="提示"
|
||||
content="该台桌购物车里有商品,是否清除该台桌里的商品?"
|
||||
@@ -484,7 +488,7 @@ function onMessage() {
|
||||
);
|
||||
}
|
||||
|
||||
if (msg.status == 0&&msg.type!='time_discount') {
|
||||
if (msg.status == 0 && msg.type != "time_discount") {
|
||||
infoBox.showToast(msg.msg || "添加失败");
|
||||
data.isGoodsAdd = true;
|
||||
// 如果是商品库存不足起售数量
|
||||
@@ -506,6 +510,7 @@ function onMessage() {
|
||||
if (!data.table.tableCode) {
|
||||
data.table.tableCode = msg.table_code;
|
||||
uni.setStorageSync("msg_id", msg.msg_id);
|
||||
data.limitTimeDiscount = limitTimeDiscountRes.value;
|
||||
websocketUtil.send(
|
||||
JSON.stringify({
|
||||
type: "shopping",
|
||||
@@ -596,6 +601,9 @@ function delCart(id) {
|
||||
* 获取订单详情
|
||||
*/
|
||||
async function getHistoryOrderDetail() {
|
||||
if(shopInfo.registerType=='before'){
|
||||
return
|
||||
}
|
||||
data.historyOrder = [];
|
||||
let res = await getHistoryOrder({
|
||||
tableCode: data.table.tableCode,
|
||||
@@ -684,11 +692,11 @@ function cartControls(cartItem, type) {
|
||||
}
|
||||
if (type == "add") {
|
||||
cars.push(cartItem);
|
||||
if ($goods){
|
||||
$goods.chooseNumber = cartItem.number;
|
||||
console.log('$goods',$goods)
|
||||
console.log('cartItem',cartItem)
|
||||
}
|
||||
if ($goods) {
|
||||
$goods.chooseNumber = cartItem.number;
|
||||
console.log("$goods", $goods);
|
||||
console.log("cartItem", cartItem);
|
||||
}
|
||||
}
|
||||
if (type == "edit") {
|
||||
editItem.value = $goods;
|
||||
@@ -1014,11 +1022,18 @@ function setTabsCurrentPosition(position = "center") {
|
||||
tabsEle.scrollWidth / 2 +
|
||||
tabsEle.tabsItems[index].width / 2;
|
||||
}
|
||||
const shopInfo = uni.getStorageSync("shopInfo");
|
||||
|
||||
provide("shopInfo", shopInfo);
|
||||
/**
|
||||
* 获取商品列表
|
||||
* @param max
|
||||
* @param isGetPrve
|
||||
*/
|
||||
async function getGoodsData(max = 6, isGetPrve = false) {
|
||||
const fuhao = !isGetPrve ? 1 : -1;
|
||||
for (let i = 0; i < max; i++) {
|
||||
if (layoutData.current + i >= layoutData.list.length - 1) {
|
||||
if (layoutData.current + i > layoutData.list.length - 1) {
|
||||
break;
|
||||
} else {
|
||||
const pageData = layoutData.list[layoutData.current + i * fuhao];
|
||||
@@ -1033,25 +1048,7 @@ async function getGoodsData(max = 6, isGetPrve = false) {
|
||||
? layoutArr[res2.data.productList.length]
|
||||
: "6-grid",
|
||||
productList: res2.data.productList.map((v) => {
|
||||
const shopInfo = uni.getStorageSync("shopInfo");
|
||||
v.is_time_discount = yskUtils.limitUtils.canUseLimitTimeDiscount(
|
||||
{ ...v, salePrice: v.lowPrice },
|
||||
data.limitTimeDiscount,
|
||||
shopInfo,
|
||||
null,
|
||||
"id"
|
||||
)
|
||||
? 1
|
||||
: 0;
|
||||
if (v.is_time_discount) {
|
||||
v.timeLimitPrice = yskUtils.limitUtils.returnPrice({
|
||||
goods: { ...v, salePrice: v.lowPrice },
|
||||
shopInfo: shopInfo,
|
||||
limitTimeDiscountRes: data.limitTimeDiscount,
|
||||
shopUserInfo: null,
|
||||
idKey: "id",
|
||||
});
|
||||
}
|
||||
v.salePrice = v.lowPrice;
|
||||
const findGoodsInCar = cars.find((cars) => {
|
||||
return cars.productId == v.id;
|
||||
});
|
||||
@@ -1086,14 +1083,18 @@ function animationStart(e) {
|
||||
}
|
||||
async function animationfinish(e) {
|
||||
if (isScrollChangeCategorySel) {
|
||||
layoutData.current = e.detail.current;
|
||||
const categoryId = layoutData.list[layoutData.current].productCategoryId
|
||||
? layoutData.list[layoutData.current].productCategoryId
|
||||
: layoutData.list[layoutData.current].productList[0].categoryId;
|
||||
const index = layoutData.category.list.findIndex((v) => v.id == categoryId);
|
||||
isScrollChangeCategorySel = true;
|
||||
layoutData.category.sel = index;
|
||||
await getLayoutGoodsInit();
|
||||
try {
|
||||
layoutData.current = e.detail.current;
|
||||
const categoryId = layoutData.list[layoutData.current].productCategoryId
|
||||
? layoutData.list[layoutData.current].productCategoryId
|
||||
: layoutData.list[layoutData.current].productList[0].categoryId;
|
||||
const index = layoutData.category.list.findIndex(
|
||||
(v) => v.id == categoryId
|
||||
);
|
||||
isScrollChangeCategorySel = true;
|
||||
layoutData.category.sel = index;
|
||||
await getLayoutGoodsInit();
|
||||
} catch (error) {}
|
||||
}
|
||||
isScrollChangeCategorySel = false;
|
||||
isTapChangeCategorySel = false;
|
||||
@@ -1104,6 +1105,21 @@ async function animationfinish(e) {
|
||||
* @param {Object} item
|
||||
*/
|
||||
async function taocanConfirm(d, item) {
|
||||
const is_time_discount = yskUtils.limitUtils.canUseLimitTimeDiscount(
|
||||
{
|
||||
...item,
|
||||
salePrice: item.lowPrice,
|
||||
memberPrice: item.memberPrice
|
||||
? item.memberPrice
|
||||
: item.skuList[0].memberPrice,
|
||||
},
|
||||
data.limitTimeDiscount,
|
||||
shopInfo,
|
||||
null,
|
||||
"id"
|
||||
)
|
||||
? 1
|
||||
: 0;
|
||||
editCart(
|
||||
{
|
||||
number: item.skuList[0].suitNum,
|
||||
@@ -1112,6 +1128,7 @@ async function taocanConfirm(d, item) {
|
||||
sku_id: item.skuList[0].id,
|
||||
pro_group_info: JSON.stringify(d),
|
||||
is_temporary: 0, //是否是临时菜
|
||||
is_time_discount,
|
||||
},
|
||||
"add"
|
||||
);
|
||||
@@ -1529,6 +1546,7 @@ function setTagDisabled() {
|
||||
|
||||
console.log(selArr);
|
||||
let selArrAllGroup = util.generateCombinations(selArr, selArr.length - 1);
|
||||
console.log("selArrAllGroup");
|
||||
console.log(selArrAllGroup);
|
||||
const matchArr = [];
|
||||
for (let key in skuMap) {
|
||||
@@ -1551,6 +1569,7 @@ function setTagDisabled() {
|
||||
return;
|
||||
}
|
||||
const includeSkuMap = matchArr.reduce((prve, cur) => {
|
||||
console.log("cur.specSnap", cur);
|
||||
const speArr = cur.specSnap.split(",");
|
||||
for (let i of speArr) {
|
||||
if (!prve.hasOwnProperty("i")) {
|
||||
@@ -1593,7 +1612,7 @@ function chooseGuige(foodsindex, index) {
|
||||
}
|
||||
}
|
||||
|
||||
async function guigeConfirm(sku, suitNum) {
|
||||
async function guigeConfirm(sku, number, is_time_discount) {
|
||||
if (!data.isGoodsAdd) {
|
||||
return;
|
||||
}
|
||||
@@ -1602,6 +1621,7 @@ async function guigeConfirm(sku, suitNum) {
|
||||
let product_id = goods.id;
|
||||
let product_type = goods.type;
|
||||
let res = findGoodsInCar(goods, sku_id);
|
||||
|
||||
if (res) {
|
||||
//更新
|
||||
let { index } = res;
|
||||
@@ -1617,7 +1637,7 @@ async function guigeConfirm(sku, suitNum) {
|
||||
product_id: product_id,
|
||||
sku_id: sku_id,
|
||||
is_temporary: carGoods.is_temporary, //是否是临时菜
|
||||
is_time_discount: goods.is_time_discount,
|
||||
is_time_discount,
|
||||
},
|
||||
"edit"
|
||||
);
|
||||
@@ -1626,12 +1646,12 @@ async function guigeConfirm(sku, suitNum) {
|
||||
//添加
|
||||
editCart(
|
||||
{
|
||||
number: suitNum,
|
||||
number: number,
|
||||
product_id: product_id,
|
||||
product_type: product_type,
|
||||
sku_id: sku_id,
|
||||
is_temporary: 0, //是否是临时菜
|
||||
is_time_discount: goods.is_time_discount,
|
||||
is_time_discount,
|
||||
},
|
||||
"add"
|
||||
);
|
||||
@@ -1748,13 +1768,27 @@ async function goodsUpdate(
|
||||
index,
|
||||
isAdd,
|
||||
searchGoodsIndex,
|
||||
showCurrentInput
|
||||
showCurrentInput,
|
||||
is_time_discount
|
||||
) {
|
||||
console.log(foodsindex, index, isAdd, searchGoodsIndex, "11111");
|
||||
if (!data.isGoodsAdd) {
|
||||
return;
|
||||
}
|
||||
const $goods = layoutData.list[foodsindex].productList[index];
|
||||
console.log($goods);
|
||||
if (is_time_discount === undefined) {
|
||||
is_time_discount = yskUtils.limitUtils.canUseLimitTimeDiscount(
|
||||
{ ...$goods, salePrice: $goods.lowPrice },
|
||||
data.limitTimeDiscount,
|
||||
shopInfo,
|
||||
null,
|
||||
"id"
|
||||
)
|
||||
? 1
|
||||
: 0;
|
||||
}
|
||||
|
||||
if ($goods.type != "sku") {
|
||||
const step = isAdd ? 1 : -1;
|
||||
//增加
|
||||
@@ -1763,7 +1797,7 @@ async function goodsUpdate(
|
||||
let { sku_id, product_id, id, number, discount_sale_amount } = isShop;
|
||||
// 数量加减
|
||||
let num = number + step;
|
||||
if (num == 0 ||num<$goods.skuList[0].suitNum) {
|
||||
if (num == 0 || num < $goods.skuList[0].suitNum) {
|
||||
let params = {
|
||||
...data.socketData,
|
||||
id: id,
|
||||
@@ -1782,6 +1816,7 @@ async function goodsUpdate(
|
||||
let cartItem = cars[goodsInCarIndex];
|
||||
num = cartItem.number * 1 + Number(showCurrentInput);
|
||||
}
|
||||
|
||||
websocketUtil.send(
|
||||
JSON.stringify({
|
||||
...data.socketData,
|
||||
@@ -1796,9 +1831,10 @@ async function goodsUpdate(
|
||||
operate_type: "edit",
|
||||
pack_number: 0, //数量
|
||||
is_temporary: 0, //是否是临时菜
|
||||
is_time_discount: $goods.is_time_discount,
|
||||
is_time_discount,
|
||||
})
|
||||
);
|
||||
|
||||
// $goods.chooseNumber = 1
|
||||
$goods.chooseNumber = num;
|
||||
}
|
||||
@@ -1811,6 +1847,7 @@ async function goodsUpdate(
|
||||
if (showCurrentInput) {
|
||||
weightNum = Number(showCurrentInput);
|
||||
}
|
||||
|
||||
let params = {
|
||||
...data.socketData,
|
||||
table_code: data.table.tableCode,
|
||||
@@ -1820,11 +1857,12 @@ async function goodsUpdate(
|
||||
sku_name: "", // 临时菜规格
|
||||
number: weightNum,
|
||||
// discount_sale_amount: $goods.lowPrice,
|
||||
discount_sale_amount:0,
|
||||
discount_sale_amount: 0,
|
||||
pack_number: 0, //数量
|
||||
is_temporary: 0, //是否是临时菜
|
||||
is_time_discount: $goods.is_time_discount,
|
||||
is_time_discount,
|
||||
};
|
||||
console.log(params, "发送消息");
|
||||
websocketUtil.send(JSON.stringify(params));
|
||||
// $goods.chooseNumber = 1
|
||||
}
|
||||
@@ -1912,7 +1950,7 @@ onShow(() => {
|
||||
title: "购物车加载中",
|
||||
mask: true,
|
||||
});
|
||||
layoutData.current = 0;
|
||||
// layoutData.current = 0;
|
||||
watchChooseTable();
|
||||
watchUpdate();
|
||||
watchSocketOpen();
|
||||
@@ -1931,11 +1969,13 @@ let sysInfo = ref({
|
||||
windowWidth: 0,
|
||||
windowHeight: 0,
|
||||
});
|
||||
console.log(yskUtils);
|
||||
const limitTimeDiscountRes = ref(null);
|
||||
async function getLimit() {
|
||||
const res = await limitTimeDiscountApi.limitTimeDiscount();
|
||||
data.limitTimeDiscount = res.data;
|
||||
limitTimeDiscountRes.value = res.data;
|
||||
if (data.table.tableCode) {
|
||||
data.limitTimeDiscount = limitTimeDiscountRes.value;
|
||||
|
||||
websocketUtil.send(
|
||||
JSON.stringify({
|
||||
type: "shopping",
|
||||
@@ -1943,7 +1983,7 @@ async function getLimit() {
|
||||
table_code: data.table.tableCode,
|
||||
shop_id: uni.getStorageSync("shopInfo").id,
|
||||
operate_type: "time_discount_save",
|
||||
data: data.limitTimeDiscount,
|
||||
data: limitTimeDiscountRes.value,
|
||||
})
|
||||
);
|
||||
console.log("limitTimeDiscount", data.limitTimeDiscount);
|
||||
@@ -1962,6 +2002,8 @@ onLoad(async (opt) => {
|
||||
isCreateOrderToDetail.value = true;
|
||||
}
|
||||
|
||||
websocketUtil.initializeWebSocket();
|
||||
|
||||
xiadanClick();
|
||||
});
|
||||
</script>
|
||||
@@ -1982,6 +2024,7 @@ onLoad(async (opt) => {
|
||||
min-height: 40px;
|
||||
padding-top: calc(var(--status-bar-height));
|
||||
padding-bottom: 6px;
|
||||
z-index: 5;
|
||||
}
|
||||
|
||||
.top {
|
||||
|
||||
Reference in New Issue
Block a user