From 3df0cce9ecd1c3eda3d482bfe6cfe7eda821932b Mon Sep 17 00:00:00 2001
From: gyq <875626088@qq.com>
Date: Tue, 11 Mar 2025 09:10:49 +0800
Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E6=8E=A5=E6=94=AF=E4=BB=98=E4=BC=98?=
=?UTF-8?q?=E6=83=A0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.env.development | 7 +-
.env.production | 2 +-
src/App.vue | 6 +-
src/api/account.js | 150 +++++
src/api/order.js | 41 +-
src/components/classify/index.vue | 75 ++-
src/components/leftMenu.vue | 2 +-
src/components/lodop/lodopPrintWork.js | 103 +--
src/components/more.vue | 12 +-
src/components/payCard/couponModal.vue | 216 +++++++
src/components/payCard/payCard.vue | 620 +++++++++++++++----
src/components/payCard/scanModal.vue | 23 +-
src/components/selectVipUser.vue | 26 +-
src/store/goods.js | 17 +-
src/store/print.js | 94 +--
src/store/socket.js | 11 +-
src/store/user.js | 41 +-
src/utils/index.js | 24 +-
src/utils/request.js | 4 +-
src/views/device/add.vue | 182 +++---
src/views/device/add_label.vue | 106 ++--
src/views/device/index.vue | 22 +-
src/views/home/components/settleAccount.vue | 152 ++---
src/views/home/components/settleItem.vue | 5 -
src/views/home/index.vue | 52 +-
src/views/login.vue | 4 +-
src/views/member/components/recordDialog.vue | 4 +-
src/views/order/components/printDrawer.vue | 45 +-
src/views/table/components/tableInfo.vue | 25 +-
src/views/work/index.vue | 145 ++---
src/views/work/record.vue | 157 ++---
31 files changed, 1527 insertions(+), 846 deletions(-)
create mode 100644 src/components/payCard/couponModal.vue
diff --git a/.env.development b/.env.development
index 781df07..5edb718 100644
--- a/.env.development
+++ b/.env.development
@@ -11,7 +11,7 @@ VITE_API_WSS = 'wss://sockets.sxczgkj.com/wss'
# VITE_API_WSS = 'ws://192.168.2.17:9998/client'
# 正式 php
-VITE_API_PHP_URL = 'https://czgdoumei.sxczgkj.com/index.php/api'
+VITE_API_PHP_URL = 'https://newblockwlx.sxczgkj.cn/index.php/api'
# 测试 php 开票
# VITE_API_KP_URL = 'http://192.168.1.13:8888/api'
@@ -34,9 +34,12 @@ VITE_API_KP_URL = 'https://invoice.sxczgkj.cn/api'
# 张松本地
# VITE_API_URL = 'https://36z1017t45.goho.co/cashier-client'
+# 谭凯凯
+VITE_API_URL = 'http://192.168.1.35/'
+
# 正式
# VITE_API_URL = 'https://cashierclient.sxczgkj.cn/cashier-client'
# 正式
-VITE_API_URL = 'https://tapi.cashier.sxczgkj.cn'
+# VITE_API_URL = 'https://tapi.cashier.sxczgkj.cn'
diff --git a/.env.production b/.env.production
index 7aa9f5d..ec77084 100644
--- a/.env.production
+++ b/.env.production
@@ -5,7 +5,7 @@ ENV = production
VITE_API_WSS = 'wss://cashier.sxczgkj.cn/client'
# 正式 php
-VITE_API_PHP_URL = 'https://czgdoumei.sxczgkj.com/index.php/api'
+VITE_API_PHP_URL = 'https://newblockwlx.sxczgkj.cn/index.php/api'
# 正式 php 开票
VITE_API_KP_URL = 'https://invoice.sxczgkj.cn/api'
diff --git a/src/App.vue b/src/App.vue
index c7b11da..fc1fb9e 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -36,15 +36,10 @@ import { ipcRenderer } from 'electron';
import { useGoods } from '@/store/goods.js'
const goodsStore = useGoods()
-
const socket = useSocket();
-
const global = useGlobal();
-
const leftMenuRef = ref(null);
-
const store = useUser();
-
const route = useRoute();
const includeList = reactive([]);
@@ -177,6 +172,7 @@ onMounted(() => {
// 防止刷新页面长连接丢失
if (store.userInfo && store.userInfo.id) {
goodsStore.initGoods()
+ store.getShopInfo()
}
ipcRenderer.on('showCloseDialog', (event, arg) => {
diff --git a/src/api/account.js b/src/api/account.js
index fc1ea75..236d938 100644
--- a/src/api/account.js
+++ b/src/api/account.js
@@ -13,6 +13,19 @@ export function login(data) {
});
}
+/**
+ * 退出登录
+ * @param {*} data
+ * @returns
+ */
+export function logout(data) {
+ return request({
+ method: "post",
+ url: "/account/admin/auth/logout",
+ data,
+ });
+}
+
/**
* 验证码获取
* @param {*} params
@@ -39,6 +52,19 @@ export function shopInfo_detail(params) {
});
}
+/**
+ * 获取当前店铺拓展通过key
+ * @param {*} params
+ * @returns
+ */
+export function shopExtendDetail(params) {
+ return request({
+ method: "get",
+ url: "/account/admin/shopExtend/detail",
+ params,
+ });
+}
+
/**
* 获取店铺用户列表
* @param {*} params
@@ -232,3 +258,127 @@ export function callTableCallState(data) {
data,
});
}
+
+/**
+ * 收银机-交班数据统计
+ */
+export function handoverTotal(params) {
+ return request({
+ method: "get",
+ url: "/account/admin/handover-record/total",
+ params,
+ });
+}
+
+/**
+ * 收银机-交班
+ */
+export function handover(isPrint) {
+ return request({
+ method: "post",
+ url: "/account/admin/handover-record/handover?isPrint=" + isPrint,
+ });
+}
+
+/**
+ * 收银机-交班记录-详情
+ */
+export function handoverData(id) {
+ return request({
+ method: "get",
+ url: `/account/admin/handover-record/detail/${id}`,
+ });
+}
+
+/**
+ * 交班记录-分页
+ */
+export function handoverRecordPage(params) {
+ return request({
+ method: "get",
+ url: `/account/admin/handover-record/page`,
+ params,
+ });
+}
+
+/**
+ * 收银机-交班/关班-网络打印机打印交班小票
+ */
+export function handoverNetworkPrint(id) {
+ return request({
+ method: "post",
+ url: `/account/admin/handover-record/network/print/${id}`,
+ });
+}
+
+/**
+ * 打印机列表
+ */
+export function printerList(subType = "") {
+ return request({
+ method: "get",
+ url: "/account/admin/printer",
+ params: {
+ name: "",
+ subType: subType,
+ connectionType: "USB",
+ page: 1,
+ size: 100,
+ },
+ });
+}
+
+/**
+ * 打印机详情
+ */
+export function printerDetail(params) {
+ return request({
+ method: "get",
+ url: "/account/admin/printer/detail",
+ params,
+ });
+}
+
+/**
+ * 新增打印机
+ */
+export function printerAdd(data, method = "post") {
+ return request({
+ method: method,
+ url: "/account/admin/printer",
+ data,
+ });
+}
+
+/**
+ * 查找优惠券 生成订单后使用
+ */
+export function findCoupon(params) {
+ return request({
+ method: "get",
+ url: "/account/admin/coupon/findCoupon",
+ params,
+ });
+}
+
+/**
+ * 002-获取订单可用积分及抵扣金额(支付页面使用)
+ */
+export function calcUsablePoints(params) {
+ return request({
+ method: "get",
+ url: "/account/admin/points/memberPoints/calcUsablePoints",
+ params,
+ });
+}
+
+/**
+ * 003-根据积分计算可抵扣金额
+ */
+export function calcDeductionAmount(params) {
+ return request({
+ method: "get",
+ url: "/account/admin/points/memberPoints/calcDeductionAmount",
+ params,
+ });
+}
diff --git a/src/api/order.js b/src/api/order.js
index 8e895e1..3b14d71 100644
--- a/src/api/order.js
+++ b/src/api/order.js
@@ -99,7 +99,7 @@ export function refundOrder(data) {
export function getOrderById(params) {
return request({
method: "get",
- url: "/order/admin/order/getOrderById",
+ url: "/order/admin/order/getOrderByIdPrint",
params,
});
}
@@ -155,3 +155,42 @@ export function refundVip(data) {
data,
});
}
+
+/**
+ * 挂账人 - 分页
+ * @param {*} data
+ * @returns
+ */
+export function buyerPage(params) {
+ return request({
+ method: "get",
+ url: "/order/admin/order/credit/buyer/page",
+ params,
+ });
+}
+
+/**
+ * 挂账人 - 付款
+ * @param {*} data
+ * @returns
+ */
+export function creditPay(data) {
+ return request({
+ method: "post",
+ url: "/order/pay/creditPay",
+ data,
+ });
+}
+
+/**
+ * 挂账人 - 会员支付订单
+ * @param {*} data
+ * @returns
+ */
+export function vipPay(data) {
+ return request({
+ method: "post",
+ url: "/order/pay/vipPay",
+ data,
+ });
+}
diff --git a/src/components/classify/index.vue b/src/components/classify/index.vue
index 77984b9..88b051c 100644
--- a/src/components/classify/index.vue
+++ b/src/components/classify/index.vue
@@ -5,8 +5,8 @@
{{ item.name }}
全部
- {{ val.name }}
+
@@ -18,9 +18,11 @@
+
+
\ No newline at end of file
diff --git a/src/components/payCard/payCard.vue b/src/components/payCard/payCard.vue
index c274d97..708c767 100644
--- a/src/components/payCard/payCard.vue
+++ b/src/components/payCard/payCard.vue
@@ -7,10 +7,11 @@
{{ money }}
- 原价:¥{{ formatDecimal(props.amount) }}
+ 原价:¥{{ formatDecimal(props.amount - goodsStore.tableInfo.tableFee) }}
+ 餐位费:¥{{ formatDecimal(goodsStore.tableInfo.tableFee) }}
优惠:¥{{ formatDecimal(props.amount - money) }}
- 折扣:{{
- formatDecimal(props.discount * 10, 1, true) }}折
+
+ 折扣:{{ discountRateVlaue }}折
@@ -27,7 +28,7 @@
{{ item.payName }}
-
+
@@ -99,7 +100,7 @@
:total="Number(tableData.total)" v-model:current-page="tableData.page" @current-change="getMemberList" />
-
+
@@ -110,7 +111,7 @@
-
+
@@ -143,49 +144,128 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+ 折
+
+
+
+
+
+
+
+
选择优惠券
+
+
优惠券
+
+
+
+
+
+ 满{{ scope.row.fullAmount }}减{{ scope.row.discountAmount }}
+
+
+
+
+
+
+
+
+
+ 删除
+
+
+
+
+
+
商品券
+
+
+
+
+ {{ scope.row.productName }} ¥{{ scope.row.lowPrice }}
+
+
+
+
+
+
+
+
+
+ 删除
+
+
+
+
+
+
+
+
+ 现有积分:{{ couponFormUser.accountPoints || 0 }}
+ 可抵扣金额:¥{{ pointOptions.amount || 0 }}
+
+ 注意:订单金额不足¥{{
+ formatDecimal(+pointOptions.minPaymentAmount) }},无法使用积分抵扣
+
+
+
+
+ ¥ {{ formatDecimal(+couponForm.amount) }}
+
+
+
+
+
+
+
+
+
diff --git a/src/components/payCard/scanModal.vue b/src/components/payCard/scanModal.vue
index a69fc95..285304e 100644
--- a/src/components/payCard/scanModal.vue
+++ b/src/components/payCard/scanModal.vue
@@ -58,7 +58,7 @@ import { scanpay, queryOrder, quickPay, queryQuickPayStatus, accountPay, querySc
import { useUser } from "@/store/user.js";
import { useGlobal } from '@/store/global.js'
import { formatDecimal } from '@/utils'
-import { microPay, queryOrderStatus, microPayVip } from '@/api/order.js'
+import { microPay, queryOrderStatus, microPayVip, vipPay } from '@/api/order.js'
const store = useUser();
const global = useGlobal()
@@ -89,6 +89,7 @@ const props = defineProps({
type: Boolean,
default: false,
},
+ // 支付类型
payType: {
type: [Number, String],
default: "",
@@ -119,11 +120,20 @@ async function submitHandle() {
if (!scanCode.value) return;
loading.value = true;
if (props.selecttype == 0) {
- // 正常下单扫码支付
- await microPay({
- ...props.payData,
- authCode: scanCode.value
- });
+ // 下单扫码支付
+ if (props.payType == 'payType') {
+
+ await microPay({
+ ...props.payData,
+ authCode: scanCode.value
+ });
+ } else if (props.payType == 'deposit') {
+ await vipPay({
+ ...props.payData,
+ payType: 'scanCode',
+ authCode: scanCode.value
+ });
+ }
} else if (props.selecttype == 1) {
// 会员扫码充值
await microPayVip({
@@ -133,6 +143,7 @@ async function submitHandle() {
authCode: scanCode.value
})
} else {
+ // 快捷收银
if (props.fast) {
await quickPay({
amount: props.amount,
diff --git a/src/components/selectVipUser.vue b/src/components/selectVipUser.vue
index 1b41c94..7dd6e12 100644
--- a/src/components/selectVipUser.vue
+++ b/src/components/selectVipUser.vue
@@ -1,9 +1,16 @@
-
+
+
+
+
+
+
+
+
搜索
重置
@@ -15,7 +22,7 @@
-
+
¥{{ formatDecimal(scope.row.amount) }}
@@ -35,14 +42,12 @@
import { ref, reactive } from 'vue'
import { shopUserList } from "@/api/account.js";
import { formatDecimal } from '@/utils/index.js'
-import { useGoods } from '@/store/goods.js'
-import { useUser } from '@/store/user.js'
-const useStore = useUser()
-const goodsStore = useGoods()
+const emits = defineEmits(['success'])
const showDialog = ref(false)
const tableData = reactive({
phone: '',
+ isVips: "",
loading: false,
list: [],
page: 1,
@@ -50,15 +55,10 @@ const tableData = reactive({
total: 0
})
-
// 选择会员去下单
async function toHomeMember(row) {
try {
- goodsStore.vipUserInfo = { ...row }
- if (useStore.shopInfo.isMemberPrice) {
- goodsStore.showVipPrice = true
- goodsStore.calcCartInfo()
- }
+ emits('success', { ...row })
} catch (error) {
console.log(error);
}
@@ -78,7 +78,7 @@ async function getMemberList() {
tableData.loading = true
const res = await shopUserList({
key: tableData.phone,
- isVips: 1,
+ isVips: tableData.isVips,
page: tableData.page,
size: tableData.size
})
diff --git a/src/store/goods.js b/src/store/goods.js
index e03773a..37cb553 100644
--- a/src/store/goods.js
+++ b/src/store/goods.js
@@ -1,4 +1,4 @@
-import _, { update } from "lodash";
+import _ from "lodash";
import { defineStore } from "pinia";
import { productPage, categoryList } from "@/api/product_new.js";
import { historyOrder } from "@/api/order.js";
@@ -6,12 +6,12 @@ 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 { ElMessage } from "element-plus";
// 商品store + 购物车store
export const useGoods = defineStore("goods", {
state: () => ({
showVipPrice: false,
+ allSelected: 0, // 是否整单打包
vipUserInfo: {}, // 会员信息
tableInfo: {
name: "A1",
@@ -331,6 +331,7 @@ export const useGoods = defineStore("goods", {
.join("、");
}
+ item.product_id = item.productId;
item.lowPrice = val.lowPrice;
item.sku_name = sku && sku.specInfo;
item.group_type = val.groupType;
@@ -385,13 +386,11 @@ export const useGoods = defineStore("goods", {
this.operateCart({ table_code: tableCode }, "cleanup");
},
// 清空购物车回执操作
- successClearCart(clearOrder = false) {
+ successClearCart() {
this.cartList = [];
this.cartInfo = {};
- if (clearOrder) {
- this.orderList = [];
- this.orderListInfo = "";
- }
+ this.orderList = [];
+ this.orderListInfo = "";
this.calcCartInfo();
},
// 下单成功清除购物车,重新加载订单
@@ -504,7 +503,9 @@ export const useGoods = defineStore("goods", {
this.tableInfo.tableFee = tableFee;
}
- this.cartInfo.totalAmount = totalAmount + packFee;
+ console.log("this.tableInfo.tableFee===", tableFee);
+
+ this.cartInfo.totalAmount = totalAmount + packFee + tableFee;
console.log("this.cartInfo===", this.cartInfo);
diff --git a/src/store/print.js b/src/store/print.js
index aff51af..7b86027 100644
--- a/src/store/print.js
+++ b/src/store/print.js
@@ -1,13 +1,12 @@
import { defineStore } from "pinia";
import { ipcRenderer } from "electron";
-import { bySubType } from "@/api/device";
import { useUser } from "@/store/user.js";
-import { useShop } from "@/store/shop.js";
import dayjs from "dayjs";
import receiptPrint from "@/components/lodop/receiptPrint.js";
import lodopPrintWork from "@/components/lodop/lodopPrintWork.js";
import invoicePrint from "@/components/lodop/invoicePrint.js";
import refundPrint from "@/components/lodop/refundPrint.js";
+import { printerList } from "@/api/account.js";
export const usePrint = defineStore("print", {
state: () => ({
@@ -22,8 +21,6 @@ export const usePrint = defineStore("print", {
actions: {
// 获取本地打印机和已添加的可以用打印机列表
async init() {
- const store = useUser();
-
// 获取本地打印机
ipcRenderer.send("getPrintList");
ipcRenderer.on("printList", (event, arg) => {
@@ -32,26 +29,24 @@ export const usePrint = defineStore("print", {
this.localDevices = arg;
});
- // // 获取已添加的小票打印机
- // this.deviceNoteList = await bySubType({
- // shopId: store.userInfo.shopId,
- // contentType: "local",
- // subType: "cash",
- // });
-
- // // 获取已添加的标签打印机
- // this.deviceLableList = await bySubType({
- // shopId: store.userInfo.shopId,
- // contentType: "local",
- // subType: "label",
- // });
- console.log("打印队列初始化成功");
+ // 获取已添加的打印机
+ const res = await printerList();
+ this.deviceNoteList = res.records.filter(
+ (item) => item.status && item.subType == "cash"
+ );
+ this.deviceLableList = res.records.filter(
+ (item) => item.status && item.subType == "label"
+ );
+ console.log("打印队列初始化成功", {
+ deviceNoteList: this.deviceNoteList,
+ deviceLableList: this.deviceLableList,
+ });
},
// 检查本地打印机是否能正常使用
- checkLocalPrint(deviceName) {
+ checkLocalPrint(address) {
let print = "";
for (let item of this.localDevices) {
- if (item.name == deviceName) {
+ if (item.name == address) {
print = item;
}
}
@@ -64,16 +59,13 @@ export const usePrint = defineStore("print", {
},
// 打印标签小票
labelPrint(props) {
- const shopInfo = useShop();
+ const store = useUser();
if (
this.deviceLableList.length &&
- this.checkLocalPrint(this.deviceLableList[0].config.deviceName)
+ this.checkLocalPrint(this.deviceLableList[0].address)
) {
- let pids = this.deviceLableList[0].config.categoryList.map(
- (item) => item.id
- );
-
+ let pids = this.deviceLableList[0].categoryList;
let count = 0;
let sum = 0;
@@ -94,16 +86,19 @@ export const usePrint = defineStore("print", {
name: item.name,
skuName: item.skuName,
masterId: props.orderInfo.tableName,
- deviceName: this.deviceLableList[0].config.deviceName,
- // deviceName: "Xprinter XP-T202UA",
+ deviceName: this.deviceLableList[0].address,
createdAt: dayjs(props.createdAt).format("YYYY-MM-DD HH:mm:ss"),
isPrint: false,
count: `${count}/${sum}`,
- ticketLogo: shopInfo.info.ticketLogo,
+ ticketLogo: store.shopInfo.ticketLogo,
});
}
}
});
+
+ console.log("this.labelList===", this.labelList);
+ // return;
+
// 执行打印操作
this.startLabelPrint();
} else {
@@ -133,38 +128,17 @@ export const usePrint = defineStore("print", {
// console.log("pushReceiptData===", props);
if (!isDevice) {
// 测试打印,无需校验本地打印机
- const store = useUser();
- props.shop_name = store.userInfo.shopName;
- props.loginAccount = store.userInfo.loginAccount;
- props.createdAt = dayjs(props.createdAt).format("YYYY-MM-DD HH:mm:ss");
- props.printTime = dayjs().format("YYYY-MM-DD HH:mm:ss");
- if (!props.orderInfo.masterId) {
- props.orderInfo.masterId = props.orderInfo.tableName;
- }
- props.orderInfo.outNumber = props.outNumber;
-
this.receiptList.push(props);
this.startReceiptPrint();
} else {
- props.deviceName = "MHT-POS58 2";
- if (!props.orderInfo.masterId) {
- props.orderInfo.masterId = props.orderInfo.tableName;
- }
- props.orderInfo.outNumber = props.outNumber;
- if (!props.discountAmount) {
- props.discountAmount = props.amount;
- }
- this.receiptList.push(props);
- this.startReceiptPrint();
- return;
if (
this.deviceNoteList.length &&
- this.checkLocalPrint(this.deviceNoteList[0].config.deviceName)
+ this.checkLocalPrint(this.deviceNoteList[0].address)
) {
const store = useUser();
- props.deviceName = this.deviceNoteList[0].config.deviceName;
- props.shop_name = store.userInfo.shopName;
- props.loginAccount = store.userInfo.loginAccount;
+ props.deviceName = this.deviceNoteList[0].address;
+ props.shop_name = store.shopInfo.shopName;
+ props.loginAccount = store.userInfo.name;
props.createdAt = dayjs(props.createdAt).format(
"YYYY-MM-DD HH:mm:ss"
);
@@ -201,9 +175,9 @@ export const usePrint = defineStore("print", {
printWork(data) {
if (
this.deviceNoteList.length &&
- this.checkLocalPrint(this.deviceNoteList[0].config.deviceName)
+ this.checkLocalPrint(this.deviceNoteList[0].address)
) {
- data.deviceName = this.deviceNoteList[0].config.deviceName;
+ data.address = this.deviceNoteList[0].address;
lodopPrintWork(data);
} else {
console.log("交班小票:没有小票打印机");
@@ -213,9 +187,9 @@ export const usePrint = defineStore("print", {
printInvoice(data) {
if (
this.deviceNoteList.length &&
- this.checkLocalPrint(this.deviceNoteList[0].config.deviceName)
+ this.checkLocalPrint(this.deviceNoteList[0].address)
) {
- data.deviceName = this.deviceNoteList[0].config.deviceName;
+ data.address = this.deviceNoteList[0].address;
invoicePrint(data);
} else {
console.log("订单发票:没有小票打印机");
@@ -225,9 +199,9 @@ export const usePrint = defineStore("print", {
printRefund(data) {
if (
this.deviceNoteList.length &&
- this.checkLocalPrint(this.deviceNoteList[0].config.deviceName)
+ this.checkLocalPrint(this.deviceNoteList[0].address)
) {
- data.deviceName = this.deviceNoteList[0].config.deviceName;
+ data.address = this.deviceNoteList[0].address;
refundPrint(data);
} else {
console.log("退单小票:没有小票打印机");
diff --git a/src/store/socket.js b/src/store/socket.js
index b60c4e4..1938e9b 100644
--- a/src/store/socket.js
+++ b/src/store/socket.js
@@ -35,16 +35,18 @@ export const useSocket = defineStore("socket", {
2000,
{ leading: true, trailing: false }
),
- cartInit(tableCode = "") {
+ cartInit() {
const store = useUser();
const goodsStore = useGoods();
+
this.ws.send(
JSON.stringify({
type: "cashier",
account: `cashier_${store.shopInfo.id}`,
operate_type: "init",
shop_id: store.shopInfo.id,
- table_code: goodsStore.tableInfo.tableCode,
+ table_code:
+ goodsStore.tableInfo.tableCode || useStorage.get("tableCode"),
})
);
},
@@ -84,9 +86,12 @@ export const useSocket = defineStore("socket", {
let data = JSON.parse(e.data);
if (data.operate_type == "init") {
// console.log("接收消息", data);
+ if (!goodsStore.tableInfo.tableCode) {
+ useStorage.set("tableCode", data.table_code);
+ }
goodsStore.getCartList(data.data);
}
-
+
this.ws.send(
JSON.stringify({
type: "receipt",
diff --git a/src/store/user.js b/src/store/user.js
index a3e699b..8a6bddd 100644
--- a/src/store/user.js
+++ b/src/store/user.js
@@ -1,6 +1,13 @@
import { defineStore } from "pinia";
-import { login, shopStaffInfo, shopInfo_detail } from "@/api/account.js";
+import {
+ login,
+ shopStaffInfo,
+ shopInfo_detail,
+ logout,
+ shopExtendDetail,
+} from "@/api/account.js";
import useStorage from "@/utils/useStorage";
+import { useSocket } from "@/store/socket.js";
export const useUser = defineStore("user", {
state: () => ({
@@ -14,7 +21,9 @@ export const useUser = defineStore("user", {
return login(param).then(async (res) => {
this.token = res.tokenInfo.tokenValue;
useStorage.set("token", this.token);
- useStorage.set("shopInfo", res.shopInfo);
+
+ const logo = await shopExtendDetail({ autoKey: "ticket_logo" });
+ useStorage.set("shopInfo", { ...res.shopInfo, ticketLogo: logo.value });
this.shopInfo = useStorage.get("shopInfo");
return await this.shopStaffInfo();
});
@@ -33,11 +42,37 @@ export const useUser = defineStore("user", {
async getShopInfo() {
try {
const res = await shopInfo_detail();
- useStorage.set("shopInfo", res);
+ // 获取标签小票的logo
+ const logo = await shopExtendDetail({ autoKey: "ticket_logo" });
+ useStorage.set("shopInfo", { ...res, ticketLogo: logo.value });
this.shopInfo = useStorage.get("shopInfo");
} catch (error) {
console.log(error);
}
},
+ // 退出登录
+ async logout() {
+ try {
+ const socket = useSocket();
+
+ await logout();
+ useStorage.del("userInfo");
+ useStorage.del("shopInfo");
+ useStorage.del("token");
+ useStorage.del("douyin");
+
+ this.userInfo = {};
+ this.shopInfo = {};
+ this.token = "";
+
+ socket.close();
+
+ setTimeout(() => {
+ window.onload();
+ }, 1000);
+ } catch (error) {
+ console.log(error);
+ }
+ },
},
});
diff --git a/src/utils/index.js b/src/utils/index.js
index b50c31e..bcfc8ff 100644
--- a/src/utils/index.js
+++ b/src/utils/index.js
@@ -19,20 +19,29 @@ export function RandomNumBoth(Max, Min = 0) {
* @param {Object} obj
*/
export function clearNoNum(obj) {
- //如果用户第一位输入的是小数点,则重置输入框内容
+ // 如果用户第一位输入的是小数点,则重置输入框内容
if (obj.value != "" && obj.value.substr(0, 1) == ".") {
obj.value = "";
}
- obj.value = obj.value.replace(/^0*(0\.|[1-9])/, "$1"); //粘贴不生效
- obj.value = obj.value.replace(/[^\d.]/g, ""); //清除“数字”和“.”以外的字符
- obj.value = obj.value.replace(/\.{2,}/g, "."); //只保留第一个. 清除多余的
+
+ // 去除数字前面多余的 0,但保留 0. 这种情况
+ obj.value = obj.value.replace(/^0*(0\.|[1-9])/, "$1");
+
+ // 清除“数字”和“.”以外的字符
+ obj.value = obj.value.replace(/[^\d.]/g, "");
+
+ // 只保留第一个. 清除多余的
+ obj.value = obj.value.replace(/\.{2,}/g, ".");
obj.value = obj.value
.replace(".", "$#$")
.replace(/\./g, "")
.replace("$#$", ".");
- obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/, "$1$2.$3"); //只能输入两个小数
+
+ // 只能输入两个小数
+ obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/, "$1$2.$3");
+
if (obj.value.indexOf(".") < 0 && obj.value != "") {
- //以上已经过滤,此处控制的是如果没有小数点,首位不能为类似于 01、02的金额
+ // 以上已经过滤,此处控制的是如果没有小数点,首位不能为类似于 01、02 的金额
if (obj.value.substr(0, 1) == "0" && obj.value.length == 2) {
obj.value = obj.value.substr(1, obj.value.length);
}
@@ -149,6 +158,7 @@ export async function getOrderByIdAjax(orderId) {
export function commOrderPrintData(orderInfo) {
const userStore = useUser();
let data = {
+ isBefore: orderInfo.isBefore || false,
shop_name: userStore.shopInfo.shopName,
loginAccount: userStore.userInfo.name,
carts: [],
@@ -160,7 +170,7 @@ export function commOrderPrintData(orderInfo) {
remark: orderInfo.remark,
orderInfo: orderInfo,
outNumber: orderInfo.tableCode,
- createdAt: orderInfo.paidTime,
+ createdAt: orderInfo.createTime,
printTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
};
diff --git a/src/utils/request.js b/src/utils/request.js
index 01bdaec..1671b89 100644
--- a/src/utils/request.js
+++ b/src/utils/request.js
@@ -9,18 +9,18 @@ const service = axios.create({
? "/api/"
: import.meta.env.VITE_API_URL,
// withCredentials: true, // 跨域请求时发送 cookies
- timeout: 10000, // 请求超时
+ timeout: 20000, // 请求超时
});
// 请求拦截器
service.interceptors.request.use(
(config) => {
// 在发送请求之前做些什么 token
+ config.headers["platformType"] = "PC";
if (useStorage.get("token")) {
// 让每个请求携带 token
// ['X-Token'] 是自定义标题键
// 请根据实际情况修改
- config.headers["platformType"] = 'PC';
config.headers["token"] = useStorage.get("token");
if (useStorage.get("shopInfo") && useStorage.get("shopInfo").id) {
config.headers["shopId"] = useStorage.get("shopInfo").id;
diff --git a/src/views/device/add.vue b/src/views/device/add.vue
index ef3fcd7..4c7cc6a 100644
--- a/src/views/device/add.vue
+++ b/src/views/device/add.vue
@@ -9,10 +9,16 @@
+
+
+
+
-
-
-
+
+
+
@@ -22,15 +28,12 @@
-
+
-
-
-
-
-
+