feat:热卖商品

This commit is contained in:
dzc committed 2025-10-28 11:06:11 +08:00
1 parent 17939088d6
commit b8f26fa8a1
3 files changed
+35 -27

No files matched your search

+11
View File
@@ -76,3 +76,14 @@ export const todayTrend = (data) => {
data,
})
}
/**
* 热卖商品
*/
export const hotProduct = (data) => {
return service({
url: 'hard/panel-shop/hot-product',
method: 'post',
data,
})
}
+1
View File
@@ -71,6 +71,7 @@ const styleConfig = [
];
const doCar = (item) => {
return
if (item.total == 0) {
ElMessage.warning(`当前${item.name}设备总数为0,无法跳转`);
return;
+23 -27
View File
@@ -3,9 +3,10 @@
<el-aside class="aside">
<AsideBlock>
<template #header>
<span>设备状态统计</span>
<span>热卖商品</span>
</template>
<DeviceStatus :data="timerObj.deviceTotal.data" />
<AbnormalEventTypeStatus title="购买次数" type="shop" :data="timerObj.shopHotProduct.data"
@changeDateType="alarmTotalByTimerChnageDateType" />
</AsideBlock>
<AsideBlock>
@@ -71,7 +72,6 @@ import { simplePoll } from "@/utils/poll"
import { displayPrice } from "@/utils/format-money"
import AsideBlock from "@/components/aside-block.vue";
import DeviceStatus from "@/components/device-status.vue";
import DeviceOnlineLineChart from "@/components/device-online-line-chart.vue";
import PersonAbnormalEventLineChart from "@/components/person-abnormal-event-line-chart.vue";
import DeviceMonitoringQuantity from "@/components/device-monitoring-quantity.vue";
@@ -79,6 +79,7 @@ import AbnormalEventTypeStatus from "@/components/abnormal-event-type-status.vue
import AbnormalEventList from "@/components/abnormal-event-list.vue";
import ShopReport from "@/components/shop-report.vue";
import useNotification from "@/components/notification/index";
const { notificationAdd, notificationClear } = useNotification();
@@ -90,8 +91,8 @@ const queryParams = reactive({
})
const timerObj = reactive({
// 设备状态统计
deviceTotal: {
// 热卖商品
shopHotProduct: {
initial: null,
interval: 10 * 1000,
data: null,
@@ -157,6 +158,7 @@ const timerObj = reactive({
});
onMounted(() => {
getShopHotProduct();
getAreaCameraTotalData();
getAlarmData();
getAlarmListData();
@@ -175,34 +177,28 @@ onBeforeUnmount(() => {
}
});
// 设备状态统计
const getDeviceStatusData = () => {
timerObj.deviceTotal.initial = simplePoll(async () => {
// 热卖商品
const getShopHotProduct = () => {
timerObj.shopHotProduct.initial = simplePoll(async () => {
try {
const { code, data } = await deviceApi.totalDevice({ ...timerObj.deviceTotal.queryParams });
const { code, data } = await shopApi.hotProduct({ ...timerObj.shopHotProduct.queryParams });
if (code != 0) throw new Error("code!=0");
console.log("设备状态统计:", data);
console.log("热卖商品:", data);
if (!data) {
return;
}
const _array = Array(3).fill({});
const _keyList = ["door", "gate", "camera"];
for (let index = 0; index < _keyList.length; index++) {
const target = data[_keyList[index]];
if (!target) continue;
_array[index] = {
name: target.deviceName,
total: target.total,
type: target.deviceCategory,
online: target.online,
onlineRate: target.onlineRate,
};
}
timerObj.deviceTotal.data = _array;
timerObj.shopHotProduct.data =
data.map((v) => {
return {
title: v.productName,
type: v.productId,
total: v.buyProductCount ?? 0,
};
}) ?? [];
} catch (error) {
console.error("|设备状态统计|意外的错误:", error);
console.error("|热卖商品|意外的错误:", error);
}
}, timerObj.deviceTotal.interval);
}, timerObj.shopHotProduct.interval);
};
const changeQueryDate = (e) => {
@@ -385,4 +381,4 @@ const getNotification = () => {
margin: 0 1vw;
}
}
</style>
</style>