代客下单将之前的打包赠送等接口从添加改为更新
This commit is contained in:
parent
2c7042e6e2
commit
411b434b26
|
|
@ -211,7 +211,7 @@ export default {
|
||||||
padding: 4px;
|
padding: 4px;
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
display: flex;
|
display: flex;
|
||||||
overflow: hidden;
|
overflow: visible;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
|
|
||||||
|
|
@ -268,8 +268,23 @@
|
||||||
:selIndex="order.selIndex"
|
:selIndex="order.selIndex"
|
||||||
></cart-item>
|
></cart-item>
|
||||||
</template>
|
</template>
|
||||||
|
<!-- 优惠菜品 -->
|
||||||
<div v-if="order.gift.list.length">
|
<div v-if="order.gift.list.length">
|
||||||
<div class="carts_list_title">以下是优惠菜品</div>
|
<div class="carts_list_title">以下是优惠菜品</div>
|
||||||
|
<template v-if="order.gift.list.length">
|
||||||
|
<cart-item
|
||||||
|
@itemClick="changeOrderSel"
|
||||||
|
@changeOrderNumber="changeOrderNumber"
|
||||||
|
@cartGoodsNumberInput="cartGoodsNumberInput"
|
||||||
|
@cartGoodsNumberChange="cartGoodsNumberChange"
|
||||||
|
v-for="(item, index) in order.list"
|
||||||
|
:key="index"
|
||||||
|
:index="index"
|
||||||
|
:item="item"
|
||||||
|
:selPlaceNum="order.selPlaceNum"
|
||||||
|
:selIndex="order.selIndex"
|
||||||
|
></cart-item>
|
||||||
|
</template>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="!order.list.length">
|
<div v-if="!order.list.length">
|
||||||
|
|
@ -321,6 +336,24 @@
|
||||||
></cart-item>
|
></cart-item>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
<!-- 打包费 -->
|
||||||
|
<template v-if="allPackMoney > 0">
|
||||||
|
<div class="list">
|
||||||
|
<div class="carts_list_title">打包费</div>
|
||||||
|
<cart-item
|
||||||
|
@itemClick="changeOrderExtraSel"
|
||||||
|
:canChangeNumber="false"
|
||||||
|
key="seatFee"
|
||||||
|
:index="0"
|
||||||
|
:item="order.packFee"
|
||||||
|
isSeatFee
|
||||||
|
:selIndex="order.extra.selIndex"
|
||||||
|
:placeNum="-10"
|
||||||
|
:selPlaceNum="order.selPlaceNum"
|
||||||
|
></cart-item>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
<div class="order_remark" v-if="note.content">
|
<div class="order_remark" v-if="note.content">
|
||||||
订单备注: {{ note.content }}
|
订单备注: {{ note.content }}
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -329,7 +362,7 @@
|
||||||
<div class="w-full bottom">
|
<div class="w-full bottom">
|
||||||
<div class="border-top">
|
<div class="border-top">
|
||||||
<div class="flex row-right youhui" v-if="giftLen">
|
<div class="flex row-right youhui" v-if="giftLen">
|
||||||
<span> 已优惠¥{{ allGiftMoney | to2 }} </span>
|
<span> 已优惠¥{{ allGiftMoney }} </span>
|
||||||
<i class="el-icon-arrow-right "></i>
|
<i class="el-icon-arrow-right "></i>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -1169,6 +1202,7 @@ import {
|
||||||
arrayContainsAll,
|
arrayContainsAll,
|
||||||
generateCombinations,
|
generateCombinations,
|
||||||
returnReverseVal,
|
returnReverseVal,
|
||||||
|
returnGiftArr
|
||||||
} from "./util.js";
|
} from "./util.js";
|
||||||
import { $status } from "@/utils/table.js";
|
import { $status } from "@/utils/table.js";
|
||||||
export default {
|
export default {
|
||||||
|
|
@ -1271,6 +1305,13 @@ export default {
|
||||||
total: 0,
|
total: 0,
|
||||||
},
|
},
|
||||||
order: {
|
order: {
|
||||||
|
packFee: {
|
||||||
|
totalNumber: 0,
|
||||||
|
status: "",
|
||||||
|
number: 0,
|
||||||
|
name: "打包费",
|
||||||
|
totalAmount: 0,
|
||||||
|
},
|
||||||
extra: {
|
extra: {
|
||||||
selIndex: -1,
|
selIndex: -1,
|
||||||
},
|
},
|
||||||
|
|
@ -1381,15 +1422,49 @@ export default {
|
||||||
return this.table ? "代客下单" + `(${this.table.name})` : "代客下单";
|
return this.table ? "代客下单" + `(${this.table.name})` : "代客下单";
|
||||||
},
|
},
|
||||||
allGiftMoney() {
|
allGiftMoney() {
|
||||||
const price = this.order.list
|
const nowprice = this.order.list
|
||||||
.filter((v) => v.isGift === "true" || v.status == "return")
|
.filter((v) => v.isGift === "true" || v.status == "return")
|
||||||
.reduce((a, b) => {
|
.reduce((a, b) => {
|
||||||
return a + b.number * b.salePrice;
|
return a + b.number * b.salePrice;
|
||||||
}, 0);
|
}, 0);
|
||||||
return price;
|
|
||||||
|
const oldPrice=this.order.old.list.reduce((a,b)=>{
|
||||||
|
const total=b.info.filter((v) => v.isGift === "true").reduce((prve, cur) => {
|
||||||
|
return prve + cur.number * cur.salePrice;
|
||||||
|
},0)
|
||||||
|
return a+total
|
||||||
|
},0)
|
||||||
|
return (nowprice+oldPrice).toFixed(2);
|
||||||
|
},
|
||||||
|
allPackMoney() {
|
||||||
|
let n = 0;
|
||||||
|
const nowPrice = this.order.list
|
||||||
|
.filter((v) => v.isPack === "true")
|
||||||
|
.reduce((a, b) => {
|
||||||
|
n += b.number * 1;
|
||||||
|
return a + b.packFee * 1;
|
||||||
|
}, 0);
|
||||||
|
const oldPrice = this.order.old.list.reduce((a, b) => {
|
||||||
|
const bPrice= b.info.filter((v) => v.isPack === "true").reduce((prve, cur) => {
|
||||||
|
n += cur.number * 1;
|
||||||
|
return prve + cur.packFee * 1;
|
||||||
|
}, 0);
|
||||||
|
return a + bPrice;
|
||||||
|
}, 0);
|
||||||
|
|
||||||
|
const total = (nowPrice + oldPrice).toFixed(2);
|
||||||
|
this.order.packFee.totalAmount = total;
|
||||||
|
this.order.packFee.totalNumber = n;
|
||||||
|
return total;
|
||||||
},
|
},
|
||||||
giftLen() {
|
giftLen() {
|
||||||
return this.order.list.filter((v) => v.isGift === "true").length;
|
const nowlen=this.order.list.filter((v) => v.isGift === "true").length
|
||||||
|
const oldlen=this.order.old.list.reduce((prve,cur)=>{
|
||||||
|
const arr=cur.info.filter((v) => v.isGift === "true")
|
||||||
|
prve.push(...arr)
|
||||||
|
return prve
|
||||||
|
},[]).length
|
||||||
|
return nowlen+oldlen;
|
||||||
},
|
},
|
||||||
isSku() {
|
isSku() {
|
||||||
if (this.order.selIndex < 0 || this.order.list.length <= 0) {
|
if (this.order.selIndex < 0 || this.order.list.length <= 0) {
|
||||||
|
|
@ -1436,6 +1511,7 @@ export default {
|
||||||
return (
|
return (
|
||||||
oldPrice +
|
oldPrice +
|
||||||
price +
|
price +
|
||||||
|
+this.order.packFee.totalAmount +
|
||||||
this.order.seatFee.totalAmount *
|
this.order.seatFee.totalAmount *
|
||||||
(this.order.seatFee.status == "return" ? 0 : 1)
|
(this.order.seatFee.status == "return" ? 0 : 1)
|
||||||
).toFixed(2);
|
).toFixed(2);
|
||||||
|
|
@ -1643,6 +1719,7 @@ export default {
|
||||||
methods: {
|
methods: {
|
||||||
changeOrderExtraSel(index, canChangeNumber, placeNum) {
|
changeOrderExtraSel(index, canChangeNumber, placeNum) {
|
||||||
// console.log(index,canChangeNumber,placeNum)
|
// console.log(index,canChangeNumber,placeNum)
|
||||||
|
this.order.selIndex = -1;
|
||||||
this.order.selGoods = this.order.seatFee;
|
this.order.selGoods = this.order.seatFee;
|
||||||
this.order.selPlaceNum = placeNum;
|
this.order.selPlaceNum = placeNum;
|
||||||
this.order.extra.selIndex = index;
|
this.order.extra.selIndex = index;
|
||||||
|
|
@ -1692,9 +1769,9 @@ export default {
|
||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
async payBeforeClear() {
|
async payBeforeClear() {
|
||||||
this.getMasterId().then(res=>{
|
this.getMasterId().then((res) => {
|
||||||
this.masterId = res.masterId;
|
this.masterId = res.masterId;
|
||||||
})
|
});
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.order.list = [];
|
this.order.list = [];
|
||||||
this.order.query.page = 1;
|
this.order.query.page = 1;
|
||||||
|
|
@ -1721,7 +1798,7 @@ export default {
|
||||||
this.key = "";
|
this.key = "";
|
||||||
this.order.orderId = "";
|
this.order.orderId = "";
|
||||||
this.perpole = "";
|
this.perpole = "";
|
||||||
this.useTypes.sel = "dine-in";
|
// this.useTypes.sel = "dine-in";
|
||||||
},
|
},
|
||||||
async cachePay() {
|
async cachePay() {
|
||||||
await this.returnCreateOrderData();
|
await this.returnCreateOrderData();
|
||||||
|
|
@ -1734,14 +1811,15 @@ export default {
|
||||||
this.order.payType = "scanCode";
|
this.order.payType = "scanCode";
|
||||||
this.payTypeItemClick({ payType: "scanCode" });
|
this.payTypeItemClick({ payType: "scanCode" });
|
||||||
},
|
},
|
||||||
changeOrderUseType(useType) {
|
async changeOrderUseType(useType) {
|
||||||
if (useType && this.order.list.length) {
|
if (useType && this.order.list.length) {
|
||||||
const tableId = useType == "takeout" ? undefined : this.table.tableId;
|
const tableId = useType == "takeout" ? undefined : this.table.tableId;
|
||||||
$changeUseType({
|
await $changeUseType({
|
||||||
useType,
|
useType,
|
||||||
tableId,
|
tableId,
|
||||||
cartIds: this.order.list.map((v) => v.id),
|
cartIds: this.order.list.map((v) => v.id),
|
||||||
});
|
});
|
||||||
|
this.getCart();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
//设置用餐类型
|
//设置用餐类型
|
||||||
|
|
@ -1955,7 +2033,8 @@ export default {
|
||||||
isSellOut(item) {
|
isSellOut(item) {
|
||||||
return (
|
return (
|
||||||
item.isPauseSale ||
|
item.isPauseSale ||
|
||||||
(item.typeEnum !== "sku" && item.specList[0].stockNumber <= 0)
|
(item.typeEnum !== "sku" &&
|
||||||
|
(item.isStock == 1 ? item.stockNumber <= 0 : false))
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
toggleFullScreen() {
|
toggleFullScreen() {
|
||||||
|
|
@ -2183,8 +2262,9 @@ export default {
|
||||||
updateOrder(par = {}) {
|
updateOrder(par = {}) {
|
||||||
let item = this.order.list[this.order.selIndex];
|
let item = this.order.list[this.order.selIndex];
|
||||||
console.log(item.specSnap);
|
console.log(item.specSnap);
|
||||||
const { productId, skuId, isPack, isGift, number } = item;
|
const { productId, skuId, isPack, isGift, number, id } = item;
|
||||||
addCart({
|
$updateCart({
|
||||||
|
cartId: id,
|
||||||
masterId: this.masterId,
|
masterId: this.masterId,
|
||||||
vipUserId: this.vipUser.id,
|
vipUserId: this.vipUser.id,
|
||||||
productId,
|
productId,
|
||||||
|
|
@ -2794,12 +2874,16 @@ export default {
|
||||||
},
|
},
|
||||||
//设置购物车数据
|
//设置购物车数据
|
||||||
setCart(res) {
|
setCart(res) {
|
||||||
|
console.log(res);
|
||||||
this.order.seatFee = res.seatFee ? res.seatFee : this.order.seatFee;
|
this.order.seatFee = res.seatFee ? res.seatFee : this.order.seatFee;
|
||||||
this.perpole = res.seatFee ? res.seatFee.totalNumber : 1;
|
this.perpole = res.seatFee ? res.seatFee.totalNumber : 1;
|
||||||
const nowCart = res.records.find((v) => v.placeNum == 0);
|
const nowCart = res.records.find((v) => v.placeNum == 0);
|
||||||
this.order.list = nowCart ? nowCart.info : [];
|
this.order.list = nowCart ? nowCart.info : [];
|
||||||
const oldCart = res.records.filter((v) => v.placeNum != 0);
|
const oldCart = res.records.filter((v) => v.placeNum != 0);
|
||||||
this.order.old.list = oldCart ? oldCart : [];
|
this.order.old.list = oldCart ? oldCart : [];
|
||||||
|
this.order.gift.list=returnGiftArr(res.records)
|
||||||
|
console.log( this.order.old.list);
|
||||||
|
|
||||||
},
|
},
|
||||||
//获取购物车数据
|
//获取购物车数据
|
||||||
async getCart() {
|
async getCart() {
|
||||||
|
|
@ -2951,9 +3035,9 @@ export default {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
let isShow = true;
|
let isShow = true;
|
||||||
if (v.typeEnum !== "sku") {
|
// if (v.typeEnum !== "sku") {
|
||||||
isShow = v.specList.length >= 1;
|
// isShow = v.specList.length >= 1;
|
||||||
}
|
// }
|
||||||
v.specList.map((spe) => {
|
v.specList.map((spe) => {
|
||||||
$goodsMap[`${v.id}_${spe.id}`] = spe;
|
$goodsMap[`${v.id}_${spe.id}`] = spe;
|
||||||
});
|
});
|
||||||
|
|
@ -3798,6 +3882,7 @@ input[type="number"]::-webkit-outer-spin-button {
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
background-color: rgba(0, 0, 0, 0);
|
background-color: rgba(0, 0, 0, 0);
|
||||||
transition: all 0.3s;
|
transition: all 0.3s;
|
||||||
|
overflow: visible;
|
||||||
.pack {
|
.pack {
|
||||||
right: 100%;
|
right: 100%;
|
||||||
width: 18px;
|
width: 18px;
|
||||||
|
|
|
||||||
|
|
@ -45,3 +45,16 @@ export function returnReverseVal(val, isReturnString = true) {
|
||||||
}
|
}
|
||||||
return reverseNewval;
|
return reverseNewval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function returnGiftArr(arr){
|
||||||
|
let result=[]
|
||||||
|
for(let i=0;i<arr.length;i++){
|
||||||
|
const info=arr[i].info
|
||||||
|
for(let j=0;j<info.length;j++){
|
||||||
|
if(info[j].isGift==='true'){
|
||||||
|
result.push(info[j])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue