Merge branch 'ymf' of https://e.coding.net/g-cphe0354/cashier/cashier-web
This commit is contained in:
commit
cff5363260
|
|
@ -0,0 +1,32 @@
|
||||||
|
import request from "@/utils/request";
|
||||||
|
import { Account_BaseUrl } from "@/api/config";
|
||||||
|
const baseURL = Account_BaseUrl + "/admin/points";
|
||||||
|
const Api = {
|
||||||
|
// 002-获取订单可用积分及抵扣金额(支付页面使用)
|
||||||
|
|
||||||
|
calcOrderUsablePoints(params: any) {
|
||||||
|
return request<any>({
|
||||||
|
url: `${baseURL}/member-points/calc-usable-points`,
|
||||||
|
method: "get",
|
||||||
|
params
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 004-根据抵扣金额计算所需积分
|
||||||
|
calcMoneyUsablePoints(params: any) {
|
||||||
|
return request<any>({
|
||||||
|
url: `${baseURL}/member-points/calc-used-points`,
|
||||||
|
method: "get",
|
||||||
|
params
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 003-根据积分计算可抵扣金额
|
||||||
|
calcPointsToMoney(params: any) {
|
||||||
|
return request<any>({
|
||||||
|
url: `${baseURL}/member-points/calc-deduction-amount`,
|
||||||
|
method: "get",
|
||||||
|
params
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Api;
|
||||||
|
|
@ -47,10 +47,28 @@ const API = {
|
||||||
shopId: shopId
|
shopId: shopId
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
// 获取店铺用户详情
|
||||||
|
get(params: getRequest) {
|
||||||
|
return request({
|
||||||
|
url: `${baseURL}/detail`,
|
||||||
|
method: "get",
|
||||||
|
params
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export default API;
|
export default API;
|
||||||
|
export interface getRequest {
|
||||||
|
/**
|
||||||
|
* 会员用户id 对应shopUserId
|
||||||
|
*/
|
||||||
|
id?: number;
|
||||||
|
/**
|
||||||
|
* 用户id 不传递id则按照userId和当前shopId查询 对应userId
|
||||||
|
*/
|
||||||
|
userId?: string;
|
||||||
|
[property: string]: any;
|
||||||
|
}
|
||||||
export interface getSummaryRequest {
|
export interface getSummaryRequest {
|
||||||
/**
|
/**
|
||||||
* 0 非vip 1 vip
|
* 0 非vip 1 vip
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,22 @@ const Api = {
|
||||||
data
|
data
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
//正扫
|
||||||
|
scanPay(data: any) {
|
||||||
|
return request<any>({
|
||||||
|
url: `${baseURL}/scanPay`,
|
||||||
|
method: "post",
|
||||||
|
data
|
||||||
|
});
|
||||||
|
},
|
||||||
|
//会员支付
|
||||||
|
vipPay(data: any) {
|
||||||
|
return request<any>({
|
||||||
|
url: `${baseURL}/vipPay`,
|
||||||
|
method: "post",
|
||||||
|
data
|
||||||
|
});
|
||||||
|
},
|
||||||
//现金支付
|
//现金支付
|
||||||
cashPay(data: any) {
|
cashPay(data: any) {
|
||||||
return request<any>({
|
return request<any>({
|
||||||
|
|
@ -26,7 +42,15 @@ const Api = {
|
||||||
method: "post",
|
method: "post",
|
||||||
data
|
data
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
|
// 获取店铺订单支付URL
|
||||||
|
orderPayUrl(params: any) {
|
||||||
|
return request<any>({
|
||||||
|
url: `${baseURL}/shopPayApi/orderPayUrl`,
|
||||||
|
method: "get",
|
||||||
|
params
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,4 +14,5 @@ export * from "./modules/settings";
|
||||||
export * from "./modules/tags-view";
|
export * from "./modules/tags-view";
|
||||||
export * from "./modules/user";
|
export * from "./modules/user";
|
||||||
export * from "./modules/dict";
|
export * from "./modules/dict";
|
||||||
|
|
||||||
export { store };
|
export { store };
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import { store } from "@/store";
|
import { store } from "@/store";
|
||||||
import WebSocketManager, { type ApifoxModel, msgType } from "@/utils/websocket";
|
import WebSocketManager, { type ApifoxModel, msgType } from "@/utils/websocket";
|
||||||
import orderApi from "@/api/order/order";
|
import orderApi from "@/api/order/order";
|
||||||
import { useUserStore } from "@/store/modules/user";
|
import { useUserStoreHook } from "@/store/modules/user";
|
||||||
|
|
||||||
const shopUser = useUserStore();
|
const shopUser = useUserStoreHook();
|
||||||
export interface CartsState {
|
export interface CartsState {
|
||||||
id: string | number;
|
id: string | number;
|
||||||
[property: string]: any;
|
[property: string]: any;
|
||||||
|
|
@ -78,6 +78,12 @@ export const useCartsStore = defineStore("carts", () => {
|
||||||
})
|
})
|
||||||
//赠菜总价
|
//赠菜总价
|
||||||
const giftMoney = computed(() => {
|
const giftMoney = computed(() => {
|
||||||
|
let oldGiftMoney = 0
|
||||||
|
for (let i in oldOrder.value.detailMap) {
|
||||||
|
oldGiftMoney += oldOrder.value.detailMap[i].reduce((prve: number, cur: any) => {
|
||||||
|
return prve + cur.number * cur.salePrice
|
||||||
|
}, 0)
|
||||||
|
}
|
||||||
return giftList.value.reduce((acc: number, cur: any) => {
|
return giftList.value.reduce((acc: number, cur: any) => {
|
||||||
return acc + cur.number * cur.salePrice
|
return acc + cur.number * cur.salePrice
|
||||||
}, 0)
|
}, 0)
|
||||||
|
|
@ -90,7 +96,13 @@ export const useCartsStore = defineStore("carts", () => {
|
||||||
const giftNumber = giftList.value.reduce((acc: number, cur: any) => {
|
const giftNumber = giftList.value.reduce((acc: number, cur: any) => {
|
||||||
return acc + cur.pack_number * 1
|
return acc + cur.pack_number * 1
|
||||||
}, 0)
|
}, 0)
|
||||||
return nowCartNumber + giftNumber
|
let oldNumber = 0
|
||||||
|
for (let i in oldOrder.value.detailMap) {
|
||||||
|
oldNumber += oldOrder.value.detailMap[i].reduce((prve: number, cur: any) => {
|
||||||
|
return prve + cur.pack_number
|
||||||
|
}, 0)
|
||||||
|
}
|
||||||
|
return nowCartNumber + giftNumber + oldNumber
|
||||||
})
|
})
|
||||||
//打包费
|
//打包费
|
||||||
const packFee = computed(() => {
|
const packFee = computed(() => {
|
||||||
|
|
@ -100,27 +112,73 @@ export const useCartsStore = defineStore("carts", () => {
|
||||||
const giftPackFee = giftList.value.reduce((acc: number, cur: any) => {
|
const giftPackFee = giftList.value.reduce((acc: number, cur: any) => {
|
||||||
return acc + (cur.packFee || 0) * cur.pack_number
|
return acc + (cur.packFee || 0) * cur.pack_number
|
||||||
}, 0)
|
}, 0)
|
||||||
return nowPackFee + giftPackFee
|
let oldPackfee = 0;
|
||||||
|
for (let i in oldOrder.value.detailMap) {
|
||||||
|
oldPackfee += oldOrder.value.detailMap[i].reduce((prve: number, cur: any) => {
|
||||||
|
return prve + (cur.packFee || 0) * cur.pack_number
|
||||||
|
}, 0)
|
||||||
|
}
|
||||||
|
return nowPackFee + giftPackFee + oldPackfee
|
||||||
|
})
|
||||||
|
//会员优惠
|
||||||
|
const vipDiscount = computed(() => {
|
||||||
|
if (!useVipPrice.value) {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
const listTotal = list.value.reduce((acc: number, cur: any) => {
|
||||||
|
const n = (cur.salePrice * 1 - cur.memberPrice * 1) * cur.number
|
||||||
|
return acc + (n <= 0 ? 0 : n)
|
||||||
|
}, 0)
|
||||||
|
|
||||||
|
return listTotal
|
||||||
|
})
|
||||||
|
//单品改价优惠
|
||||||
|
const singleDiscount = computed(() => {
|
||||||
|
const listTotal = list.value.reduce((acc: number, cur: any) => {
|
||||||
|
if (cur.discount_sale_amount * 1 <= 0) {
|
||||||
|
return acc + 0
|
||||||
|
}
|
||||||
|
const originPrice = useVipPrice.value ? (cur.memberPrice || cur.salePrice) : cur.salePrice
|
||||||
|
const n = (originPrice * 1 - cur.discount_sale_amount * 1) * cur.number
|
||||||
|
return acc + (n <= 0 ? 0 : n)
|
||||||
|
}, 0)
|
||||||
|
return listTotal
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
// 优惠
|
// 优惠
|
||||||
const yiyouhui = computed(() => {
|
const yiyouhui = computed(() => {
|
||||||
const youhui = giftMoney.value
|
const youhui = giftMoney.value * 1 + vipDiscount.value * 1 + singleDiscount.value * 1
|
||||||
if (youhui > 0) {
|
if (youhui > 0) {
|
||||||
return '已优惠¥' + youhui.toFixed(2)
|
return '已优惠¥' + youhui.toFixed(2)
|
||||||
}
|
}
|
||||||
return ''
|
return ''
|
||||||
})
|
})
|
||||||
|
|
||||||
|
//历史订单价格
|
||||||
|
const oldOrderMoney = computed(() => {
|
||||||
|
let total = 0
|
||||||
|
for (let i in oldOrder.value.detailMap) {
|
||||||
|
console.log(oldOrder.value)
|
||||||
|
total += oldOrder.value.detailMap[i].reduce((prve: number, cur: any) => {
|
||||||
|
const discount_sale_amount = cur.discount_sale_amount * 1 || 0
|
||||||
|
const memberPrice = cur.skuData ? (cur.skuData.memberPrice || cur.skuData.salePrice) : 0
|
||||||
|
const price = (discount_sale_amount || cur.salePrice || 0)
|
||||||
|
return prve + cur.number * (discount_sale_amount || (useVipPrice.value ? memberPrice : price))
|
||||||
|
}, 0)
|
||||||
|
}
|
||||||
|
return total
|
||||||
|
})
|
||||||
|
|
||||||
//支付总价
|
//支付总价
|
||||||
const payMoney = computed(() => {
|
const payMoney = computed(() => {
|
||||||
const money = list.value.reduce((acc: number, cur: any) => {
|
const money = list.value.reduce((acc: number, cur: any) => {
|
||||||
|
const discount_sale_amount = cur.discount_sale_amount * 1 || 0
|
||||||
const memberPrice = cur.skuData ? (cur.skuData.memberPrice || cur.skuData.salePrice) : 0
|
const memberPrice = cur.skuData ? (cur.skuData.memberPrice || cur.skuData.salePrice) : 0
|
||||||
const price = (cur.discount_sale_amount * 1 || cur.salePrice || 0)
|
const price = (cur.discount_sale_amount * 1 || cur.salePrice || 0)
|
||||||
return acc + cur.number * (useVipPrice.value ? memberPrice : price)
|
return acc + cur.number * (discount_sale_amount || (useVipPrice.value ? memberPrice : price))
|
||||||
}, 0)
|
}, 0)
|
||||||
return (money + packFee.value).toFixed(2)
|
return (money + packFee.value + oldOrderMoney.value * 1).toFixed(2)
|
||||||
})
|
})
|
||||||
//总计数量
|
//总计数量
|
||||||
const totalNumber = computed(() => {
|
const totalNumber = computed(() => {
|
||||||
|
|
@ -130,7 +188,14 @@ export const useCartsStore = defineStore("carts", () => {
|
||||||
const giftNumber = list.value.reduce((acc: number, cur: any) => {
|
const giftNumber = list.value.reduce((acc: number, cur: any) => {
|
||||||
return acc + cur.number * 1
|
return acc + cur.number * 1
|
||||||
}, 0)
|
}, 0)
|
||||||
return cartNumber + giftNumber
|
let oldNumber = 0
|
||||||
|
|
||||||
|
for (let i in oldOrder.value.detailMap) {
|
||||||
|
oldNumber += oldOrder.value.detailMap[i].reduce((prve: number, cur: any) => {
|
||||||
|
return prve + cur.number * 1
|
||||||
|
}, 0)
|
||||||
|
}
|
||||||
|
return cartNumber + giftNumber + oldNumber
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -238,6 +303,10 @@ export const useCartsStore = defineStore("carts", () => {
|
||||||
if (cart.number * 1 < cart.skuData.suitNum * 1) {
|
if (cart.number * 1 < cart.skuData.suitNum * 1) {
|
||||||
return sendMessage('del', cart);
|
return sendMessage('del', cart);
|
||||||
}
|
}
|
||||||
|
console.log(key, val)
|
||||||
|
if (key == 'discount_sale_amount' && val * 1 <= 0) {
|
||||||
|
return ElMessage.error('价格不能为0!')
|
||||||
|
}
|
||||||
sendMessage('edit', { ...cart, [key]: val });
|
sendMessage('edit', { ...cart, [key]: val });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -245,13 +314,12 @@ export const useCartsStore = defineStore("carts", () => {
|
||||||
sendMessage('cleanup', {});
|
sendMessage('cleanup', {});
|
||||||
}
|
}
|
||||||
function dataReset() {
|
function dataReset() {
|
||||||
list.value = [];
|
selListIndex.value = -1;
|
||||||
giftList.value = [];
|
|
||||||
selListIndex.value = -1
|
|
||||||
selPlaceNum.value = 1
|
selPlaceNum.value = 1
|
||||||
isOldOrder.value = false
|
isOldOrder.value = false
|
||||||
selListIndex.value = -1;
|
|
||||||
isSelGift.value = false
|
isSelGift.value = false
|
||||||
|
list.value = [];
|
||||||
|
giftList.value = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 寻找套餐商品sku
|
// 寻找套餐商品sku
|
||||||
|
|
@ -304,14 +372,15 @@ export const useCartsStore = defineStore("carts", () => {
|
||||||
const newData: { [key: string]: any } = {}
|
const newData: { [key: string]: any } = {}
|
||||||
for (let i in data) {
|
for (let i in data) {
|
||||||
newData[i] = data[i].map((v: any) => {
|
newData[i] = data[i].map((v: any) => {
|
||||||
|
|
||||||
const skuData = getProductDetails({ product_id: v.productId, sku_id: v.skuId })
|
const skuData = getProductDetails({ product_id: v.productId, sku_id: v.skuId })
|
||||||
|
console.log(v)
|
||||||
return {
|
return {
|
||||||
...skuData,
|
...skuData,
|
||||||
placeNum: v.placeNum,
|
placeNum: v.placeNum,
|
||||||
number: v.num,
|
number: v.num,
|
||||||
id: v.id
|
id: v.id,
|
||||||
|
pack_number: v.packNumber,
|
||||||
|
discount_sale_amount: v.discountSaleAmount * 1 || 0
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -332,7 +401,7 @@ export const useCartsStore = defineStore("carts", () => {
|
||||||
...$oldOrder,
|
...$oldOrder,
|
||||||
detailMap: returnDetailMap($oldOrder.detailMap)
|
detailMap: returnDetailMap($oldOrder.detailMap)
|
||||||
}
|
}
|
||||||
console.log('initParams', initParams)
|
console.log('oldOrder.detailMap', oldOrder.value.detailMap)
|
||||||
|
|
||||||
table_code.value = initParams && initParams.table_code ? initParams.table_code : '';
|
table_code.value = initParams && initParams.table_code ? initParams.table_code : '';
|
||||||
|
|
||||||
|
|
@ -454,13 +523,7 @@ export const useCartsStore = defineStore("carts", () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (msg.operate_type === "manage_cleanup") {
|
if (msg.operate_type === "manage_cleanup") {
|
||||||
list.value = []
|
dataReset()
|
||||||
giftList.value = []
|
|
||||||
oldOrder.value = {
|
|
||||||
detailMap: [],
|
|
||||||
originAmount: 0
|
|
||||||
}
|
|
||||||
table_code.value = ''
|
|
||||||
}
|
}
|
||||||
console.log(list.value)
|
console.log(list.value)
|
||||||
});
|
});
|
||||||
|
|
@ -478,6 +541,8 @@ export const useCartsStore = defineStore("carts", () => {
|
||||||
WebSocketManager.sendMessage(msg);
|
WebSocketManager.sendMessage(msg);
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
|
singleDiscount,
|
||||||
|
vipDiscount,
|
||||||
dataReset,
|
dataReset,
|
||||||
useVipPrice,
|
useVipPrice,
|
||||||
changeUser,
|
changeUser,
|
||||||
|
|
@ -503,6 +568,6 @@ export const useCartsStore = defineStore("carts", () => {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
export function useDictStoreHook() {
|
export function useCartsStoreHook() {
|
||||||
return useCartsStore(store);
|
return useCartsStore(store);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,10 @@ export const usePermissionStore = defineStore("permission", () => {
|
||||||
*/
|
*/
|
||||||
function generateRoutes() {
|
function generateRoutes() {
|
||||||
return new Promise<RouteRecordRaw[]>((resolve, reject) => {
|
return new Promise<RouteRecordRaw[]>((resolve, reject) => {
|
||||||
|
if (isTest) {
|
||||||
|
isRoutesLoaded.value = true;
|
||||||
|
resolve(constantRoutes);
|
||||||
|
}
|
||||||
MenuAPI.getRoutes()
|
MenuAPI.getRoutes()
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
if (!isTest) {
|
if (!isTest) {
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@ import UserAPI, { type UserInfo } from "@/api/system/user";
|
||||||
import { setToken, setRefreshToken, getRefreshToken, clearToken } from "@/utils/auth";
|
import { setToken, setRefreshToken, getRefreshToken, clearToken } from "@/utils/auth";
|
||||||
|
|
||||||
export const useUserStore = defineStore("user", () => {
|
export const useUserStore = defineStore("user", () => {
|
||||||
|
// const isShopAdmin = ref(false) // 0商户 1员工
|
||||||
|
const isShopAdmin = useStorage("isShopAdmin", false) // 0商户 1员工
|
||||||
const userInfo = useStorage<UserInfo>("userInfo", {} as UserInfo);
|
const userInfo = useStorage<UserInfo>("userInfo", {} as UserInfo);
|
||||||
const promissionList = useStorage<string[]>("promissionList", [] as string[]);
|
const promissionList = useStorage<string[]>("promissionList", [] as string[]);
|
||||||
|
|
||||||
|
|
@ -26,6 +28,7 @@ export const useUserStore = defineStore("user", () => {
|
||||||
return new Promise<void>((resolve, reject) => {
|
return new Promise<void>((resolve, reject) => {
|
||||||
AuthAPI.login(loginRequest)
|
AuthAPI.login(loginRequest)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
|
isShopAdmin.value = data.loginType == 0 ? true : false;
|
||||||
Object.assign(userInfo.value, { ...data.shopInfo, shopId: data.shopInfo.id });
|
Object.assign(userInfo.value, { ...data.shopInfo, shopId: data.shopInfo.id });
|
||||||
promissionList.value = data.promissionList;
|
promissionList.value = data.promissionList;
|
||||||
const token = data.tokenInfo.tokenValue;
|
const token = data.tokenInfo.tokenValue;
|
||||||
|
|
@ -115,6 +118,7 @@ export const useUserStore = defineStore("user", () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
isShopAdmin,
|
||||||
userInfo,
|
userInfo,
|
||||||
promissionList,
|
promissionList,
|
||||||
getUserInfo,
|
getUserInfo,
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,6 @@ class WebSocketManager {
|
||||||
};
|
};
|
||||||
this.client.onerror = (error) => {
|
this.client.onerror = (error) => {
|
||||||
console.error("WebSocket 发生错误:", error);
|
console.error("WebSocket 发生错误:", error);
|
||||||
|
|
||||||
// ElNotification({
|
// ElNotification({
|
||||||
// title: "提示",
|
// title: "提示",
|
||||||
// message: "WebSocket 发生错误",
|
// message: "WebSocket 发生错误",
|
||||||
|
|
|
||||||
|
|
@ -92,8 +92,8 @@ const state = reactive({
|
||||||
codeUrl: "",
|
codeUrl: "",
|
||||||
cookiePass: "",
|
cookiePass: "",
|
||||||
loginForm: {
|
loginForm: {
|
||||||
username: "admin",
|
username: "ymf",
|
||||||
password: "12345",
|
password: "123456",
|
||||||
// rememberMe: false,
|
// rememberMe: false,
|
||||||
code: "",
|
code: "",
|
||||||
uuid: "",
|
uuid: "",
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,8 @@ const contentConfig: IContentConfig = {
|
||||||
label: "订单原金额 不含折扣价格",
|
label: "订单原金额 不含折扣价格",
|
||||||
align: "center",
|
align: "center",
|
||||||
prop: "originAmount",
|
prop: "originAmount",
|
||||||
|
templet: 'custom',
|
||||||
|
slotName: 'originAmount',
|
||||||
width: 120,
|
width: 120,
|
||||||
hidden: true,
|
hidden: true,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,9 @@
|
||||||
@operat-click="handleOperatClick"
|
@operat-click="handleOperatClick"
|
||||||
@filter-change="handleFilterChange"
|
@filter-change="handleFilterChange"
|
||||||
>
|
>
|
||||||
|
<template #originAmount="scope">
|
||||||
|
{{ returnOriginAmount(scope.row) }}
|
||||||
|
</template>
|
||||||
<template #status="scope">
|
<template #status="scope">
|
||||||
<el-tag :type="scope.row[scope.prop] == 1 ? 'success' : 'info'">
|
<el-tag :type="scope.row[scope.prop] == 1 ? 'success' : 'info'">
|
||||||
{{ scope.row[scope.prop] == 1 ? "启用" : "禁用" }}
|
{{ scope.row[scope.prop] == 1 ? "启用" : "禁用" }}
|
||||||
|
|
@ -132,6 +135,16 @@ const {
|
||||||
handleFilterChange,
|
handleFilterChange,
|
||||||
} = usePage();
|
} = usePage();
|
||||||
|
|
||||||
|
//计算订单原金额
|
||||||
|
function returnOriginAmount(order: OrderInfoVo) {
|
||||||
|
console.log(order);
|
||||||
|
let amount = 0;
|
||||||
|
// order.goods.forEach((item) => {
|
||||||
|
// amount += item.productPrice * item.number;
|
||||||
|
// });
|
||||||
|
return amount;
|
||||||
|
}
|
||||||
|
|
||||||
// 新增
|
// 新增
|
||||||
async function handleAddClick() {
|
async function handleAddClick() {
|
||||||
addModalRef.value?.setModalVisible();
|
addModalRef.value?.setModalVisible();
|
||||||
|
|
|
||||||
|
|
@ -52,8 +52,8 @@
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="经营模式">
|
<el-form-item label="经营模式">
|
||||||
<el-radio-group v-model="state.form.registerType">
|
<el-radio-group v-model="state.form.registerType">
|
||||||
<el-radio-button value="munchies">快餐版</el-radio-button>
|
<el-radio-button value="before">先付费</el-radio-button>
|
||||||
<el-radio-button value="restaurant">餐饮版</el-radio-button>
|
<el-radio-button value="after">后付费</el-radio-button>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
<div class="tips">请谨慎修改!!!</div>
|
<div class="tips">请谨慎修改!!!</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@
|
||||||
<div class="note" v-if="item.remark">备注:{{ item.remark }}</div>
|
<div class="note" v-if="item.remark">备注:{{ item.remark }}</div>
|
||||||
<div class="note flex" v-else>
|
<div class="note flex" v-else>
|
||||||
<span>备注:</span>
|
<span>备注:</span>
|
||||||
<el-icon @click="editNote" color="#999"><EditPen /></el-icon>
|
<el-icon v-if="!isOld" @click="editNote" color="#999"><EditPen /></el-icon>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="note" v-if="placeNum != 0 && item.note">备注:{{ item.remark || "" }}</div>
|
<div class="note" v-if="placeNum != 0 && item.note">备注:{{ item.remark || "" }}</div>
|
||||||
|
|
@ -83,22 +83,26 @@
|
||||||
<div>¥0</div>
|
<div>¥0</div>
|
||||||
<div class="free-price">
|
<div class="free-price">
|
||||||
<span v-if="isSeatFee">¥{{ to2(item.totalAmount) }}</span>
|
<span v-if="isSeatFee">¥{{ to2(item.totalAmount) }}</span>
|
||||||
<span v-else>¥{{ to2(isShowVipPrice ? vipAllPrice : allPrice) }}</span>
|
<span v-else>¥{{ to2(useVipPrice ? vipAllPrice : allPrice) }}</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template v-else-if="item.discountSaleAmount">
|
<!-- 单品改价 -->
|
||||||
<div>¥{{ discountNewPrice }}</div>
|
<template
|
||||||
|
v-else-if="item.discount_sale_amount * 1 > 0 && discount_before_price != allPrice"
|
||||||
|
>
|
||||||
|
<div>¥{{ to2(allPrice) }}</div>
|
||||||
<div class="free-price">
|
<div class="free-price">
|
||||||
<span>¥{{ to2(isShowVipPrice ? vipAllPrice : allPrice) }}</span>
|
<span>¥{{ to2(discount_before_price) }}</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<div v-if="isSeatFee">¥{{ to2(item.totalAmount) }}</div>
|
<div>
|
||||||
<div v-else>
|
<div v-if="useVipPrice && vipAllPrice * 1 != allPrice * 1">
|
||||||
<div v-if="isShowVipPrice && vipAllPrice != allPrice">¥{{ vipAllPrice }}</div>
|
¥{{ to2(vipAllPrice) }}
|
||||||
|
</div>
|
||||||
<div
|
<div
|
||||||
:class="{
|
:class="{
|
||||||
'free-price': isShowVipPrice && vipAllPrice != allPrice,
|
'free-price': useVipPrice && vipAllPrice != allPrice,
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<span>¥{{ to2(allPrice) }}</span>
|
<span>¥{{ to2(allPrice) }}</span>
|
||||||
|
|
@ -116,10 +120,6 @@ const props = defineProps({
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
isShowVipPrice: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
//是否是餐位费
|
//是否是餐位费
|
||||||
isSeatFee: {
|
isSeatFee: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
|
@ -180,9 +180,13 @@ const discountNewPrice = computed(() => {
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
const vipAllPrice = computed(() => {
|
const vipAllPrice = computed(() => {
|
||||||
return 0;
|
const n = (props.item.memberPrice || props.item.salePrice) * props.item.number;
|
||||||
|
return n;
|
||||||
});
|
});
|
||||||
const allPrice = computed(() => {
|
const allPrice = computed(() => {
|
||||||
|
if (props.item.discount_sale_amount * 1 > 0) {
|
||||||
|
return props.item.discount_sale_amount * props.item.number;
|
||||||
|
}
|
||||||
if (props.useVipPrice) {
|
if (props.useVipPrice) {
|
||||||
const memberPrice = props.item.memberPrice || props.item.salePrice;
|
const memberPrice = props.item.memberPrice || props.item.salePrice;
|
||||||
return memberPrice * props.item.number;
|
return memberPrice * props.item.number;
|
||||||
|
|
@ -195,7 +199,12 @@ const allPrice = computed(() => {
|
||||||
}
|
}
|
||||||
return props.item.number * props.item.salePrice;
|
return props.item.number * props.item.salePrice;
|
||||||
});
|
});
|
||||||
|
const discount_before_price = computed(() => {
|
||||||
|
if (props.useVipPrice) {
|
||||||
|
return props.item.number * (props.item.memberPrice || props.item.salePrice);
|
||||||
|
}
|
||||||
|
return props.item.number * props.item.salePrice;
|
||||||
|
});
|
||||||
const isActive = computed(() => {
|
const isActive = computed(() => {
|
||||||
return props.item.id == props.selCart.id ? "active" : "";
|
return props.item.id == props.selCart.id ? "active" : "";
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,20 @@
|
||||||
></carts-item>
|
></carts-item>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<!-- 赠菜 -->
|
||||||
|
<div class="cart-title" v-if="carts.giftList.length > 0"><span>以下是优惠菜品</span></div>
|
||||||
|
<div v-for="(item, index) in carts.giftList" :key="index">
|
||||||
|
<carts-item
|
||||||
|
:item="item"
|
||||||
|
@changeNumber="changeNumber"
|
||||||
|
:useVipPrice="carts.useVipPrice"
|
||||||
|
:selCart="carts.selCart"
|
||||||
|
@itemClick="itemClick(item)"
|
||||||
|
@editNote="editNote"
|
||||||
|
></carts-item>
|
||||||
|
</div>
|
||||||
|
<el-empty :image-size="60" v-if="carts.isEmpty" description="点餐列表为空" />
|
||||||
<!-- 打包费 -->
|
<!-- 打包费 -->
|
||||||
<template v-if="carts.packNum > 0">
|
<template v-if="carts.packNum > 0">
|
||||||
<div class="cart-title"><span>打包费</span></div>
|
<div class="cart-title"><span>打包费</span></div>
|
||||||
|
|
@ -24,20 +38,6 @@
|
||||||
<div class="cart-title"><span>餐位费</span></div>
|
<div class="cart-title"><span>餐位费</span></div>
|
||||||
<extra-fee name="餐位费" :number="perpole" :price="canWeiFee"></extra-fee>
|
<extra-fee name="餐位费" :number="perpole" :price="canWeiFee"></extra-fee>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<!-- 赠菜 -->
|
|
||||||
<div class="cart-title" v-if="carts.giftList.length > 0"><span>以下是优惠菜品</span></div>
|
|
||||||
<div v-for="(item, index) in carts.giftList" :key="index">
|
|
||||||
<carts-item
|
|
||||||
:item="item"
|
|
||||||
@changeNumber="changeNumber"
|
|
||||||
:selCart="carts.selCart"
|
|
||||||
@itemClick="itemClick(item)"
|
|
||||||
@editNote="editNote"
|
|
||||||
></carts-item>
|
|
||||||
</div>
|
|
||||||
<el-empty :image-size="60" v-if="carts.isEmpty" description="点餐列表为空" />
|
|
||||||
|
|
||||||
<!-- 历史订单 -->
|
<!-- 历史订单 -->
|
||||||
<template v-for="(item, index) in carts.oldOrder.detailMap" :key="index">
|
<template v-for="(item, index) in carts.oldOrder.detailMap" :key="index">
|
||||||
<div class="cart-title">
|
<div class="cart-title">
|
||||||
|
|
@ -46,6 +46,7 @@
|
||||||
|
|
||||||
<div v-for="(detaiItem, index) in item" :key="index">
|
<div v-for="(detaiItem, index) in item" :key="index">
|
||||||
<carts-item
|
<carts-item
|
||||||
|
:useVipPrice="carts.useVipPrice"
|
||||||
:canChangeNumber="false"
|
:canChangeNumber="false"
|
||||||
isOld
|
isOld
|
||||||
:item="detaiItem"
|
:item="detaiItem"
|
||||||
|
|
@ -60,7 +61,29 @@
|
||||||
<!-- <div class="color-666 u-font-14">订单备注:{{ "123" }}</div> -->
|
<!-- <div class="color-666 u-font-14">订单备注:{{ "123" }}</div> -->
|
||||||
</div>
|
</div>
|
||||||
<div class="bottom">
|
<div class="bottom">
|
||||||
<div class="yiyouhui">{{ carts.yiyouhui }}</div>
|
<div class="u-flex u-row-right">
|
||||||
|
<el-tooltip
|
||||||
|
placement="top"
|
||||||
|
effect="light"
|
||||||
|
popper-class="youhui-tips"
|
||||||
|
:popper-options="{
|
||||||
|
'background-color': '#fff',
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
<template #content>
|
||||||
|
<div class="u-flex color-000 u-font-14 u-row-between">
|
||||||
|
<span class="font-bold">会员优惠</span>
|
||||||
|
<span class="u-m-l-30">{{ carts.vipDiscount }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="u-flex color-000 u-font-14 u-row-between">
|
||||||
|
<span class="font-bold">单品改价优惠</span>
|
||||||
|
<span class="u-m-l-30">{{ carts.singleDiscount }}</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<div class="yiyouhui">{{ carts.yiyouhui }}</div>
|
||||||
|
</el-tooltip>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="u-flex u-row-between">
|
<div class="u-flex u-row-between">
|
||||||
<el-link type="primary">打印制作单</el-link>
|
<el-link type="primary">打印制作单</el-link>
|
||||||
<div>
|
<div>
|
||||||
|
|
@ -180,7 +203,8 @@ function init() {
|
||||||
for (let goods of props.goodsList) {
|
for (let goods of props.goodsList) {
|
||||||
goodsMap[goods.id] = goods;
|
goodsMap[goods.id] = goods;
|
||||||
}
|
}
|
||||||
console.log(props.table);
|
console.log("cartsinit");
|
||||||
|
console.log(props.oldOrder);
|
||||||
|
|
||||||
carts.init({ table_code: props.table.tableCode }, goodsMap, props.oldOrder);
|
carts.init({ table_code: props.table.tableCode }, goodsMap, props.oldOrder);
|
||||||
}
|
}
|
||||||
|
|
@ -193,9 +217,6 @@ function changeNumber(step, item) {
|
||||||
carts.changeNumber(step * 1, item);
|
carts.changeNumber(step * 1, item);
|
||||||
}
|
}
|
||||||
const totalMoney = computed(() => {
|
const totalMoney = computed(() => {
|
||||||
console.log(carts.payMoney);
|
|
||||||
console.log(carts.oldOrder.originAmount);
|
|
||||||
|
|
||||||
return (carts.payMoney * 1 + (carts.oldOrder.originAmount || 0) * 1).toFixed(2);
|
return (carts.payMoney * 1 + (carts.oldOrder.originAmount || 0) * 1).toFixed(2);
|
||||||
});
|
});
|
||||||
defineExpose({
|
defineExpose({
|
||||||
|
|
|
||||||
|
|
@ -7,33 +7,42 @@
|
||||||
<div class="color-red u-font-18 font-600">¥{{ form.money }}</div>
|
<div class="color-red u-font-18 font-600">¥{{ form.money }}</div>
|
||||||
<!-- <el-input :value="form.money" disabled> </el-input> -->
|
<!-- <el-input :value="form.money" disabled> </el-input> -->
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="减免金额">
|
<el-form-item label="优惠类型" v-if="shopUser.isShopAdmin">
|
||||||
<el-input
|
<el-radio-group v-model="discountType">
|
||||||
|
<el-radio-button label="金额" :value="0"></el-radio-button>
|
||||||
|
<el-radio-button label="折扣" :value="1"></el-radio-button>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="减免金额" v-if="discountType == 0">
|
||||||
|
<el-input-number
|
||||||
v-model="form.reduceMoney"
|
v-model="form.reduceMoney"
|
||||||
clearable
|
clearable
|
||||||
autofocus
|
autofocus
|
||||||
type="number"
|
type="number"
|
||||||
@keyup.enter="init('reduceMoney')"
|
@change="init('reduceMoney')"
|
||||||
@blur="init('reduceMoney')"
|
|
||||||
>
|
>
|
||||||
<template #append>元</template>
|
<template #append>元</template>
|
||||||
</el-input>
|
</el-input-number>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="优惠折扣">
|
|
||||||
<el-input
|
<el-form-item label="优惠折扣" v-if="discountType == 1">
|
||||||
|
<el-input-number
|
||||||
v-model="form.discount"
|
v-model="form.discount"
|
||||||
|
:step="1"
|
||||||
|
step-strictly
|
||||||
type="number"
|
type="number"
|
||||||
@keyup.enter="init('discount')"
|
@change="init('discount')"
|
||||||
@blur="init('discount')"
|
|
||||||
>
|
>
|
||||||
<template #append>%</template>
|
<template #append>%</template>
|
||||||
</el-input>
|
</el-input-number>
|
||||||
|
<span>%</span>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="实收金额">
|
<el-form-item label="实收金额">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="form.curretnMoney"
|
v-model="form.curretnMoney"
|
||||||
type="number"
|
type="number"
|
||||||
clearable
|
clearable
|
||||||
|
disabled
|
||||||
@keyup.enter="init('curretnMoney')"
|
@keyup.enter="init('curretnMoney')"
|
||||||
@blur="init('curretnMoney')"
|
@blur="init('curretnMoney')"
|
||||||
>
|
>
|
||||||
|
|
@ -49,7 +58,11 @@
|
||||||
</div>
|
</div>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script setup>
|
||||||
|
import { useUserStore } from "@/store/modules/user";
|
||||||
|
import { ElMessage } from "element-plus";
|
||||||
|
const shopUser = useUserStore();
|
||||||
|
|
||||||
function toFixedNoRounding(num) {
|
function toFixedNoRounding(num) {
|
||||||
// 转换为字符串
|
// 转换为字符串
|
||||||
var numStr = num.toString();
|
var numStr = num.toString();
|
||||||
|
|
@ -62,99 +75,103 @@ function toFixedNoRounding(num) {
|
||||||
// 拼接回数字字符串并返回
|
// 拼接回数字字符串并返回
|
||||||
return parts.join(".");
|
return parts.join(".");
|
||||||
}
|
}
|
||||||
|
//折扣类型
|
||||||
|
const discountType = ref(1);
|
||||||
|
|
||||||
export default {
|
const props = defineProps({
|
||||||
props: {
|
title: {
|
||||||
title: {
|
type: String,
|
||||||
type: String,
|
default: "优惠金额",
|
||||||
default: "优惠金额",
|
|
||||||
},
|
|
||||||
value: {
|
|
||||||
type: [String, Number],
|
|
||||||
default: 0,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
data() {
|
value: {
|
||||||
return {
|
type: [String, Number],
|
||||||
form: {
|
default: 0,
|
||||||
money: 0,
|
|
||||||
discount: 100,
|
|
||||||
reduceMoney: 0,
|
|
||||||
curretnMoney: 0,
|
|
||||||
},
|
|
||||||
number: "0",
|
|
||||||
show: false,
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
methods: {
|
});
|
||||||
init(key) {
|
|
||||||
const { money, reduceMoney, discount, curretnMoney } = this.form;
|
|
||||||
if (key == "reduceMoney") {
|
|
||||||
if (reduceMoney < 0) {
|
|
||||||
this.$message.error("减免金额不能小于0");
|
|
||||||
this.form.reduceMoney = 0;
|
|
||||||
}
|
|
||||||
if (reduceMoney > money) {
|
|
||||||
this.$message.error("减免金额不能大于总金额");
|
|
||||||
this.form.reduceMoney = money;
|
|
||||||
}
|
|
||||||
this.form.curretnMoney = (money - this.form.reduceMoney).toFixed(2);
|
|
||||||
this.form.discount = toFixedNoRounding(((this.form.curretnMoney / money) * 100).toFixed(3));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (key == "discount") {
|
|
||||||
if (discount < 0) {
|
|
||||||
this.$message.error("折扣不能小于0");
|
|
||||||
this.form.discount = 0;
|
|
||||||
}
|
|
||||||
if (discount > 100) {
|
|
||||||
this.$message.error("折扣不能大于100");
|
|
||||||
this.form.discount = 100;
|
|
||||||
}
|
|
||||||
this.form.curretnMoney = ((money * this.form.discount) / 100).toFixed(2);
|
|
||||||
this.form.reduceMoney = ((money * (100 - this.form.discount)) / 100).toFixed(2);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (key == "curretnMoney") {
|
|
||||||
if (curretnMoney < 0) {
|
|
||||||
this.$message.error("实收金额不能小于0");
|
|
||||||
this.form.curretnMoney = 0;
|
|
||||||
}
|
|
||||||
if (curretnMoney > money) {
|
|
||||||
this.$message.error("实收金额不能大于总金额");
|
|
||||||
this.form.curretnMoney = this.form.money;
|
|
||||||
}
|
|
||||||
this.form.reduceMoney = (money - this.form.curretnMoney).toFixed(2);
|
|
||||||
this.form.discount = toFixedNoRounding(((this.form.curretnMoney / money) * 100).toFixed(3));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.form.curretnMoney = ((money * discount) / 100).toFixed(2);
|
|
||||||
this.form.reduceMoney = (money - this.form.curretnMoney).toFixed(2);
|
|
||||||
},
|
|
||||||
changeKey(key, val) {
|
|
||||||
this[key] = val;
|
|
||||||
},
|
|
||||||
|
|
||||||
confirm() {
|
const state = reactive({
|
||||||
console.log(this.form.discount / 100);
|
form: {
|
||||||
this.$emit("confirm", this.form);
|
money: 0,
|
||||||
this.close();
|
discount: 100,
|
||||||
},
|
reduceMoney: 0,
|
||||||
open(data) {
|
curretnMoney: 0,
|
||||||
console.log(data);
|
|
||||||
this.form.money = data.amount * 1;
|
|
||||||
this.form.discount = data.discount ? toFixedNoRounding(data.discount.toFixed(3)) : 100;
|
|
||||||
this.show = true;
|
|
||||||
this.init();
|
|
||||||
},
|
|
||||||
close() {
|
|
||||||
this.show = false;
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
mounted() {
|
number: "0",
|
||||||
this.number = `${this.value}`;
|
show: false,
|
||||||
},
|
});
|
||||||
};
|
const { form, number, show } = toRefs(state);
|
||||||
|
function init(key) {
|
||||||
|
const { money, reduceMoney, discount, curretnMoney } = form.value;
|
||||||
|
if (key == "reduceMoney") {
|
||||||
|
if (reduceMoney < 0) {
|
||||||
|
ElMessage.error("减免金额不能小于0");
|
||||||
|
form.value.reduceMoney = 0;
|
||||||
|
}
|
||||||
|
if (reduceMoney > money) {
|
||||||
|
ElMessage.error("减免金额不能大于总金额");
|
||||||
|
form.value.reduceMoney = money;
|
||||||
|
}
|
||||||
|
form.value.curretnMoney = (money - form.value.reduceMoney).toFixed(2);
|
||||||
|
form.value.discount = toFixedNoRounding(((form.value.curretnMoney / money) * 100).toFixed(3));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (key == "discount") {
|
||||||
|
if (discount < 0) {
|
||||||
|
ElMessage.error("折扣不能小于0");
|
||||||
|
form.value.discount = 0;
|
||||||
|
}
|
||||||
|
if (discount > 100) {
|
||||||
|
ElMessage.error("折扣不能大于100");
|
||||||
|
form.value.discount = 100;
|
||||||
|
}
|
||||||
|
form.value.curretnMoney = (money * (form.value.discount / 100)).toFixed(2);
|
||||||
|
form.value.reduceMoney = ((money * (100 - form.value.discount)) / 100).toFixed(2);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (key == "curretnMoney") {
|
||||||
|
if (curretnMoney < 0) {
|
||||||
|
ElMessage.error("实收金额不能小于0");
|
||||||
|
form.value.curretnMoney = 0;
|
||||||
|
}
|
||||||
|
if (curretnMoney > money) {
|
||||||
|
ElMessage.error("实收金额不能大于总金额");
|
||||||
|
form.value.curretnMoney = form.value.money;
|
||||||
|
}
|
||||||
|
form.value.reduceMoney = (money - form.value.curretnMoney).toFixed(2);
|
||||||
|
form.value.discount = toFixedNoRounding(((form.value.curretnMoney / money) * 100).toFixed(3));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
form.value.curretnMoney = ((money * discount) / 100).toFixed(2);
|
||||||
|
form.value.reduceMoney = (money - form.value.curretnMoney).toFixed(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
const emits = defineEmits(["confirm"]);
|
||||||
|
function confirm() {
|
||||||
|
console.log(form.value);
|
||||||
|
if (discountType.value == 1) {
|
||||||
|
emits("confirm", { discount: form.value.discount });
|
||||||
|
} else {
|
||||||
|
emits("confirm", { discountAmount: form.value.reduceMoney });
|
||||||
|
}
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
function open(data) {
|
||||||
|
console.log(data);
|
||||||
|
form.value.money = data.amount * 1;
|
||||||
|
form.value.discount = data.discount ? toFixedNoRounding(data.discount.toFixed(3)) : 100;
|
||||||
|
show.value = true;
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
function close() {
|
||||||
|
show.value = false;
|
||||||
|
}
|
||||||
|
onMounted(() => {
|
||||||
|
number.value = `${props.value}`;
|
||||||
|
});
|
||||||
|
defineExpose({
|
||||||
|
close,
|
||||||
|
open,
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="userinfo" v-else @click="chooseUser">
|
<div class="userinfo" v-else @click="chooseUser">
|
||||||
<el-avatar class="avatar" :size="50" />
|
<el-avatar class="avatar" :size="50" />
|
||||||
<div class="u-m-l-12">
|
<div class="u-m-l-12 no-wrap">
|
||||||
<p>
|
<p>
|
||||||
<span class="name u-font-16">服务员下单</span>
|
<span class="name u-font-16">服务员下单</span>
|
||||||
</p>
|
</p>
|
||||||
|
|
@ -27,45 +27,47 @@
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="score">
|
<template v-if="user.id">
|
||||||
<div class="u-flex u-col-center u-m-t-10">
|
<div class="score">
|
||||||
<span class="u-font-14 font-bold u-m-r-20">积分抵扣</span>
|
<div class="u-flex u-col-center u-m-t-10">
|
||||||
<el-radio-group v-model="score.sel" size="small" class="">
|
<span class="u-font-14 font-bold u-m-r-20">积分抵扣</span>
|
||||||
<el-radio :value="0">
|
<el-radio-group v-model="score.sel" size="small" class="">
|
||||||
<span class="u-font-14">全部抵扣</span>
|
<el-radio :value="0">
|
||||||
</el-radio>
|
<span class="u-font-14">全部抵扣</span>
|
||||||
<el-radio :value="1">
|
</el-radio>
|
||||||
<span class="u-font-14">部分抵扣</span>
|
<el-radio :value="1">
|
||||||
</el-radio>
|
<span class="u-font-14">部分抵扣</span>
|
||||||
</el-radio-group>
|
</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</div>
|
||||||
|
<p class="u-font-14 color-666 u-m-t-10">
|
||||||
|
<span class="color-red">*</span>
|
||||||
|
<span>积分不足或小于最低使用门槛1</span>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<p class="u-font-14 color-666 u-m-t-10">
|
<div class="u-flex u-col-center u-m-t-20 no-wrap">
|
||||||
<span class="color-red">*</span>
|
<span class="u-font-14 font-bold u-m-r-20">团购代金券</span>
|
||||||
<span>积分不足或小于最低使用门槛1</span>
|
<div class="u-flex my-select">
|
||||||
</p>
|
<span class="u-m-r-10">代金券名称</span>
|
||||||
</div>
|
<el-icon><ArrowDown /></el-icon>
|
||||||
<div class="u-flex u-col-center u-m-t-20 no-wrap">
|
</div>
|
||||||
<span class="u-font-14 font-bold u-m-r-20">团购代金券</span>
|
<svg-icon iconClass="scan" size="30" class="u-m-l-10 cur-pointer"></svg-icon>
|
||||||
<div class="u-flex my-select">
|
|
||||||
<span class="u-m-r-10">代金券名称</span>
|
|
||||||
<el-icon><ArrowDown /></el-icon>
|
|
||||||
</div>
|
</div>
|
||||||
<svg-icon iconClass="scan" size="30" class="u-m-l-10 cur-pointer"></svg-icon>
|
<div class="u-flex u-col-center u-m-t-20 no-wrap">
|
||||||
</div>
|
<span class="u-font-14 font-bold u-m-r-20">优惠券</span>
|
||||||
<div class="u-flex u-col-center u-m-t-20 no-wrap">
|
<div class="u-flex my-select" @click="openCoupon">
|
||||||
<span class="u-font-14 font-bold u-m-r-20">优惠券</span>
|
<span class="u-m-r-10">选择优惠券</span>
|
||||||
<div class="u-flex my-select">
|
<el-icon><ArrowDown /></el-icon>
|
||||||
<span class="u-m-r-10">选择优惠券</span>
|
</div>
|
||||||
<el-icon><ArrowDown /></el-icon>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="u-m-t-30">
|
<div class="u-m-t-30">
|
||||||
<el-button size="large" @click="discountShow">整单打折/减免</el-button>
|
<el-button size="large" @click="discountShow">整单打折/减免</el-button>
|
||||||
</div>
|
</div>
|
||||||
<div class="u-m-t-30">
|
<div class="u-m-t-30">
|
||||||
<p class="u-font-16 font-bold u-m-r-20 font-bold">选择支付方式</p>
|
<p class="u-font-16 font-bold u-m-r-20 font-bold u-flex">选择支付方式</p>
|
||||||
<div class="u-m-t-20">
|
<div class="u-m-t-20">
|
||||||
<el-button
|
<el-button
|
||||||
v-for="(item, index) in payTypes.list"
|
v-for="(item, index) in payTypes.list"
|
||||||
|
|
@ -91,65 +93,90 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="u-flex u-m-b-10 u-row-between">
|
<div class="u-flex u-m-b-10 u-row-between">
|
||||||
<span class="title">餐位费</span>
|
<span class="title">餐位费</span>
|
||||||
<span class="u-m-l-10 value">{{ orderInfo.seatAmount }}</span>
|
<span class="u-m-l-10 value">¥{{ orderInfo.seatAmount }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="u-flex u-m-b-10 u-row-between">
|
<div class="u-flex u-m-b-10 u-row-between">
|
||||||
<span class="title">打包费</span>
|
<span class="title">打包费</span>
|
||||||
<span class="u-m-l-10 value">{{ orderInfo.packFee }}</span>
|
<span class="u-m-l-10 value">¥{{ orderInfo.packFee }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="u-flex u-m-b-10 u-row-between">
|
<div class="u-flex u-m-b-10 u-row-between">
|
||||||
<span class="title">总价</span>
|
<span class="title">总价</span>
|
||||||
<span class="u-m-l-10 value">{{ orderInfo.orderAmount }}</span>
|
<span class="u-m-l-10 value">¥{{ carts.payMoney }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="u-flex u-m-b-10 u-row-between">
|
<div class="u-flex u-m-b-10 u-row-between">
|
||||||
<span class="title">优惠券</span>
|
<span class="title">优惠券</span>
|
||||||
<span class="u-m-l-10 value">{{ coupDiscount }}</span>
|
<span class="u-m-l-10 value">¥{{ coupDiscount }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="u-flex u-m-b-10 u-row-between">
|
<div class="u-flex u-m-b-10 u-row-between">
|
||||||
<span class="title">积分抵扣</span>
|
<span class="title">积分抵扣</span>
|
||||||
<span class="u-m-l-10 value">{{ orderInfo.pointsDiscountAmount || 0 }}</span>
|
<span class="u-m-l-10 value">-¥{{ orderInfo.pointsDiscountAmount || 0 }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="u-flex u-m-b-10 u-row-between">
|
<div class="u-flex u-m-b-10 u-row-between">
|
||||||
<span class="title">整单改价</span>
|
<span class="title">整单改价</span>
|
||||||
<span class="u-m-l-10 value"></span>
|
<span class="u-m-l-10 value">-¥{{ checkOrderPay.discountAmount || 0 }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="u-flex u-m-b-10 u-row-between">
|
<div class="u-flex u-m-b-10 u-row-between">
|
||||||
<span class="title">抹零</span>
|
<span class="title">抹零</span>
|
||||||
<span class="u-m-l-10 value"></span>
|
<span class="u-m-l-10 value">-¥{{ orderInfo.pointsDiscountAmount || 0 }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="u-flex u-m-b-10 u-row-between">
|
<div class="u-flex u-m-b-10 u-row-between">
|
||||||
<span class="title">应付金额</span>
|
<span class="title">应付金额</span>
|
||||||
<span class="u-m-l-10 value">{{ payMoney }}</span>
|
<span class="u-m-l-10 value price">¥{{ currentpayMoney }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- 扫码 -->
|
<!-- 扫码 -->
|
||||||
<scanPay ref="refScanPay" :order="orderInfo"></scanPay>
|
<scanPay
|
||||||
|
ref="refScanPay"
|
||||||
|
:order="orderInfo"
|
||||||
|
@paySuccess="paySuccess"
|
||||||
|
@confirm="refScanPayConfirm"
|
||||||
|
></scanPay>
|
||||||
<!-- 打折 -->
|
<!-- 打折 -->
|
||||||
<discount ref="refDiscount" @confirm="discountConfirm"></discount>
|
<discount ref="refDiscount" @confirm="discountConfirm"></discount>
|
||||||
|
<!-- 优惠券 -->
|
||||||
|
<popup-coupon ref="refCoupon" @confirm="refCouponConfirm"></popup-coupon>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import { useCartsStore } from "@/store/modules/carts";
|
||||||
|
const carts = useCartsStore();
|
||||||
|
|
||||||
|
import popupCoupon from "./popup-coupon.vue";
|
||||||
|
import PointsApi from "@/api/account/points";
|
||||||
|
|
||||||
import payTypeApi from "@/api/account/payType";
|
import payTypeApi from "@/api/account/payType";
|
||||||
import payApi from "@/api/order/pay";
|
import payApi from "@/api/order/pay";
|
||||||
import scanPay from "./scan-pay.vue";
|
import scanPay from "./scan-pay.vue";
|
||||||
import discount from "./discount.vue";
|
import discount from "./discount.vue";
|
||||||
|
import { ElLoading } from "element-plus";
|
||||||
import { ElMessage, ElMessageBox } from "element-plus";
|
import { ElMessage, ElMessageBox } from "element-plus";
|
||||||
|
|
||||||
|
//优惠券
|
||||||
|
const refCoupon = ref();
|
||||||
|
function openCoupon() {
|
||||||
|
refCoupon.value.open();
|
||||||
|
}
|
||||||
|
function couponChange(data) {}
|
||||||
|
|
||||||
//打折
|
//打折
|
||||||
const refDiscount = ref();
|
const refDiscount = ref();
|
||||||
const checkOrderPay = reactive({
|
const checkOrderPay = reactive({
|
||||||
discountAmount: 0, //手动优惠金额
|
discountAmount: 0, //手动优惠金额
|
||||||
|
discount: 0,
|
||||||
});
|
});
|
||||||
function discountConfirm(e) {
|
function discountConfirm(e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
checkOrderPay.discountAmount = e.reduceMoney;
|
Object.assign(checkOrderPay, e);
|
||||||
|
if (e.discount) {
|
||||||
|
checkOrderPay.discountAmount =
|
||||||
|
carts.payMoney - (carts.payMoney * (e.discount / 100).toFixed(2)).toFixed(2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
function discountShow(e) {
|
function discountShow(e) {
|
||||||
refDiscount.value.open({
|
refDiscount.value.open({
|
||||||
amount: props.orderInfo.originAmount,
|
amount: carts.payMoney,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -160,13 +187,44 @@ const props = defineProps({
|
||||||
},
|
},
|
||||||
user: {
|
user: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => {},
|
default: () => {
|
||||||
|
return { id: "" };
|
||||||
|
},
|
||||||
},
|
},
|
||||||
orderInfo: {
|
orderInfo: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => {},
|
default: () => {},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.user.id,
|
||||||
|
(newval) => {
|
||||||
|
if (newval !== "") {
|
||||||
|
pointsInit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
watch(
|
||||||
|
() => props.orderInfo.id,
|
||||||
|
(newval) => {
|
||||||
|
if (newval !== "") {
|
||||||
|
pointsInit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
//002-获取订单可用积分及抵扣金额(支付页面使用)
|
||||||
|
function pointsInit() {
|
||||||
|
if (!props.user.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
PointsApi.calcOrderUsablePoints({
|
||||||
|
userId: props.user.id,
|
||||||
|
orderAmount: (carts.payMoney - checkOrderPay.discountAmount).toFixed(2),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const emits = defineEmits(["chooseUser", "paysuccess"]);
|
const emits = defineEmits(["chooseUser", "paysuccess"]);
|
||||||
function chooseUser() {
|
function chooseUser() {
|
||||||
emits("chooseUser");
|
emits("chooseUser");
|
||||||
|
|
@ -191,78 +249,118 @@ const payTypes = reactive({
|
||||||
|
|
||||||
const refScanPay = ref();
|
const refScanPay = ref();
|
||||||
function changePayType(i) {
|
function changePayType(i) {
|
||||||
if (payTypes.list[i].payType === "scanCode") {
|
const payType = payTypes.list[i].payType;
|
||||||
return refScanPay.value.open({
|
refScanPayOpen(payType);
|
||||||
money: props.orderInfo.orderAmount,
|
|
||||||
shopId: localStorage.getItem("shopId"),
|
|
||||||
checkOrderPay: {
|
|
||||||
orderId: props.orderInfo.id,
|
|
||||||
discountRatio: 1,
|
|
||||||
orderAmount: props.orderInfo.orderAmount,
|
|
||||||
seatNum: props.orderInfo.seatNum,
|
|
||||||
originAmount: props.orderInfo.originAmount,
|
|
||||||
discountAmount: props.orderInfo.discountAmount,
|
|
||||||
productCouponDiscountAmount: props.orderInfo.productCouponDiscountAmount,
|
|
||||||
orderAmount: props.orderInfo.orderAmount,
|
|
||||||
roundAmount: props.orderInfo.roundAmount,
|
|
||||||
pointsDiscountAmount: props.orderInfo.pointsDiscountAmount,
|
|
||||||
pointsNum: props.orderInfo.pointsNum,
|
|
||||||
fullCouponDiscountAmount: props.orderInfo.fullCouponDiscountAmount,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
payTypes.sel = i;
|
payTypes.sel = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function returnPayParams() {
|
||||||
|
return {
|
||||||
|
shopId: localStorage.getItem("shopId"),
|
||||||
|
authCode: "",
|
||||||
|
checkOrderPay: {
|
||||||
|
orderId: props.orderInfo.id,
|
||||||
|
// discountRatio: (checkOrderPay.discount / 100).toFixed(2),
|
||||||
|
discountRatio: 0,
|
||||||
|
seatNum: props.orderInfo.seatNum,
|
||||||
|
originAmount: carts.payMoney * 1,
|
||||||
|
discountAmount: checkOrderPay.discountAmount * 1,
|
||||||
|
productCouponDiscountAmount: props.orderInfo.productCouponDiscountAmount || 0,
|
||||||
|
orderAmount: currentpayMoney.value * 1,
|
||||||
|
roundAmount: props.orderInfo.roundAmount,
|
||||||
|
pointsDiscountAmount: props.orderInfo.pointsDiscountAmount || 0,
|
||||||
|
pointsNum: props.orderInfo.pointsNum,
|
||||||
|
fullCouponDiscountAmount: props.orderInfo.fullCouponDiscountAmount || 0,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function refScanPayOpen(payType) {
|
||||||
|
if (payType == "deposit") {
|
||||||
|
return refScanPay.value.open(returnPayParams(), "deposit");
|
||||||
|
}
|
||||||
|
if (payType == "scanCode") {
|
||||||
|
return refScanPay.value.open(returnPayParams(), "scanCode");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function getPaytype() {
|
async function getPaytype() {
|
||||||
const res = await payTypeApi.getList();
|
const res = await payTypeApi.getList();
|
||||||
payTypes.list = res;
|
payTypes.list = res;
|
||||||
}
|
}
|
||||||
function nowPayClick() {
|
function nowPayClick() {
|
||||||
const payType = payTypes.list[payTypes.sel].payType;
|
const payType = payTypes.list[payTypes.sel].payType;
|
||||||
console.log(payType);
|
|
||||||
if (payType === "cash") {
|
if (payType === "cash") {
|
||||||
ElMessageBox.confirm("是否确认已现金收款:" + payMoney.value + "元", "快捷支付", {
|
ElMessageBox.confirm("是否确认已现金收款:" + currentpayMoney.value + "元", "快捷支付", {
|
||||||
confirmButtonText: "确定",
|
confirmButtonText: "确定",
|
||||||
cancelButtonText: "取消",
|
cancelButtonText: "取消",
|
||||||
type: "warning",
|
type: "warning",
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
payApi
|
payOrder("cash");
|
||||||
.cashPay({
|
|
||||||
shopId: localStorage.getItem("shopId"),
|
|
||||||
checkOrderPay: {
|
|
||||||
orderId: props.orderInfo.id,
|
|
||||||
discountRatio: 1,
|
|
||||||
orderAmount: props.orderInfo.orderAmount,
|
|
||||||
seatNum: props.orderInfo.seatNum,
|
|
||||||
originAmount: props.orderInfo.originAmount,
|
|
||||||
discountAmount: props.orderInfo.discountAmount,
|
|
||||||
productCouponDiscountAmount: props.orderInfo.productCouponDiscountAmount,
|
|
||||||
orderAmount: props.orderInfo.orderAmount,
|
|
||||||
roundAmount: props.orderInfo.roundAmount,
|
|
||||||
pointsDiscountAmount: props.orderInfo.pointsDiscountAmount,
|
|
||||||
pointsNum: props.orderInfo.pointsNum,
|
|
||||||
fullCouponDiscountAmount: props.orderInfo.fullCouponDiscountAmount,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.then((res) => {
|
|
||||||
ElMessage.success("支付成功");
|
|
||||||
emits("paysuccess");
|
|
||||||
});
|
|
||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
refScanPayOpen(payType);
|
||||||
}
|
}
|
||||||
|
|
||||||
const payMoney = computed(() => {
|
function refScanPayConfirm(authCode, isScan) {
|
||||||
if (!props.orderInfo.orderAmount) {
|
const payType = payTypes.list[payTypes.sel].payType;
|
||||||
return "";
|
payParams.authCode = authCode;
|
||||||
|
payOrder(payType, isScan);
|
||||||
|
}
|
||||||
|
|
||||||
|
let payTimer = null;
|
||||||
|
//是否是正扫
|
||||||
|
async function payOrder(payType, isScan) {
|
||||||
|
clearTimeout(payTimer);
|
||||||
|
const loading = ElLoading.service({
|
||||||
|
lock: true,
|
||||||
|
text: "支付中,请稍等……",
|
||||||
|
background: "rgba(0, 0, 0, 0.7)",
|
||||||
|
});
|
||||||
|
payTimer = setTimeout(() => {
|
||||||
|
ElMessage.error("支付超时");
|
||||||
|
loading.close();
|
||||||
|
}, 1000 * 20);
|
||||||
|
let res = undefined;
|
||||||
|
try {
|
||||||
|
if (payType == "scanCode") {
|
||||||
|
res = isScan
|
||||||
|
? await payApi.scanPay(returnPayParams())
|
||||||
|
: await payApi.microPay(returnPayParams());
|
||||||
|
}
|
||||||
|
if (payType == "cash") {
|
||||||
|
res = await payApi.cashPay(returnPayParams());
|
||||||
|
}
|
||||||
|
if (payType == "deposit") {
|
||||||
|
res = await payApi.vipPay({ ...returnPayParams(), payType: "scanCode" });
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
clearTimeout(payTimer);
|
||||||
|
loading.close();
|
||||||
}
|
}
|
||||||
return (props.orderInfo.orderAmount - checkOrderPay.discountAmount).toFixed(2);
|
|
||||||
|
if (res) {
|
||||||
|
clearTimeout(payTimer);
|
||||||
|
ElMessage.success("支付成功");
|
||||||
|
emits("paysuccess");
|
||||||
|
loading.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//应付金额
|
||||||
|
const currentpayMoney = computed(() => {
|
||||||
|
if (checkOrderPay.discount) {
|
||||||
|
return (carts.payMoney * (checkOrderPay.discount / 100)).toFixed(2);
|
||||||
|
}
|
||||||
|
return (carts.payMoney - checkOrderPay.discountAmount).toFixed(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getPaytype();
|
getPaytype();
|
||||||
|
pointsInit();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,273 @@
|
||||||
|
<template>
|
||||||
|
<el-dialog width="700px" :title="title" v-model="show" top="20px" @close="reset">
|
||||||
|
<div class="u-p-15">
|
||||||
|
<div class="">
|
||||||
|
<el-tabs v-model="activeName" @tab-click="tabClick">
|
||||||
|
<el-tab-pane label="优惠券(单选)" name="youhui">
|
||||||
|
<el-table
|
||||||
|
ref="table"
|
||||||
|
empty-text="无可用优惠券"
|
||||||
|
:data="quans.fullReductionCoupon"
|
||||||
|
@cell-click="fullReductionCouponClick"
|
||||||
|
>
|
||||||
|
<el-table-column type="index" label="">
|
||||||
|
<template v-slot="scope">
|
||||||
|
<el-checkbox
|
||||||
|
@change="fullReductionCouponClick(scope.row)"
|
||||||
|
:value="scope.row.id == fullReductionCouponSel.id"
|
||||||
|
></el-checkbox>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column type="index" label="#"></el-table-column>
|
||||||
|
<el-table-column prop="name" label="券名称"></el-table-column>
|
||||||
|
<el-table-column label="券类型" width="80">
|
||||||
|
<template v-slot="scope">
|
||||||
|
{{ scope.row.type == 1 ? "优惠券" : "商品券" }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="discountAmount" label="抵扣">
|
||||||
|
<template v-slot="scope">
|
||||||
|
<span class="color-red">¥{{ scope.row.discountAmount }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="discountAmount" label="限制" width="120">
|
||||||
|
<template v-slot="scope">
|
||||||
|
<div class="u-flex">
|
||||||
|
<span>支付满</span>
|
||||||
|
<span class="color-red no-wrap">
|
||||||
|
{{ scope.row.fullAmount }}
|
||||||
|
</span>
|
||||||
|
<span>元可用</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="useRestrictions" label="描述"></el-table-column>
|
||||||
|
</el-table>
|
||||||
|
</el-tab-pane>
|
||||||
|
<el-tab-pane label="商品券(多选)" name="goods">
|
||||||
|
<el-table
|
||||||
|
ref="table1"
|
||||||
|
@cell-click="productCouponClick"
|
||||||
|
empty-text="无可用商品券"
|
||||||
|
:data="quans.productCoupon"
|
||||||
|
style="width: 100%"
|
||||||
|
>
|
||||||
|
<el-table-column>
|
||||||
|
<template v-slot="scope">
|
||||||
|
<el-checkbox
|
||||||
|
@change="productCouponClick(scope.row)"
|
||||||
|
:value="scope.row.checked"
|
||||||
|
></el-checkbox>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column type="index" width="50" label="#"></el-table-column>
|
||||||
|
<el-table-column prop="name" label="券名称"></el-table-column>
|
||||||
|
|
||||||
|
<el-table-column label="商品信息" width="120">
|
||||||
|
<template v-slot="scope">
|
||||||
|
<div class="u-flex">
|
||||||
|
<div class="u-flex">
|
||||||
|
<el-image
|
||||||
|
:src="scope.row.productCover"
|
||||||
|
fit="cover"
|
||||||
|
style="width: 40px; height: 40px"
|
||||||
|
:preview-src-list="[scope.row.productCover]"
|
||||||
|
></el-image>
|
||||||
|
</div>
|
||||||
|
<div class="u-p-l-10">
|
||||||
|
<div class="">{{ scope.row.productName }}</div>
|
||||||
|
<div class="">x{{ scope.row.num || "" }}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<!-- <el-table-column prop="discountAmount" label="抵扣">
|
||||||
|
<template v-slot="scope">
|
||||||
|
<span class="color-red">
|
||||||
|
¥{{ scope.row.discountAmount }}
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column> -->
|
||||||
|
<el-table-column label="券类型">
|
||||||
|
<template v-slot="scope">
|
||||||
|
{{ scope.row.type == 1 ? "优惠券" : "商品券" }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="useRestrictions" label="描述"></el-table-column>
|
||||||
|
<!-- <el-table-column prop="useRestrictions" label="是否可用">
|
||||||
|
<template v-slot="scope">
|
||||||
|
{{ scope.row.use ? "可以" : "不可用" }}
|
||||||
|
</template>
|
||||||
|
</el-table-column> -->
|
||||||
|
</el-table>
|
||||||
|
</el-tab-pane>
|
||||||
|
</el-tabs>
|
||||||
|
<div v-if="quansSelArr.length > 0">
|
||||||
|
<div class="font-bold u-m-b-10">已选优惠券</div>
|
||||||
|
<el-table empty-text="未选择优惠券" :data="quansSelArr">
|
||||||
|
<el-table-column type="index" width="50" label="#"></el-table-column>
|
||||||
|
<el-table-column prop="name" label="券名称"></el-table-column>
|
||||||
|
<el-table-column label="券类型" width="80">
|
||||||
|
<template v-slot="scope">
|
||||||
|
{{ scope.row.type == 1 ? "优惠券" : "商品券" }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="商品信息" width="120">
|
||||||
|
<template v-slot="scope">
|
||||||
|
<div class="u-flex" v-if="scope.row.type == 2">
|
||||||
|
<div class="u-flex">
|
||||||
|
<el-image
|
||||||
|
:src="scope.row.productCover"
|
||||||
|
fit="cover"
|
||||||
|
style="width: 40px; height: 40px"
|
||||||
|
:preview-src-list="[scope.row.productCover]"
|
||||||
|
></el-image>
|
||||||
|
</div>
|
||||||
|
<div class="u-p-l-10">
|
||||||
|
<div class="">{{ scope.row.productName }}</div>
|
||||||
|
<div class="">x{{ scope.row.num || "" }}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="discountAmount" label="抵扣">
|
||||||
|
<template v-slot="scope">
|
||||||
|
<span class="color-red" v-if="scope.row.type == 1">
|
||||||
|
¥{{ scope.row.discountAmount }}
|
||||||
|
</span>
|
||||||
|
<span class="color-red" v-if="scope.row.type == 2">
|
||||||
|
¥{{ returnProDiscount(scope.row, scope.row.index) }}
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="useRestrictions" label="描述"></el-table-column>
|
||||||
|
<el-table-column prop="useRestrictions" label="">
|
||||||
|
<template v-slot="scope">
|
||||||
|
<el-button type="danger" size="mini" @click="delQuan(scope.row)">删除</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
</div>
|
||||||
|
<div class="u-flex u-row-between u-m-t-20">
|
||||||
|
<div class="u-flex">
|
||||||
|
<span>抵扣金额:</span>
|
||||||
|
<span class="color-red">¥{{ AllCouponPrice }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="u-flex u-relative">
|
||||||
|
<span>支付金额:</span>
|
||||||
|
<span class="color-red">¥{{ payPrice }}</span>
|
||||||
|
<div
|
||||||
|
class="u-absolute u-flex line-th color-999"
|
||||||
|
style="right: 0; bottom: 100%"
|
||||||
|
v-if="orderPrice * 1 != payPrice * 1"
|
||||||
|
>
|
||||||
|
<span class="">¥{{ orderPrice }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="u-flex u-row-center u-m-t-50">
|
||||||
|
<el-button size="medium" @click="close">取消</el-button>
|
||||||
|
<el-button size="medium" type="primary" @click="confirm">确定</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
<script setup>
|
||||||
|
const props = defineProps({
|
||||||
|
title: {
|
||||||
|
type: String,
|
||||||
|
default: "选择优惠券",
|
||||||
|
},
|
||||||
|
goodsArr: {
|
||||||
|
type: Array,
|
||||||
|
default: [],
|
||||||
|
},
|
||||||
|
vipUser: {
|
||||||
|
type: Object,
|
||||||
|
default: () => {
|
||||||
|
return {
|
||||||
|
isVip: false,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
function tabClick() {}
|
||||||
|
|
||||||
|
const state = reactive({
|
||||||
|
discount: 1,
|
||||||
|
orderPrice: 0,
|
||||||
|
fullReductionCouponSel: {
|
||||||
|
id: "",
|
||||||
|
},
|
||||||
|
quansSelArr: [],
|
||||||
|
quans: {
|
||||||
|
fullReductionCoupon: [],
|
||||||
|
productCoupon: [],
|
||||||
|
},
|
||||||
|
currentRow: null,
|
||||||
|
multipleSelection: null,
|
||||||
|
fullReductionCouponSelId: "",
|
||||||
|
activeName: "youhui",
|
||||||
|
form: {},
|
||||||
|
show: false,
|
||||||
|
isSetProductCoup: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
const {
|
||||||
|
discount,
|
||||||
|
orderPrice,
|
||||||
|
fullReductionCouponSel,
|
||||||
|
quansSelArr,
|
||||||
|
quans,
|
||||||
|
currentRow,
|
||||||
|
multipleSelection,
|
||||||
|
fullReductionCouponSelId,
|
||||||
|
activeName,
|
||||||
|
form,
|
||||||
|
show,
|
||||||
|
isSetProductCoup,
|
||||||
|
} = toRefs(state);
|
||||||
|
const AllCouponPrice = computed(() => {
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
const payPrice = computed(() => {
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
function open() {
|
||||||
|
show.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function close() {
|
||||||
|
show.value = false;
|
||||||
|
}
|
||||||
|
const emits = defineEmits(["confirm"]);
|
||||||
|
function confirm() {
|
||||||
|
emits("confirm");
|
||||||
|
}
|
||||||
|
function reset() {}
|
||||||
|
defineExpose({
|
||||||
|
close,
|
||||||
|
open,
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.line-th {
|
||||||
|
text-decoration: line-through;
|
||||||
|
}
|
||||||
|
.codeImg {
|
||||||
|
width: 160px;
|
||||||
|
border: 1px solid rgb(220, 223, 230);
|
||||||
|
height: 160px;
|
||||||
|
}
|
||||||
|
:deep(.el-input .el-input__inner::-webkit-inner-spin-button) {
|
||||||
|
-webkit-appearance: none;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.el-input .el-input__inner::-webkit-outer-spin-button) {
|
||||||
|
-webkit-appearance: none;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<el-dialog width="400px" :title="title" v-model="show" @close="reset">
|
<el-dialog width="400px" :title="title" v-model="show" @close="reset">
|
||||||
<div class="u-p-15">
|
<div class="u-p-15">
|
||||||
<div v-if="openSwitch">
|
<div v-if="openSwitch" class="u-m-b-20">
|
||||||
<el-button
|
<el-button
|
||||||
@click="changeKey('paysSel', index)"
|
@click="changeKey('paysSel', index)"
|
||||||
v-for="(item, index) in pays"
|
v-for="(item, index) in pays"
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
{{ item.text }}
|
{{ item.text }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
<div class="u-m-t-20">
|
<div class="">
|
||||||
<el-alert :closable="false" v-if="tips" :title="tips" type="warning" show-icon></el-alert>
|
<el-alert :closable="false" v-if="tips" :title="tips" type="warning" show-icon></el-alert>
|
||||||
</div>
|
</div>
|
||||||
<div class="u-m-t-20">
|
<div class="u-m-t-20">
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
<el-input
|
<el-input
|
||||||
v-model="form.code"
|
v-model="form.code"
|
||||||
@change="codeInputChange"
|
@change="codeInputChange"
|
||||||
|
autofocus
|
||||||
placeholder="请扫码或者输入付款码"
|
placeholder="请扫码或者输入付款码"
|
||||||
ref="refInputCode"
|
ref="refInputCode"
|
||||||
></el-input>
|
></el-input>
|
||||||
|
|
@ -43,9 +44,9 @@
|
||||||
|
|
||||||
<!-- <img :src="codeImg" class="codeImg" alt="" /> -->
|
<!-- <img :src="codeImg" class="codeImg" alt="" /> -->
|
||||||
</div>
|
</div>
|
||||||
<div class="color-333 u-font-20 u-m-t-20">{{ to2(price) }}元</div>
|
<div class="color-333 u-font-20 u-m-t-20">{{ form.money }}元</div>
|
||||||
<div class="color-aaa u-font-12 u-m-t-10">
|
<div class="color-aaa u-font-12 u-m-t-10">
|
||||||
<i class="el-icon-loading"></i>
|
<el-icon class="loading-ani"><Loading /></el-icon>
|
||||||
<span>等待用户支付</span>
|
<span>等待用户支付</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -61,18 +62,10 @@ import payApi from "@/api/order/pay";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
openSwitch: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
order: {
|
order: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => ({}),
|
default: () => ({}),
|
||||||
},
|
},
|
||||||
title: {
|
|
||||||
type: String,
|
|
||||||
default: "支付",
|
|
||||||
},
|
|
||||||
price: {
|
price: {
|
||||||
type: [String, Number],
|
type: [String, Number],
|
||||||
default: 0,
|
default: 0,
|
||||||
|
|
@ -84,6 +77,8 @@ export default {
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
title: "支付",
|
||||||
|
openSwitch: false,
|
||||||
tips: "",
|
tips: "",
|
||||||
paymentQrcode: "",
|
paymentQrcode: "",
|
||||||
paysSel: 0,
|
paysSel: 0,
|
||||||
|
|
@ -119,11 +114,13 @@ export default {
|
||||||
if (newval == 0) {
|
if (newval == 0) {
|
||||||
this.clear();
|
this.clear();
|
||||||
this.tips = "请使用扫码枪扫微信/支付宝收款码";
|
this.tips = "请使用扫码枪扫微信/支付宝收款码";
|
||||||
this.$refs.refInputCode.focus();
|
this.$nextTick(() => {
|
||||||
|
this.$refs.refInputCode.focus();
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
this.getPayUrl();
|
this.getPayUrl();
|
||||||
this.tips = "请用户使用微信/支付宝扫描付款码";
|
this.tips = "请用户使用微信/支付宝扫描付款码";
|
||||||
// this.startGetOrderInfo();
|
this.startGetOrderInfo();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
number(newval) {
|
number(newval) {
|
||||||
|
|
@ -142,7 +139,7 @@ export default {
|
||||||
shopId: localStorage.getItem("shopId"),
|
shopId: localStorage.getItem("shopId"),
|
||||||
orderId: this.order.id,
|
orderId: this.order.id,
|
||||||
});
|
});
|
||||||
if (res.status == "closed") {
|
if (res.status == "done") {
|
||||||
this.clear();
|
this.clear();
|
||||||
this.$emit("paySuccess");
|
this.$emit("paySuccess");
|
||||||
}
|
}
|
||||||
|
|
@ -173,10 +170,12 @@ export default {
|
||||||
return this.$message.error("请输入或扫付款码");
|
return this.$message.error("请输入或扫付款码");
|
||||||
}
|
}
|
||||||
this.close();
|
this.close();
|
||||||
this.$emit("confirm", this.form.code);
|
this.$emit("confirm", this.form.code, this.paysSel ? true : false);
|
||||||
},
|
},
|
||||||
async getPayUrl() {
|
async getPayUrl() {
|
||||||
const res = await payApi.microPay(this.payPar);
|
const formdata = { ...this.payPar, ...this.payPar.checkOrderPay };
|
||||||
|
delete formdata.checkOrderPay;
|
||||||
|
const res = await payApi.orderPayUrl(formdata);
|
||||||
console.log(res);
|
console.log(res);
|
||||||
this.paymentQrcode = res;
|
this.paymentQrcode = res;
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
|
|
@ -190,7 +189,16 @@ export default {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
open(data) {
|
open(data, payType) {
|
||||||
|
if (payType == "deposit") {
|
||||||
|
// 储值卡
|
||||||
|
this.openSwitch = false;
|
||||||
|
this.title = "储值卡支付";
|
||||||
|
}
|
||||||
|
if (payType == "scanCode") {
|
||||||
|
this.openSwitch = true;
|
||||||
|
this.title = "扫码支付";
|
||||||
|
}
|
||||||
this.show = true;
|
this.show = true;
|
||||||
this.form.money = Number(data.money).toFixed(2);
|
this.form.money = Number(data.money).toFixed(2);
|
||||||
this.payPar = data;
|
this.payPar = data;
|
||||||
|
|
@ -198,7 +206,9 @@ export default {
|
||||||
// this.getPayUrl();
|
// this.getPayUrl();
|
||||||
}
|
}
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$refs.refInputCode.focus();
|
setTimeout(() => {
|
||||||
|
this.$refs.refInputCode.focus();
|
||||||
|
}, 100);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
close() {
|
close() {
|
||||||
|
|
@ -226,4 +236,18 @@ export default {
|
||||||
height: 164px;
|
height: 164px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
@keyframes rotating {
|
||||||
|
0% {
|
||||||
|
-webkit-transform: rotate(0deg);
|
||||||
|
transform: rotate(0deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
to {
|
||||||
|
-webkit-transform: rotate(1turn);
|
||||||
|
transform: rotate(1turn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.loading-ani {
|
||||||
|
animation: rotating 2s linear infinite;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
@ -20,10 +20,12 @@
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div class="u-flex">
|
<div class="u-flex">
|
||||||
<div class="ft-13 color-000">{{ user.nickName }}</div>
|
<div class="ft-13 color-000 no-wrap">{{ user.nickName }}</div>
|
||||||
<div class="vip" v-if="user.isVip">VIP{{ user.isVip }}</div>
|
<div class="vip" v-if="user.isVip">VIP{{ user.isVip }}</div>
|
||||||
</div>
|
</div>
|
||||||
<div style="margin-top: 2px" class="color-666 ft-12">余额:{{ user.amount }}</div>
|
<div style="margin-top: 2px" class="no-wrap color-666 ft-12">
|
||||||
|
余额:{{ user.amount }}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -219,8 +221,12 @@ import productApi from "@/api/product/index";
|
||||||
import tableApi from "@/api/account/table";
|
import tableApi from "@/api/account/table";
|
||||||
import $status from "@/views/tool/table/status.js";
|
import $status from "@/views/tool/table/status.js";
|
||||||
import orderApi from "@/api/order/order";
|
import orderApi from "@/api/order/order";
|
||||||
|
import shopUserApi from "@/api/account/shopUser";
|
||||||
import { useCartsStore } from "@/store/modules/carts";
|
import { useCartsStore } from "@/store/modules/carts";
|
||||||
import { useUserStore } from "@/store/modules/user";
|
import { useUserStore } from "@/store/modules/user";
|
||||||
|
|
||||||
|
import { ElLoading } from "element-plus";
|
||||||
|
|
||||||
const carts = useCartsStore();
|
const carts = useCartsStore();
|
||||||
const shopUser = useUserStore();
|
const shopUser = useUserStore();
|
||||||
|
|
||||||
|
|
@ -245,9 +251,8 @@ function showDinerNumber() {
|
||||||
let user = ref({});
|
let user = ref({});
|
||||||
const refChooseUser = ref();
|
const refChooseUser = ref();
|
||||||
function chooseUserConfirm(e) {
|
function chooseUserConfirm(e) {
|
||||||
console.log(e);
|
user.value = e ? e : {};
|
||||||
user.value = e;
|
refCart.value.carts.changeUser(e ? e : {});
|
||||||
refCart.value.carts.changeUser(e);
|
|
||||||
}
|
}
|
||||||
function showChooseUser() {
|
function showChooseUser() {
|
||||||
refChooseUser.value.open();
|
refChooseUser.value.open();
|
||||||
|
|
@ -258,42 +263,62 @@ const showOrder = ref(false);
|
||||||
function hideOrder() {
|
function hideOrder() {
|
||||||
showOrder.value = false;
|
showOrder.value = false;
|
||||||
}
|
}
|
||||||
const oldOrder = ref({});
|
const oldOrder = ref({ detailMap: [] });
|
||||||
|
|
||||||
const orderInfo = ref({});
|
const orderInfo = ref({});
|
||||||
|
|
||||||
|
let createOrderTimer = null;
|
||||||
async function createOrder(key) {
|
async function createOrder(key) {
|
||||||
console.log(refCart.value.carts.table_code);
|
console.log(refCart.value.carts.table_code);
|
||||||
const res = await orderApi.add({
|
clearTimeout(createOrderTimer);
|
||||||
orderId: oldOrder.value.id || "",
|
const loading = ElLoading.service({
|
||||||
shopId: shopUser.userInfo.id,
|
lock: true,
|
||||||
userId: user.value.userId,
|
text: "订单生成中,请稍等……",
|
||||||
seatNum: 0,
|
background: "rgba(0, 0, 0, 0.7)",
|
||||||
packFee: refCart.value.carts.packFee * 1,
|
|
||||||
originAmount: refCart.value.carts.payMoney * 1,
|
|
||||||
tableCode: refCart.value.carts.table_code,
|
|
||||||
dineMode: diners.sel == 0 ? "dine-in" : "take-out",
|
|
||||||
remark: "",
|
|
||||||
seatNum: perpole.value * 1,
|
|
||||||
placeNum: 1,
|
|
||||||
waitCall: false,
|
|
||||||
vipPrice: user.value.id && user.value.isVip,
|
|
||||||
});
|
});
|
||||||
if (res) {
|
createOrderTimer = setTimeout(() => {
|
||||||
refCart.value.carts.clear();
|
ElMessage.error("订单生成超时");
|
||||||
if (key == "only-create") {
|
loading.close();
|
||||||
router.replace(route.path);
|
}, 1000 * 20);
|
||||||
return;
|
try {
|
||||||
|
const res = await orderApi.add({
|
||||||
|
orderId: oldOrder.value.id || "",
|
||||||
|
shopId: shopUser.userInfo.id,
|
||||||
|
userId: user.value.userId,
|
||||||
|
seatNum: 0,
|
||||||
|
packFee: refCart.value.carts.packFee * 1,
|
||||||
|
originAmount: refCart.value.carts.payMoney * 1,
|
||||||
|
tableCode: refCart.value.carts.table_code,
|
||||||
|
dineMode: diners.sel == 0 ? "dine-in" : "take-out",
|
||||||
|
remark: "",
|
||||||
|
seatNum: perpole.value * 1,
|
||||||
|
placeNum: oldOrder.value.placeNum * 1 + 1,
|
||||||
|
waitCall: false,
|
||||||
|
vipPrice: user.value.id && user.value.isVip,
|
||||||
|
});
|
||||||
|
clearTimeout(createOrderTimer);
|
||||||
|
loading.close();
|
||||||
|
if (res) {
|
||||||
|
refCart.value.carts.clear();
|
||||||
|
if (key == "only-create") {
|
||||||
|
router.replace(route.path);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (res.id) {
|
||||||
|
// 获取历史订单数据
|
||||||
|
const res1 = await orderApi.getHistoryList({
|
||||||
|
orderId: res.id,
|
||||||
|
});
|
||||||
|
oldOrder.value = res1;
|
||||||
|
orderInfo.value = res1;
|
||||||
|
refCart.value.carts.init();
|
||||||
|
}
|
||||||
|
showOrder.value = true;
|
||||||
|
|
||||||
|
// oldOrder.value = res;
|
||||||
}
|
}
|
||||||
if (key == "to-pay" && oldOrder.value.id) {
|
} catch (error) {
|
||||||
// 获取历史订单数据
|
clearTimeout(createOrderTimer);
|
||||||
const res = await orderApi.getHistoryList({
|
|
||||||
orderId: oldOrder.value.id,
|
|
||||||
});
|
|
||||||
oldOrder.value = res;
|
|
||||||
}
|
|
||||||
orderInfo.value = res;
|
|
||||||
showOrder.value = true;
|
|
||||||
// oldOrder.value = res;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -580,12 +605,21 @@ onMounted(async () => {
|
||||||
};
|
};
|
||||||
if (noPayStatus[res.status]) {
|
if (noPayStatus[res.status]) {
|
||||||
ElMessage.error(noPayStatus[res.status]);
|
ElMessage.error(noPayStatus[res.status]);
|
||||||
refresh();
|
router.replace(route.path);
|
||||||
|
console.log(route.path);
|
||||||
|
setTimeout(() => {
|
||||||
|
refCart.value.carts.dataReset();
|
||||||
|
refresh();
|
||||||
|
}, 2000);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (res.tableCode) {
|
if (res.tableCode) {
|
||||||
table.value = { tableCode: res.tableCode };
|
table.value = { tableCode: res.tableCode };
|
||||||
}
|
}
|
||||||
|
if (res.userId) {
|
||||||
|
const userRes = await shopUserApi.get({ userId: res.userId });
|
||||||
|
user.value = userRes;
|
||||||
|
}
|
||||||
if (res) {
|
if (res) {
|
||||||
oldOrder.value = res;
|
oldOrder.value = res;
|
||||||
orderInfo.value = res;
|
orderInfo.value = res;
|
||||||
|
|
@ -599,7 +633,10 @@ onMounted(async () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
function refresh() {
|
function refresh() {
|
||||||
router.go(0);
|
router.replace(route.path);
|
||||||
|
setTimeout(() => {
|
||||||
|
router.go(1000);
|
||||||
|
}, 1500);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue