更新折扣优惠和代客下单

This commit is contained in:
gyq
2024-08-26 18:28:24 +08:00
parent 48a3443c5f
commit fbfee69b25
15 changed files with 611 additions and 169 deletions

View File

@@ -99,8 +99,13 @@
<div class="button">
<el-button type="primary" style="width: 100%" :disabled="!cartList.length" v-loading="createOrderLoading"
@click="createOrderHandle">
<span v-if="!createOrderLoading">结算({{ cartInfo.totalAmount || 0 }})</span>
<span v-else>下单中...</span>
<template v-if="!createOrderLoading">
<template v-if="!global.tableInfo.id">
结算
</template>
<template v-else>下单</template>
({{ cartInfo.totalAmount || 0 }})</template>
<template v-else>下单中...</template>
</el-button>
</div>
</div>
@@ -161,6 +166,7 @@ import {
// 商品列表
import goods from "@/views/home/components/goods.vue";
import member from "@/views/member/index.vue";
import { ElMessage } from "element-plus";
const global = useGlobal()
@@ -200,10 +206,19 @@ async function createOrderHandle() {
masterId: masterId.value,
shopId: store.userInfo.shopId,
remark: remark.value,
vipUserId: global.orderMemberInfo.id || '',
tableId: global.tableInfo.qrcode || ''
});
orderInfo.value = res;
settleAccountRef.value.show();
createOrderLoading.value = false;
if (global.tableInfo.id) {
ElMessage.success('下单成功')
global.setOrderTable({})
createCodeAjax(1)
} else {
orderInfo.value = res;
settleAccountRef.value.show();
}
} catch (error) {
console.log(error);
createOrderLoading.value = false;
@@ -216,6 +231,7 @@ async function clearCartHandle() {
await clearCart({
shopId: store.userInfo.shopId,
masterId: masterId.value,
tableId: global.tableInfo.qrcode || ''
});
queryCartAjax();
@@ -247,6 +263,8 @@ async function pendingCart(params, status = true) {
masterId: params.masterId,
status: status,
uuid: params.uuid,
vipUserId: global.orderMemberInfo.id || '',
tableId: global.tableInfo.qrcode || ''
});
if (status && cartList.value.length) {
await createCodeAjax();
@@ -255,6 +273,7 @@ async function pendingCart(params, status = true) {
cartLoading.value = false;
}
} catch (error) {
cartLoading.value = false;
console.log(error);
}
}
@@ -317,7 +336,8 @@ async function addCart(params, type = "add") {
const res = await createCart({
productId: params.productId,
masterId: masterId.value,
tableId: global.tableInfo.id || '',
tableId: global.tableInfo.qrcode || '',
vipUserId: global.orderMemberInfo.id || '',
shopId: store.userInfo.shopId,
skuId: type == "add" ? params.id : params.skuId,
number: params.number || 1,
@@ -343,6 +363,8 @@ async function queryCartAjax() {
const res = await queryCart({
masterId: masterId.value,
shopId: store.userInfo.shopId,
tableId: global.tableInfo.qrcode || '',
vipUserId: global.orderMemberInfo.id || ''
});
cartList.value = res.list;
cartInfo.value = res.amount;
@@ -376,11 +398,15 @@ async function createCodeAjax(type = "0") {
// })
// masterId.value = res.code
// }
const res = await createCode({
shopId: store.userInfo.shopId,
type: type,
});
masterId.value = res.code;
if (global.tableInfo.masterId) {
masterId.value = global.tableInfo.masterId
} else {
const res = await createCode({
shopId: store.userInfo.shopId,
type: type,
});
masterId.value = res.code;
}
queryCartAjax();
if (type == 1) {
@@ -396,6 +422,7 @@ async function createCodeAjax(type = "0") {
function clearMember() {
global.setOrderMember({})
global.setOrderTable({})
createCodeAjax()
}
onMounted(() => {