This commit is contained in:
gyq 2025-10-11 13:51:25 +08:00
commit b65955f2cc
11 changed files with 920 additions and 531 deletions

View File

@ -8,13 +8,13 @@ VITE_APP_PORT=3000
# VITE_APP_API_URL=https://tapi.cashier.sxczgkj.cn/ # 测试 # VITE_APP_API_URL=https://tapi.cashier.sxczgkj.cn/ # 测试
# VITE_APP_API_URL=https://cashier.sxczgkj.com/ # 正式 # VITE_APP_API_URL=https://cashier.sxczgkj.com/ # 正式
VITE_APP_API_URL=http://192.168.1.31/ # 本地 VITE_APP_API_URL=http://192.168.1.42/ # 本地
# WebSocket 端点(不配置则关闭),线上 ws://api.youlai.tech/ws ,本地 ws://localhost:8989/ws # WebSocket 端点(不配置则关闭),线上 ws://api.youlai.tech/ws ,本地 ws://localhost:8989/ws
# VITE_APP_WS_ENDPOINT=wss://sockets.sxczgkj.com/wss # VITE_APP_WS_ENDPOINT=wss://sockets.sxczgkj.com/wss
# VITE_APP_WS_ENDPOINT=wss://czgeatws.sxczgkj.com/wss # 正式 # VITE_APP_WS_ENDPOINT=wss://czgeatws.sxczgkj.com/wss # 正式
VITE_APP_WS_ENDPOINT=ws://192.168.1.31:2348 # 本地 VITE_APP_WS_ENDPOINT=ws://192.168.1.42:2348 # 本地
# 启用 Mock 服务 # 启用 Mock 服务

View File

@ -34,8 +34,8 @@ vscode如果无代码提示
映射地址 映射地址
<https://fv901fw8033.vicp.fun/> <https://fv901fw8033.vicp.fun/>
1. 上传.zip文件解压到服务器的 /home/web下 1. ***cd /usr/share/nginx/html***
2. cd到/home/web 2. 上传.zip文件服务器的 /usr/share/nginx/html
3. 执行命令 3. 执行命令
```unzip -o dist.zip``` ```unzip -o dist.zip```

View File

@ -1,9 +1,9 @@
import request from "@/utils/request"; import request from "@/utils/request";
const baseURL = "account/admin/shopInfo"; const baseURL = "/account/admin/shopInfo";
const ShopApi = { const ShopApi = {
/** 获取店铺列表*/ /** 获取店铺列表*/
getList(params : PageQuery) { getList(params: PageQuery) {
return request<any, ShopInfoEditDTO[]>({ return request<any, ShopInfoEditDTO[]>({
url: `${baseURL}`, url: `${baseURL}`,
method: "get", method: "get",
@ -11,48 +11,48 @@ const ShopApi = {
}); });
}, },
/** 获取店铺分店列表*/ /** 获取店铺分店列表*/
getOtherShopList(params : PageQuery) { getOtherShopList(params: PageQuery) {
return request<any, ShopInfoEditDTO[]>({ return request<any, ShopInfoEditDTO[]>({
url: `${baseURL}/otherShop`, url: `${baseURL}/otherShop`,
method: "get", method: "get",
params: params, params: params,
}); });
}, },
getBranchList(params : PageQuery) { getBranchList(params: PageQuery) {
return request<any, ShopInfoEditDTO[]>({ return request<any, ShopInfoEditDTO[]>({
url: `${baseURL}/branchList`, url: `${baseURL}/branchList`,
method: "get", method: "get",
params: params, params: params,
}); });
}, },
getBranchChange(id : PageQuery) { getBranchChange(id: PageQuery) {
return request<any, ShopInfoEditDTO[]>({ return request<any, ShopInfoEditDTO[]>({
url: `${baseURL}/change/${id}`, url: `${baseURL}/change/${id}`,
method: "post", method: "post",
}); });
}, },
add(data : ShopInfoEditDTO) { add(data: ShopInfoEditDTO) {
return request<any, ShopInfoEditDTO>({ return request<any, ShopInfoEditDTO>({
url: `${baseURL}`, url: `${baseURL}`,
method: "post", method: "post",
data, data,
}); });
}, },
edit(data : ShopInfoEditDTO) { edit(data: ShopInfoEditDTO) {
return request<any, ShopInfoEditDTO>({ return request<any, ShopInfoEditDTO>({
url: `${baseURL}`, url: `${baseURL}`,
method: "put", method: "put",
data, data,
}); });
}, },
get(params : getRequest) { get(params: getRequest) {
return request<any, ShopInfo>({ return request<any, ShopInfo>({
url: `${baseURL}/detail`, url: `${baseURL}/detail`,
method: "get", method: "get",
params params
}); });
}, },
delete(params : any) { delete(params: any) {
return request({ return request({
url: `${baseURL}`, url: `${baseURL}`,
method: "delete", method: "delete",
@ -66,39 +66,39 @@ export interface getRequest {
/** /**
* id * id
*/ */
id ?: string | number; id?: string | number;
[property : string] : any; [property: string]: any;
} }
/** /**
* ShopInfoEditDTO * ShopInfoEditDTO
*/ */
export interface ShopInfoEditDTO { export interface ShopInfoEditDTO {
accountName ?: null | string; accountName?: null | string;
accountPwd ?: null | string; accountPwd?: null | string;
activateCode ?: null | string; activateCode?: null | string;
address ?: null | string; address?: null | string;
chainName ?: null | string; chainName?: null | string;
detail ?: null | string; detail?: null | string;
frontImg ?: null | string; frontImg?: null | string;
id : number | null; id: number | null;
lat ?: null | string; lat?: null | string;
lng ?: null | string; lng?: null | string;
logo ?: null | string; logo?: null | string;
phone ?: null | string; phone?: null | string;
profiles ?: null | string; profiles?: null | string;
roleId ?: number | null; roleId?: number | null;
shopName ?: null | string; shopName?: null | string;
shopType ?: null | string; shopType?: null | string;
[property : string] : any; [property: string]: any;
} }
export interface PageQuery { export interface PageQuery {
page : number; page: number;
shopName ?: string; shopName?: string;
size : number; size: number;
status ?: number; status?: number;
[property : string] : any; [property: string]: any;
} }
@ -109,193 +109,193 @@ export interface ShopInfo {
/** /**
* *
*/ */
address ?: null | string; address?: null | string;
/** /**
* *
*/ */
article ?: null | string; article?: null | string;
/** /**
* *
*/ */
backImg ?: null | string; backImg?: null | string;
/** /**
* *
*/ */
bindAccount ?: null | string; bindAccount?: null | string;
/** /**
* *
*/ */
bookingSms ?: null | string; bookingSms?: null | string;
/** /**
* () * ()
*/ */
businessEndDay ?: null | string; businessEndDay?: null | string;
/** /**
* () * ()
*/ */
businessStartDay ?: null | string; businessStartDay?: null | string;
/** /**
* *
*/ */
businessTime ?: null | string; businessTime?: null | string;
/** /**
* *
*/ */
chainName ?: null | string; chainName?: null | string;
/** /**
* *
*/ */
cities ?: null | string; cities?: null | string;
/** /**
* all- vip- * all- vip-
*/ */
consumeColony ?: null | string; consumeColony?: null | string;
/** /**
* *
*/ */
contactName ?: null | string; contactName?: null | string;
/** /**
* *
*/ */
coverImg ?: null | string; coverImg?: null | string;
createTime ?: null | string; createTime?: null | string;
/** /**
* *
*/ */
detail ?: null | string; detail?: null | string;
/** /**
* / * /
*/ */
districts ?: null | string; districts?: null | string;
/** /**
* dine-in take-out * dine-in take-out
*/ */
eatModel ?: null | string; eatModel?: null | string;
/** /**
* *
*/ */
expireTime ?: null | string; expireTime?: null | string;
/** /**
* *
*/ */
frontImg ?: null | string; frontImg?: null | string;
/** /**
* 使 sys_user id * 使 sys_user id
*/ */
id ?: number | null; id?: number | null;
/** /**
* *
*/ */
isAccountPay ?: number | null; isAccountPay?: number | null;
/** /**
* 1 0 * 1 0
*/ */
isCustomAmount ?: number | null; isCustomAmount?: number | null;
/** /**
* 1 0 * 1 0
*/ */
isMemberInPwd ?: number | null; isMemberInPwd?: number | null;
/** /**
* 01 * 01
*/ */
isMemberPrice ?: number | null; isMemberPrice?: number | null;
/** /**
* 退 1 0 * 退 1 0
*/ */
isMemberReturnPwd ?: number | null; isMemberReturnPwd?: number | null;
/** /**
* 退 1 0 * 退 1 0
*/ */
isReturnPwd ?: number | null; isReturnPwd?: number | null;
/** /**
* 01 * 01
*/ */
isTableFee ?: number | null; isTableFee?: number | null;
/** /**
* *
*/ */
lat ?: null | string; lat?: null | string;
/** /**
* *
*/ */
lng ?: null | string; lng?: null | string;
/** /**
* logo * logo
*/ */
logo ?: null | string; logo?: null | string;
/** /**
* id * id
*/ */
mainId ?: number | null; mainId?: number | null;
/** /**
* 0 1 2 * 0 1 2
*/ */
onSale ?: number | null; onSale?: number | null;
/** /**
* *
*/ */
operationPwd ?: null | string; operationPwd?: null | string;
/** /**
* *
*/ */
paymentQrcode ?: null | string; paymentQrcode?: null | string;
/** /**
* *
*/ */
phone ?: null | string; phone?: null | string;
/** /**
* trial试用版release正式 * trial试用版release正式
*/ */
profiles ?: null | string; profiles?: null | string;
/** /**
* *
*/ */
provinces ?: null | string; provinces?: null | string;
registerType ?: null | string; registerType?: null | string;
/** /**
* *
*/ */
sdType ?: null | string; sdType?: null | string;
/** /**
* *
*/ */
shopName ?: null | string; shopName?: null | string;
/** /**
* *
*/ */
shopQrcode ?: null | string; shopQrcode?: null | string;
/** /**
* --only --chain--join type * --only --chain--join type
*/ */
shopType ?: null | string; shopType?: null | string;
/** /**
* () * ()
*/ */
smallQrcode ?: null | string; smallQrcode?: null | string;
/** /**
* -1 0-1 * -1 0-1
*/ */
status ?: number | null; status?: number | null;
/** /**
* *
*/ */
subTitle ?: null | string; subTitle?: null | string;
/** /**
* *
*/ */
tableFee ?: number | null; tableFee?: number | null;
/** /**
* *
*/ */
tag ?: null | string; tag?: null | string;
/** /**
* *
*/ */
taxAmount ?: null | string; taxAmount?: null | string;
/** /**
* 0 1, 1 0 * 0 1, 1 0
*/ */
tubeType ?: number | null; tubeType?: number | null;
updateTime ?: null | string; updateTime?: null | string;
[property : string] : any; [property: string]: any;
} }

View File

@ -4,8 +4,8 @@
// 商品,耗材相关:<https://tapi.cashier.sxczgkj.cn/product/> // 商品,耗材相关:<https://tapi.cashier.sxczgkj.cn/product/>
// 系统相关:<https://tapi.cashier.sxczgkj.cn/system/> // 系统相关:<https://tapi.cashier.sxczgkj.cn/system/>
export const Account_BaseUrl = "account"; export const Account_BaseUrl = "/account";
export const Order_BaseUrl = "order"; export const Order_BaseUrl = "/order";
export const Product_BaseUrl = "product"; export const Product_BaseUrl = "/product";
export const System_BaseUrl = "system"; export const System_BaseUrl = "/system";
export const Market_BaseUrl = "market"; export const Market_BaseUrl = "/market";

View File

@ -31,6 +31,7 @@ interface PointDeductionRule {
maxDeductionAmount: number; maxDeductionAmount: number;
} }
export const useCartsStore = defineStore("carts", () => { export const useCartsStore = defineStore("carts", () => {
// ------------------------------ 1. 移到内部的工具函数(核心修复) ------------------------------ // ------------------------------ 1. 移到内部的工具函数(核心修复) ------------------------------
// 适配工具库 BaseCartItem 接口的商品数据转换函数(原外部函数,现在内部) // 适配工具库 BaseCartItem 接口的商品数据转换函数(原外部函数,现在内部)
@ -93,7 +94,7 @@ export const useCartsStore = defineStore("carts", () => {
const vipUser = ref<{ id?: string | number, isVip?: boolean }>({}); const vipUser = ref<{ id?: string | number, isVip?: boolean }>({});
function changeUser(user: any) { function changeUser(user: any) {
vipUser.value = user; vipUser.value = user;
userPoints.value = 0; payParamsInit()
} }
// 就餐类型 // 就餐类型
@ -274,6 +275,7 @@ export const useCartsStore = defineStore("carts", () => {
// 订单费用汇总(调用内部的 getAllGoodsList // 订单费用汇总(调用内部的 getAllGoodsList
const orderCostSummary = computed(() => { const orderCostSummary = computed(() => {
allGoods.value = getAllGoodsList(); allGoods.value = getAllGoodsList();
console.log(' allGoods.value', allGoods.value);
const costSummary = OrderPriceCalculator.calculateOrderCostSummary( const costSummary = OrderPriceCalculator.calculateOrderCostSummary(
allGoods.value, allGoods.value,
dinnerType.value, dinnerType.value,
@ -283,6 +285,8 @@ export const useCartsStore = defineStore("carts", () => {
cartOrder.value, cartOrder.value,
new Date() new Date()
); );
console.log('costSummary', costSummary);
return costSummary; return costSummary;
}); });
@ -381,10 +385,10 @@ export const useCartsStore = defineStore("carts", () => {
} }
function changeSelCart(cart: CartsState) { function changeSelCart(cart: CartsState) {
console.log(cart)
if (!cart.id) { if (!cart.id) {
return return
} }
if (cart.placeNum) { if (cart.placeNum) {
selPlaceNum.value = cart.placeNum selPlaceNum.value = cart.placeNum
isOldOrder.value = true isOldOrder.value = true
@ -394,11 +398,7 @@ export const useCartsStore = defineStore("carts", () => {
}) })
return return
} }
if (cart.is_gift) {
isSelGift.value = true
} else {
isSelGift.value = false
}
if (cart.is_gift) { if (cart.is_gift) {
isSelGift.value = true isSelGift.value = true
@ -407,7 +407,9 @@ export const useCartsStore = defineStore("carts", () => {
} else { } else {
isSelGift.value = false isSelGift.value = false
isOldOrder.value = false
selListIndex.value = list.value.findIndex((item: CartsState) => item.id === cart.id); selListIndex.value = list.value.findIndex((item: CartsState) => item.id === cart.id);
console.log('selListIndex.value', selListIndex.value)
} }
} }
@ -672,10 +674,14 @@ export const useCartsStore = defineStore("carts", () => {
} }
if (msg.operate_type === "manage_edit") { if (msg.operate_type === "manage_edit") {
const newCart = msg.data; const skuData = getProductDetails({ product_id: msg.data.product_id, sku_id: msg.data.sku_id });
console.log('skuData,', skuData);
const newCart = { ...skuData, ...msg.data };
const listIndex = list.value.findIndex(item => item.id === newCart.id); const listIndex = list.value.findIndex(item => item.id === newCart.id);
const giftIndex = giftList.value.findIndex(item => item.id === newCart.id); const giftIndex = giftList.value.findIndex(item => item.id === newCart.id);
if (giftIndex > -1) { if (giftIndex > -1) {
if (!newCart.is_gift) { if (!newCart.is_gift) {
giftList.value.splice(giftIndex, 1); giftList.value.splice(giftIndex, 1);

View File

@ -77,7 +77,6 @@ export function returnCanDikouGoodsArr(canDikouGoodsArr, selCoupon, user) {
prev.push(...goodsWithType); prev.push(...goodsWithType);
return prev; return prev;
}, []); }, []);
const arr = _.cloneDeep(canDikouGoodsArr) const arr = _.cloneDeep(canDikouGoodsArr)
.map((v) => { .map((v) => {
const findCart = goodsCouponGoods.find((carts) => carts.id == v.id); const findCart = goodsCouponGoods.find((carts) => carts.id == v.id);
@ -116,19 +115,17 @@ export function returnCanDikouGoodsArr(canDikouGoodsArr, selCoupon, user) {
*/ */
export function returnCouponCanUse(args) { export function returnCouponCanUse(args) {
let { canDikouGoodsArr, coupon, goodsOrderPrice, user, selCoupon, shopInfo } = args; let { canDikouGoodsArr, coupon, goodsOrderPrice, user, selCoupon, shopInfo } = args;
// 优惠券未启用 // 优惠券未启用
if (!coupon.use) { if (!coupon.use) {
return { return {
canUse: false, canUse: false,
reason: "优惠券未启用", reason: coupon.noUseRestrictions || "不在可用时间段内",
}; };
} }
// 计算门槛金额 // 计算门槛金额
let fullAmount = goodsOrderPrice; let fullAmount = goodsOrderPrice;
canDikouGoodsArr = returnCanDikouGoodsArr(canDikouGoodsArr, selCoupon, user, shopInfo); canDikouGoodsArr = returnCanDikouGoodsArr(canDikouGoodsArr, selCoupon, user, shopInfo);
//优惠券指定门槛商品列表 //优惠券指定门槛商品列表
let canCalcGoodsArr = [...canDikouGoodsArr]; let canCalcGoodsArr = [...canDikouGoodsArr];
//部分商品参与门槛计算 //部分商品参与门槛计算
@ -187,7 +184,13 @@ export function returnCouponCanUse(args) {
// 商品兑换券,第二件半价和买一送一判断是否有可用商品 // 商品兑换券,第二件半价和买一送一判断是否有可用商品
if ([2, 4, 5].includes(coupon.type)) { if ([2, 4, 5].includes(coupon.type)) {
// 没有符合条件的商品 // 没有符合条件的商品
if (!isDikouAll && canCalcGoodsArr.length === 0) { if (isDikouAll && canDikouGoodsArr.length === 0) {
return {
canUse: false,
reason: "没有符合条件的商品",
};
}
if (!isDikouAll && canUseGoodsArr.length === 0) {
return { return {
canUse: false, canUse: false,
reason: "没有符合条件的商品", reason: "没有符合条件的商品",
@ -289,7 +292,8 @@ export function returnCouponDiscount(arr, coupon, user, goodsOrderPrice, selCoup
return returnCouponProductDiscount(canDikouGoodsArr, coupon, user, shopInfo); return returnCouponProductDiscount(canDikouGoodsArr, coupon, user, shopInfo);
} }
if (coupon.type == 6) { if (coupon.type == 6) {
return returnCouponBuyOneGiveOneDiscount(canDikouGoodsArr, coupon, user, shopInfo); const result = returnCouponBuyOneGiveOneDiscount(canDikouGoodsArr, coupon, user, shopInfo);
return result;
} }
if (coupon.type == 4) { if (coupon.type == 4) {
return returnSecoendDiscount(canDikouGoodsArr, coupon, user, shopInfo); return returnSecoendDiscount(canDikouGoodsArr, coupon, user, shopInfo);
@ -403,7 +407,7 @@ function returnCouponBuyOneGiveOneDiscount(canDikouGoodsArr, coupon, user, shopI
if (useRule == "price_asc") { if (useRule == "price_asc") {
discountGoods = canUseGoods[canUseGoods.length - 1]; discountGoods = canUseGoods[canUseGoods.length - 1];
} else { } else {
discountGoods = canUseGoods.slice(0, 1); discountGoods = canUseGoods[0];
} }
} else { } else {
//符合抵扣条件的商品 //符合抵扣条件的商品
@ -411,13 +415,18 @@ function returnCouponBuyOneGiveOneDiscount(canDikouGoodsArr, coupon, user, shopI
if (useRule == "price_asc") { if (useRule == "price_asc") {
discountGoods = canUseGoods1[canUseGoods1.length - 1]; discountGoods = canUseGoods1[canUseGoods1.length - 1];
} else { } else {
discountGoods = canUseGoods1.slice(0, 1); discountGoods = canUseGoods1[0];
} }
} }
const discountPrice = returnGoodsPrice(discountGoods, user, shopInfo); let discountPrice = 0;
const hasDiscountGoodsArr = [discountGoods]; let hasDiscountGoodsArr = [];
console.log("returnCouponBuyOneGiveOneDiscount:discountGoods", discountGoods);
if (discountGoods) {
discountPrice = returnGoodsPrice(discountGoods, user, shopInfo);
hasDiscountGoodsArr = [discountGoods];
}
return { return {
discountPrice, discountPrice: discountPrice <= 0 ? 0 : discountPrice,
hasDiscountGoodsArr, hasDiscountGoodsArr,
}; };
} }
@ -433,14 +442,14 @@ function returnSecoendDiscount(canDikouGoodsArr, coupon, user, shopInfo) {
const { useFoods, useRule } = coupon; const { useFoods, useRule } = coupon;
//抵扣商品 //抵扣商品
let discountGoods = undefined; let discountGoods = undefined;
//符合买一送一条件的商品 //符合条件的商品
const canUseGoods = canDikouGoodsArr.filter((v) => v.num >= 2); const canUseGoods = canDikouGoodsArr.filter((v) => v.num >= 2);
//抵扣全部商品 //抵扣全部商品
if (useFoods.length === 0) { if (useFoods.length === 0) {
if (useRule == "price_asc") { if (useRule == "price_asc") {
discountGoods = canUseGoods[canUseGoods.length - 1]; discountGoods = canUseGoods[canUseGoods.length - 1];
} else { } else {
discountGoods = canUseGoods.slice(0, 1); discountGoods = canUseGoods[0];
} }
} else { } else {
//符合抵扣条件的商品 //符合抵扣条件的商品
@ -448,16 +457,18 @@ function returnSecoendDiscount(canDikouGoodsArr, coupon, user, shopInfo) {
if (useRule == "price_asc") { if (useRule == "price_asc") {
discountGoods = canUseGoods1[canUseGoods1.length - 1]; discountGoods = canUseGoods1[canUseGoods1.length - 1];
} else { } else {
discountGoods = canUseGoods1.slice(0, 1); discountGoods = canUseGoods1[0];
} }
} }
console.log("returnSecoendDiscount:discountGoods", discountGoods); let discountPrice = 0;
const discountPrice = returnGoodsPrice(discountGoods[0], user, shopInfo); let hasDiscountGoodsArr = [];
console.log("returnSecoendDiscount:discountPrice", discountPrice); if (discountGoods) {
const hasDiscountGoodsArr = [discountGoods]; discountPrice = returnGoodsPrice(discountGoods, user, shopInfo);
hasDiscountGoodsArr = [discountGoods];
}
//返回半价价格 //返回半价价格
return { return {
discountPrice: new BigNumber(discountPrice).dividedBy(2).toNumber(), discountPrice: discountPrice <= 0 ? 0 : new BigNumber(discountPrice).dividedBy(2).toNumber(),
hasDiscountGoodsArr, hasDiscountGoodsArr,
}; };
} }

File diff suppressed because it is too large Load Diff

View File

@ -212,6 +212,7 @@ const vipAllPrice = computed(() => {
return n; return n;
}); });
const allPrice = computed(() => { const allPrice = computed(() => {
console.log("allPrice", props.item);
if (props.item.discount_sale_amount * 1 > 0) { if (props.item.discount_sale_amount * 1 > 0) {
return props.item.discount_sale_amount * props.item.number; return props.item.discount_sale_amount * props.item.number;
} }

View File

@ -125,9 +125,7 @@
<el-button <el-button
type="primary" type="primary"
size="large" size="large"
:disabled=" :disabled="disabledMorePay"
!carts.isLinkFinshed || showOrder || (carts.oldOrder.detailMap.length && !showOrder)
"
@click="createOrder('more-pay')" @click="createOrder('more-pay')"
> >
更多支付 更多支付
@ -146,7 +144,7 @@
<el-button <el-button
type="primary" type="primary"
size="large" size="large"
:disabled="!carts.isLinkFinshed" :disabled="disabledMorePay"
@click="createOrder('to-pay')" @click="createOrder('to-pay')"
> >
去结账 去结账
@ -257,6 +255,25 @@ function itemClick(item) {
function changeNumber(step, item) { function changeNumber(step, item) {
carts.changeNumber(step * 1, item); carts.changeNumber(step * 1, item);
} }
const disabledMorePay = computed(() => {
if (!carts.isLinkFinshed) {
return true;
}
if (props.showOrder) {
return true;
}
if (Array.isArray(carts.oldOrder.detailMap)) {
if (carts.oldOrder.detailMap.length && !props.showOrder) {
return true;
}
} else {
if (carts.isEmpty && JSON.stringify(carts.oldOrder.detailMap) === "{}") {
return true;
}
}
return false;
});
defineExpose({ defineExpose({
carts, carts,

View File

@ -81,32 +81,20 @@
<el-icon><ArrowDown /></el-icon> <el-icon><ArrowDown /></el-icon>
</div> </div>
</div> </div>
{{ carts.orderCostSummary }} <div class="u-m-t-20" v-if="quansSelArr.length > 0">
<div class="u-m-t-20" v-if="carts.coupons.length > 0">
<div class="font-bold u-m-b-10">已选优惠券</div> <div class="font-bold u-m-b-10">已选优惠券</div>
<el-table empty-text="未选择优惠券" :data="carts.coupons"> <el-table empty-text="未选择优惠券" :data="quansSelArr">
<el-table-column type="index" width="50" label="#"></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 prop="name" label="券名称"></el-table-column>
<el-table-column label="券类型" width="80"> <el-table-column label="券类型" width="80">
<template v-slot="scope"> <template v-slot="scope">
{{ scope.row.type == 1 ? "优惠券" : "商品券" }} {{ UTILS.returnCoupType(scope.row.type) }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="商品信息"> <el-table-column label="商品信息">
<template v-slot="scope"> <template v-slot="scope">
<div v-if="scope.row.type == 2"> <div>
<div class="u-flex"> {{ scope.row.foods }}
<el-image
:src="scope.row.productImg"
fit="cover"
style="width: 40px; height: 40px"
:preview-src-list="[scope.row.productImg]"
></el-image>
</div>
<div class="u-m-t-10">
<div class="">{{ scope.row.productName }}</div>
<div class="u-m-t-4">x{{ scope.row.num || "" }}</div>
</div>
</div> </div>
</template> </template>
</el-table-column> </el-table-column>
@ -232,6 +220,8 @@
</template> </template>
<script setup> <script setup>
import * as UTILS from "@/utils/coupon-utils.js";
import * as quanUtil from "../quan_util.js"; import * as quanUtil from "../quan_util.js";
import { OrderPriceCalculator } from "@/utils/goods"; import { OrderPriceCalculator } from "@/utils/goods";
import { useCartsStore } from "@/store/modules/carts"; import { useCartsStore } from "@/store/modules/carts";
@ -302,6 +292,7 @@ function delQuan(row) {
if (index != -1) { if (index != -1) {
quansSelArr.value.splice(index, 1); quansSelArr.value.splice(index, 1);
} }
carts.setCoupons(quansSelArr.value);
} }
function couponChange(data) {} function couponChange(data) {}
@ -406,12 +397,13 @@ watch(
//002-使 //002-使
const pointsRes = ref({ usable: true, maxUsablePoints: 0, minDeductionPoints: 0 }); const pointsRes = ref({ usable: true, maxUsablePoints: 0, minDeductionPoints: 0 });
const usePointsNumber = ref(0); const usePointsNumber = ref(0);
const orderAmountOrderAmount = computed(() => { //
return (carts.goodsTotal - checkOrderPay.discountAmount).toFixed(2); const scoreMaxMoney = computed(() => {
return carts.orderCostSummary.finalPayAmount - carts.orderCostSummary.pointDeductionAmount;
}); });
const pointsDiscountAmount = ref(0); const pointsDiscountAmount = ref(0);
watch( watch(
() => orderAmountOrderAmount.value, () => scoreMaxMoney.value,
(newval) => { (newval) => {
pointsInit(); pointsInit();
} }
@ -424,7 +416,7 @@ function returnPointsDiscountAmount() {
} }
async function pointsInit() { async function pointsInit() {
if (!props.user.id || score.sel == -1) { if (!props.user.id) {
return; return;
} }
const res = await PointsApi.calcOrderUsablePoints({ const res = await PointsApi.calcOrderUsablePoints({
@ -433,6 +425,9 @@ async function pointsInit() {
}); });
pointsRes.value = res; pointsRes.value = res;
carts.pointDeductionRule.pointsPerYuan = res.equivalentPoints; carts.pointDeductionRule.pointsPerYuan = res.equivalentPoints;
if (score.sel == -1) {
return;
}
usePointsNumber.value = res.usable ? res.maxUsablePoints : 0; usePointsNumber.value = res.usable ? res.maxUsablePoints : 0;
if (res.usable) { if (res.usable) {

View File

@ -32,7 +32,11 @@
</el-table-column> </el-table-column>
<el-table-column prop="discountAmount" label="最大抵扣金额" align="center"> <el-table-column prop="discountAmount" label="最大抵扣金额" align="center">
<template v-slot="scope"> <template v-slot="scope">
<span class="color-red">{{ scope.row.maxDiscountAmount }}</span> <span class="color-red">
{{
!scope.row.maxDiscountAmount ? "无上限" : "¥" + scope.row.maxDiscountAmount
}}
</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="discountAmount" label="限制" width="180"> <el-table-column prop="discountAmount" label="限制" width="180">
@ -70,21 +74,9 @@
<el-table-column label="商品信息" width="220"> <el-table-column label="商品信息" width="220">
<template v-slot="scope"> <template v-slot="scope">
<div class="u-flex" v-if="scope.row.useFoods.length"> <div class="u-flex">
<div class="u-flex"> {{ scope.row.foods }}
<el-image
:src="scope.row.productImg"
fit="cover"
style="width: 40px; height: 40px"
:preview-src-list="[scope.row.productImg]"
></el-image>
</div>
<div class="u-p-l-10">
<!-- <div class="">{{ scope.row.productName }}</div> -->
<div class="">x{{ scope.row.discountNum || 1 }}</div>
</div>
</div> </div>
<div class="u-flex" v-else>任意商品 x{{ scope.row.discountNum || 1 }}</div>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="discountAmount" label="抵扣"> <el-table-column prop="discountAmount" label="抵扣">
@ -107,9 +99,9 @@
</el-table> </el-table>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
<div v-if="quansSelArr.length > 0"> <div class="u-m-t-10" v-if="noUseCoupon.length > 0">
<div class="font-bold u-m-b-10">已选优惠券</div> <div class="font-bold u-m-b-10">不可用优惠券</div>
<el-table empty-text="未选择优惠券" :data="quansSelArr" max-height="20vh"> <el-table empty-text="" :data="noUseCoupon" max-height="30vh">
<el-table-column type="index" width="50" label="#"></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 prop="name" label="券名称"></el-table-column>
<el-table-column label="券类型" width="80"> <el-table-column label="券类型" width="80">
@ -119,21 +111,38 @@
</el-table-column> </el-table-column>
<el-table-column label="商品信息" width="120"> <el-table-column label="商品信息" width="120">
<template v-slot="scope"> <template v-slot="scope">
<div class="u-flex" v-if="scope.row.type == 2"> <div class="u-flex">
<div v-if="scope.row.useFoods.length"> {{ scope.row.foods }}
<div class="u-flex"> </div>
<el-image </template>
:src="scope.row.productImg" </el-table-column>
fit="cover" <el-table-column prop="discountAmount" label="抵扣">
style="width: 40px; height: 40px" <template v-slot="scope">
></el-image> <span class="color-red">{{ scope.row.discountAmount }}</span>
</div> </template>
<div class="u-p-l-10"> </el-table-column>
<div class="">{{ scope.row.productName }}</div> <el-table-column prop="useRestrictions" label="描述"></el-table-column>
<div class="">x{{ scope.row.discountNum || 1 }}</div> <el-table-column label="不可用原因">
</div> <template v-slot="scope">
</div> <span class="color-red">{{ scope.row.canuseResult.reason }}</span>
<div v-else>任意商品 x{{ scope.row.discountNum || 1 }}</div> </template>
</el-table-column>
</el-table>
</div>
<div class="u-m-t-10" v-if="quansSelArr.length > 0">
<div class="font-bold u-m-b-10">已选优惠券</div>
<el-table empty-text="" :data="quansSelArr" max-height="20vh">
<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">
{{ UTILS.returnCoupType(scope.row) }}
</template>
</el-table-column>
<el-table-column label="商品信息" width="120">
<template v-slot="scope">
<div class="u-flex">
{{ scope.row.foods }}
</div> </div>
</template> </template>
</el-table-column> </el-table-column>
@ -237,7 +246,7 @@ const {
isSetProductCoup, isSetProductCoup,
} = toRefs(state); } = toRefs(state);
const quansSelArr = computed(() => { const quansSelArr = computed(() => {
return [couponSel.value, goodsCouponSel.value].filter((v) => v.id); return [goodsCouponSel.value, couponSel.value].filter((v) => v.id);
}); });
const refTable = ref(); const refTable = ref();
const refTable1 = ref(); const refTable1 = ref();
@ -246,6 +255,8 @@ let orderPrice = ref(0);
// //
let canDikouGoodsArr = []; let canDikouGoodsArr = [];
let goodsArr = []; let goodsArr = [];
//
const noUseCoupon = ref([]);
function open(money, orderInfo) { function open(money, orderInfo) {
let arr = []; let arr = [];
@ -260,72 +271,96 @@ function open(money, orderInfo) {
show.value = true; show.value = true;
} }
let couponList = [];
async function getcoup() { async function getcoup() {
const res = await couponApi.findCoupon({ shopUserId: props.user.id }); const res = await couponApi.findCoupon({ shopUserId: props.user.id });
console.log(res); couponList = res || [];
let canUseGoodsCoupon = [];
let canUseDiscountCoupon = [];
let noUseGoodsCoupon = [];
let noUseDiscountCoupon = [];
for (let i = 0; i < couponList.length; i++) {
const coupon = couponList[i];
const selCoupon =
activeName.value == "goods"
? quansSelArr.value.filter((v) => v.type != 2)
: quansSelArr.value.filter((v) => v.type == 2);
const canuseResult = UTILS.returnCouponCanUse({
canDikouGoodsArr,
coupon,
orderPrice: orderPrice.value,
user: props.user,
selCoupon,
shopInfo: shopUser.userInfo,
});
const { canUse, reason } = canuseResult;
if (coupon.type == 2) {
if (canUse || goodsCouponSel.value.id == coupon.id) {
canUseGoodsCoupon.push(coupon);
} else {
noUseGoodsCoupon.push({
...coupon,
canuseResult,
});
}
} else {
if (canUse || couponSel.value.id == coupon.id) {
canUseDiscountCoupon.push(coupon);
} else {
noUseDiscountCoupon.push({
...coupon,
canuseResult,
});
}
}
}
//
canUseGoodsCoupon = canUseGoodsCoupon.map((v) => {
const discount = UTILS.returnCouponDiscount(
canDikouGoodsArr,
v,
props.user,
orderPrice.value,
quansSelArr.value,
shopUser.userInfo
);
return {
...v,
discount,
discountAmount: discount ? discount.discountPrice : v.discountAmount,
};
});
// //
quans.value.coupon = res canUseDiscountCoupon = canUseDiscountCoupon.map((v) => {
.filter((v) => v.type != 2) const discount = UTILS.returnCouponDiscount(
.filter((coupon) => { canDikouGoodsArr,
const { canUse, msg } = UTILS.returnCouponCanUse({ v,
canDikouGoodsArr, props.user,
coupon, orderPrice.value,
orderPrice: orderPrice.value, quansSelArr.value,
user: props.user, shopUser.userInfo
selCoupon: quansSelArr.value, );
shopInfo: shopUser.userInfo, return {
}); ...v,
return canUse; discount,
}) discountAmount: discount ? discount.discountPrice : v.discountAmount,
.map((v) => { };
const discount = UTILS.returnCouponDiscount( });
canDikouGoodsArr,
v, quans.value.productCoupon = canUseGoodsCoupon;
props.user, quans.value.coupon = canUseDiscountCoupon;
orderPrice.value, if (activeName.value == "goods") {
quansSelArr.value, noUseCoupon.value = [...noUseGoodsCoupon];
shopUser.userInfo } else {
); noUseCoupon.value = [...noUseDiscountCoupon];
return { }
...v,
discount,
discountAmount: discount ? discount.discountPrice : v.discountAmount,
};
});
quans.value.productCoupon = res
.filter((v) => v.type == 2)
.filter((coupon) => {
const { canUse, msg } = UTILS.returnCouponCanUse({
canDikouGoodsArr,
coupon,
orderPrice: orderPrice.value,
user: props.user,
selCoupon: quansSelArr.value,
shopInfo: shopUser.userInfo,
});
return canUse;
})
.map((v) => {
const findGoods = goodsArr.find((goods) => goods.productId == v.proId);
const discount = UTILS.returnCouponDiscount(
canDikouGoodsArr,
v,
props.user,
orderPrice.value,
quansSelArr.value,
shopUser.userInfo
);
return {
...v,
productImg: findGoods ? findGoods.productImg : "",
productName: findGoods ? findGoods.productName : "",
discount,
discountAmount: discount ? discount.discountPrice : v.discountAmount,
};
});
} }
function couponClick(checked, row) { function couponClick(checked, row) {
couponSel.value = checked ? row : { id: "" }; couponSel.value = checked ? row : { id: "" };
updateSelCoupon();
} }
const AllCouponPrice = computed(() => { const AllCouponPrice = computed(() => {
return quansSelArr.value.reduce((pre, cur) => pre + cur.discountAmount, 0); return quansSelArr.value.reduce((pre, cur) => pre + cur.discountAmount, 0);
@ -336,6 +371,7 @@ const payPrice = computed(() => {
}); });
function productCouponClick(checked, item) { function productCouponClick(checked, item) {
goodsCouponSel.value = checked ? item : { id: "" }; goodsCouponSel.value = checked ? item : { id: "" };
updateSelCoupon();
} }
// //
@ -369,9 +405,51 @@ watch(
getcoup(); getcoup();
} }
); );
function updateSelCoupon() {
const newval = quansSelArr.value;
if (newval.length >= 2) {
let goodsCoupon = newval.filter((v) => v.type == 2);
let otherCoupon = newval.filter((v) => v.type != 2);
goodsCoupon = goodsCoupon.map((v) => {
const discount = UTILS.returnCouponDiscount(
canDikouGoodsArr,
v,
props.user,
orderPrice.value,
[],
shopUser.userInfo
);
return {
...v,
discount,
discountAmount: discount ? discount.discountPrice : v.discountAmount,
};
});
otherCoupon = otherCoupon.map((v) => {
const discount = UTILS.returnCouponDiscount(
canDikouGoodsArr,
v,
props.user,
orderPrice.value,
goodsCoupon,
shopUser.userInfo
);
return {
...v,
discount,
discountAmount: discount ? discount.discountPrice : v.discountAmount,
};
});
couponSel.value = otherCoupon[0];
goodsCouponSel.value = goodsCoupon[0];
}
}
watch( watch(
() => quansSelArr.value, () => quansSelArr.value,
() => { (newval) => {
console.log("quansSelArr", newval);
getcoup(); getcoup();
} }
); );