diff --git a/.env.development b/.env.development index 8a2f4db..23c6711 100644 --- a/.env.development +++ b/.env.development @@ -1,7 +1,7 @@ VITE_NOW_TYPE = 'dist' -VITE_PUSH_URL = 'ws://192.168.1.22:8787' -VITE_BASE_URL = 'http://192.168.1.22:8546' +# 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 = 'https://erp.lihaink.cn' \ No newline at end of file +VITE_PUSH_URL ='wss://erp.lihaink.cn/pull' +VITE_BASE_URL = 'https://erp.lihaink.cn' \ No newline at end of file diff --git a/src/layout/index.vue b/src/layout/index.vue index 7c067ea..1bbc831 100644 --- a/src/layout/index.vue +++ b/src/layout/index.vue @@ -32,7 +32,7 @@ user_channel.on('message', function (data) { }); // 断线事件 user_channel.on('close', function () { - + }); const KeyboardEvent = (e)=>{ diff --git a/src/layout/myAside.vue b/src/layout/myAside.vue index 3f41d55..38f23ac 100644 --- a/src/layout/myAside.vue +++ b/src/layout/myAside.vue @@ -21,15 +21,22 @@ const setOrderCount = (e = 1) => { }) }; +let isPlaying = false; const newOrder = (e) => { merchantOrderCountApi().then((res) => { setOrderCount(res?.data?.order_count || 0); }); - ElMessage.success('您有新的订单') + ElMessage.success('您有新的订单'); + if (isPlaying) return; //正在播放时有新订单直接跳过播放 // 创建音频对象 var audio = new Audio("/src/assets/order.mp3"); // 播放音频 audio.play(); + isPlaying = true; + // 添加ended事件监听器来检测播放结束 + audio.addEventListener('ended', function() { + isPlaying = false; + }); }; // setTimeout(() => { @@ -68,6 +75,9 @@ onMounted(() => { mitt.on("up", aup); mitt.on("down", adown); mitt.on("new_order", newOrder); + mitt.on("set-order-count-zero", ()=>{ + setOrderCount(0); + }); merchantOrderCountApi().then((res) => { setOrderCount(res?.data?.order_count || 0); }); @@ -77,6 +87,7 @@ onUnmounted(() => { mitt.off("aup", aup); mitt.off("adown", adown); mitt.off("new_order", newOrder); + mitt.on("set-order-count-zero"); }); diff --git a/src/views/order/component/order.vue b/src/views/order/component/order.vue index 059f348..19211db 100644 --- a/src/views/order/component/order.vue +++ b/src/views/order/component/order.vue @@ -10,7 +10,7 @@ import { } from "@/api/store.js"; import { useUserStore } from "@/store/user.js"; import { ElMessage } from "element-plus"; -import { useRouter } from "vue-router"; +import { useRoute } from "vue-router"; import mitt from "@/utils/mitt.js"; import moment from "moment"; @@ -26,6 +26,8 @@ const props = defineProps({ }, }); +const route = useRoute(); + const lists = ref([]); const tabPosition = ref(1); // 1-全部, 2-未支付 @@ -51,6 +53,7 @@ const where = ref({ page_size: 20, number: "", date: moment(new Date()).format("YYYY-MM-DD"), + is_mer: 1 // source: props.source, }); @@ -66,6 +69,7 @@ const getOrderList = (reload = false) => { loading.value = true; if (tabPosition.value == 1) where.value.paid = null; if (tabPosition.value == 2) where.value.paid = 0; + dialogVisible.value = false; orderListApi(where.value) .then((res) => { if (reload) orderList.value = res.data.lists; @@ -87,6 +91,7 @@ const submitOrder = ()=>{ createOrderApi().then(res=>{ ElMessage.success("提交成功"); getOrderList(true); + mitt.emit("set-order-count-zero", res.data); }) } @@ -104,10 +109,18 @@ const addAddress = (item)=>{ emit('addAddress',item) } +const dialogVisible = ref(false); + onMounted(() => { mitt.on("update-c-order-detail", (item) => { orderList.value[activeStore.value].paid = 1; }); + dialogVisible.value = true; + mitt.on("new_order", ()=>{ + if(route.name == "order"){ + dialogVisible.value = true; + } + }); }); onUnmounted(()=>{ mitt.off("update-c-order-detail"); @@ -227,6 +240,21 @@ onUnmounted(()=>{ 提交采购 + + +