diff --git a/src/api/shop.js b/src/api/shop.js index 6524f52..54e4fb4 100644 --- a/src/api/shop.js +++ b/src/api/shop.js @@ -76,3 +76,14 @@ export const todayTrend = (data) => { data, }) } + +/** + * 热卖商品 + */ +export const hotProduct = (data) => { + return service({ + url: 'hard/panel-shop/hot-product', + method: 'post', + data, + }) +} diff --git a/src/components/device-status.vue b/src/components/device-status.vue index 6695a75..3f8ec8c 100644 --- a/src/components/device-status.vue +++ b/src/components/device-status.vue @@ -71,6 +71,7 @@ const styleConfig = [ ]; const doCar = (item) => { + return if (item.total == 0) { ElMessage.warning(`当前${item.name}设备总数为0,无法跳转`); return; diff --git a/src/views/shop.vue b/src/views/shop.vue index 955fd03..9d46073 100644 --- a/src/views/shop.vue +++ b/src/views/shop.vue @@ -3,9 +3,10 @@ - + @@ -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; } } - + \ No newline at end of file