This commit is contained in:
weipengfei 2024-05-17 18:24:08 +08:00
parent 968e194688
commit eb1a881d92
4 changed files with 46 additions and 7 deletions

View File

@ -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'
VITE_PUSH_URL ='wss://erp.lihaink.cn/pull'
VITE_BASE_URL = 'https://erp.lihaink.cn'

View File

@ -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");
});
</script>

View File

@ -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(()=>{
提交采购</el-button
>
</div>
<el-dialog
v-model="dialogVisible"
title="您有新的订单,是否立即刷新"
width="500"
:before-close="handleClose"
>
<template #footer>
<div class="dialog-footer">
<el-button @click="dialogVisible = false">稍后刷新</el-button>
<el-button type="primary" @click="getOrderList(true)">
立即刷新
</el-button>
</div>
</template>
</el-dialog>
</div>
</template>