代客下单修改先付费页面逻辑样式

This commit is contained in:
YeMingfei666 2024-09-27 09:39:25 +08:00
parent a210389439
commit 60bc61d40f
5 changed files with 225 additions and 86 deletions

View File

@ -45,9 +45,13 @@ export function gettbConsInfo(params) {
// params
// });
return request({
url: "/api/viewConInfoFlow",
url: "/api/tbConsInfo",
method: "get",
params
params:{
...params,
shopId: localStorage.getItem("shopId"),
status:1
}
});
}

View File

@ -233,6 +233,8 @@ import {
tbShopTable,
} from "@/api/table";
import dayjs from "dayjs";
export default {
components: {
addEara,
@ -253,18 +255,48 @@ export default {
selTable: "", //
areaMap: {},
shopInfo: {},
timer:null
};
},
beforeDestroy() {
this.clearTimer();
console.log('beforeDestroy')
},
mounted() {
this.clearTimer();
this.setTimter(60);
this.tbShopAreaGet();
this.getShopInfo();
},
filters: {
formatTime(time) {
return dayjs(time).format("HH小时mm分");
formatTime(milliseconds) {
if (!milliseconds) {
return "";
}
const days = Math.floor(milliseconds / (1000 * 60 * 60 * 24));
const hours = Math.floor(
(milliseconds % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)
);
const minutes = Math.floor(
(milliseconds % (1000 * 60 * 60)) / (1000 * 60)
);
return `${days ? days + "天" : ""} ${hours ? hours + "时" : ""} ${
minutes ? minutes + "分" : ""
}`;
},
},
methods: {
clearTimer(){
console.log('clearTimer')
clearInterval(this.timer);
this.timer=null;
},
setTimter(time=60){
this.timer=setInterval(() => {
const showloading=false
this.tbShopTableGet(showloading)
}, time*1000);
},
//
async getShopInfo() {
try {
@ -322,7 +354,7 @@ export default {
this.selTable = item;
if (this.shopInfo.isTableFee) {
//
this.toInstead({num: 0,key});
this.toInstead({ num: 0, key });
// this.$refs.diancan.open(item, key, '');
return;
}
@ -330,20 +362,23 @@ export default {
if (item.useNum <= 0) {
return this.$refs.refChooseDinersNumber.open();
}
this.toInstead({num: num,key});
this.toInstead({ num: num, key });
// this.$refs.diancan.open(item, key, num);
},
toInstead(query) {
this.$router.push({ path: "/tool/Instead/index", query: {
table_name: this.selTable.name,
tableId: this.selTable.tableId,
maxCapacity:this.selTable.maxCapacity,
useType: this.selTable.useType,
...query
}});
this.$router.push({
path: "/tool/Instead/index",
query: {
table_name: this.selTable.name,
tableId: this.selTable.tableId,
useType: this.selTable.useType,
maxCapacity:this.selTable.maxCapacity,
...query,
},
});
},
chooseDinersNumberConfirm(num) {
this.toInstead({num: num});
this.toInstead({ num: num });
// this.$refs.diancan.open(this.selTable, undefined, num);
},
tabClick() {
@ -369,8 +404,8 @@ export default {
}
},
//
async tbShopTableGet() {
this.loading = true;
async tbShopTableGet(showloading=true) {
this.loading = showloading;
try {
const { content, total } = await tbShopTableGet({
shopId: localStorage.getItem("shopId"),

View File

@ -151,9 +151,9 @@ export default {
this.$emit("changeOrderNumber", this.index, isReduce);
},
itemClick() {
if(this.isSeatFee){
return
}
// if(this.isSeatFee){
// return
// }
this.$emit("itemClick", this.index,this.canChangeNumber,this.placeNum);
},
},

View File

@ -51,8 +51,7 @@ export default {
async init() {
const res = await $getPayType();
this.list = res.filter(v=>v.isDisplay);
console.log(res[0]);
this.sel = this.sel ? this.sel : res[0].payType;
this.sel = this.sel ? this.sel : 'scanCode';
},
},
mounted() {

View File

@ -237,11 +237,8 @@
</div>
</template>
</div>
<el-button
@click="clearCart"
type="text"
size="mini"
:disabled="order.list.length <= 0"
<el-button @click="clearCart" type="text" size="mini"
:disabled="order.list.length<=0"
>清空</el-button
>
</div>
@ -308,14 +305,14 @@
<template v-if="order.seatFee && order.seatFee.totalAmount > 0">
<div class="carts_list_title">餐位费</div>
<cart-item
@itemClick="changeOrderOldSel"
@itemClick="changeOrderExtraSel"
:canChangeNumber="false"
key="seatFee"
:index="0"
:item="order.seatFee"
isSeatFee
:selIndex="order.old.selIndex"
:placeNum="-1"
:selIndex="order.extra.selIndex"
:placeNum="-10"
:selPlaceNum="order.selPlaceNum"
></cart-item>
</template>
@ -349,41 +346,77 @@
</div>
<div class="flex mt-14">
<template v-if="isCreateOrder">
<button
class="my-btn flex-1 default"
@click="createOrderClose"
>
<span>加菜/返回</span>
</button>
<div style="width: 15px"></div>
<button class="my-btn flex-1 primary" @click="payOrder">
<span>立即支付</span>
</button>
<template v-if="!postPay">
<template v-if="isCreateOrder">
<button
class="my-btn flex-1 default"
@click="createOrderClose"
>
<span>加菜/返回</span>
</button>
</template>
<template v-else>
<button
class="my-btn flex-1 primary"
@click="scanPayClick"
>
<span>微信/支付宝</span>
</button>
<div style="width: 15px"></div>
<button
class="my-btn flex-1 primary"
@click="cashPayClick"
>
<span>现金</span>
</button>
<div style="width: 15px"></div>
<button
class="my-btn flex-1 default"
@click="morePayClick"
>
<span>更多支付</span>
</button>
</template>
</template>
<template v-else>
<template v-if="postPay">
<template v-if="isCreateOrder">
<button
class="my-btn flex-1 default"
@click="createOrderClose"
>
<span>加菜/返回</span>
</button>
<div style="width: 15px"></div>
<button class="my-btn flex-1 primary" @click="payOrder">
<span>立即支付</span>
</button>
</template>
<template v-else>
<template v-if="postPay">
<div class="flex-1">
<el-button
type="primary"
size="medium"
:disabled="!order.list.length"
@click="toCreateOrderDebounce(false)"
>
仅下单
</el-button>
</div>
<div style="width: 15px"></div>
</template>
<div class="flex-1">
<el-button
type="primary"
size="medium"
:disabled="!order.list.length"
@click="toCreateOrderDebounce(false)"
:disabled="
!order.list.length && !order.old.list.length
"
@click="toCreateOrderDebounce(true)"
>
仅下单
去结账
</el-button>
</div>
<div style="width: 15px"></div>
</template>
<div class="flex-1">
<el-button
size="medium"
:disabled="!order.list.length && !order.old.list.length"
@click="toCreateOrderDebounce(true)"
>
去结账
</el-button>
</div>
</template>
</div>
</div>
@ -488,10 +521,7 @@
<div
class="btn"
:class="{
disabled:
order.placeNum <= 0 ||
order.old.selIndex < 0 ||
order.selGoods.status == 'return',
disabled: disableTuicai,
}"
@click="orderBtnsClick('returnCart')"
>
@ -885,7 +915,7 @@
v-if="!skuGoods.data.isGrounding"
disabled
>
已下架
已下架/库存不足
</button>
<template v-else>
<button
@ -1221,6 +1251,9 @@ export default {
total: 0,
},
order: {
extra: {
selIndex: -1,
},
seatFee: { totalAmount: 0 }, //
orderId: "",
payType: "",
@ -1315,6 +1348,12 @@ export default {
};
},
computed: {
disableTuicai() {
return (
this.order.placeNum>=1 ||this.order.selIndex>=0||!this.order.selGoods||
this.order.selGoods.status == "return"
);
},
title() {
return this.table ? "代客下单" + `(${this.table.name})` : "代客下单";
},
@ -1571,10 +1610,54 @@ export default {
// this.refToggle('refScanCode',true)
// this.refToggle("refDiscount", true);
this.getShopInfo();
console.log(this.$route.query.tableId)
this.open(this.$route.query.tableId?this.$route.query:'');
console.log(this.$route.query.tableId);
this.open(this.$route.query.tableId ? this.$route.query : "");
},
methods: {
changeOrderExtraSel(index, canChangeNumber, placeNum) {
// console.log(index,canChangeNumber,placeNum)
this.order.selGoods = this.order.seatFee;
this.order.selPlaceNum = placeNum;
this.order.extra.selIndex = index;
},
async morePayClick() {
const res = await this.returnCreateOrderData();
this.createOrder.data = res;
this.order.payType = "";
this.isCreateOrder = true;
},
cashPayClick() {
this.$confirm("是否确认已现金收款:" + this.allPrice + "?", "快捷支付", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
}).then(() => {
this.order.payType = "cash";
this.cachePay();
});
},
returnCreateOrderData() {
return $createOrder({
masterId: this.order.masterId || this.masterId,
vipUserId: this.vipUser.id,
tableId: this.table.tableId,
note: this.note.content,
postPay: this.postPay,
orderld: this.order.orderId,
});
},
async cachePay() {
const res = await this.returnCreateOrderData();
this.createOrder.data = res;
this.pays();
},
async scanPayClick() {
const res = await this.returnCreateOrderData();
this.createOrder.data = res;
this.createOrder.discount = 1;
this.order.payType = "scanCode";
this.payTypeItemClick({ payType: "scanCode" });
},
changeOrderUseType(useType) {
if (useType && this.order.list.length) {
$changeUseType({
@ -1645,18 +1728,27 @@ export default {
this.perpole = 1;
await this.changePerpole();
}
//
const item=this.table;
if (item && item.useType) {
localStorage.setItem("useType", item.useType);
this.useTypes.sel =
item.useType == "takeout"
? item.useType
: item.useType.replace(/-after|-before/g, "");
}
this.getCart();
this.getCacheOrder();
console.log(this.isCreateOrder)
if (!this.shopInfo.isTableFee && this.table.tableId&&this.perpole>0) {
console.log(this.isCreateOrder);
if (!this.shopInfo.isTableFee && this.table.tableId && this.perpole > 0) {
//
const seatFee= await $choseCount({
const seatFee = await $choseCount({
masterId: this.masterId,
tableId: this.table.tableId,
num: this.perpole,
});
this.order.seatFee = seatFee;
this.perpole=seatFee.totalNumber
this.perpole = seatFee.totalNumber;
}
if (this.isCreateOrder) {
this.toCreateOrder(true);
@ -1704,7 +1796,9 @@ export default {
const { content, total } = await tbShopTableGet({
shopId: localStorage.getItem("shopId"),
});
this.tableList = content.filter((v) => v.status != "closed"&&v.status != "cleaning");
this.tableList = content.filter(
(v) => v.status != "closed" && v.status != "cleaning"
);
} catch (error) {
console.log(error);
}
@ -1876,7 +1970,7 @@ export default {
type: "success",
});
this.close();
// this.reset();
// this.reset();
},
chooseTableConfirm(item) {
console.log(item);
@ -1897,7 +1991,7 @@ export default {
this.$refs.refChooseUser.open();
},
createOrderClose() {
console.log('createOrderClose')
console.log("createOrderClose");
this.isCreateOrder = false;
},
//
@ -2281,9 +2375,9 @@ export default {
},
//
clearCart() {
if (this.order.list.length <= 0) {
return;
}
// if (this.order.list.length <= 0) {
// return;
// }
this.$confirm("确定要清空点餐列表吗?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
@ -2513,7 +2607,7 @@ export default {
.filter((v) => v.specSnap.match(i))
.every((v) => {
// return isCanBuy(v,this.selGoods.data.isStock)
return !isCanBuy(v);
return !isCanBuy(v, true);
});
}
}
@ -2583,7 +2677,7 @@ export default {
this.useTypes.sel = "dine-in";
},
//
setCart(res){
setCart(res) {
this.order.seatFee = res.seatFee ? res.seatFee : this.order.seatFee;
this.perpole = res.seatFee ? res.seatFee.totalNumber : 1;
const nowCart = res.records.find((v) => v.placeNum == 0);
@ -2632,7 +2726,7 @@ export default {
return prve;
}, {});
const canBudyGoods = this.selGoods.data.specList
.filter((v) => isCanBuy(v))
.filter((v) => isCanBuy(v, true))
.sort((a, b) => {
const aNumber = a.specSnap.split(",").reduce((prve, cur) => {
return prve + skuMapNumber[cur];
@ -2753,19 +2847,20 @@ export default {
this.getGoods();
this.getCategory();
this.getTable();
console.log(params)
console.log(params);
if (!params) {
//
return;
}
const item = { name: params.table_name, tableId: params.tableId , useType: params.useType,maxCapacity:params.maxCapacity*1},
const item = {
name: params.table_name,
tableId: params.tableId,
useType: params.useType,
maxCapacity: params.maxCapacity * 1,
},
key = params.key,
perpoleNumber = params.num;
//
this.key = key;
this.isCreateOrder =this.key == "isPayOrder"? true:false;
this.perpole = perpoleNumber;
this.table = item;
if (item && item.useType) {
localStorage.setItem("useType", item.useType);
this.useTypes.sel =
@ -2773,13 +2868,19 @@ export default {
? item.useType
: item.useType.replace(/-after|-before/g, "");
}
// this.getCart();
// this.getGoods();
// this.getCategory();
// this.getTable();
this.key = key;
this.isCreateOrder = this.key == "isPayOrder" ? true : false;
this.perpole = perpoleNumber;
this.table = item;
},
close() {
this.$router.push({ path: "/table/table_list"});
if (this.table.tableId) {
this.$router.replace({ path: "/table/table_list" });
} else {
this.$router.go(0);
// this.reset();
// this.$router.replace({ path: "/tool/Instead/index" });
}
this.informationdialogshow = false;
this.$emit("close");
},