From f65aed1e0c3d89c37796883accf38259bca9d699 Mon Sep 17 00:00:00 2001 From: weipengfei <2187978347@qq.com> Date: Mon, 1 Jul 2024 18:49:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/payUser.vue | 13 ++-- src/layout/index.vue | 5 ++ src/utils/EscPos.js | 15 ++-- src/views/user/component/add.vue | 12 +++- src/views/user/component/detail.vue | 100 ++++++++++++++++++++------ src/views/user/component/order.vue | 108 +++++++++++++++++++++++++++- 6 files changed, 215 insertions(+), 38 deletions(-) diff --git a/src/components/payUser.vue b/src/components/payUser.vue index 06c2721..c4e86d1 100644 --- a/src/components/payUser.vue +++ b/src/components/payUser.vue @@ -48,7 +48,8 @@ const changeActive = (e) => { const form = ref({ price: 0, - uid: '' + uid: '', + user_ship: '', }); const cart_id = ref([]); const isRePay = ref(false); @@ -107,6 +108,7 @@ const handleEnter = () => { } userRechangeAmountApi({ uid: form.value.uid, + user_ship: form.value.user_ship, price: form.value.price, pay_type: pay_type, auth_code: input.value, @@ -123,13 +125,13 @@ const handleEnter = () => { } else { if (res.msg == "用户支付中" && res.code == 1) { ElMessage.warning(res.msg); - mitt.on("pay_success", (e) => { + mitt.on("pay_user_success", (e) => { ElMessage({ message: "支付成功", type: "success", }); setTimeout(() => { - mitt.off("pay_success"); + mitt.off("pay_user_success"); }, 200); drawer.value = false; beforeClose(e); @@ -175,13 +177,13 @@ const orderPay = () => { } else { if (res.msg == "用户支付中" && res.code == 1) { ElMessage.warning(res.msg); - mitt.on("pay_success", (e) => { + mitt.on("pay_user_success", (e) => { ElMessage({ message: "支付成功", type: "success", }); setTimeout(() => { - mitt.off("pay_success"); + mitt.off("pay_user_success"); }, 200); drawer.value = false; beforeClose(e); @@ -323,6 +325,7 @@ const cashBnt = () => { else userRechangeAmountApi({ uid: form.value.uid, + user_ship: form.value.user_ship, price: form.value.price, pay_type: 17, }) diff --git a/src/layout/index.vue b/src/layout/index.vue index 65f3377..d58e72e 100644 --- a/src/layout/index.vue +++ b/src/layout/index.vue @@ -5,6 +5,7 @@ import { ref, nextTick, onMounted, onUnmounted } from "vue"; import mitt from "@/utils/mitt.js"; import { useUserStore } from "@/store/user.js"; import { Push } from "@/common/push.js"; +import { ElMessage } from "element-plus"; const userStore = useUserStore(); const connection = new Push({ @@ -30,6 +31,9 @@ user_channel.on('message', function (data) { if (data?.content?.type == 'platform_print') { mitt.emit('letPrintReceipt', data?.content?.data); } + if (data?.content?.msg == '订单支付成功') { + mitt.emit('pay_user_success', data?.content?.data); + } } catch (error) { } @@ -45,6 +49,7 @@ user_channel.on('close', function () { const KeyboardEvent = (e) => { console.log('按下', e.keyCode); +// ElMessage.warning('按下', e.keyCode) if (e.keyCode == 16) mitt.emit('shift'); if (e.keyCode == 120) mitt.emit('F9'); if (e.keyCode == 13) mitt.emit('enter'); diff --git a/src/utils/EscPos.js b/src/utils/EscPos.js index df1d8db..b9282f8 100644 --- a/src/utils/EscPos.js +++ b/src/utils/EscPos.js @@ -113,10 +113,10 @@ const testObj = { export const printTicket = (obj = {}, test = false) => { let str = ""; - if(!obj || !obj.order_id) obj = testObj; + if (!obj || !obj.order_id) obj = testObj; str += Esc.Size2(2) + Esc.Center() + Esc.boldFontOn() + obj.system_store_name + Esc.Size1() + "\n"; str += Esc.fillLine(" ") + Esc.boldFontOff() + "\n"; - if(obj.shipping_type) str += Esc.Left() + "核销码: " + Esc.boldFontOn() + obj.verify_code + Esc.boldFontOff() + "\n"; + if (obj.shipping_type) str += Esc.Left() + "核销码: " + Esc.boldFontOn() + obj.verify_code + Esc.boldFontOff() + "\n"; str += Esc.Left() + "单号: " + obj.order_id + "\n"; str += Esc.Left() + "下单时间: " + obj.create_time + "\n"; @@ -128,19 +128,22 @@ export const printTicket = (obj = {}, test = false) => { str += Esc.Left() + item.store_name + "\n"; let total = +item.price || 0; total *= +item.cart_num; - str += Esc.inline3(`${item.price || '0.00'}元`, `${item.cart_num}${item.unit_name||''}`, `${total}元`, " ", 1) + "\n"; + str += Esc.inline3(`${item.price || '0.00'}元`, `${item.cart_num}${item.unit_name || ''}`, `${total}元`, " ", 1) + "\n"; }) str += Esc.fillLine("=") + "\n"; - // str += Esc.Left() + "合计: " + obj.total_price + "元" + "\n"; - str += Esc.Left() + "合计: " + obj.pay_price + "元" + "\n"; + if (obj.deduction_price) { // 有优惠 + str += Esc.Left() + "合计: " + obj.total_price + "元" + "\n"; + str += Esc.Left() + "优惠: " + obj.deduction_price + "元" + "\n"; + } + else str += Esc.Left() + "合计: " + obj.pay_price + "元" + "\n"; str += Esc.Left() + "实付款: " + obj.pay_price + "元" + "\n"; str += Esc.Left() + "支付方式: " + obj.pay_type_name + "\n"; // str += Esc.Left() + "支付单号: " + obj.order_id + "\n"; str += Esc.Left() + "店铺电话: " + obj.system_store_phone + "\n"; - if(obj.shipping_type == 1){ // 快递 + if (obj.shipping_type == 1) { // 快递 str += Esc.fillLine("=") + "\n"; str += Esc.Left() + "收货人: " + obj.real_name + "\n"; str += Esc.Left() + "收货电话: " + obj.user_phone + "\n"; diff --git a/src/views/user/component/add.vue b/src/views/user/component/add.vue index 72eda92..78d2236 100644 --- a/src/views/user/component/add.vue +++ b/src/views/user/component/add.vue @@ -120,7 +120,9 @@ const props = { const userShip = ref([]) const getUserShip = () => { userShipApi().then(res => { - userShip.value = res.data.lists; + userShip.value = res.data.lists?.filter((item) => { + return item.id == 0 || item.id == 4 + }); }) } getUserShip() @@ -142,6 +144,12 @@ const addUser = () => { forms.brigade = formDataInfo.selectedValues[4] forms.store_id = userStore.userInfo.store_id; userAddApi(forms).then(res=>{ + formDataInfo.mobile = ''; + formDataInfo.code = ''; + formDataInfo.user_ship = ''; + formDataInfo.real_name = ''; + formDataInfo.selectedValues = []; + formDataRef.value.resetFields(); emit('close') }) } @@ -188,7 +196,7 @@ defineExpose({ - + diff --git a/src/views/user/component/detail.vue b/src/views/user/component/detail.vue index a53d658..5472fb1 100644 --- a/src/views/user/component/detail.vue +++ b/src/views/user/component/detail.vue @@ -1,5 +1,5 @@