diff --git a/.env.development b/.env.development index d76eab7..238e42b 100644 --- a/.env.development +++ b/.env.development @@ -5,10 +5,10 @@ ENV = development # VITE_API_WSS = 'wss://sockets.sxczgkj.com/wss' # 正式ws -# VITE_API_WSS = 'wss://czgeatws.sxczgkj.com/wss' +VITE_API_WSS = 'wss://czgeatws.sxczgkj.com/wss' # 本地ws -VITE_API_WSS = 'ws://192.168.1.43:2348' +# VITE_API_WSS = 'ws://192.168.1.43:2348' # 正式 php VITE_API_PHP_URL = 'https://newblockwlx.sxczgkj.cn/index.php/api' @@ -35,11 +35,11 @@ VITE_API_KP_URL = 'https://invoice.sxczgkj.cn/api' # VITE_API_URL = 'http://192.168.1.35/' # 阿伟 -VITE_API_URL = 'http://192.168.1.21:8000/' +# VITE_API_URL = 'http://192.168.1.21:8000/' # 测试 # VITE_API_URL = 'https://tapi.cashier.sxczgkj.cn' # 正式 -# VITE_API_URL = 'https://cashier.sxczgkj.com' +VITE_API_URL = 'https://cashier.sxczgkj.com' diff --git a/src/api/account.js b/src/api/account.js index 9b25301..1aad1e8 100644 --- a/src/api/account.js +++ b/src/api/account.js @@ -382,3 +382,14 @@ export function calcDeductionAmount(params) { params, }); } + +/** + * 获取店铺用户详情 + */ +export function shopUserDetail(params) { + return request({ + method: "get", + url: "/account/admin/shopUser/detail", + params, + }); +} diff --git a/src/components/payCard/payCard.vue b/src/components/payCard/payCard.vue index e07fd2a..8f9bff9 100644 --- a/src/components/payCard/payCard.vue +++ b/src/components/payCard/payCard.vue @@ -226,7 +226,7 @@ - + @@ -708,8 +708,10 @@ async function selectUserHandle(row) { goodsStore.vipUserInfo = { ...row } // 选择会员后重新计算会员价 if (store.shopInfo.isMemberPrice && row.isVip) { + console.log('选择会员后重新计算会员价===', row); goodsStore.showVipPrice = 1 } + goodsStore.calcCartInfo() emit('reset') @@ -717,11 +719,10 @@ async function selectUserHandle(row) { couponForm.value.discountRatio = '' discountInput('') - setTimeout(() => { - couponDialogOpen() - }, 100) - if (showCoupon.value) { + setTimeout(() => { + couponDialogOpen() + }, 100) couponFormUserList.value = [ { id: row.userId, @@ -737,7 +738,9 @@ async function selectUserHandle(row) { } } else { if (payList.value[payActive.value].payType == 'member-account') { - vipPayAjax(row) + setTimeout(() => { + vipPayAjax(row) + }, 500) } } } catch (error) { diff --git a/src/components/selectVipUser.vue b/src/components/selectVipUser.vue index 1d687e6..6739776 100644 --- a/src/components/selectVipUser.vue +++ b/src/components/selectVipUser.vue @@ -5,7 +5,7 @@ - + @@ -43,6 +43,13 @@ import { ref, reactive } from 'vue' import { shopUserList } from "@/api/account.js"; import { formatDecimal } from '@/utils/index.js' +const props = defineProps({ + amount: { + type: Number, + default: 0 + } +}) + const emits = defineEmits(['success']) const showDialog = ref(false) const tableData = reactive({ @@ -68,6 +75,12 @@ async function toHomeMember(row) { // 重置表格 function resetTable() { tableData.phone = '' + tableData.isVips = '' + tableData.page = 1 + getMemberList() +} + +function changeIsVips() { tableData.page = 1 getMemberList() } @@ -80,14 +93,17 @@ async function getMemberList() { key: tableData.phone, isVips: tableData.isVips, page: tableData.page, - size: tableData.size + size: tableData.size, + amount: props.amount }) tableData.list = res.records tableData.total = res.totalRow } catch (error) { console.log(error); } - tableData.loading = false + setTimeout(() => { + tableData.loading = false + }, 500); } // 显示选择会员弹窗 diff --git a/src/store/goods.js b/src/store/goods.js index 9f96087..25dc157 100644 --- a/src/store/goods.js +++ b/src/store/goods.js @@ -7,6 +7,7 @@ import { useUser } from "@/store/user.js"; import { useSocket } from "@/store/socket.js"; import useStorage from "@/utils/useStorage.js"; import { formatDecimal } from "@/utils/index.js"; +import { shopUserDetail } from "@/api/account.js"; // 商品store + 购物车store export const useGoods = defineStore("goods", { @@ -15,10 +16,10 @@ export const useGoods = defineStore("goods", { allSelected: 0, // 是否整单打包 vipUserInfo: {}, // 会员信息 // tableInfo: { - // name: "A1", - // id: 1, - // num: 4, - // tableCode: "66666666", + // name: "测试A1", + // id: 185, + // num: 1, + // tableCode: "3000101010", // }, // 台桌信息 tableInfo: { id: "", @@ -52,6 +53,15 @@ export const useGoods = defineStore("goods", { pendingList: useStorage.get("pendingList") || [], }), actions: { + // 清除所有商品信息 + clearAllGoods() { + this.categoryIndex = 0; + this.categoryList = []; + this.originCategoryList = []; + this.goodsListLoading = false; + this.goodsList = []; + this.originGoodsList = []; + }, // 清除会员信息 clearVipUserInfo() { this.vipUserInfo = {}; @@ -171,6 +181,19 @@ export const useGoods = defineStore("goods", { }); if (res) { + if (res.userId) { + const userInfo = await shopUserDetail({ + userId: res.userId, + }); + if (userInfo.id) { + this.vipUserInfo = userInfo; + + if (userInfo.isVip) { + this.showVipPrice = 1; + } + } + } + this.orderListInfo = res; let arr = []; @@ -353,7 +376,7 @@ export const useGoods = defineStore("goods", { // ) { // await this.historyOrderAjax(this.tableInfo.tableCode); // } - // this.calcCartInfo(); + this.calcCartInfo(); console.log("getCartList.cartList===", this.cartList); } catch (error) { console.log("getCartList===", error); @@ -598,17 +621,15 @@ export const useGoods = defineStore("goods", { } // 清空商品列表的角标 - // this.goodsList.map((item) => { - // item.map((val) => { - // val.number = 0; - // }); - // }); + if (!this.cartList.length && !this.orderList.length) { + this.updateGoodsNumber(); + } }, // 下单成功清除购物车,重新加载订单 async updateOrderList() { await this.historyOrderAjax(this.cartList[0].table_code); this.cartList = []; - // this.calcCartInfo(); + this.calcCartInfo(); }, // 计算购物车信息 calcCartInfo() { @@ -643,13 +664,15 @@ export const useGoods = defineStore("goods", { console.log("arr===11111", arr); arr.map((val, index) => { - console.log("val===", val); - let lowPrice = 0; let number = val.number - (val.returnNum || 0); if (this.vipUserInfo.id && store.shopInfo.isMemberPrice) { - lowPrice = val.memberPrice; + if (!+val.memberPrice) { + lowPrice = val.lowPrice; + } else { + lowPrice = +val.memberPrice; + } } else { lowPrice = val.lowPrice; } diff --git a/src/store/socket.js b/src/store/socket.js index 576efef..69709d8 100644 --- a/src/store/socket.js +++ b/src/store/socket.js @@ -117,6 +117,11 @@ export const useSocket = defineStore("socket", { break; case "cleanup": // 清空购物车 + if ( + data.data.table_code == goodsStore.orderListInfo.tableCode && + !data.type + ) + return; goodsStore.successClearCart(); break; case "batch": @@ -169,7 +174,7 @@ export const useSocket = defineStore("socket", { startheartbeat() { this.heartbeatTimer = setInterval(() => { if (this.log) console.log("发送心跳"); - this.ws.send(JSON.stringify({ type: "ping_interval" })); + this.ws.send(JSON.stringify({ type: "ping_interval", set: "cashier" })); }, 10000); }, // 清除心跳 @@ -190,7 +195,10 @@ export const useSocket = defineStore("socket", { } else { const orderInfo = await getOrderByIdAjax(this.orderList[0]); if (orderInfo.status == "done" && orderInfo.platformType != "PC") { + // 打印小票 printStore.pushReceiptData(commOrderPrintData(orderInfo)); + // 打印标签小票 + printStore.labelPrint(commOrderPrintData(orderInfo)); } this.orderList.splice(0, 1); } diff --git a/src/views/group_buy/index.vue b/src/views/group_buy/index.vue index 6d59928..0cb58de 100644 --- a/src/views/group_buy/index.vue +++ b/src/views/group_buy/index.vue @@ -70,7 +70,7 @@ - + diff --git a/src/views/home/components/cartItem.vue b/src/views/home/components/cartItem.vue index 1822a5f..f8af408 100644 --- a/src/views/home/components/cartItem.vue +++ b/src/views/home/components/cartItem.vue @@ -9,7 +9,8 @@ ¥{{ formatDecimal(+props.item.discount_sale_amount, 2, true) }} - ¥{{ formatDecimal(goodsStore.showVipPrice ? +props.item.memberPrice : +props.item.lowPrice, 2, + ¥{{ formatDecimal(goodsStore.showVipPrice ? +props.item.memberPrice || +props.item.lowPrice : + +props.item.lowPrice, 2, true) }} @@ -26,7 +27,7 @@
- ¥{{ formatDecimal(goodsStore.showVipPrice ? +props.item.memberPrice : +props.item.lowPrice, + ¥{{ formatDecimal(goodsStore.showVipPrice ? +props.item.memberPrice || +props.item.lowPrice : +props.item.lowPrice, 2, true) }} diff --git a/src/views/home/components/goods.vue b/src/views/home/components/goods.vue index 494dab4..b5e7a6a 100644 --- a/src/views/home/components/goods.vue +++ b/src/views/home/components/goods.vue @@ -89,7 +89,7 @@
diff --git a/src/views/home/components/settleAccount.vue b/src/views/home/components/settleAccount.vue index 36957d4..2e0ae13 100644 --- a/src/views/home/components/settleAccount.vue +++ b/src/views/home/components/settleAccount.vue @@ -243,7 +243,6 @@ function show(t) { setTimeout(() => { payCardRef.value.reset() }, 100) - // if (t = 1) cartList.value = [...goodsStore.cartList]; } defineExpose({ diff --git a/src/views/home/index.vue b/src/views/home/index.vue index 4ec599a..0696bcf 100644 --- a/src/views/home/index.vue +++ b/src/views/home/index.vue @@ -270,6 +270,8 @@ async function createOrderHandle(t = 0) { goodsStore.orderListInfo = res if (t == 1) { + // 向其他端发送清空购物车消息 + goodsStore.operateCart({ table_code: goodsStore.orderListInfo.tableCode }, "cleanup"); settleAccountRef.value.show(t) } else { goodsStore.clearCart() diff --git a/src/views/work/index.vue b/src/views/work/index.vue index 1ecfe85..43761fb 100644 --- a/src/views/work/index.vue +++ b/src/views/work/index.vue @@ -149,8 +149,10 @@ import { useRouter } from "vue-router"; import { useUser } from "@/store/user.js"; import { formatDecimal } from '@/utils/index.js' import { usePrint } from "@/store/print.js"; +import { useGoods } from "@/store/goods.js"; import { staffPermission } from '@/api/user.js' +const goodsStore = useGoods(); const printStore = usePrint(); const store = useUser(); const router = useRouter(); @@ -200,6 +202,7 @@ async function logoutHandle() { try { loading.value = true; await store.logout() + goodsStore.clearAllGoods() ElMessage.success("交班成功"); setTimeout(() => { router.replace({