This commit is contained in:
weipengfei 2024-05-16 17:29:12 +08:00
parent 7d82a14b0f
commit 968e194688
20 changed files with 318 additions and 139 deletions

View File

@ -1,7 +1,7 @@
VITE_NOW_TYPE = 'dist' VITE_NOW_TYPE = 'dist'
VITE_PUSH_URL = 'ws://192.168.1.22:8787' VITE_PUSH_URL = 'ws://192.168.1.22:8787'
VITE_BASE_URL = 'http://192.168.1.22:8546'
# VITE_PUSH_URL ='wss://erp.lihaink.cn/pull'
# VITE_BASE_URL = 'http://192.168.1.22:8546' # VITE_BASE_URL = 'https://erp.lihaink.cn'
VITE_BASE_URL = 'https://erp.lihaink.cn'

View File

@ -148,3 +148,10 @@ export function opurchaseOrderApi(data) {
export function subOrdersListApi(data) { export function subOrdersListApi(data) {
return request.get(`/order/OpurchaseOrder/sub_orders`, { params: data }) return request.get(`/order/OpurchaseOrder/sub_orders`, { params: data })
} }
/**
* @description 摊贩订单数量统计
*/
export function merchantOrderCountApi(data) {
return request.get(`/order/retailOrder/merchant_order_count`, { params: data })
}

BIN
src/assets/order.mp3 Normal file

Binary file not shown.

View File

@ -110,22 +110,36 @@ const handleEnter = () => {
message: res.data.trade_state_desc || '支付成功', message: res.data.trade_state_desc || '支付成功',
type: "success", type: "success",
}); });
if(res.data.message) audioplay(res.data.message); // if(res.data.message) audioplay(res.data.message);
beforeClose(); beforeClose(res.data);
} else { } else {
if (!res.data.group_order_sn) { if(res.msg=='用户支付中'&&res.code==1){
order_id.value = res.data.result.order_id; ElMessage.warning(res.msg);
loading.value = false; mitt.on('pay_success', (e)=>{
return ElMessage({ ElMessage({
message: res.message, message: '支付成功',
type: "error", type: "success",
}); });
} else { setTimeout(()=>{
order_id.value = res.data.group_order_id; mitt.off('pay_success');
count.value = 0; }, 200);
timecount = 0; drawer.value = false;
getOrderStatus(res.data.group_order_sn); beforeClose(e);
})
} }
// if (!res.data.group_order_sn) {
// order_id.value = res.data.result.order_id;
// loading.value = false;
// return ElMessage({
// message: res.message,
// type: "error",
// });
// } else {
// order_id.value = res.data.group_order_id;
// count.value = 0;
// timecount = 0;
// getOrderStatus(res.data.group_order_sn);
// }
} }
}) })
.catch((err) => { .catch((err) => {
@ -165,8 +179,8 @@ const orderPay = (id) => {
message: res.message=='success'?'支付成功':res.message, message: res.message=='success'?'支付成功':res.message,
type: "success", type: "success",
}); });
if(res.data.message) audioplay(res.data.message); // if(res.data.message) audioplay(res.data.message);
beforeClose(); beforeClose(res.data);
} else { } else {
order_id.value = res.data.group_order_id; order_id.value = res.data.group_order_id;
count.value = 0; count.value = 0;
@ -197,7 +211,7 @@ const getOrderStatus = (id) => {
message: res.message, message: res.message,
type: "success", type: "success",
}); });
if(res.data.message) audioplay(res.data.message); // if(res.data.message) audioplay(res.data.message);
beforeClose(); beforeClose();
} else { } else {
ElMessage({ ElMessage({
@ -229,7 +243,7 @@ const getOrderStatus = (id) => {
}); });
}; };
const beforeClose = () => { const beforeClose = (data) => {
window.removeEventListener("keydown", keyboard); window.removeEventListener("keydown", keyboard);
reLoad.value = false; reLoad.value = false;
loading.value = false; loading.value = false;
@ -237,7 +251,7 @@ const beforeClose = () => {
collection.value = ""; collection.value = "";
collectionArray.value = []; collectionArray.value = [];
codeRef.value?.blur(); codeRef.value?.blur();
emit("paySuccess"); emit("paySuccess", data);
drawer.value = false; drawer.value = false;
}; };
@ -314,7 +328,7 @@ const cashBnt = () => {
type: "success", type: "success",
}); });
changeActive(1); changeActive(1);
if(res.data.message) audioplay(res.data.message); // if(res.data.message) audioplay(res.data.message);
beforeClose(); beforeClose();
} else { } else {
if (!res.data.group_order_sn) { if (!res.data.group_order_sn) {

View File

@ -12,14 +12,23 @@ const connection = new Push({
app_key: '2ce3ce22329517213caa7dad261f5695', app_key: '2ce3ce22329517213caa7dad261f5695',
}); });
// user-1 // user-1
const user_channel = connection.subscribe(`store_merchant_${userStore.userInfo.merchant.mer_id}`); const user_channel = connection.subscribe(`store_merchant_${userStore.userInfo.merchant.mer_id}`);
// const user_channel = connection.subscribe(`store_merchant_${1}`); // const user_channel = connection.subscribe(`store_merchant_${1}`);
// user-2message // user-2message
user_channel.on('message', function (data) { user_channel.on('message', function (data) {
console.log("收到消息--",data, JSON.parse(data.content)); console.log("收到消息--",data);
try {
if(data?.content?.type=='cash_register'&&data?.content?.msg=="您有一笔订单已支付"){
mitt.emit('pay_success', data?.content?.data);
}
if(data?.content?.type=='store_merchant'&&data?.content?.msg=="您有一笔新的订单"){
mitt.emit('new_order', data?.content);
}
} catch (error) {
}
}); });
// 线 // 线
user_channel.on('close', function () { user_channel.on('close', function () {

View File

@ -2,18 +2,56 @@
import { useRoute, useRouter } from "vue-router"; import { useRoute, useRouter } from "vue-router";
import { ref, onMounted, onUnmounted } from "vue"; import { ref, onMounted, onUnmounted } from "vue";
import mitt from "@/utils/mitt.js"; import mitt from "@/utils/mitt.js";
import { useOrderStore } from "@/store/order.js";
import { merchantOrderCountApi } from "@/api/store.js";
import { ElMessage } from "element-plus";
const router = useRouter(); const router = useRouter();
const route = useRoute(); const route = useRoute();
const orderStore = useOrderStore();
// setInterval(()=>{
// setOrderCount(+orderStore.orderCount + 1)
// }, 2000)
const setOrderCount = (e = 1) => {
orderStore.setOrderCount(e)
list.value.forEach(item=>{
if(item.name == "order") item.count = e;
})
};
const newOrder = (e) => {
merchantOrderCountApi().then((res) => {
setOrderCount(res?.data?.order_count || 0);
});
ElMessage.success('您有新的订单')
//
var audio = new Audio("/src/assets/order.mp3");
//
audio.play();
};
// setTimeout(() => {
// newOrder({
// msg: "",
// });
// }, 3000);
const navTo = (name) => { const navTo = (name) => {
router.push({ name }); router.push({ name });
}; };
const list = ref([ const list = ref([
{ name: "saleHome", title: "收银", ico: "Sell", count: 0 }, { name: "saleHome", title: "收银", ico: "Sell", count: 0 },
{ name: "saleOrder", title: "收银订单", ico: "DataLine", count: 0 }, { name: "saleOrder", title: "收银订单", ico: "DataLine", count: 0 },
{ name: "order", title: "摊贩订单", ico: "DataAnalysis", count: 2 }, {
{ name: "purchaseOrder", title: "采购订单", ico: "Tickets", count: 0 }, name: "order",
title: "摊贩订单",
ico: "DataAnalysis",
count: +orderStore.orderCount,
},
{ name: "purchaseOrder", title: "采购订单", ico: "Van", count: 0 },
{ name: "orderCount", title: "订单统计", ico: "DocumentRemove", count: 0 },
// { name: "test", title: "", ico: "Tickets", count: 0 }, // { name: "test", title: "", ico: "Tickets", count: 0 },
]); ]);
const aup = () => { const aup = () => {
@ -29,11 +67,16 @@ const adown = () => {
onMounted(() => { onMounted(() => {
mitt.on("up", aup); mitt.on("up", aup);
mitt.on("down", adown); mitt.on("down", adown);
mitt.on("new_order", newOrder);
merchantOrderCountApi().then((res) => {
setOrderCount(res?.data?.order_count || 0);
});
}); });
onUnmounted(() => { onUnmounted(() => {
mitt.off("aup", aup); mitt.off("aup", aup);
mitt.off("adown", adown); mitt.off("adown", adown);
mitt.off("new_order", newOrder);
}); });
</script> </script>

View File

@ -6,7 +6,7 @@ import { ElMessage } from "element-plus";
import { useRouter } from "vue-router"; import { useRouter } from "vue-router";
import mitt from "@/utils/mitt.js"; import mitt from "@/utils/mitt.js";
import { usePrintStore } from "@/store/print.js"; import { usePrintStore } from "@/store/print.js";
import * as Esc from "@/utils/EscPostUtils.js"; import { printTicket } from "@/utils/EscPos.js";
const userStore = useUserStore(); const userStore = useUserStore();
const printStore = usePrintStore(); const printStore = usePrintStore();
@ -48,9 +48,7 @@ let isPrint = false; //是否正在打印小票
// //
const printReceipt = (content = "") => { const printReceipt = (content = "") => {
console.log("预打印"); console.log("预打印");
// console.log(Esc.inline3(" ", "", "", " ", 1) + "\n"); console.log(printTicket(content, true));
// console.log(Esc.inline3("2.36 ", "10", "30.00", " ", 1) + "\n");
// return ;
if (isPrint) return; if (isPrint) return;
isPrint = true; isPrint = true;
uni.getEnv((res) => { uni.getEnv((res) => {
@ -70,46 +68,7 @@ const printReceipt = (content = "") => {
const APPprint = (content = "") => { const APPprint = (content = "") => {
let str = ""; let str = "";
if (content === "") { if (content === "") {
// str += "********************************\n"; str = printTicket({}, true); //
// str += "\n";
// str += ": PF171568087790938356\n";
// str += " 0.01/kg\n";
// str += "x 3 \t\t 0.10 \n";
// str += " 1.33/kg\n";
// str += "x 10 \t\t 13.30\n";
// str += " 36.59/\n";
// str += "x 3 \t\t 106.97\n";
// str += " \t : ¥235.36\n";
// str += "\n";
// str += "--------------------------------\n";
// str += "\n";
str += Esc.Size2(0) + Esc.Center() + Esc.boldFontOn() + "莲花农贸市场" + "\n";
str += Esc.fillLine(" ") + Esc.boldFontOff() + "\n";
str += Esc.Left() + "单号: PF171568087790938356" + "\n";
str += Esc.Left() + "下单时间: 2024-5-15 18:00:32" + "\n";
//
str += Esc.fillLine("=") + "\n";
str += Esc.inline3("单价 ", "数量", "小计", " ", 1) + "\n";
str += Esc.Left() + "白菜 大白菜" + "\n";
str += Esc.inline3("206.36元 ", "10包", "3600.00元", " ", 1) + "\n";
str += Esc.Left() + "白菜 大白菜" + "\n";
str += Esc.inline3("206.36元 ", "10包", "3600.00元", " ", 1) + "\n";
str += Esc.Left() + "白菜 大白菜" + "\n";
str += Esc.inline3("206.36元 ", "10包", "3600.00元", " ", 1) + "\n";
str += Esc.fillLine("=") + "\n";
str += Esc.Left() + "应付款: " + "29.96元" + "\n";
str += Esc.Left() + "实付款: " + "29.96元" + "\n";
str += Esc.Left() + "支付方式: " + "微信支付" + "\n";
str += Esc.Left() + "支付单号: " + "4200002159202405159003084211" + "\n";
str += Esc.fillLine("=") + "\n";
//
str += Esc.fillLine(" ") + "\n";
str += Esc.Center() + "欢迎下次光临!" + "\n";
str += Esc.feedLines(" ") + "\n";
//
str += Esc.cutPaper();
console.log(str); console.log(str);
} else str = content; } else str = content;
uni.postMessage({ uni.postMessage({
@ -150,7 +109,7 @@ onUnmounted(() => {
src="https://lihai001.oss-cn-chengdu.aliyuncs.com/def/12c93202404101530591311.png" src="https://lihai001.oss-cn-chengdu.aliyuncs.com/def/12c93202404101530591311.png"
></el-image> ></el-image>
</div> </div>
<div class="card-title">里海收银系统</div> <div class="card-title">泸优采收银系统</div>
<div <div
style=" style="
margin-left: 1rem; margin-left: 1rem;

View File

@ -35,6 +35,12 @@ const routes = [
meta: { title: '采购订单' }, meta: { title: '采购订单' },
component: () => import('@/views/purchaseOrder/index.vue'), component: () => import('@/views/purchaseOrder/index.vue'),
}, },
{
path: '/orderCount',
name: 'orderCount',
meta: { title: '订单统计' },
component: () => import('@/views/saleOrder/indexCount.vue'),
},
{ {
path: '/test', path: '/test',
name: 'test', name: 'test',

18
src/store/order.js Normal file
View File

@ -0,0 +1,18 @@
import { defineStore } from "pinia"
import { ref } from "vue"
export const useOrderStore = defineStore('order', () => {
const orderCount = ref(localStorage.getItem('orderCount')||0);
const setOrderCount = (e)=>{
orderCount.value = e;
localStorage.setItem('orderCount',e);
}
return {
orderCount,
setOrderCount
}
})

70
src/utils/EscPos.js Normal file
View File

@ -0,0 +1,70 @@
import * as Esc from "@/utils/EscPostUtils.js";
const testObj = {
mer_name: "莲花农贸市场", //商户名称
service_phone: "0830-2669767", //客服电话
number: "PF171568087790938356", //单号
create_time: "2024-5-15 18:00:32", //下单时间
total_price: "29.96", //总价
pay_price: "29.96", //实付
pay_type: "微信支付", //支付方式
pay_number: "4200002159202405159003084211", //支付单号
goods: [
{
name: "白菜 大白菜", //商品名称
sell: "236.60", //单价
nums: "13", //数量
unit_name: "kg", //单位
total: "2896.34" //小计
},
{
name: "小黄鸭", //商品名称
sell: "9.56", //单价
nums: "2", //数量
unit_name: "只", //单位
total: "19.38" //小计
},
{
name: "卷心菜", //商品名称
sell: "15.37", //单价
nums: "8", //数量
unit_name: "斤", //单位
total: "134.38" //小计
}
]
}
export const printTicket = (obj = {}, test = false) => {
let str = "";
if(!obj || !obj.number) obj = testObj;
str += Esc.Size2(0) + Esc.Center() + Esc.boldFontOn() + obj.mer_name + "\n";
str += Esc.fillLine(" ") + Esc.boldFontOff() + "\n";
str += Esc.Left() + "单号: " + obj.number + "\n";
str += Esc.Left() + "下单时间: " + obj.create_time + "\n";
// 商品信息
str += Esc.fillLine("=") + "\n";
str += Esc.inline3("单价", "数量", "小计", " ", 1) + "\n";
obj.goods.forEach(item => {
str += Esc.Left() + item.name + "\n";
str += Esc.inline3(`${item.sell}`, `${item.nums}${item.unit_name}`, `${item.total}`, " ", 1) + "\n";
})
str += Esc.fillLine("=") + "\n";
str += Esc.Left() + "应付款: " + obj.total_price + "元" + "\n";
str += Esc.Left() + "实付款: " + obj.pay_price + "元" + "\n";
str += Esc.Left() + "支付方式: " + obj.pay_type + "\n";
str += Esc.Left() + "支付单号: " + obj.pay_number + "\n";
str += Esc.Left() + "联系电话: " + obj.service_phone + "\n";
str += Esc.fillLine("=") + "\n";
// 票尾
str += Esc.fillLine(" ") + "\n";
str += Esc.Center() + "欢迎下次光临!" + "\n";
str += Esc.feedLines(" ") + "\n";
// 切纸
str += Esc.cutPaper();
return str;
}

View File

@ -1,3 +1,5 @@
// 此为指令集, 如非必要请不要进行修改操作, 以免打印效果异常
// 打印机纸宽58mm页的宽度384字符宽度为1每行最多盛放32个字符 // 打印机纸宽58mm页的宽度384字符宽度为1每行最多盛放32个字符
// 打印机纸宽80mm页的宽度576字符宽度为1每行最多盛放48个字符 // 打印机纸宽80mm页的宽度576字符宽度为1每行最多盛放48个字符
const PAGE_WIDTH = 384; const PAGE_WIDTH = 384;
@ -238,39 +240,19 @@ export function inline(str1, str2, fillWith = ' ', fontWidth = 1) {
* @param {string} fillWith 列之间的填充字符 * @param {string} fillWith 列之间的填充字符
* @param {number} fontWidth 字符宽度默认为1 * @param {number} fontWidth 字符宽度默认为1
*/ */
export function inlineThreeColumns(str1, str2, str3, fillWith = ' ', fontWidth = 1) {
const lineWidth = MAX_CHAR_COUNT_EACH_LINE / fontWidth;
// 计算每列的宽度(假设三列等宽)
const columnWidth = Math.floor(lineWidth / 3);
// 计算每列的实际宽度
const width1 = getStringWidth(str1);
const width2 = getStringWidth(str2);
const width3 = getStringWidth(str3);
// 计算每列需要的填充数量
let fillCount1 = columnWidth - width1;
let fillCount2 = columnWidth - width2;
let fillCount3 = lineWidth - columnWidth - (width1 + fillCount1 * fontWidth + width2 + fillCount2 * fontWidth + width3);
// 创建填充字符串
let fillStr1 = new Array(fillCount1).fill(fillWith.charAt(0)).join('');
let fillStr2 = new Array(fillCount2).fill(fillWith.charAt(0)).join('');
let fillStr3 = new Array(fillCount3).fill(fillWith.charAt(0)).join('');
// 拼接字符串
return str1 + fillStr1 + str2 + fillStr2 + str3 + fillStr3;
}
export function inline3(str1, str2, str3, fillWith = ' ', fontWidth = 1) { export function inline3(str1, str2, str3, fillWith = ' ', fontWidth = 1) {
const lineWidth = MAX_CHAR_COUNT_EACH_LINE / fontWidth; const lineWidth = MAX_CHAR_COUNT_EACH_LINE / fontWidth;
// 需要填充的字符数量 // 需要填充的字符数量
let fillCount = lineWidth - (getStringWidth(str1) + getStringWidth(str2) + getStringWidth(str3)) % lineWidth; let fillCount = lineWidth - (getStringWidth(str1) + getStringWidth(str2) + getStringWidth(str3)) % lineWidth;
console.log("=",lineWidth, getStringWidth(str1) + getStringWidth(str2) + getStringWidth(str3), fillCount); let count2 = Math.floor(fillCount / 2); //分别计算出两边各自需要填充的数量
fillCount = Math.floor(fillCount / 2); let count1 = fillCount - count2;
let fillStr = new Array(fillCount).fill(fillWith.charAt(0)).join(''); if(fillCount>2){ //往左偏移两位, 防止打印时,小计与数量重叠
return str1 + fillStr + str2 + fillStr + str3; count1 -= 2;
count2 += 2;
}
let fillStr1 = new Array(count1).fill(fillWith.charAt(0)).join('');
let fillStr2 = new Array(count2).fill(fillWith.charAt(0)).join('');
return str1 + fillStr1 + str2 + fillStr2 + str3;
} }
/** /**

View File

@ -175,8 +175,8 @@ onUnmounted(() => {
<div class="info-item-title">支付方式:</div> <div class="info-item-title">支付方式:</div>
<div class="info-item-info"> <div class="info-item-info">
<span v-if="formData.pay_type == 9">微信收款</span> <span v-if="formData.pay_type == 9">微信收款</span>
<span v-if="formData.pay_type == 1">余额支付</span> <span v-if="formData.pay_type == 3">余额支付</span>
<span v-if="formData.pay_type == 3">微信支付</span> <span v-if="formData.pay_type == 1">微信支付</span>
</div> </div>
</div> </div>
</div> </div>

View File

@ -51,7 +51,7 @@ const where = ref({
page_size: 20, page_size: 20,
number: "", number: "",
date: moment(new Date()).format("YYYY-MM-DD"), date: moment(new Date()).format("YYYY-MM-DD"),
source: props.source, // source: props.source,
}); });
const loading = ref(false); const loading = ref(false);
@ -86,6 +86,7 @@ const getOrderList = (reload = false) => {
const submitOrder = ()=>{ const submitOrder = ()=>{
createOrderApi().then(res=>{ createOrderApi().then(res=>{
ElMessage.success("提交成功"); ElMessage.success("提交成功");
getOrderList(true);
}) })
} }
@ -203,8 +204,8 @@ onUnmounted(()=>{
<div v-if="item.paid"> <div v-if="item.paid">
已支付 已支付
<span v-if="item.pay_type == 9">(微信收款)</span> <span v-if="item.pay_type == 9">(微信收款)</span>
<span v-if="item.pay_type == 1">(余额支付)</span> <span v-if="item.pay_type == 3">(余额支付)</span>
<span v-if="item.pay_type == 3">(微信支付)</span> <span v-if="item.pay_type == 1">(微信支付)</span>
</div> </div>
<div v-else style="color: #ff4a00">未支付</div> <div v-else style="color: #ff4a00">未支付</div>
</div> </div>

View File

@ -31,13 +31,18 @@ const rules = ref({
detail: [{ required: true, message: "请输入地址", trigger: "blur" }], detail: [{ required: true, message: "请输入地址", trigger: "blur" }],
}); });
const formRef = ref(null);
const submit = () => { const submit = () => {
formRef.value?.validate((valid) => {
if (valid) {
merchantCreateApi(form.value).then((res) => { merchantCreateApi(form.value).then((res) => {
dialogFormVisible.value = false; dialogFormVisible.value = false;
orderRef.value?.getOrderList(true); orderRef.value?.getOrderList(true);
}); });
}
});
}; };
</script> </script>
<template> <template>
@ -47,7 +52,7 @@ const submit = () => {
<detail ref="detailRef" @addAddress="addAddress" /> <detail ref="detailRef" @addAddress="addAddress" />
<el-dialog v-model="dialogFormVisible" title="添加地址" width="500"> <el-dialog v-model="dialogFormVisible" title="添加地址" width="500">
<el-form :model="form" label-width="100" :rules="rules"> <el-form ref="formRef" :model="form" label-width="100" :rules="rules">
<el-form-item <el-form-item
label="收货人" label="收货人"
:label-width="formLabelWidth" :label-width="formLabelWidth"

View File

@ -117,8 +117,8 @@ defineExpose({
<div class="info-item-title">支付方式:</div> <div class="info-item-title">支付方式:</div>
<div class="info-item-info"> <div class="info-item-info">
<span v-if="formData.pay_type == 9">微信收款</span> <span v-if="formData.pay_type == 9">微信收款</span>
<span v-if="formData.pay_type == 1">余额支付</span> <span v-if="formData.pay_type == 3">余额支付</span>
<span v-if="formData.pay_type == 3">微信支付</span> <span v-if="formData.pay_type == 1">微信支付</span>
</div> </div>
</div> </div>
</div> </div>

View File

@ -15,11 +15,11 @@ const codeRef = ref(null);
const emit = defineEmits(["getStoreList", "changeItem", "loadMore"]); const emit = defineEmits(["getStoreList", "changeItem", "loadMore"]);
const bar_code = ref(""); const name = ref("");
const loadMore = () => { const loadMore = () => {
emit("loadMore", { emit("loadMore", {
bar_code: bar_code.value, name: name.value,
}); });
}; };
@ -31,12 +31,12 @@ const changeItem = (item) => {
const handleEnter = _.throttle(() => { const handleEnter = _.throttle(() => {
emit("getStoreList", { emit("getStoreList", {
bar_code: bar_code.value, name: name.value,
}, true); }, true);
}, 300) }, 300)
defineExpose({ defineExpose({
bar_code, name,
}); });
const isfocus = ref(false); const isfocus = ref(false);
@ -70,7 +70,7 @@ onUnmounted(() => {
<div class="nav-item-label">搜索 (Shift)</div> <div class="nav-item-label">搜索 (Shift)</div>
<div class="nav-item-input"> <div class="nav-item-input">
<el-input <el-input
v-model="bar_code" v-model="name"
placeholder=" 搜索商品名称/条形码或点击聚焦扫码, 按回车(Enter)搜索" placeholder=" 搜索商品名称/条形码或点击聚焦扫码, 按回车(Enter)搜索"
clearable clearable
ref="codeRef" ref="codeRef"
@ -105,7 +105,7 @@ onUnmounted(() => {
<div class="shop-name">{{ item.name }}</div> <div class="shop-name">{{ item.name }}</div>
<div class="shop-price"> <div class="shop-price">
¥<span>{{ item.sell }}</span> ¥<span>{{ item.sell }}</span>
<span style="color: #777;font-size: 0.9rem;">/{{item.unit_name}}</span> <span class="unit-name">/{{item.unit_name}}</span>
</div> </div>
<div class="no-stock" v-if="item.stock == 0"> <div class="no-stock" v-if="item.stock == 0">
<div> <div>
@ -222,6 +222,9 @@ onUnmounted(() => {
font-size: 1.2rem; font-size: 1.2rem;
margin-left: 0.187rem; margin-left: 0.187rem;
} }
.unit-name{
color: #777;font-size: 0.9rem;
}
} }
&:hover { &:hover {
@ -230,6 +233,9 @@ onUnmounted(() => {
.shop-price { .shop-price {
color: #fff; color: #fff;
} }
.unit-name{
color: #fff;
}
} }
.no-stock { .no-stock {

View File

@ -11,6 +11,8 @@ import { saleStoreListApi } from "@/api/shop.js";
import { useUserStore } from "@/store/user.js"; import { useUserStore } from "@/store/user.js";
import { useRoute } from "vue-router"; import { useRoute } from "vue-router";
import mitt from "@/utils/mitt.js"; import mitt from "@/utils/mitt.js";
import moment from "moment";
import { printTicket } from "@/utils/EscPos.js";
const pupopRef = ref(null); const pupopRef = ref(null);
const orderRef = ref(null); const orderRef = ref(null);
@ -66,7 +68,7 @@ const cartAddInfo = (item, change = "") => {
let q = { let q = {
goods_id: item.id, goods_id: item.id,
is_new: 0, is_new: 0,
cart_num: item.cart_num cart_num: item.cart_num,
}; };
cartCreateApi(q).then((res) => { cartCreateApi(q).then((res) => {
orderRef.value.getList(); orderRef.value.getList();
@ -78,12 +80,12 @@ const changeItem = (item, change) => {
pupopRef.value.show(true); pupopRef.value.show(true);
}; };
const editPupop = (item) => { const editPupop = (item) => {
pupopRef.value.setForm(item, "edit"); pupopRef.value.setForm(item, "edit");
pupopRef.value.show(true); pupopRef.value.show(true);
}; };
const orderForm = ref({});
// //
const checkOut = () => { const checkOut = () => {
let cart_id = orderRef.value.list.map((item) => item.cart_id); let cart_id = orderRef.value.list.map((item) => item.cart_id);
@ -95,6 +97,7 @@ const checkOut = () => {
query.pay_type = "micropay"; query.pay_type = "micropay";
} }
orderCheckApi(query).then((res) => { orderCheckApi(query).then((res) => {
orderForm.value = res.data.order;
payRef.value.setForm({ payRef.value.setForm({
data: res.data.order, data: res.data.order,
cart_id: cart_id, cart_id: cart_id,
@ -107,10 +110,62 @@ const goPay = () => {
payRef.value.drawer = true; payRef.value.drawer = true;
}; };
const paySuccess = () => { const paySuccess = (data = null) => {
// data = {
// out_trade_no: "PF171568087790938356", //
// create_time: "2024-05-14 17:59:05", //
// trade_type: "MICROPAY", //
// transaction_id: "4200002159202405159003084211", //
// }
if(data) onPrint(data);
setTimeout(()=>{
orderRef.value.getList(); orderRef.value.getList();
})
}; };
//
const onPrint = (data)=>{
let goods = [];
orderRef.value.list.forEach((item) => {
goods.push({
name: item.goods_name, //
sell: item.sell, //
nums: item.cart_num, //
unit_name: item.unit_name, //
total: item.goods_total_price, //
});
});
let obj = {
mer_name: userStore.userInfo.merchant.mer_name, //
service_phone: userStore.userInfo.merchant.service_phone, //
number: data.out_trade_no, //
create_time: data.create_time, //
total_price: orderForm.value.total, //
pay_price: orderForm.value.total, //
pay_type: data.trade_type=='MICROPAY' ? '微信支付':'余额支付', //
pay_number: data.transaction_id, //
goods: goods, //
};
if (goods.length > 0) {
let str = printTicket(obj);
console.log(str);
uni.getEnv((res) => {
if (res.app) {
APPprint(content);
setTimeout(() => {
isPrint = false;
}, 4000);
}
});
uni.postMessage({
data: {
type: "print",
content: str,
},
});
}
}
// //
const aF9 = () => { const aF9 = () => {
if (route.name != "saleHome") return; if (route.name != "saleHome") return;

View File

@ -169,8 +169,8 @@ onUnmounted(() => {
<div class="info-item-title">支付方式:</div> <div class="info-item-title">支付方式:</div>
<div class="info-item-info"> <div class="info-item-info">
<span v-if="formData.pay_type == 9">微信收款</span> <span v-if="formData.pay_type == 9">微信收款</span>
<span v-if="formData.pay_type == 1">余额支付</span> <span v-if="formData.pay_type == 3">余额支付</span>
<span v-if="formData.pay_type == 3">微信支付</span> <span v-if="formData.pay_type == 1">微信支付</span>
</div> </div>
</div> </div>
</div> </div>

View File

@ -43,6 +43,11 @@ const changeDate = () => {
getOrderList(true); getOrderList(true);
}; };
const disabledDate = (time)=>{
return time.getTime() > Date.now();
}
const where = ref({ const where = ref({
page_no: 1, page_no: 1,
page_size: 20, page_size: 20,
@ -187,8 +192,8 @@ onUnmounted(()=>{
<div v-if="item.paid"> <div v-if="item.paid">
已支付 已支付
<span v-if="item.pay_type == 9">(微信收款)</span> <span v-if="item.pay_type == 9">(微信收款)</span>
<span v-if="item.pay_type == 1">(余额支付)</span> <span v-if="item.pay_type == 3">(余额支付)</span>
<span v-if="item.pay_type == 3">(微信支付)</span> <span v-if="item.pay_type == 1">(微信支付)</span>
<!-- <span class="manage-btn">待处理</span> --> <!-- <span class="manage-btn">待处理</span> -->
</div> </div>
<div v-else style="color: #ff4a00">未支付</div> <div v-else style="color: #ff4a00">未支付</div>

View File

@ -23,20 +23,19 @@ const payRef = ref(null);
const where = ref({ const where = ref({
page_no: 1, page_no: 1,
page_size: 15, page_size: 15,
staff_id: userStore.userInfo.service.service_id,
}); });
const loading = ref(false); const loading = ref(false);
const total = ref(0); const total = ref(0);
const getOrderList = () => { const getOrderList = () => {
orderPriceApi(userStore.userInfo.service.mer_id, where.value).then((res) => { orderPriceApi(where.value).then((res) => {
orderList.value = res.data; orderList.value = res.data;
// total.value = res.data.count; // total.value = res.data.count;
}); });
}; };
getOrderList(); // getOrderList();
const formData = ref({}); const formData = ref({});
const getStatistics = () => { const getStatistics = () => {
@ -48,7 +47,7 @@ const getStatistics = () => {
loading.value = false; loading.value = false;
}); });
}; };
getStatistics(); // getStatistics();
const prevClick = (e) => { const prevClick = (e) => {
where.value.page_no = e; where.value.page_no = e;