Merge branch 'ymf' of https://newgitea.sxczgkj.cn/czg_team/cashier-web into gyq
This commit is contained in:
commit
b65955f2cc
|
|
@ -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 服务
|
||||||
|
|
|
||||||
|
|
@ -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```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
/**
|
/**
|
||||||
* 是否启用会员价 0否1是
|
* 是否启用会员价 0否1是
|
||||||
*/
|
*/
|
||||||
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;
|
||||||
/**
|
/**
|
||||||
* 是否免除桌位费 0否1是
|
* 是否免除桌位费 0否1是
|
||||||
*/
|
*/
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
@ -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";
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
|
|
||||||
|
|
@ -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
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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,
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue