优化代客下单限时折扣
This commit is contained in:
@@ -69,7 +69,7 @@
|
|||||||
"vue-clipboard3": "^2.0.0",
|
"vue-clipboard3": "^2.0.0",
|
||||||
"vue-i18n": "^11.1.0",
|
"vue-i18n": "^11.1.0",
|
||||||
"vue-router": "^4.5.0",
|
"vue-router": "^4.5.0",
|
||||||
"ysk-utils": "^1.0.62"
|
"ysk-utils": "^1.0.68"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@commitlint/cli": "^19.7.1",
|
"@commitlint/cli": "^19.7.1",
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import WebSocketManager, { type ApifoxModel, msgType } from "@/utils/websocket";
|
|||||||
import orderApi from "@/api/order/order";
|
import orderApi from "@/api/order/order";
|
||||||
import { useUserStoreHook } from "@/store/modules/user";
|
import { useUserStoreHook } from "@/store/modules/user";
|
||||||
import productApi from "@/api/product/index";
|
import productApi from "@/api/product/index";
|
||||||
|
import shopUserApi from '@/api/account/shopUser'
|
||||||
import limitTimeDiscountApi from '@/api/market/limitTimeDiscount.js'
|
import limitTimeDiscountApi from '@/api/market/limitTimeDiscount.js'
|
||||||
import * as UTILS from "@/utils/coupon-utils.js";
|
import * as UTILS from "@/utils/coupon-utils.js";
|
||||||
import { BigNumber } from "bignumber.js";
|
import { BigNumber } from "bignumber.js";
|
||||||
@@ -49,6 +50,13 @@ interface PointDeductionRule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const useCartsStore = defineStore("carts", () => {
|
export const useCartsStore = defineStore("carts", () => {
|
||||||
|
const shopInfoStr = localStorage.getItem('userInfo') || '{}';
|
||||||
|
const shopInfo = JSON.parse(shopInfoStr);
|
||||||
|
const limitDiscountRes = ref<Record<string, any> | null>(null);
|
||||||
|
|
||||||
|
const shopInfoTyped = shopInfo as Record<string, any>;
|
||||||
|
const ldRes = limitDiscountRes.value as LimitDiscountResult | null;
|
||||||
|
|
||||||
// ------------------------------ 1. 移到内部的工具函数(核心修复) ------------------------------
|
// ------------------------------ 1. 移到内部的工具函数(核心修复) ------------------------------
|
||||||
// 适配工具库 BaseCartItem 接口的商品数据转换函数(原外部函数,现在内部)
|
// 适配工具库 BaseCartItem 接口的商品数据转换函数(原外部函数,现在内部)
|
||||||
const convertToBaseCartItem = (item: any): BaseCartItem => {
|
const convertToBaseCartItem = (item: any): BaseCartItem => {
|
||||||
@@ -60,6 +68,8 @@ export const useCartsStore = defineStore("carts", () => {
|
|||||||
}
|
}
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
|
// console.log('skuData===========', skuData);
|
||||||
|
|
||||||
let productType: GoodsType = GoodsType.NORMAL;
|
let productType: GoodsType = GoodsType.NORMAL;
|
||||||
switch (item.product_type) {
|
switch (item.product_type) {
|
||||||
case 'weight': productType = GoodsType.WEIGHT; break;
|
case 'weight': productType = GoodsType.WEIGHT; break;
|
||||||
@@ -68,7 +78,10 @@ export const useCartsStore = defineStore("carts", () => {
|
|||||||
default: productType = GoodsType.NORMAL;
|
default: productType = GoodsType.NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
...item,
|
||||||
id: item.id,
|
id: item.id,
|
||||||
product_id: item.product_id,
|
product_id: item.product_id,
|
||||||
number: item.number || 0,
|
number: item.number || 0,
|
||||||
@@ -88,9 +101,7 @@ export const useCartsStore = defineStore("carts", () => {
|
|||||||
}
|
}
|
||||||
: undefined,
|
: undefined,
|
||||||
skuData,
|
skuData,
|
||||||
is_time_discount: item.is_time_discount,
|
salePrice: item.salePrice
|
||||||
isTimeDiscount: item.is_time_discount,
|
|
||||||
salePrice: item.limitDiscountPrice || 0
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -103,31 +114,72 @@ export const useCartsStore = defineStore("carts", () => {
|
|||||||
const oldOrderGoods = Object.values(oldOrder.value.detailMap || {})
|
const oldOrderGoods = Object.values(oldOrder.value.detailMap || {})
|
||||||
.flat()
|
.flat()
|
||||||
.map(convertToBaseCartItem);
|
.map(convertToBaseCartItem);
|
||||||
|
|
||||||
|
|
||||||
// console.log('list=====================================', list.value);
|
// console.log('list=====================================', list.value);
|
||||||
// console.log('giftList=====================================', giftList.value);
|
// console.log('giftList=====================================', giftList.value);
|
||||||
// console.log('oldOrder.value.detailMap=====================================', oldOrder.value.detailMap);
|
// console.log('oldOrder.value.detailMap=====================================', oldOrder.value.detailMap);
|
||||||
// console.log('getAllGoodsList.[]===================', [...currentGoods, ...giftGoods, ...oldOrderGoods])
|
// console.log('getAllGoodsList.[]===================', [...currentGoods, ...giftGoods, ...oldOrderGoods])
|
||||||
|
|
||||||
|
|
||||||
return [...currentGoods, ...giftGoods, ...oldOrderGoods];
|
return [...currentGoods, ...giftGoods, ...oldOrderGoods];
|
||||||
};
|
};
|
||||||
|
|
||||||
const limitDiscountRes = ref<Record<string, any> | null>(null);
|
|
||||||
|
|
||||||
// ------------------------------ 2. Store 内部原有响应式变量 ------------------------------
|
// ------------------------------ 2. Store 内部原有响应式变量 ------------------------------
|
||||||
// 选择用户
|
// 选择用户
|
||||||
const vipUser = ref<{ id?: string | number, isVip?: boolean }>({});
|
const vipUser = ref<{ id?: string | number, isVip?: boolean }>({});
|
||||||
async function changeUser(user: any) {
|
async function changeUser(user: any) {
|
||||||
|
|
||||||
vipUser.value = {
|
vipUser.value = {
|
||||||
...user,
|
...user,
|
||||||
isMemberPrice: shopUser.userInfo.isMemberPrice
|
isMemberPrice: shopUser.userInfo.isMemberPrice
|
||||||
};
|
};
|
||||||
|
|
||||||
|
console.log('changeUser', vipUser.value);
|
||||||
await getGoods({})
|
await getGoods({})
|
||||||
|
|
||||||
|
// 选择用户后重新刷新历史订单限时折扣信息
|
||||||
|
setOldOrder(oldOrder.value)
|
||||||
|
|
||||||
allGoods.value = getAllGoodsList()
|
allGoods.value = getAllGoodsList()
|
||||||
|
|
||||||
console.log('选择用户后刷新所有订单购物车数据====', allGoods.value);
|
console.log('选择用户后刷新所有订单购物车数据====', allGoods.value);
|
||||||
|
sendWsTimeDiscount()
|
||||||
payParamsInit()
|
payParamsInit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 给长连接发送更新购物车限时折扣信息
|
||||||
|
const sendWsTimeDiscount = _.throttle(function () {
|
||||||
|
// 在这里准备给ws发送刷新消息
|
||||||
|
const cart = (list.value || []).map(convertToBaseCartItem);
|
||||||
|
const history = Object.values(oldOrder.value.detailMap || {})
|
||||||
|
.flat()
|
||||||
|
.map(convertToBaseCartItem);
|
||||||
|
|
||||||
|
if (cart.length || history.length) {
|
||||||
|
WebSocketManager.sendMessage({
|
||||||
|
type: "shopping",
|
||||||
|
operate_type: "bulk_edit",
|
||||||
|
table_code: table_code.value,
|
||||||
|
shop_id: localStorage.getItem("shopId"),
|
||||||
|
data: {
|
||||||
|
cart: cart.map(item => {
|
||||||
|
return {
|
||||||
|
id: item.id,
|
||||||
|
is_time_discount: limitUtils.canUseLimitTimeDiscount(item, limitDiscountRes.value, shopInfoTyped, vipUser.value) ? 1 : 0
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
history: history.map(item => {
|
||||||
|
return {
|
||||||
|
id: item.id,
|
||||||
|
is_time_discount: limitUtils.canUseLimitTimeDiscount(item, limitDiscountRes.value, shopInfoTyped, vipUser.value) ? 1 : 0
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}, 3000)
|
||||||
|
|
||||||
// 就餐类型
|
// 就餐类型
|
||||||
let dinnerType = ref<'dine-in' | 'take-out'>('dine-in');
|
let dinnerType = ref<'dine-in' | 'take-out'>('dine-in');
|
||||||
|
|
||||||
@@ -176,6 +228,16 @@ export const useCartsStore = defineStore("carts", () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const sendThrottledMessage = _.throttle(function () {
|
||||||
|
WebSocketManager.sendMessage({
|
||||||
|
type: "shopping",
|
||||||
|
operate_type: "time_discount_save",
|
||||||
|
table_code: table_code.value,
|
||||||
|
shop_id: localStorage.getItem("shopId"),
|
||||||
|
data: limitDiscountRes.value,
|
||||||
|
});
|
||||||
|
}, 3000);
|
||||||
|
|
||||||
// 代客下单页面商品缓存
|
// 代客下单页面商品缓存
|
||||||
const goods = useStorage<any[]>("Instead_goods", []);
|
const goods = useStorage<any[]>("Instead_goods", []);
|
||||||
async function getGoods(query: any) {
|
async function getGoods(query: any) {
|
||||||
@@ -193,13 +255,7 @@ export const useCartsStore = defineStore("carts", () => {
|
|||||||
if (limitDiscountRes.value !== null) {
|
if (limitDiscountRes.value !== null) {
|
||||||
checkLinkFinished().then(() => {
|
checkLinkFinished().then(() => {
|
||||||
console.log('给ws发送限时折扣信息');
|
console.log('给ws发送限时折扣信息');
|
||||||
WebSocketManager.sendMessage({
|
sendThrottledMessage()
|
||||||
type: "shopping",
|
|
||||||
operate_type: "time_discount_save",
|
|
||||||
table_code: table_code.value,
|
|
||||||
shop_id: localStorage.getItem("shopId"),
|
|
||||||
data: limitDiscountRes.value,
|
|
||||||
});
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,9 +268,6 @@ export const useCartsStore = defineStore("carts", () => {
|
|||||||
...query,
|
...query,
|
||||||
});
|
});
|
||||||
|
|
||||||
const shopInfoStr = localStorage.getItem('userInfo') || '{}';
|
|
||||||
const shopInfo = JSON.parse(shopInfoStr);
|
|
||||||
|
|
||||||
interface ProductItem {
|
interface ProductItem {
|
||||||
id: string | number;
|
id: string | number;
|
||||||
lowMemberPrice?: number;
|
lowMemberPrice?: number;
|
||||||
@@ -232,21 +285,21 @@ export const useCartsStore = defineStore("carts", () => {
|
|||||||
limitDiscountPrice: number;
|
limitDiscountPrice: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
const shopInfoTyped = shopInfo as Record<string, any>;
|
|
||||||
const ldRes = limitDiscountRes.value as LimitDiscountResult | null;
|
|
||||||
|
|
||||||
goods.value = (res.records as ProductItem[]).map((item: ProductItem): GoodsWithDiscount => {
|
goods.value = (res.records as ProductItem[]).map((item: ProductItem): GoodsWithDiscount => {
|
||||||
|
item.salePrice = item.lowPrice
|
||||||
|
item.memberPrice = item.lowMemberPrice
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...item,
|
...item,
|
||||||
isLimitDiscount: ldRes !== null && limitUtils.canUseLimitTimeDiscount(item, ldRes, shopInfoTyped, vipUser.value, 'id'),
|
is_time_discount: limitUtils.canUseLimitTimeDiscount(item, limitDiscountRes.value, shopInfoTyped, vipUser.value) ? 1 : 0,
|
||||||
limitDiscountPrice: limitUtils.returnPrice({
|
time_discount_price: limitUtils.returnPrice({
|
||||||
goods: { ...item, memberPrice: item.lowMemberPrice, salePrice: item.lowPrice },
|
goods: { ...item },
|
||||||
shopInfo: shopInfoTyped,
|
shopInfo: shopInfoTyped,
|
||||||
limitTimeDiscountRes: ldRes,
|
limitTimeDiscountRes: limitDiscountRes.value,
|
||||||
shopUserInfo: vipUser.value,
|
shopUserInfo: vipUser.value,
|
||||||
idKey: 'id'
|
idKey: 'id'
|
||||||
})
|
})
|
||||||
} as GoodsWithDiscount;
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('代客下单页面商品缓存.goods.value', goods.value);
|
console.log('代客下单页面商品缓存.goods.value', goods.value);
|
||||||
@@ -361,7 +414,7 @@ export const useCartsStore = defineStore("carts", () => {
|
|||||||
limitTimeDiscount: limitDiscountRes.value,
|
limitTimeDiscount: limitDiscountRes.value,
|
||||||
shopUserInfo: vipUser.value,
|
shopUserInfo: vipUser.value,
|
||||||
newUserDiscount: newUserDiscount.value
|
newUserDiscount: newUserDiscount.value
|
||||||
}));
|
}) as OrderExtraConfig);
|
||||||
|
|
||||||
// 营销活动列表
|
// 营销活动列表
|
||||||
const activityList = computed<ActivityConfig[]>(() => {
|
const activityList = computed<ActivityConfig[]>(() => {
|
||||||
@@ -405,8 +458,6 @@ 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);
|
|
||||||
console.log('orderExtraConfig.value', orderExtraConfig.value);
|
|
||||||
const costSummary = OrderPriceCalculator.calculateOrderCostSummary(
|
const costSummary = OrderPriceCalculator.calculateOrderCostSummary(
|
||||||
allGoods.value,
|
allGoods.value,
|
||||||
dinnerType.value,
|
dinnerType.value,
|
||||||
@@ -417,7 +468,6 @@ export const useCartsStore = defineStore("carts", () => {
|
|||||||
new Date()
|
new Date()
|
||||||
);
|
);
|
||||||
console.log('costSummary----------------------------', costSummary);
|
console.log('costSummary----------------------------', costSummary);
|
||||||
|
|
||||||
return costSummary;
|
return costSummary;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -565,7 +615,7 @@ export const useCartsStore = defineStore("carts", () => {
|
|||||||
function add(data: any) {
|
function add(data: any) {
|
||||||
goods.value.map(item => {
|
goods.value.map(item => {
|
||||||
if (item.id == data.product_id) {
|
if (item.id == data.product_id) {
|
||||||
data.is_time_discount = item.isLimitDiscount ? 1 : 0
|
data.is_time_discount = item.is_time_discount ? 1 : 0
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -667,8 +717,10 @@ export const useCartsStore = defineStore("carts", () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取历史订单信息
|
||||||
async function getOldOrder(table_code: string | number) {
|
async function getOldOrder(table_code: string | number) {
|
||||||
const res = await orderApi.getHistoryList({ tableCode: table_code });
|
const res = await orderApi.getHistoryList({ tableCode: table_code });
|
||||||
|
console.log('获取历史订单信息===', res);
|
||||||
if (res) setOldOrder(res);
|
if (res) setOldOrder(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -684,9 +736,11 @@ export const useCartsStore = defineStore("carts", () => {
|
|||||||
skuData = { ...SnapSku, salePrice: SnapSku ? SnapSku.price : 0 };
|
skuData = { ...SnapSku, salePrice: SnapSku ? SnapSku.price : 0 };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('skuData===', skuData);
|
||||||
|
|
||||||
|
|
||||||
if (skuData) {
|
if (skuData) {
|
||||||
return {
|
return {
|
||||||
limitDiscountPrice: goods.limitDiscountPrice,
|
|
||||||
salePrice: skuData.salePrice || 0,
|
salePrice: skuData.salePrice || 0,
|
||||||
memberPrice: skuData.memberPrice || 0,
|
memberPrice: skuData.memberPrice || 0,
|
||||||
coverImg: goods.coverImg,
|
coverImg: goods.coverImg,
|
||||||
@@ -694,12 +748,21 @@ export const useCartsStore = defineStore("carts", () => {
|
|||||||
specInfo: skuData.specInfo,
|
specInfo: skuData.specInfo,
|
||||||
packFee: goods.packFee || 0,
|
packFee: goods.packFee || 0,
|
||||||
type: goods.type,
|
type: goods.type,
|
||||||
skuData
|
skuData,
|
||||||
|
is_time_discount: limitUtils.canUseLimitTimeDiscount(goods, limitDiscountRes.value, shopInfo, vipUser.value),
|
||||||
|
time_discount_price: limitUtils.returnPrice({
|
||||||
|
goods: skuData,
|
||||||
|
shopInfo: shopInfoTyped,
|
||||||
|
limitTimeDiscountRes: limitDiscountRes.value,
|
||||||
|
shopUserInfo: vipUser.value,
|
||||||
|
idKey: 'productId'
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 历史订单信息补全
|
||||||
function returnDetailMap(data: any) {
|
function returnDetailMap(data: any) {
|
||||||
const newData: { [key: string]: any } = {};
|
const newData: { [key: string]: any } = {};
|
||||||
for (let i in data) {
|
for (let i in data) {
|
||||||
@@ -722,20 +785,34 @@ export const useCartsStore = defineStore("carts", () => {
|
|||||||
sku_name: v.skuName,
|
sku_name: v.skuName,
|
||||||
sku_id: v.skuId,
|
sku_id: v.skuId,
|
||||||
product_type: v.productType,
|
product_type: v.productType,
|
||||||
is_time_discount: v.isTimeDiscount
|
is_time_discount: limitUtils.canUseLimitTimeDiscount(v, limitDiscountRes.value, shopInfoTyped, vipUser.value, 'productId'),
|
||||||
|
time_discount_price: limitUtils.returnPrice({
|
||||||
|
goods: { ...v, ...skuData },
|
||||||
|
shopInfo: shopInfoTyped,
|
||||||
|
limitTimeDiscountRes: limitDiscountRes.value,
|
||||||
|
shopUserInfo: vipUser.value,
|
||||||
|
idKey: 'productId'
|
||||||
|
})
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
console.log('returnDetailMap.newData================', newData);
|
console.log('newData2025年11月13日', newData);
|
||||||
|
|
||||||
return newData;
|
return newData;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setOldOrder(data: any) {
|
// 初始话订单信息/补全历史订单信息
|
||||||
|
async function setOldOrder(data: any) {
|
||||||
|
console.log('补全订单信息', data);
|
||||||
oldOrder.value = {
|
oldOrder.value = {
|
||||||
...data,
|
...data,
|
||||||
detailMap: returnDetailMap(data.detailMap)
|
detailMap: returnDetailMap(data.detailMap)
|
||||||
};
|
};
|
||||||
|
console.log('oldOrder.value.detailMap==', oldOrder.value.detailMap);
|
||||||
|
|
||||||
|
if (!vipUser.value.id && data.userId) {
|
||||||
|
const res = await shopUserApi.get({ userId: data.userId })
|
||||||
|
changeUser(res)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let $initParams = {} as ApifoxModel;
|
let $initParams = {} as ApifoxModel;
|
||||||
@@ -750,6 +827,9 @@ export const useCartsStore = defineStore("carts", () => {
|
|||||||
table_code.value = initParams.table_code;
|
table_code.value = initParams.table_code;
|
||||||
$initParams = initParams;
|
$initParams = initParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
concocatSocket($initParams);
|
concocatSocket($initParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -875,6 +955,11 @@ export const useCartsStore = defineStore("carts", () => {
|
|||||||
msg.operate_type = 'manage_' + msg.operate_type;
|
msg.operate_type = 'manage_' + msg.operate_type;
|
||||||
concocatSocket(initParams);
|
concocatSocket(initParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (msg.operate_type === "bulk_edit") {
|
||||||
|
msg.operate_type = 'manage_' + msg.operate_type;
|
||||||
|
concocatSocket({ ...$initParams, table_code: table_code.value });
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -955,7 +1040,8 @@ export const useCartsStore = defineStore("carts", () => {
|
|||||||
setCoupons,
|
setCoupons,
|
||||||
payParamsInit,
|
payParamsInit,
|
||||||
limitDiscountRes,
|
limitDiscountRes,
|
||||||
getAllGoodsList
|
getAllGoodsList,
|
||||||
|
vipUser
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
185
src/store/modules/limit.js
Normal file
185
src/store/modules/limit.js
Normal file
@@ -0,0 +1,185 @@
|
|||||||
|
"use strict";
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.utils = void 0;
|
||||||
|
exports.canUseLimitTimeDiscount = canUseLimitTimeDiscount;
|
||||||
|
exports.returnPrice = returnPrice;
|
||||||
|
exports.returnLimitPrice = returnLimitPrice;
|
||||||
|
exports.canReturnMemberPrice = canReturnMemberPrice;
|
||||||
|
exports.returnMemberPrice = returnMemberPrice;
|
||||||
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
||||||
|
/**
|
||||||
|
* 判断商品是否可以使用限时折扣
|
||||||
|
* @param goods 商品对象
|
||||||
|
* @param limitTimeDiscountRes 限时折扣配置
|
||||||
|
* @param shopInfo 店铺信息
|
||||||
|
* @param shopUserInfo 店铺用户信息
|
||||||
|
* @param idKey 商品ID键名,默认"id"
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
function canUseLimitTimeDiscount(goods, limitTimeDiscountRes, shopInfo, shopUserInfo, idKey = "id") {
|
||||||
|
shopInfo = shopInfo || {};
|
||||||
|
shopUserInfo = shopUserInfo || {};
|
||||||
|
if (!limitTimeDiscountRes || !limitTimeDiscountRes.id) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const canUseFoods = (limitTimeDiscountRes.foods || "").split(",");
|
||||||
|
const goodsCanUse = limitTimeDiscountRes.foodType == 1 ||
|
||||||
|
canUseFoods.includes(`${goods[idKey]}`);
|
||||||
|
if (!goodsCanUse) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (limitTimeDiscountRes.discountPriority == "limit-time") {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (limitTimeDiscountRes.discountPriority == "vip-price") {
|
||||||
|
if (shopUserInfo.isVip != 1 || shopUserInfo.isMemberPrice != 1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (shopUserInfo.isVip == 1 &&
|
||||||
|
shopUserInfo.isMemberPrice == 1 &&
|
||||||
|
goods.memberPrice * 1 <= 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 返回商品显示价格
|
||||||
|
* @params {*} args 参数对象
|
||||||
|
* @params {*} args.goods 商品对象
|
||||||
|
* @params {*} args.shopInfo 店铺信息
|
||||||
|
* @params {*} args.limitTimeDiscountRes 限时折扣信息
|
||||||
|
* @params {*} args.shopUserInfo 店铺用户信息
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
function returnPrice(args) {
|
||||||
|
let { goods, shopInfo, limitTimeDiscountRes, shopUserInfo, idKey = "product_id", } = args;
|
||||||
|
|
||||||
|
console.log('limits.returnPrice===', args);
|
||||||
|
|
||||||
|
|
||||||
|
limitTimeDiscountRes = limitTimeDiscountRes || {
|
||||||
|
foods: "",
|
||||||
|
foodType: 2,
|
||||||
|
discountPriority: "",
|
||||||
|
discountRate: 0,
|
||||||
|
id: 0,
|
||||||
|
shopId: 0,
|
||||||
|
useType: "",
|
||||||
|
};
|
||||||
|
const canUseFoods = (limitTimeDiscountRes.foods || "").split(",");
|
||||||
|
const includesGoods = limitTimeDiscountRes.foodType == 1 ||
|
||||||
|
canUseFoods.includes("" + goods[idKey]);
|
||||||
|
shopInfo = shopInfo || {};
|
||||||
|
shopUserInfo = shopUserInfo || {};
|
||||||
|
if (shopUserInfo.isMemberPrice == 1 &&
|
||||||
|
shopUserInfo.isVip == 1 &&
|
||||||
|
shopInfo.isMemberPrice == 1) {
|
||||||
|
const memberPrice = goods.memberPrice || goods.salePrice;
|
||||||
|
//是会员而且启用会员价
|
||||||
|
if (limitTimeDiscountRes) {
|
||||||
|
//使用限时折扣
|
||||||
|
//限时折扣优先
|
||||||
|
if (limitTimeDiscountRes.discountPriority == "limit-time") {
|
||||||
|
if (includesGoods) {
|
||||||
|
return returnLimitPrice({
|
||||||
|
price: goods.salePrice,
|
||||||
|
limitTimeDiscountRes,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return memberPrice;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (limitTimeDiscountRes.discountPriority == "vip-price" &&
|
||||||
|
includesGoods) {
|
||||||
|
if (goods.memberPrice * 1 > 0) {
|
||||||
|
//会员优先
|
||||||
|
return memberPrice;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const price = returnLimitPrice({
|
||||||
|
price: goods.salePrice,
|
||||||
|
limitTimeDiscountRes,
|
||||||
|
goods: goods,
|
||||||
|
});
|
||||||
|
return price;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return memberPrice;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//是会员没有限时折扣
|
||||||
|
return memberPrice;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// console.log('不是会员或者没有启用会员价',goods,limitTimeDiscountRes);
|
||||||
|
//不是会员或者没有启用会员价
|
||||||
|
if (limitTimeDiscountRes && limitTimeDiscountRes.id && includesGoods) {
|
||||||
|
const price = returnLimitPrice({
|
||||||
|
price: goods.salePrice,
|
||||||
|
limitTimeDiscountRes,
|
||||||
|
goods: goods,
|
||||||
|
});
|
||||||
|
return price;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return goods.salePrice;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 返回限时折扣价格
|
||||||
|
* @params {*} args 参数对象
|
||||||
|
* @params {*} args.limitTimeDiscountRes 限时折扣信息
|
||||||
|
* @params {*} args.price 商品价格
|
||||||
|
* @param {*} args.goods 商品对象
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
function returnLimitPrice(args) {
|
||||||
|
const { limitTimeDiscountRes, price, goods } = args;
|
||||||
|
const discountRate = new bignumber_js_1.default(limitTimeDiscountRes ? limitTimeDiscountRes.discountRate : 100).dividedBy(100);
|
||||||
|
const result = (0, bignumber_js_1.default)(price)
|
||||||
|
.times(discountRate)
|
||||||
|
.decimalPlaces(2, bignumber_js_1.default.ROUND_UP)
|
||||||
|
.toNumber();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 判断是否返回会员价
|
||||||
|
* @param {*} args 参数对象
|
||||||
|
* @param {*} args.shopInfo 店铺信息
|
||||||
|
* @param {*} args.shopUserInfo 店铺用户信息
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
function canReturnMemberPrice(args) {
|
||||||
|
const { shopInfo, shopUserInfo } = args;
|
||||||
|
if (shopUserInfo.isMemberPrice == 1 && shopUserInfo.isVip == 1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 返回会员价格
|
||||||
|
* @param {*} goods
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
function returnMemberPrice(goods) {
|
||||||
|
return goods.memberPrice || goods.salePrice;
|
||||||
|
}
|
||||||
|
exports.utils = {
|
||||||
|
returnPrice,
|
||||||
|
canUseLimitTimeDiscount,
|
||||||
|
returnLimitPrice,
|
||||||
|
canReturnMemberPrice,
|
||||||
|
returnMemberPrice,
|
||||||
|
};
|
||||||
|
exports.default = exports.utils;
|
||||||
@@ -1,345 +0,0 @@
|
|||||||
import BigNumber from "bignumber.js";
|
|
||||||
|
|
||||||
import _ from "lodash";
|
|
||||||
|
|
||||||
export interface Goods {
|
|
||||||
productId: string | number; // 商品ID(唯一标识商品,用于优惠券/活动匹配,必选)
|
|
||||||
skuId: string | number; // 商品规格ID(唯一标识商品规格,如颜色/尺寸)
|
|
||||||
id: string | number; // 购物车ID(唯一标识购物车中的条目,如购物车项主键)
|
|
||||||
product_id: string | number; // 商品ID(唯一标识商品,用于优惠券/活动匹配,必选)
|
|
||||||
salePrice: number; // 商品原价(元)
|
|
||||||
number: number; // 商品数量
|
|
||||||
product_type: string; // 商品类型
|
|
||||||
is_temporary?: number; // 是否临时菜(默认false)
|
|
||||||
is_gift?: number; // 是否赠菜(默认false)
|
|
||||||
returnNum?: number; // 退货数量(历史订单用,默认0)
|
|
||||||
memberPrice: number; // 商品会员价(元,优先级:商品会员价 > 会员折扣)
|
|
||||||
discountSaleAmount?: number; // 商家改价后单价(元,优先级最高)
|
|
||||||
packFee?: number; // 单份打包费(元,默认0)
|
|
||||||
packNumber?: number; // 堂食打包数量(默认0)
|
|
||||||
skuData?: {
|
|
||||||
// SKU扩展数据(可选)
|
|
||||||
id: string | number; // SKU ID(唯一标识商品规格,如颜色/尺寸)
|
|
||||||
memberPrice?: number; // SKU会员价
|
|
||||||
salePrice?: number; // SKU原价
|
|
||||||
};
|
|
||||||
discount_sale_amount: number; // 商家改价后单价(元,优先级最高)
|
|
||||||
[property: string]: any;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface User {
|
|
||||||
isVip: number; // 是否会员 1是会员
|
|
||||||
[property: string]: any;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ShopInfo {
|
|
||||||
isMemberPrice: number; // 是否开启会员价 1是开启
|
|
||||||
[property: string]: any;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ThresholdFood {
|
|
||||||
id: string | number; // 商品ID
|
|
||||||
[property: string]: any;
|
|
||||||
}
|
|
||||||
export interface UseFood {
|
|
||||||
id: string | number;
|
|
||||||
[property: string]: any;
|
|
||||||
}
|
|
||||||
export interface Coupon {
|
|
||||||
id: string | number;
|
|
||||||
use: boolean;
|
|
||||||
type: number;
|
|
||||||
thresholdFoods: ThresholdFood[];
|
|
||||||
useFoods: UseFood[];
|
|
||||||
noUseRestrictions?: string;
|
|
||||||
discountShare: number; // 是否与折扣优惠同享 1是同享
|
|
||||||
vipPriceShare: number; // 是否与会员优惠同享 1是同享
|
|
||||||
otherCouponShare: number; // 是否与其他优惠券同享 1是同享
|
|
||||||
fullAmount: number; // 使用门槛金额
|
|
||||||
discountRate: number; // 折扣率(满减券:折扣金额/门槛金额,折扣券:折扣率)
|
|
||||||
maxDiscountAmount: number; // 最大折扣金额(满减券:折扣金额,折扣券:折扣金额)
|
|
||||||
discountNum: number; // 抵扣商品数量(商品券:抵扣商品数量,折扣券:0)
|
|
||||||
useRule: string; // 使用规则(price_asc:按商品单价升序,price_desc:按商品单价降序)
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface couponDiscount {
|
|
||||||
discountPrice: number;
|
|
||||||
hasDiscountGoodsArr: Goods[];
|
|
||||||
}
|
|
||||||
export interface selCoupon extends Coupon {
|
|
||||||
discount?: couponDiscount;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface couponCalcParams {
|
|
||||||
canDikouGoodsArr: Goods[];
|
|
||||||
coupon: Coupon;
|
|
||||||
user: User;
|
|
||||||
shopInfo: ShopInfo;
|
|
||||||
selCoupon: selCoupon[];
|
|
||||||
goodsOrderPrice: number; //商品订单总价
|
|
||||||
isMemberPrice: number; // 是否开启会员价 1是开启
|
|
||||||
limitTimeDiscount?: TimeLimitDiscountConfig | null | undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
//限时折扣配置
|
|
||||||
export interface TimeLimitDiscountConfig {
|
|
||||||
/**
|
|
||||||
* 折扣优先级 limit-time/vip-price
|
|
||||||
*/
|
|
||||||
discountPriority: string;
|
|
||||||
/**
|
|
||||||
* 折扣% 范围1-99
|
|
||||||
*/
|
|
||||||
discountRate: number;
|
|
||||||
/**
|
|
||||||
* 参与商品
|
|
||||||
*/
|
|
||||||
foods: string;
|
|
||||||
/**
|
|
||||||
* 参与商品 1全部 2部分
|
|
||||||
*/
|
|
||||||
foodType: number;
|
|
||||||
/**
|
|
||||||
* 自增主键
|
|
||||||
*/
|
|
||||||
id: number;
|
|
||||||
/**
|
|
||||||
* 店铺ID
|
|
||||||
*/
|
|
||||||
shopId: number;
|
|
||||||
/**
|
|
||||||
* 可使用类型:堂食 dine-in 外带 take-out 外卖 take-away 配送 post
|
|
||||||
*/
|
|
||||||
useType: string;
|
|
||||||
[property: string]: any;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface CanDikouGoodsArrArgs {
|
|
||||||
canDikouGoodsArr: Goods[];
|
|
||||||
selCoupon: selCoupon[];
|
|
||||||
user: User;
|
|
||||||
shopInfo: ShopInfo;
|
|
||||||
limitTimeDiscount?: TimeLimitDiscountConfig | null | undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断商品是否可以使用限时折扣
|
|
||||||
* @param goods 商品对象
|
|
||||||
* @param limitTimeDiscountRes 限时折扣配置
|
|
||||||
* @param shopInfo 店铺信息
|
|
||||||
* @param shopUserInfo 店铺用户信息
|
|
||||||
* @param idKey 商品ID键名,默认"id"
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
export function canUseLimitTimeDiscount(
|
|
||||||
goods: Goods,
|
|
||||||
limitTimeDiscountRes: TimeLimitDiscountConfig | null | undefined,
|
|
||||||
shopInfo: ShopInfo,
|
|
||||||
shopUserInfo: User,
|
|
||||||
idKey = "id"
|
|
||||||
) {
|
|
||||||
shopInfo = shopInfo || {};
|
|
||||||
shopUserInfo = shopUserInfo || {};
|
|
||||||
if (!limitTimeDiscountRes || !limitTimeDiscountRes.id) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const canUseFoods = (limitTimeDiscountRes.foods || "").split(",");
|
|
||||||
|
|
||||||
const goodsCanUse =
|
|
||||||
limitTimeDiscountRes.foodType == 1 ||
|
|
||||||
canUseFoods.includes(`${goods[idKey]}`);
|
|
||||||
if (!goodsCanUse) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (limitTimeDiscountRes.discountPriority == "limit-time") {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (limitTimeDiscountRes.discountPriority == "vip-price") {
|
|
||||||
if (goods.id == 727) {
|
|
||||||
console.log('goods', goods);
|
|
||||||
console.log('shopUserInfo', shopUserInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (shopUserInfo.isVip != 1 || shopUserInfo.isMemberPrice != 1) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
|
||||||
shopUserInfo.isVip == 1 &&
|
|
||||||
shopUserInfo.isMemberPrice == 1 &&
|
|
||||||
goods.memberPrice * 1 <= 0
|
|
||||||
) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
export interface CanDikouGoodsArrArgs {
|
|
||||||
goods: Goods;
|
|
||||||
shopInfo: ShopInfo;
|
|
||||||
limitTimeDiscountRes: TimeLimitDiscountConfig | null | undefined;
|
|
||||||
shopUserInfo: User;
|
|
||||||
idKey?: string;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 返回商品显示价格
|
|
||||||
* @params {*} args 参数对象
|
|
||||||
* @params {*} args.goods 商品对象
|
|
||||||
* @params {*} args.shopInfo 店铺信息
|
|
||||||
* @params {*} args.limitTimeDiscountRes 限时折扣信息
|
|
||||||
* @params {*} args.shopUserInfo 店铺用户信息
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
export function returnPrice(args: CanDikouGoodsArrArgs) {
|
|
||||||
let {
|
|
||||||
goods,
|
|
||||||
shopInfo,
|
|
||||||
limitTimeDiscountRes,
|
|
||||||
shopUserInfo,
|
|
||||||
idKey = "product_id",
|
|
||||||
} = args;
|
|
||||||
limitTimeDiscountRes = limitTimeDiscountRes || {
|
|
||||||
foods: "",
|
|
||||||
foodType: 2,
|
|
||||||
discountPriority: "",
|
|
||||||
discountRate: 0,
|
|
||||||
id: 0,
|
|
||||||
shopId: 0,
|
|
||||||
useType: "",
|
|
||||||
};
|
|
||||||
const canUseFoods = (limitTimeDiscountRes.foods || "").split(",");
|
|
||||||
const includesGoods =
|
|
||||||
limitTimeDiscountRes.foodType == 1 ||
|
|
||||||
canUseFoods.includes("" + goods[idKey]);
|
|
||||||
|
|
||||||
shopInfo = shopInfo || {};
|
|
||||||
shopUserInfo = shopUserInfo || {};
|
|
||||||
if (
|
|
||||||
shopUserInfo.isMemberPrice == 1 &&
|
|
||||||
shopUserInfo.isVip == 1 &&
|
|
||||||
shopInfo.isMemberPrice == 1
|
|
||||||
) {
|
|
||||||
|
|
||||||
const memberPrice = goods.memberPrice || goods.salePrice;
|
|
||||||
|
|
||||||
//是会员而且启用会员价
|
|
||||||
if (limitTimeDiscountRes) {
|
|
||||||
//使用限时折扣
|
|
||||||
//限时折扣优先
|
|
||||||
if (limitTimeDiscountRes.discountPriority == "limit-time") {
|
|
||||||
if (includesGoods) {
|
|
||||||
return returnLimitPrice({
|
|
||||||
price: goods.salePrice,
|
|
||||||
limitTimeDiscountRes,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
return memberPrice;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
limitTimeDiscountRes.discountPriority == "vip-price" &&
|
|
||||||
includesGoods
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (goods.memberPrice * 1 > 0) {
|
|
||||||
//会员优先
|
|
||||||
return memberPrice;
|
|
||||||
} else {
|
|
||||||
const price = returnLimitPrice({
|
|
||||||
price: goods.salePrice,
|
|
||||||
limitTimeDiscountRes,
|
|
||||||
goods: goods,
|
|
||||||
});
|
|
||||||
|
|
||||||
return price;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return memberPrice;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//是会员没有限时折扣
|
|
||||||
return memberPrice;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// console.log('不是会员或者没有启用会员价',goods,limitTimeDiscountRes);
|
|
||||||
|
|
||||||
//不是会员或者没有启用会员价
|
|
||||||
if (limitTimeDiscountRes && limitTimeDiscountRes.id && includesGoods) {
|
|
||||||
const price = returnLimitPrice({
|
|
||||||
price: goods.salePrice,
|
|
||||||
limitTimeDiscountRes,
|
|
||||||
goods: goods,
|
|
||||||
});
|
|
||||||
return price;
|
|
||||||
} else {
|
|
||||||
return goods.salePrice;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
interface returnLimitPriceArgs {
|
|
||||||
limitTimeDiscountRes: TimeLimitDiscountConfig | null | undefined;
|
|
||||||
price: number;
|
|
||||||
goods?: Goods;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 返回限时折扣价格
|
|
||||||
* @params {*} args 参数对象
|
|
||||||
* @params {*} args.limitTimeDiscountRes 限时折扣信息
|
|
||||||
* @params {*} args.price 商品价格
|
|
||||||
* @param {*} args.goods 商品对象
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
export function returnLimitPrice(args: returnLimitPriceArgs) {
|
|
||||||
const { limitTimeDiscountRes, price, goods } = args;
|
|
||||||
const discountRate = new BigNumber(
|
|
||||||
limitTimeDiscountRes ? limitTimeDiscountRes.discountRate : 100
|
|
||||||
).dividedBy(100);
|
|
||||||
|
|
||||||
const result = BigNumber(price)
|
|
||||||
.times(discountRate)
|
|
||||||
.decimalPlaces(2, BigNumber.ROUND_UP)
|
|
||||||
.toNumber();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断是否返回会员价
|
|
||||||
* @param {*} args 参数对象
|
|
||||||
* @param {*} args.shopInfo 店铺信息
|
|
||||||
* @param {*} args.shopUserInfo 店铺用户信息
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
interface CanReturnMemberPriceArgs {
|
|
||||||
shopInfo?: ShopInfo;
|
|
||||||
shopUserInfo: User;
|
|
||||||
}
|
|
||||||
export function canReturnMemberPrice(args: CanReturnMemberPriceArgs) {
|
|
||||||
const { shopInfo, shopUserInfo } = args;
|
|
||||||
if (shopUserInfo.isMemberPrice == 1 && shopUserInfo.isVip == 1) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回会员价格
|
|
||||||
* @param {*} goods
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
export function returnMemberPrice(goods: Goods) {
|
|
||||||
return goods.memberPrice || goods.salePrice;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const utils = {
|
|
||||||
returnPrice,
|
|
||||||
canUseLimitTimeDiscount,
|
|
||||||
returnLimitPrice,
|
|
||||||
canReturnMemberPrice,
|
|
||||||
returnMemberPrice,
|
|
||||||
};
|
|
||||||
|
|
||||||
export default utils;
|
|
||||||
@@ -28,6 +28,7 @@
|
|||||||
<div class="flex u-col-top">
|
<div class="flex u-col-top">
|
||||||
<div class="img">
|
<div class="img">
|
||||||
<div class="xszk" v-if="item.isLimitDiscount || item.is_time_discount">限时折扣</div>
|
<div class="xszk" v-if="item.isLimitDiscount || item.is_time_discount">限时折扣</div>
|
||||||
|
<!-- <div class="xszk" v-if="cartStore.useVipPrice">会员价</div> -->
|
||||||
<div class="isSeatFee img u-line-1 u-flex u-col-center u-row-center" v-if="isSeatFee">
|
<div class="isSeatFee img u-line-1 u-flex u-col-center u-row-center" v-if="isSeatFee">
|
||||||
<span>{{ item.name }}</span>
|
<span>{{ item.name }}</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -109,9 +110,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<div v-if="item.isLimitDiscount || item.is_time_discount">
|
<div v-if="item.is_time_discount">
|
||||||
<div>
|
<div>
|
||||||
¥{{ to2(item.limitDiscountPrice) }}
|
¥{{ to2(item.time_discount_price) }}
|
||||||
</div>
|
</div>
|
||||||
<div class="free-price">
|
<div class="free-price">
|
||||||
<span>¥{{ to2(item.salePrice) }}</span>
|
<span>¥{{ to2(item.salePrice) }}</span>
|
||||||
@@ -135,6 +136,9 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { customTruncateToTwoDecimals } from "@/views/tool/Instead/util";
|
import { customTruncateToTwoDecimals } from "@/views/tool/Instead/util";
|
||||||
|
import { useCartsStore } from '@/store/modules/carts'
|
||||||
|
|
||||||
|
const cartStore = useCartsStore()
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
dinerType: {
|
dinerType: {
|
||||||
|
|||||||
@@ -3,23 +3,23 @@
|
|||||||
<el-image v-if="item.coverImg" class="goods-image"
|
<el-image v-if="item.coverImg" class="goods-image"
|
||||||
:src="item.coverImg + '?x-oss-process=image/resize,m_lfit,w_100,h_100'" fit="cover"></el-image>
|
:src="item.coverImg + '?x-oss-process=image/resize,m_lfit,w_100,h_100'" fit="cover"></el-image>
|
||||||
<div class="info" @click="itemClick">
|
<div class="info" @click="itemClick">
|
||||||
<div class="dot" v-if="item.isLimitDiscount">限时折扣</div>
|
<div class="dot" v-if="item.is_time_discount">限时折扣</div>
|
||||||
<div class="dot" v-if="cartStore.useVipPrice">会员价</div>
|
<!-- <div class="dot" v-if="cartStore.useVipPrice">会员价</div> -->
|
||||||
<div class="btm">
|
<div class="btm">
|
||||||
<div class="name u-flex u-flex-wrap">
|
<div class="name u-flex u-flex-wrap">
|
||||||
<span class="weight" v-if="item.type == 'weight'">称重</span>
|
<span class="weight" v-if="item.type == 'weight'">称重</span>
|
||||||
<span class="u-line-3">{{ item.name }}</span>
|
<span class="u-line-3">{{ item.name }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="limit_wrap" v-if="item.isLimitDiscount">
|
<div class="limit_wrap" v-if="item.is_time_discount">
|
||||||
<span class="o_price">¥{{ item.lowPrice }}</span>
|
<span class="o_price">¥{{ item.lowPrice }}</span>
|
||||||
<span class="sale_price">¥{{ item.limitDiscountPrice }}</span>
|
<span class="sale_price">¥{{ item.time_discount_price }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="limit_wrap" v-else>
|
<div class="limit_wrap" v-else>
|
||||||
<template v-if="cartStore.useVipPrice">
|
<template v-if="cartStore.useVipPrice">
|
||||||
<span class="o_price">¥{{ item.lowPrice }}</span>
|
<span class="o_price">¥{{ item.lowPrice }}</span>
|
||||||
<span>¥{{ item.lowMemberPrice }}</span>
|
<span>¥{{ item.lowMemberPrice }}</span>
|
||||||
</template>
|
</template>
|
||||||
<template>
|
<template v-else>
|
||||||
¥{{ item.lowPrice }}
|
¥{{ item.lowPrice }}
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -175,6 +175,10 @@
|
|||||||
<span class="title">商品优惠券</span>
|
<span class="title">商品优惠券</span>
|
||||||
<span class="u-m-l-10 value">-¥{{ productCouponDiscountAmount }}</span>
|
<span class="u-m-l-10 value">-¥{{ productCouponDiscountAmount }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="u-flex u-m-b-10 u-row-between">
|
||||||
|
<span class="title">会员折扣</span>
|
||||||
|
<span class="u-m-l-10 value">-¥{{ carts.orderCostSummary.vipDiscountAmount }}</span>
|
||||||
|
</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">-¥{{ fullCouponDiscountAmount }}</span>
|
<span class="u-m-l-10 value">-¥{{ fullCouponDiscountAmount }}</span>
|
||||||
|
|||||||
@@ -6,20 +6,21 @@
|
|||||||
<span class="title">代客下单</span>
|
<span class="title">代客下单</span>
|
||||||
<div class="u-m-l-20 flex">
|
<div class="u-m-l-20 flex">
|
||||||
<div class="choose-user flex u-font-14" @click="showChooseUser">
|
<div class="choose-user flex u-font-14" @click="showChooseUser">
|
||||||
<el-button type="primary" v-if="!user.id">选择用户</el-button>
|
<el-button type="primary" v-if="!carts.vipUser.id">选择用户</el-button>
|
||||||
|
|
||||||
<div v-else class="flex cur-pointer">
|
<div v-else class="flex cur-pointer">
|
||||||
<img v-if="user.headImg && user.headImg != 'null'" class="headimg" :src="user.headImg" alt="" />
|
<img v-if="carts.vipUser.headImg && carts.vipUser.headImg != 'null'" class="headimg"
|
||||||
|
:src="carts.vipUser.headImg" alt="" />
|
||||||
<div v-else class="headimg flex flex-x-y-center">
|
<div v-else class="headimg flex flex-x-y-center">
|
||||||
<i class="el-icon-user"></i>
|
<i class="el-icon-user"></i>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div class="u-flex">
|
<div class="u-flex">
|
||||||
<div class="ft-13 color-000 no-wrap">{{ user.nickName }}</div>
|
<div class="ft-13 color-000 no-wrap">{{ carts.vipUser.nickName }}</div>
|
||||||
<div class="vip" v-if="user.isVip">VIP{{ user.isVip }}</div>
|
<div class="vip" v-if="carts.vipUser.isVip">{{ carts.vipUser.memberLevelName }}</div>
|
||||||
</div>
|
</div>
|
||||||
<div style="margin-top: 2px" class="no-wrap color-666 ft-12">
|
<div style="margin-top: 2px" class="no-wrap color-666 ft-12">
|
||||||
余额:{{ user.amount }}
|
余额:{{ carts.vipUser.amount }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -711,9 +712,6 @@ function clearCarts() {
|
|||||||
}
|
}
|
||||||
function addCarts(item, isWeight = false) {
|
function addCarts(item, isWeight = false) {
|
||||||
console.log('index.addCarts===', item);
|
console.log('index.addCarts===', item);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (isWeight) {
|
if (isWeight) {
|
||||||
carts.add({ pack_number: diners.sel ? 1 : 0, ...item, is_time_discount: item.isLimitDiscount ? 1 : 0 });
|
carts.add({ pack_number: diners.sel ? 1 : 0, ...item, is_time_discount: item.isLimitDiscount ? 1 : 0 });
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user