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
|
||||
}
|
||||
});
|
||||
},
|
||||
// 获取店铺用户详情
|
||||
get(params: getRequest) {
|
||||
return request({
|
||||
url: `${baseURL}/detail`,
|
||||
method: "get",
|
||||
params
|
||||
});
|
||||
}
|
||||
}
|
||||
export default API;
|
||||
|
||||
export interface getRequest {
|
||||
/**
|
||||
* 会员用户id 对应shopUserId
|
||||
*/
|
||||
id?: number;
|
||||
/**
|
||||
* 用户id 不传递id则按照userId和当前shopId查询 对应userId
|
||||
*/
|
||||
userId?: string;
|
||||
[property: string]: any;
|
||||
}
|
||||
export interface getSummaryRequest {
|
||||
/**
|
||||
* 0 非vip 1 vip
|
||||
|
|
|
|||
|
|
@ -19,6 +19,22 @@ const Api = {
|
|||
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) {
|
||||
return request<any>({
|
||||
|
|
@ -26,7 +42,15 @@ const Api = {
|
|||
method: "post",
|
||||
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/user";
|
||||
export * from "./modules/dict";
|
||||
|
||||
export { store };
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { store } from "@/store";
|
||||
import WebSocketManager, { type ApifoxModel, msgType } from "@/utils/websocket";
|
||||
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 {
|
||||
id: string | number;
|
||||
[property: string]: any;
|
||||
|
|
@ -78,6 +78,12 @@ export const useCartsStore = defineStore("carts", () => {
|
|||
})
|
||||
//赠菜总价
|
||||
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 acc + cur.number * cur.salePrice
|
||||
}, 0)
|
||||
|
|
@ -90,7 +96,13 @@ export const useCartsStore = defineStore("carts", () => {
|
|||
const giftNumber = giftList.value.reduce((acc: number, cur: any) => {
|
||||
return acc + cur.pack_number * 1
|
||||
}, 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(() => {
|
||||
|
|
@ -100,27 +112,73 @@ export const useCartsStore = defineStore("carts", () => {
|
|||
const giftPackFee = giftList.value.reduce((acc: number, cur: any) => {
|
||||
return acc + (cur.packFee || 0) * cur.pack_number
|
||||
}, 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 youhui = giftMoney.value
|
||||
const youhui = giftMoney.value * 1 + vipDiscount.value * 1 + singleDiscount.value * 1
|
||||
if (youhui > 0) {
|
||||
return '已优惠¥' + youhui.toFixed(2)
|
||||
}
|
||||
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 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 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)
|
||||
return (money + packFee.value).toFixed(2)
|
||||
return (money + packFee.value + oldOrderMoney.value * 1).toFixed(2)
|
||||
})
|
||||
//总计数量
|
||||
const totalNumber = computed(() => {
|
||||
|
|
@ -130,7 +188,14 @@ export const useCartsStore = defineStore("carts", () => {
|
|||
const giftNumber = list.value.reduce((acc: number, cur: any) => {
|
||||
return acc + cur.number * 1
|
||||
}, 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) {
|
||||
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 });
|
||||
}
|
||||
|
||||
|
|
@ -245,13 +314,12 @@ export const useCartsStore = defineStore("carts", () => {
|
|||
sendMessage('cleanup', {});
|
||||
}
|
||||
function dataReset() {
|
||||
list.value = [];
|
||||
giftList.value = [];
|
||||
selListIndex.value = -1
|
||||
selListIndex.value = -1;
|
||||
selPlaceNum.value = 1
|
||||
isOldOrder.value = false
|
||||
selListIndex.value = -1;
|
||||
isSelGift.value = false
|
||||
list.value = [];
|
||||
giftList.value = [];
|
||||
}
|
||||
|
||||
// 寻找套餐商品sku
|
||||
|
|
@ -304,14 +372,15 @@ export const useCartsStore = defineStore("carts", () => {
|
|||
const newData: { [key: string]: any } = {}
|
||||
for (let i in data) {
|
||||
newData[i] = data[i].map((v: any) => {
|
||||
|
||||
const skuData = getProductDetails({ product_id: v.productId, sku_id: v.skuId })
|
||||
|
||||
console.log(v)
|
||||
return {
|
||||
...skuData,
|
||||
placeNum: v.placeNum,
|
||||
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,
|
||||
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 : '';
|
||||
|
||||
|
|
@ -454,13 +523,7 @@ export const useCartsStore = defineStore("carts", () => {
|
|||
}
|
||||
}
|
||||
if (msg.operate_type === "manage_cleanup") {
|
||||
list.value = []
|
||||
giftList.value = []
|
||||
oldOrder.value = {
|
||||
detailMap: [],
|
||||
originAmount: 0
|
||||
}
|
||||
table_code.value = ''
|
||||
dataReset()
|
||||
}
|
||||
console.log(list.value)
|
||||
});
|
||||
|
|
@ -478,6 +541,8 @@ export const useCartsStore = defineStore("carts", () => {
|
|||
WebSocketManager.sendMessage(msg);
|
||||
}
|
||||
return {
|
||||
singleDiscount,
|
||||
vipDiscount,
|
||||
dataReset,
|
||||
useVipPrice,
|
||||
changeUser,
|
||||
|
|
@ -503,6 +568,6 @@ export const useCartsStore = defineStore("carts", () => {
|
|||
};
|
||||
});
|
||||
|
||||
export function useDictStoreHook() {
|
||||
export function useCartsStoreHook() {
|
||||
return useCartsStore(store);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,10 @@ export const usePermissionStore = defineStore("permission", () => {
|
|||
*/
|
||||
function generateRoutes() {
|
||||
return new Promise<RouteRecordRaw[]>((resolve, reject) => {
|
||||
if (isTest) {
|
||||
isRoutesLoaded.value = true;
|
||||
resolve(constantRoutes);
|
||||
}
|
||||
MenuAPI.getRoutes()
|
||||
.then((data) => {
|
||||
if (!isTest) {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ import UserAPI, { type UserInfo } from "@/api/system/user";
|
|||
import { setToken, setRefreshToken, getRefreshToken, clearToken } from "@/utils/auth";
|
||||
|
||||
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 promissionList = useStorage<string[]>("promissionList", [] as string[]);
|
||||
|
||||
|
|
@ -26,6 +28,7 @@ export const useUserStore = defineStore("user", () => {
|
|||
return new Promise<void>((resolve, reject) => {
|
||||
AuthAPI.login(loginRequest)
|
||||
.then((data) => {
|
||||
isShopAdmin.value = data.loginType == 0 ? true : false;
|
||||
Object.assign(userInfo.value, { ...data.shopInfo, shopId: data.shopInfo.id });
|
||||
promissionList.value = data.promissionList;
|
||||
const token = data.tokenInfo.tokenValue;
|
||||
|
|
@ -115,6 +118,7 @@ export const useUserStore = defineStore("user", () => {
|
|||
}
|
||||
|
||||
return {
|
||||
isShopAdmin,
|
||||
userInfo,
|
||||
promissionList,
|
||||
getUserInfo,
|
||||
|
|
|
|||
|
|
@ -74,7 +74,6 @@ class WebSocketManager {
|
|||
};
|
||||
this.client.onerror = (error) => {
|
||||
console.error("WebSocket 发生错误:", error);
|
||||
|
||||
// ElNotification({
|
||||
// title: "提示",
|
||||
// message: "WebSocket 发生错误",
|
||||
|
|
|
|||
|
|
@ -92,8 +92,8 @@ const state = reactive({
|
|||
codeUrl: "",
|
||||
cookiePass: "",
|
||||
loginForm: {
|
||||
username: "admin",
|
||||
password: "12345",
|
||||
username: "ymf",
|
||||
password: "123456",
|
||||
// rememberMe: false,
|
||||
code: "",
|
||||
uuid: "",
|
||||
|
|
|
|||
|
|
@ -58,6 +58,8 @@ const contentConfig: IContentConfig = {
|
|||
label: "订单原金额 不含折扣价格",
|
||||
align: "center",
|
||||
prop: "originAmount",
|
||||
templet: 'custom',
|
||||
slotName: 'originAmount',
|
||||
width: 120,
|
||||
hidden: true,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -20,6 +20,9 @@
|
|||
@operat-click="handleOperatClick"
|
||||
@filter-change="handleFilterChange"
|
||||
>
|
||||
<template #originAmount="scope">
|
||||
{{ returnOriginAmount(scope.row) }}
|
||||
</template>
|
||||
<template #status="scope">
|
||||
<el-tag :type="scope.row[scope.prop] == 1 ? 'success' : 'info'">
|
||||
{{ scope.row[scope.prop] == 1 ? "启用" : "禁用" }}
|
||||
|
|
@ -132,6 +135,16 @@ const {
|
|||
handleFilterChange,
|
||||
} = 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() {
|
||||
addModalRef.value?.setModalVisible();
|
||||
|
|
|
|||
|
|
@ -52,8 +52,8 @@
|
|||
</el-form-item>
|
||||
<el-form-item label="经营模式">
|
||||
<el-radio-group v-model="state.form.registerType">
|
||||
<el-radio-button value="munchies">快餐版</el-radio-button>
|
||||
<el-radio-button value="restaurant">餐饮版</el-radio-button>
|
||||
<el-radio-button value="before">先付费</el-radio-button>
|
||||
<el-radio-button value="after">后付费</el-radio-button>
|
||||
</el-radio-group>
|
||||
<div class="tips">请谨慎修改!!!</div>
|
||||
</el-form-item>
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@
|
|||
<div class="note" v-if="item.remark">备注:{{ item.remark }}</div>
|
||||
<div class="note flex" v-else>
|
||||
<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 class="note" v-if="placeNum != 0 && item.note">备注:{{ item.remark || "" }}</div>
|
||||
|
|
@ -83,22 +83,26 @@
|
|||
<div>¥0</div>
|
||||
<div class="free-price">
|
||||
<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>
|
||||
</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">
|
||||
<span>¥{{ to2(isShowVipPrice ? vipAllPrice : allPrice) }}</span>
|
||||
<span>¥{{ to2(discount_before_price) }}</span>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div v-if="isSeatFee">¥{{ to2(item.totalAmount) }}</div>
|
||||
<div v-else>
|
||||
<div v-if="isShowVipPrice && vipAllPrice != allPrice">¥{{ vipAllPrice }}</div>
|
||||
<div>
|
||||
<div v-if="useVipPrice && vipAllPrice * 1 != allPrice * 1">
|
||||
¥{{ to2(vipAllPrice) }}
|
||||
</div>
|
||||
<div
|
||||
:class="{
|
||||
'free-price': isShowVipPrice && vipAllPrice != allPrice,
|
||||
'free-price': useVipPrice && vipAllPrice != allPrice,
|
||||
}"
|
||||
>
|
||||
<span>¥{{ to2(allPrice) }}</span>
|
||||
|
|
@ -116,10 +120,6 @@ const props = defineProps({
|
|||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
isShowVipPrice: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
//是否是餐位费
|
||||
isSeatFee: {
|
||||
type: Boolean,
|
||||
|
|
@ -180,9 +180,13 @@ const discountNewPrice = computed(() => {
|
|||
return 0;
|
||||
});
|
||||
const vipAllPrice = computed(() => {
|
||||
return 0;
|
||||
const n = (props.item.memberPrice || props.item.salePrice) * props.item.number;
|
||||
return n;
|
||||
});
|
||||
const allPrice = computed(() => {
|
||||
if (props.item.discount_sale_amount * 1 > 0) {
|
||||
return props.item.discount_sale_amount * props.item.number;
|
||||
}
|
||||
if (props.useVipPrice) {
|
||||
const memberPrice = props.item.memberPrice || props.item.salePrice;
|
||||
return memberPrice * props.item.number;
|
||||
|
|
@ -195,7 +199,12 @@ const allPrice = computed(() => {
|
|||
}
|
||||
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(() => {
|
||||
return props.item.id == props.selCart.id ? "active" : "";
|
||||
});
|
||||
|
|
|
|||
|
|
@ -14,6 +14,20 @@
|
|||
></carts-item>
|
||||
</div>
|
||||
</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">
|
||||
<div class="cart-title"><span>打包费</span></div>
|
||||
|
|
@ -24,20 +38,6 @@
|
|||
<div class="cart-title"><span>餐位费</span></div>
|
||||
<extra-fee name="餐位费" :number="perpole" :price="canWeiFee"></extra-fee>
|
||||
</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">
|
||||
<div class="cart-title">
|
||||
|
|
@ -46,6 +46,7 @@
|
|||
|
||||
<div v-for="(detaiItem, index) in item" :key="index">
|
||||
<carts-item
|
||||
:useVipPrice="carts.useVipPrice"
|
||||
:canChangeNumber="false"
|
||||
isOld
|
||||
:item="detaiItem"
|
||||
|
|
@ -60,7 +61,29 @@
|
|||
<!-- <div class="color-666 u-font-14">订单备注:{{ "123" }}</div> -->
|
||||
</div>
|
||||
<div class="bottom">
|
||||
<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">
|
||||
<el-link type="primary">打印制作单</el-link>
|
||||
<div>
|
||||
|
|
@ -180,7 +203,8 @@ function init() {
|
|||
for (let goods of props.goodsList) {
|
||||
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);
|
||||
}
|
||||
|
|
@ -193,9 +217,6 @@ function changeNumber(step, item) {
|
|||
carts.changeNumber(step * 1, item);
|
||||
}
|
||||
const totalMoney = computed(() => {
|
||||
console.log(carts.payMoney);
|
||||
console.log(carts.oldOrder.originAmount);
|
||||
|
||||
return (carts.payMoney * 1 + (carts.oldOrder.originAmount || 0) * 1).toFixed(2);
|
||||
});
|
||||
defineExpose({
|
||||
|
|
|
|||
|
|
@ -7,33 +7,42 @@
|
|||
<div class="color-red u-font-18 font-600">¥{{ form.money }}</div>
|
||||
<!-- <el-input :value="form.money" disabled> </el-input> -->
|
||||
</el-form-item>
|
||||
<el-form-item label="减免金额">
|
||||
<el-input
|
||||
<el-form-item label="优惠类型" v-if="shopUser.isShopAdmin">
|
||||
<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"
|
||||
clearable
|
||||
autofocus
|
||||
type="number"
|
||||
@keyup.enter="init('reduceMoney')"
|
||||
@blur="init('reduceMoney')"
|
||||
@change="init('reduceMoney')"
|
||||
>
|
||||
<template #append>元</template>
|
||||
</el-input>
|
||||
</el-input-number>
|
||||
</el-form-item>
|
||||
<el-form-item label="优惠折扣">
|
||||
<el-input
|
||||
|
||||
<el-form-item label="优惠折扣" v-if="discountType == 1">
|
||||
<el-input-number
|
||||
v-model="form.discount"
|
||||
:step="1"
|
||||
step-strictly
|
||||
type="number"
|
||||
@keyup.enter="init('discount')"
|
||||
@blur="init('discount')"
|
||||
@change="init('discount')"
|
||||
>
|
||||
<template #append>%</template>
|
||||
</el-input>
|
||||
</el-input-number>
|
||||
<span>%</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="实收金额">
|
||||
<el-input
|
||||
v-model="form.curretnMoney"
|
||||
type="number"
|
||||
clearable
|
||||
disabled
|
||||
@keyup.enter="init('curretnMoney')"
|
||||
@blur="init('curretnMoney')"
|
||||
>
|
||||
|
|
@ -49,7 +58,11 @@
|
|||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script>
|
||||
<script setup>
|
||||
import { useUserStore } from "@/store/modules/user";
|
||||
import { ElMessage } from "element-plus";
|
||||
const shopUser = useUserStore();
|
||||
|
||||
function toFixedNoRounding(num) {
|
||||
// 转换为字符串
|
||||
var numStr = num.toString();
|
||||
|
|
@ -62,9 +75,10 @@ function toFixedNoRounding(num) {
|
|||
// 拼接回数字字符串并返回
|
||||
return parts.join(".");
|
||||
}
|
||||
//折扣类型
|
||||
const discountType = ref(1);
|
||||
|
||||
export default {
|
||||
props: {
|
||||
const props = defineProps({
|
||||
title: {
|
||||
type: String,
|
||||
default: "优惠金额",
|
||||
|
|
@ -73,9 +87,9 @@ export default {
|
|||
type: [String, Number],
|
||||
default: 0,
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
});
|
||||
|
||||
const state = reactive({
|
||||
form: {
|
||||
money: 0,
|
||||
discount: 100,
|
||||
|
|
@ -84,77 +98,80 @@ export default {
|
|||
},
|
||||
number: "0",
|
||||
show: false,
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
init(key) {
|
||||
const { money, reduceMoney, discount, curretnMoney } = this.form;
|
||||
});
|
||||
const { form, number, show } = toRefs(state);
|
||||
function init(key) {
|
||||
const { money, reduceMoney, discount, curretnMoney } = form.value;
|
||||
if (key == "reduceMoney") {
|
||||
if (reduceMoney < 0) {
|
||||
this.$message.error("减免金额不能小于0");
|
||||
this.form.reduceMoney = 0;
|
||||
ElMessage.error("减免金额不能小于0");
|
||||
form.value.reduceMoney = 0;
|
||||
}
|
||||
if (reduceMoney > money) {
|
||||
this.$message.error("减免金额不能大于总金额");
|
||||
this.form.reduceMoney = money;
|
||||
ElMessage.error("减免金额不能大于总金额");
|
||||
form.value.reduceMoney = money;
|
||||
}
|
||||
this.form.curretnMoney = (money - this.form.reduceMoney).toFixed(2);
|
||||
this.form.discount = toFixedNoRounding(((this.form.curretnMoney / money) * 100).toFixed(3));
|
||||
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) {
|
||||
this.$message.error("折扣不能小于0");
|
||||
this.form.discount = 0;
|
||||
ElMessage.error("折扣不能小于0");
|
||||
form.value.discount = 0;
|
||||
}
|
||||
if (discount > 100) {
|
||||
this.$message.error("折扣不能大于100");
|
||||
this.form.discount = 100;
|
||||
ElMessage.error("折扣不能大于100");
|
||||
form.value.discount = 100;
|
||||
}
|
||||
this.form.curretnMoney = ((money * this.form.discount) / 100).toFixed(2);
|
||||
this.form.reduceMoney = ((money * (100 - this.form.discount)) / 100).toFixed(2);
|
||||
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) {
|
||||
this.$message.error("实收金额不能小于0");
|
||||
this.form.curretnMoney = 0;
|
||||
ElMessage.error("实收金额不能小于0");
|
||||
form.value.curretnMoney = 0;
|
||||
}
|
||||
if (curretnMoney > money) {
|
||||
this.$message.error("实收金额不能大于总金额");
|
||||
this.form.curretnMoney = this.form.money;
|
||||
ElMessage.error("实收金额不能大于总金额");
|
||||
form.value.curretnMoney = form.value.money;
|
||||
}
|
||||
this.form.reduceMoney = (money - this.form.curretnMoney).toFixed(2);
|
||||
this.form.discount = toFixedNoRounding(((this.form.curretnMoney / money) * 100).toFixed(3));
|
||||
form.value.reduceMoney = (money - form.value.curretnMoney).toFixed(2);
|
||||
form.value.discount = toFixedNoRounding(((form.value.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;
|
||||
},
|
||||
form.value.curretnMoney = ((money * discount) / 100).toFixed(2);
|
||||
form.value.reduceMoney = (money - form.value.curretnMoney).toFixed(2);
|
||||
}
|
||||
|
||||
confirm() {
|
||||
console.log(this.form.discount / 100);
|
||||
this.$emit("confirm", this.form);
|
||||
this.close();
|
||||
},
|
||||
open(data) {
|
||||
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);
|
||||
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() {
|
||||
this.number = `${this.value}`;
|
||||
},
|
||||
};
|
||||
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>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
</div>
|
||||
<div class="userinfo" v-else @click="chooseUser">
|
||||
<el-avatar class="avatar" :size="50" />
|
||||
<div class="u-m-l-12">
|
||||
<div class="u-m-l-12 no-wrap">
|
||||
<p>
|
||||
<span class="name u-font-16">服务员下单</span>
|
||||
</p>
|
||||
|
|
@ -27,6 +27,7 @@
|
|||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<template v-if="user.id">
|
||||
<div class="score">
|
||||
<div class="u-flex u-col-center u-m-t-10">
|
||||
<span class="u-font-14 font-bold u-m-r-20">积分抵扣</span>
|
||||
|
|
@ -54,18 +55,19 @@
|
|||
</div>
|
||||
<div class="u-flex u-col-center u-m-t-20 no-wrap">
|
||||
<span class="u-font-14 font-bold u-m-r-20">优惠券</span>
|
||||
<div class="u-flex my-select">
|
||||
<div class="u-flex my-select" @click="openCoupon">
|
||||
<span class="u-m-r-10">选择优惠券</span>
|
||||
<el-icon><ArrowDown /></el-icon>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<div class="u-m-t-30">
|
||||
<el-button size="large" @click="discountShow">整单打折/减免</el-button>
|
||||
</div>
|
||||
<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">
|
||||
<el-button
|
||||
v-for="(item, index) in payTypes.list"
|
||||
|
|
@ -91,65 +93,90 @@
|
|||
</div>
|
||||
<div class="u-flex u-m-b-10 u-row-between">
|
||||
<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 class="u-flex u-m-b-10 u-row-between">
|
||||
<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 class="u-flex u-m-b-10 u-row-between">
|
||||
<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 class="u-flex u-m-b-10 u-row-between">
|
||||
<span class="title">优惠券</span>
|
||||
<span class="u-m-l-10 value">{{ coupDiscount }}</span>
|
||||
<span class="u-m-l-10 value">¥{{ coupDiscount }}</span>
|
||||
</div>
|
||||
<div class="u-flex u-m-b-10 u-row-between">
|
||||
<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 class="u-flex u-m-b-10 u-row-between">
|
||||
<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 class="u-flex u-m-b-10 u-row-between">
|
||||
<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 class="u-flex u-m-b-10 u-row-between">
|
||||
<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>
|
||||
<!-- 扫码 -->
|
||||
<scanPay ref="refScanPay" :order="orderInfo"></scanPay>
|
||||
<scanPay
|
||||
ref="refScanPay"
|
||||
:order="orderInfo"
|
||||
@paySuccess="paySuccess"
|
||||
@confirm="refScanPayConfirm"
|
||||
></scanPay>
|
||||
<!-- 打折 -->
|
||||
<discount ref="refDiscount" @confirm="discountConfirm"></discount>
|
||||
<!-- 优惠券 -->
|
||||
<popup-coupon ref="refCoupon" @confirm="refCouponConfirm"></popup-coupon>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<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 payApi from "@/api/order/pay";
|
||||
import scanPay from "./scan-pay.vue";
|
||||
import discount from "./discount.vue";
|
||||
|
||||
import { ElLoading } from "element-plus";
|
||||
import { ElMessage, ElMessageBox } from "element-plus";
|
||||
|
||||
//优惠券
|
||||
const refCoupon = ref();
|
||||
function openCoupon() {
|
||||
refCoupon.value.open();
|
||||
}
|
||||
function couponChange(data) {}
|
||||
|
||||
//打折
|
||||
const refDiscount = ref();
|
||||
const checkOrderPay = reactive({
|
||||
discountAmount: 0, //手动优惠金额
|
||||
discount: 0,
|
||||
});
|
||||
function discountConfirm(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) {
|
||||
refDiscount.value.open({
|
||||
amount: props.orderInfo.originAmount,
|
||||
amount: carts.payMoney,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -160,13 +187,44 @@ const props = defineProps({
|
|||
},
|
||||
user: {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
default: () => {
|
||||
return { id: "" };
|
||||
},
|
||||
},
|
||||
orderInfo: {
|
||||
type: Object,
|
||||
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"]);
|
||||
function chooseUser() {
|
||||
emits("chooseUser");
|
||||
|
|
@ -191,78 +249,118 @@ const payTypes = reactive({
|
|||
|
||||
const refScanPay = ref();
|
||||
function changePayType(i) {
|
||||
if (payTypes.list[i].payType === "scanCode") {
|
||||
return refScanPay.value.open({
|
||||
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,
|
||||
},
|
||||
});
|
||||
}
|
||||
const payType = payTypes.list[i].payType;
|
||||
refScanPayOpen(payType);
|
||||
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() {
|
||||
const res = await payTypeApi.getList();
|
||||
payTypes.list = res;
|
||||
}
|
||||
function nowPayClick() {
|
||||
const payType = payTypes.list[payTypes.sel].payType;
|
||||
console.log(payType);
|
||||
if (payType === "cash") {
|
||||
ElMessageBox.confirm("是否确认已现金收款:" + payMoney.value + "元", "快捷支付", {
|
||||
ElMessageBox.confirm("是否确认已现金收款:" + currentpayMoney.value + "元", "快捷支付", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
})
|
||||
.then(() => {
|
||||
payApi
|
||||
.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");
|
||||
});
|
||||
payOrder("cash");
|
||||
})
|
||||
.catch(() => {});
|
||||
return;
|
||||
}
|
||||
refScanPayOpen(payType);
|
||||
}
|
||||
|
||||
const payMoney = computed(() => {
|
||||
if (!props.orderInfo.orderAmount) {
|
||||
return "";
|
||||
function refScanPayConfirm(authCode, isScan) {
|
||||
const payType = payTypes.list[payTypes.sel].payType;
|
||||
payParams.authCode = authCode;
|
||||
payOrder(payType, isScan);
|
||||
}
|
||||
return (props.orderInfo.orderAmount - checkOrderPay.discountAmount).toFixed(2);
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
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(() => {
|
||||
getPaytype();
|
||||
pointsInit();
|
||||
});
|
||||
</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>
|
||||
<el-dialog width="400px" :title="title" v-model="show" @close="reset">
|
||||
<div class="u-p-15">
|
||||
<div v-if="openSwitch">
|
||||
<div v-if="openSwitch" class="u-m-b-20">
|
||||
<el-button
|
||||
@click="changeKey('paysSel', index)"
|
||||
v-for="(item, index) in pays"
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
{{ item.text }}
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="u-m-t-20">
|
||||
<div class="">
|
||||
<el-alert :closable="false" v-if="tips" :title="tips" type="warning" show-icon></el-alert>
|
||||
</div>
|
||||
<div class="u-m-t-20">
|
||||
|
|
@ -24,6 +24,7 @@
|
|||
<el-input
|
||||
v-model="form.code"
|
||||
@change="codeInputChange"
|
||||
autofocus
|
||||
placeholder="请扫码或者输入付款码"
|
||||
ref="refInputCode"
|
||||
></el-input>
|
||||
|
|
@ -43,9 +44,9 @@
|
|||
|
||||
<!-- <img :src="codeImg" class="codeImg" alt="" /> -->
|
||||
</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">
|
||||
<i class="el-icon-loading"></i>
|
||||
<el-icon class="loading-ani"><Loading /></el-icon>
|
||||
<span>等待用户支付</span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -61,18 +62,10 @@ import payApi from "@/api/order/pay";
|
|||
|
||||
export default {
|
||||
props: {
|
||||
openSwitch: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
order: {
|
||||
type: Object,
|
||||
default: () => ({}),
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
default: "支付",
|
||||
},
|
||||
price: {
|
||||
type: [String, Number],
|
||||
default: 0,
|
||||
|
|
@ -84,6 +77,8 @@ export default {
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
title: "支付",
|
||||
openSwitch: false,
|
||||
tips: "",
|
||||
paymentQrcode: "",
|
||||
paysSel: 0,
|
||||
|
|
@ -119,11 +114,13 @@ export default {
|
|||
if (newval == 0) {
|
||||
this.clear();
|
||||
this.tips = "请使用扫码枪扫微信/支付宝收款码";
|
||||
this.$nextTick(() => {
|
||||
this.$refs.refInputCode.focus();
|
||||
});
|
||||
} else {
|
||||
this.getPayUrl();
|
||||
this.tips = "请用户使用微信/支付宝扫描付款码";
|
||||
// this.startGetOrderInfo();
|
||||
this.startGetOrderInfo();
|
||||
}
|
||||
},
|
||||
number(newval) {
|
||||
|
|
@ -142,7 +139,7 @@ export default {
|
|||
shopId: localStorage.getItem("shopId"),
|
||||
orderId: this.order.id,
|
||||
});
|
||||
if (res.status == "closed") {
|
||||
if (res.status == "done") {
|
||||
this.clear();
|
||||
this.$emit("paySuccess");
|
||||
}
|
||||
|
|
@ -173,10 +170,12 @@ export default {
|
|||
return this.$message.error("请输入或扫付款码");
|
||||
}
|
||||
this.close();
|
||||
this.$emit("confirm", this.form.code);
|
||||
this.$emit("confirm", this.form.code, this.paysSel ? true : false);
|
||||
},
|
||||
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);
|
||||
this.paymentQrcode = res;
|
||||
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.form.money = Number(data.money).toFixed(2);
|
||||
this.payPar = data;
|
||||
|
|
@ -198,7 +206,9 @@ export default {
|
|||
// this.getPayUrl();
|
||||
}
|
||||
this.$nextTick(() => {
|
||||
setTimeout(() => {
|
||||
this.$refs.refInputCode.focus();
|
||||
}, 100);
|
||||
});
|
||||
},
|
||||
close() {
|
||||
|
|
@ -226,4 +236,18 @@ export default {
|
|||
height: 164px;
|
||||
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>
|
||||
|
|
@ -20,10 +20,12 @@
|
|||
</div>
|
||||
<div>
|
||||
<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>
|
||||
<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>
|
||||
|
|
@ -219,8 +221,12 @@ import productApi from "@/api/product/index";
|
|||
import tableApi from "@/api/account/table";
|
||||
import $status from "@/views/tool/table/status.js";
|
||||
import orderApi from "@/api/order/order";
|
||||
import shopUserApi from "@/api/account/shopUser";
|
||||
import { useCartsStore } from "@/store/modules/carts";
|
||||
import { useUserStore } from "@/store/modules/user";
|
||||
|
||||
import { ElLoading } from "element-plus";
|
||||
|
||||
const carts = useCartsStore();
|
||||
const shopUser = useUserStore();
|
||||
|
||||
|
|
@ -245,9 +251,8 @@ function showDinerNumber() {
|
|||
let user = ref({});
|
||||
const refChooseUser = ref();
|
||||
function chooseUserConfirm(e) {
|
||||
console.log(e);
|
||||
user.value = e;
|
||||
refCart.value.carts.changeUser(e);
|
||||
user.value = e ? e : {};
|
||||
refCart.value.carts.changeUser(e ? e : {});
|
||||
}
|
||||
function showChooseUser() {
|
||||
refChooseUser.value.open();
|
||||
|
|
@ -258,11 +263,24 @@ const showOrder = ref(false);
|
|||
function hideOrder() {
|
||||
showOrder.value = false;
|
||||
}
|
||||
const oldOrder = ref({});
|
||||
const oldOrder = ref({ detailMap: [] });
|
||||
|
||||
const orderInfo = ref({});
|
||||
|
||||
let createOrderTimer = null;
|
||||
async function createOrder(key) {
|
||||
console.log(refCart.value.carts.table_code);
|
||||
clearTimeout(createOrderTimer);
|
||||
const loading = ElLoading.service({
|
||||
lock: true,
|
||||
text: "订单生成中,请稍等……",
|
||||
background: "rgba(0, 0, 0, 0.7)",
|
||||
});
|
||||
createOrderTimer = setTimeout(() => {
|
||||
ElMessage.error("订单生成超时");
|
||||
loading.close();
|
||||
}, 1000 * 20);
|
||||
try {
|
||||
const res = await orderApi.add({
|
||||
orderId: oldOrder.value.id || "",
|
||||
shopId: shopUser.userInfo.id,
|
||||
|
|
@ -274,27 +292,34 @@ async function createOrder(key) {
|
|||
dineMode: diners.sel == 0 ? "dine-in" : "take-out",
|
||||
remark: "",
|
||||
seatNum: perpole.value * 1,
|
||||
placeNum: 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 (key == "to-pay" && oldOrder.value.id) {
|
||||
if (res.id) {
|
||||
// 获取历史订单数据
|
||||
const res = await orderApi.getHistoryList({
|
||||
orderId: oldOrder.value.id,
|
||||
const res1 = await orderApi.getHistoryList({
|
||||
orderId: res.id,
|
||||
});
|
||||
oldOrder.value = res;
|
||||
oldOrder.value = res1;
|
||||
orderInfo.value = res1;
|
||||
refCart.value.carts.init();
|
||||
}
|
||||
orderInfo.value = res;
|
||||
showOrder.value = true;
|
||||
|
||||
// oldOrder.value = res;
|
||||
}
|
||||
} catch (error) {
|
||||
clearTimeout(createOrderTimer);
|
||||
}
|
||||
}
|
||||
|
||||
//可选套餐商品
|
||||
|
|
@ -580,12 +605,21 @@ onMounted(async () => {
|
|||
};
|
||||
if (noPayStatus[res.status]) {
|
||||
ElMessage.error(noPayStatus[res.status]);
|
||||
router.replace(route.path);
|
||||
console.log(route.path);
|
||||
setTimeout(() => {
|
||||
refCart.value.carts.dataReset();
|
||||
refresh();
|
||||
}, 2000);
|
||||
return;
|
||||
}
|
||||
if (res.tableCode) {
|
||||
table.value = { tableCode: res.tableCode };
|
||||
}
|
||||
if (res.userId) {
|
||||
const userRes = await shopUserApi.get({ userId: res.userId });
|
||||
user.value = userRes;
|
||||
}
|
||||
if (res) {
|
||||
oldOrder.value = res;
|
||||
orderInfo.value = res;
|
||||
|
|
@ -599,7 +633,10 @@ onMounted(async () => {
|
|||
});
|
||||
|
||||
function refresh() {
|
||||
router.go(0);
|
||||
router.replace(route.path);
|
||||
setTimeout(() => {
|
||||
router.go(1000);
|
||||
}, 1500);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue