From eba5899cd6f5fba77abca57e9140998acc46a60c Mon Sep 17 00:00:00 2001 From: xjs Date: Fri, 23 May 2025 11:39:05 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=8E=A5=E5=8F=A3=E5=AF=B9=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/js/polling.worker.js | 39 ++ src/api/customAxios.ts | 205 ----------- src/api/customFetch.ts | 62 ++++ src/api/encryptUrl.ts | 12 - src/api/fetchUrl.ts | 13 + src/components/watch/DigitalWatch.vue | 6 +- src/composables/useDate.ts | 4 +- src/composables/usePolling.ts | 59 +++ src/utils/convertNumber.ts | 13 + src/utils/date.ts | 34 ++ src/views/components/AskSection.vue | 7 +- src/views/components/ChargingRanking.vue | 22 +- src/views/components/GainToday.vue | 20 +- src/views/components/GainTotal.vue | 17 +- src/views/components/LossStatic.vue | 14 +- src/views/components/OfflineStatus.vue | 203 ++++++----- src/views/components/OnlineStatus.vue | 31 +- src/views/components/OperatingTrends.vue | 36 +- src/views/components/PaymentTotal.vue | 33 +- src/views/components/SixStatistics.vue | 6 +- src/views/components/StudentSource.vue | 21 +- src/views/components/TodayPayment.vue | 22 +- src/views/components/WinCustomer.vue | 21 +- .../chartsComponents/AskSectionChart.vue | 344 +++++++++++------- .../chartsComponents/OperatingTrendsChart.vue | 215 ++++++++--- .../chartsComponents/ProportionCharts.vue | 224 ++++++------ .../chartsComponents/SixStatisticsChart.vue | 17 +- .../chartsComponents/StudentSourceChart.vue | 5 +- src/views/composables/useFetchData.ts | 65 ++++ src/views/home.vue | 35 +- 30 files changed, 1100 insertions(+), 705 deletions(-) create mode 100644 public/js/polling.worker.js delete mode 100644 src/api/customAxios.ts create mode 100644 src/api/customFetch.ts delete mode 100644 src/api/encryptUrl.ts create mode 100644 src/api/fetchUrl.ts create mode 100644 src/composables/usePolling.ts create mode 100644 src/utils/convertNumber.ts create mode 100644 src/utils/date.ts create mode 100644 src/views/composables/useFetchData.ts diff --git a/public/js/polling.worker.js b/public/js/polling.worker.js new file mode 100644 index 0000000..0ef0bca --- /dev/null +++ b/public/js/polling.worker.js @@ -0,0 +1,39 @@ +// timer.worker.js +let timer = null; +let interval = 1000; + +self.addEventListener('message', (e) => { + switch (e.data.command) { + case 'start': + startTimer(e.data.interval); + break; + case 'stop': + stopTimer(); + break; + case 'update': + interval = e.data.interval; + break; + } +}); + +// 关闭时的清理逻辑 +self.addEventListener('close', () => { + stopTimer(); + }); + +function startTimer(newInterval) { + interval = newInterval || interval; + stopTimer(); // 先停止已有定时器 + self.postMessage({ type: 'tick', timestamp:performance.now() }); + timer = setInterval(() => { + const timestamp = performance.now(); + self.postMessage({ type: 'tick', timestamp }); + }, interval); +} + +function stopTimer() { + if (timer) { + clearInterval(timer); + timer = null; + } +} \ No newline at end of file diff --git a/src/api/customAxios.ts b/src/api/customAxios.ts deleted file mode 100644 index 39b23b7..0000000 --- a/src/api/customAxios.ts +++ /dev/null @@ -1,205 +0,0 @@ -import axios, { AxiosRequestConfig } from 'axios' -import { handleUrl } from './encryptUrl' - -// 自定义判断元素类型JS -function toType(obj: any): string { - return {}.toString - .call(obj) - .match(/\s([a-zA-Z]+)/)![1] - .toLowerCase() -} -// 参数过滤函数 -function filterNull(o: any) { - for (var key in o) { - if (o[key] === null) { - delete o[key] - } - if (toType(o[key]) === 'string') { - o[key] = o[key].trim() - } else if (toType(o[key]) === 'object') { - o[key] = filterNull(o[key]) - } else if (toType(o[key]) === 'array') { - o[key] = filterNull(o[key]) - } - } - return o -} -/* - 接口处理函数 - 这个函数每个项目都是不一样的,我现在调整的是适用于 - https://cnodejs.org/api/v1 的接口,如果是其他接口 - 需要根据接口的参数进行调整。参考说明文档地址: - https://cnodejs.org/topic/5378720ed6e2d16149fa16bd - 主要是,不同的接口的成功标识和失败提示是不一致的。 - 另外,不同的项目的处理方法也是不一致的,这里出错就是简单的alert -*/ - -function apiAxios( - method: string, - url: string, - params: null | string | object, - success: any, - failure: any, - unEncrypt: boolean = false // 是否不加密 -) { - let contentTypeIsJson = false - if (params && typeof params != 'string') { - params = filterNull(params) - } else contentTypeIsJson = true - - axios({ - method: method, - url: url, - data: method === 'POST' || method === 'PUT' ? params : null, - params: method === 'GET' || method === 'DELETE' ? params : null, - withCredentials: true, - crossDomain: true, - unEncrypt, - transformRequest: [ - function (data) { - if (contentTypeIsJson) return data - let ret = '' - for (let it in data) { - ret += - encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&' - } - return ret - }, - ], - headers: { - 'Content-Type': contentTypeIsJson - ? 'application/json' - : 'application/x-www-form-urlencoded', - }, - } as AxiosRequestConfig) - .then(function (res) { - let response = res.data - if (response.code == 200) { - if (success) { - success(response) - } - } else { - if (failure) { - failure(response) - } else { - if (response.code == 2) { - //错误处理 - setTimeout(() => { - location.reload() - }, 1000) - } else { - //错误处理 - } - } - } - }) - .catch(function (err) { - let res = err.response - console.error(res || err) - if (res) { - // 清楚所有的错误提示 - clearTimeout(timeObj) - if (res.data.msg) { - //错误处理 - } else { - //错误处理 - } - return - } - }) -} - - -let requestCount = 0 -let timeObj: NodeJS.Timeout -// http request 拦截器 -axios.interceptors.request.use((config) => { - requestCount++ - if (requestCount == 1) { - timeObj = setTimeout(() => { - //加载中提示 - }, 800) - } - - if ( - config.data && - Object.prototype.toString.call(config.data) == '[object FormData]' - ) { - config.headers!!['Content-Type'] = 'multipart/form-data;charset=utf-8' - config.transformRequest = [ - function (data) { - return data - }, - ] - } - // 拦截配置,有新的配置,在这里新增函数处理,然后合并config - let _config = handleUrl(config) - config = Object.assign(config, _config) - return config -}) - -// http response 拦截器 -axios.interceptors.response.use((response) => { - requestCount-- - if (requestCount === 0) { - setTimeout(() => { - // 关闭所有提示 - }, 1500) - clearTimeout(timeObj) - } - return response -},error =>{ - // let xhrErrL = { type: "XHRERR", data: error.response }; - if (error.response) { - const { status, data } = error.response; - if (status === 422) { - alert(data) - } - } -}) - - -// 返回在vue模板中的调用接口 -export default { - get: function ( - url: string, - params: string | object | null, - success: any, - failure: any - ) { - return apiAxios('GET', url, params, success, failure) - }, - post: function ( - url: string, - params: string | object, - success: any, - failure: any - ) { - return apiAxios('POST', url, params, success, failure) - }, - put: function ( - url: string, - params: string | object, - success: any, - failure: any - ) { - return apiAxios('PUT', url, params, success, failure) - }, - delete: function ( - url: string, - params: string | object, - success: any, - failure: any - ) { - return apiAxios('DELETE', url, params, success, failure) - }, - // 不加密的post请求 - unEncryptPost: function ( - url: string, - params: string | object, - success: any, - failure: any, - ) { - return apiAxios('POST', url, params, success, failure,true) - } -} \ No newline at end of file diff --git a/src/api/customFetch.ts b/src/api/customFetch.ts new file mode 100644 index 0000000..85931ae --- /dev/null +++ b/src/api/customFetch.ts @@ -0,0 +1,62 @@ +/* + * @Author: HideInMatrix + * @Date: 2024-07-15 + * @LastEditors: error: git config user.name & please set dead value or install git + * @LastEditTime: 2024-09-01 + * @Description: 请求封装 + * @FilePath: /free-music-react/src/lib/customFetch.ts + */ +type HttpMethod = "GET" | "POST" | "PUT" | "DELETE"; + +interface FetchOptions extends RequestInit { + headers?: Record; +} + +interface ApiResponse { + result?: unknown; + error?: string; + code?: number; + success?: boolean; + message?:string; +} + +const apiClient = (method: HttpMethod) => { + return async ( + url: string, + data?: unknown, + options: FetchOptions = {} + ): Promise => { + const config: FetchOptions = { + method, + ...options, + }; + + if (method !== "GET" && data) { + config.body = JSON.stringify(data); + } else if (method === "GET" && data) { + const _params = []; + for (const [key, value] of Object.entries(data)) { + _params.push(`${key}=${value}`); + } + url += `?${_params.join("&")}`; + } + + const response = await fetch(`${url}`, config); + + const result = await response.json(); + + if (!response.ok) { + return { + error: result.message || "Request failed", + code: response.status, + }; + } + + return result; + }; +}; + +export const getRequest = apiClient("GET"); +export const postRequest = apiClient("POST"); +export const putRequest = apiClient("PUT"); +export const deleteRequest = apiClient("DELETE"); diff --git a/src/api/encryptUrl.ts b/src/api/encryptUrl.ts deleted file mode 100644 index 5963771..0000000 --- a/src/api/encryptUrl.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 对指定请求链接进行加密 - -import { AxiosRequestConfig } from "axios"; -import { useUserStore } from "@/store/user"; - -export const handleUrl = async (config: (AxiosRequestConfig & {unEncrypt?: boolean})) => { - const userStore = useUserStore() - if(userStore.getToken){ - config.headers!!["Authorization"] = `Bearer ${userStore.getToken}` - } - return config; -} \ No newline at end of file diff --git a/src/api/fetchUrl.ts b/src/api/fetchUrl.ts new file mode 100644 index 0000000..0f64249 --- /dev/null +++ b/src/api/fetchUrl.ts @@ -0,0 +1,13 @@ +const baseUrl = "http://api.screen.jinze.ycymedu.com"; + +export const getPaymentUrl = () => `${baseUrl}/api/bigScreenData/bigScreenData`; + +export const getGainUrl = () => `${baseUrl}/api/bigScreenData/bigScreenCustomerAcq`; + +export const getAcqTrend = () => `${baseUrl}/api/bigScreenData/bigScreenAcqTrend`; + +export const getSegmentStatic = () => `${baseUrl}/api/bigScreenData/bigScreenStages`; + +export const getBigScreenRanking = () => `${baseUrl}/api/bigScreenData/bigScreenRanks`; + +export const getSixStatisticsUrl = () => `${baseUrl}/api/bigScreenData/wechatData` diff --git a/src/components/watch/DigitalWatch.vue b/src/components/watch/DigitalWatch.vue index 4c60817..052135a 100644 --- a/src/components/watch/DigitalWatch.vue +++ b/src/components/watch/DigitalWatch.vue @@ -117,11 +117,11 @@ const getSegmentClass = (digit: string, index: number) => { let timer: number | null = null; -let { hours, minutes, seconds, updateTime } = useDate() +let { hours, minutes, seconds, formateTime } = useDate() onMounted(() => { - updateTime(); - timer = window.setInterval(updateTime, 500); + formateTime(); + timer = window.setInterval(formateTime, 500); }); onUnmounted(() => { diff --git a/src/composables/useDate.ts b/src/composables/useDate.ts index b29477b..d7dc3d3 100644 --- a/src/composables/useDate.ts +++ b/src/composables/useDate.ts @@ -9,7 +9,7 @@ export const useDate = () => { let timer: number | null = null; - const updateTime = () => { + const formateTime = () => { const now = new Date(); hours.value = now.getHours().toString().padStart(2, "0"); @@ -35,6 +35,6 @@ export const useDate = () => { day, weekday, // 返回星期几 timer, - updateTime, + formateTime, }; }; \ No newline at end of file diff --git a/src/composables/usePolling.ts b/src/composables/usePolling.ts new file mode 100644 index 0000000..d9e6aba --- /dev/null +++ b/src/composables/usePolling.ts @@ -0,0 +1,59 @@ +// 定义函数类型,支持任意参数 +type PollingCallback = (...args: any[]) => void; + +export const requestArray = new Map(); +// 添加函数到 Map +export const addRequest = (key: string, callback: PollingCallback, args?: any[]) => { + requestArray.set(key, { callback, args }); +}; + +// 从 Map 中移除函数 +export const removeRequest = (key: string) => { + requestArray.delete(key); +}; + +export const runImmediatelyByKey = (key: string) => { + const { callback, args } = requestArray.get(key) || {}; + if (callback) { + callback(...(args || [])); + } +}; + +export const runImmediatelyAll = () => { + updateTime.value = new Date().getTime(); + requestArray.forEach(({ callback, args }) => { + if (args) { + callback(...args); + }else{ + callback() + } + }); +}; + +export let updateTime = ref(0); + +export const usePolling = () => { + const pollingWorker = new Worker("/js/polling.worker.js"); + + pollingWorker.onmessage = (_e: any) => { + // 执行所有存储的函数 + updateTime.value = new Date().getTime(); + requestArray.forEach(({ callback, args }) => { + if (args) { + callback(...args); + } else { + callback(); + } + }); + }; + + onMounted(() => { + pollingWorker.postMessage({ command: "start", interval: 1000 * 60 * 60 }); + }); + + onBeforeUnmount(() => { + pollingWorker.postMessage({ command: "stop" }); + // 清理所有存储的函数 + requestArray.clear(); + }); +}; diff --git a/src/utils/convertNumber.ts b/src/utils/convertNumber.ts new file mode 100644 index 0000000..50f92e5 --- /dev/null +++ b/src/utils/convertNumber.ts @@ -0,0 +1,13 @@ +export function convertNumber(n: number): string { + if (n >= 10000) { + const value = n / 10000; + return `${value.toString().replace(/\.0$/, '')}W`; + } else if (n >= 1000) { + const value = n / 1000; + return `${value.toString().replace(/\.0$/, '')}K`; + } else if (n >= 1) { + const value = n / 1000; + return `${value.toString().replace(/0+$/, '').replace(/\.$/, '')}K`; + } + return n.toString(); +} \ No newline at end of file diff --git a/src/utils/date.ts b/src/utils/date.ts new file mode 100644 index 0000000..b4ffa95 --- /dev/null +++ b/src/utils/date.ts @@ -0,0 +1,34 @@ +/** + * 将毫秒时间戳转换为 "月.日 时:分:秒" 的格式 + * @param timestamp 时间戳(毫秒) + * @returns 格式化后的时间字符串,如 "6.12 12:00:00" + */ +export const formatDatetime = (timestamp: number): string => { + const date = new Date(timestamp); + + // 获取月份(注意:getMonth 返回的月份是从0开始的,所以需要+1) + const month = date.getMonth() + 1; + + // 获取日期 + const day = date.getDate(); + + // 获取小时 + const hours = date.getHours().toString().padStart(2, '0'); + + // 获取分钟 + const minutes = date.getMinutes().toString().padStart(2, '0'); + + // 获取秒数 + const seconds = date.getSeconds().toString().padStart(2, '0'); + + // 组合成最终格式 + return `${month}.${day} ${hours}:${minutes}:${seconds}`; +}; + +/** + * 获取当前时间的毫秒时间戳 + * @returns 当前时间的毫秒时间戳 + */ +export const getCurrentTimestamp = (): number => { + return Date.now(); +}; diff --git a/src/views/components/AskSection.vue b/src/views/components/AskSection.vue index 7f7b832..a76665d 100644 --- a/src/views/components/AskSection.vue +++ b/src/views/components/AskSection.vue @@ -11,7 +11,7 @@
- +
@@ -38,7 +38,10 @@ const { default: svg } = await import("/src/assets/svg-img/arrow-left.svg?raw"); arrowLeftSvg.value = svg; }; - + + const askSectionData = inject("askSectionData",ref({stages:[]})) + + onBeforeMount(() => { getHeaderLeftSvg(); getHeaderRightSvg(); diff --git a/src/views/components/ChargingRanking.vue b/src/views/components/ChargingRanking.vue index 3844903..bc19696 100644 --- a/src/views/components/ChargingRanking.vue +++ b/src/views/components/ChargingRanking.vue @@ -39,10 +39,28 @@ const columns = [ { field: "rank", header: "名次", align: "justify-center", width: "68px" }, { field: "name", header: "姓名", align: "justify-left", width: "100px" }, - { field: "Status", header: "获客人数", align: "justify-center", width: "96px" }, + { field: "total", header: "收费人数", align: "justify-center", width: "96px" }, ]; - const products = [{ name: "张三" }, { name: "张三" }, { name: "张三" }, { name: "张三" }, { name: "张三" }]; + let products = ref([]); + const chargingRankingData = inject( + "chargingRankingData", + ref<{ + paymentRanks: any[]; + }>({ + paymentRanks: [], + }), + ); + + watch( + () => chargingRankingData.value, + () => { + if(chargingRankingData.value.paymentRanks){ + products.value = chargingRankingData.value.paymentRanks + + } + }, + ); const headerLeftSvg = ref(""); const headerRightSvg = ref(""); diff --git a/src/views/components/GainToday.vue b/src/views/components/GainToday.vue index 1864130..4b6cb9a 100644 --- a/src/views/components/GainToday.vue +++ b/src/views/components/GainToday.vue @@ -5,8 +5,8 @@
今日获客
-
- 125 +
+ {{ gainData.toDayAcq || 0 }}
@@ -17,11 +17,11 @@

昨日获客人数

-

177人

-
+

{{ gainData.yestertDayAcq || 0 }}人

+
今日较昨日 - - 12人 + + {{ Math.abs(gainDifferentTody) }}人
@@ -34,6 +34,7 @@ import SvgIcon from "@/components/svg-icon/SvgIcon.vue"; + const gainData = inject("gainData",ref({toDayAcq:0,yestertDayAcq:0})) const groupSvg = ref(""); const getGroupBackgroundSvg = async () => { @@ -41,6 +42,13 @@ groupSvg.value = svg; }; + const gainDifferentTody = computed(() => { + if((Object.prototype.toString.call(gainData.value.toDayAcq) !== "[object Undefined]") && (Object.prototype.toString.call(gainData.value.yestertDayAcq) !== "[object Undefined]")){ + return gainData.value.toDayAcq - gainData.value.yestertDayAcq + }else{ + return 0; + } + }) const hexagonalBoxSvg = ref(""); diff --git a/src/views/components/GainTotal.vue b/src/views/components/GainTotal.vue index 80e9e85..bec21ca 100644 --- a/src/views/components/GainTotal.vue +++ b/src/views/components/GainTotal.vue @@ -5,17 +5,17 @@
总获客
-
- 125 +
+ {{gainData.acqTotal}}
- 目标值2W + 目标值{{ convertNumber(gainData.goalTotal || 0)}} - 当前值0.5W + 当前值{{convertNumber(gainData.acqTotal ||0) }}
@@ -23,6 +23,7 @@ - - - \ No newline at end of file +
+
+
+ + +
+
+
+
690
+
+
+
线下
+
+
+
    +
  • +
    +
    +
    + {{ item.name }} + {{ item.value }}人 +
    +
    +
    +
  • +
+
+
+ + + + + diff --git a/src/views/components/OnlineStatus.vue b/src/views/components/OnlineStatus.vue index 5cdfaf8..baf24a1 100644 --- a/src/views/components/OnlineStatus.vue +++ b/src/views/components/OnlineStatus.vue @@ -17,11 +17,8 @@
-
-
- 690 -
+
+
690
线上
@@ -36,7 +33,7 @@ {{ item.value }}人
-
+
@@ -71,12 +68,22 @@ const { default: svg } = await import("/src/assets/svg-img/arrow-left.svg?raw"); arrowLeftSvg.value = svg; }; - const chartData = ref([ - { name: "类型A", value: 250, color: "#0783FA" }, - { name: "类型B", value: 274, color: "#07D1FA" }, - { name: "类型C", value: 310, color: "#20E6A4" }, - { name: "类型D", value: 135, color: "#FFD15C" }, - ]); + + const colorList = ref(["#0783FA", "#07D1FA", "#20E6A4", "#FFD15C"]); + + const askSectionData = inject("askSectionData", ref<{ online: any[] }>({ online: [] })); + + const chartData = ref([]); + + watch(() => askSectionData.value, () => { + if (askSectionData.value.online.length > 0) { + chartData.value = askSectionData.value.online.map((item, index) => ({ + name: item.tag, + value: item.total, + color: colorList.value[index % colorList.value.length], + })); + } + }); onBeforeMount(() => { getHeaderLeftSvg(); diff --git a/src/views/components/OperatingTrends.vue b/src/views/components/OperatingTrends.vue index 5b2461a..c5cef7d 100644 --- a/src/views/components/OperatingTrends.vue +++ b/src/views/components/OperatingTrends.vue @@ -1,24 +1,46 @@ + diff --git a/src/views/components/chartsComponents/SixStatisticsChart.vue b/src/views/components/chartsComponents/SixStatisticsChart.vue index 1d49fe5..737a035 100644 --- a/src/views/components/chartsComponents/SixStatisticsChart.vue +++ b/src/views/components/chartsComponents/SixStatisticsChart.vue @@ -25,6 +25,17 @@ echarts.use([ const chartRef = useTemplateRef("chartRef") let chart: echarts.ECharts | null = null; +const props = defineProps({ + chartData:{ + type:Array, + default: () => [] + } +}) + +watch(() => props.chartData,() => { + initChart(); +}) + const initChart = () => { if(!chartRef.value) return; chart = echarts.init(chartRef.value) @@ -42,7 +53,7 @@ const initChart = () => { xAxis: { type: 'category', boundaryGap: false, - data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'], + data: props.chartData.map((item:any) => item.date), axisLine: { show: false }, @@ -73,7 +84,7 @@ const initChart = () => { name: '数据1', type: 'line', smooth: true, - data: [120, 132, 101, 134, 90, 230, 210], + data: props.chartData.map((item:any) => item.total), lineStyle: { color: 'rgba(41, 241, 250, 1)', width: 2 @@ -103,7 +114,7 @@ const initChart = () => { } onMounted(() => { - initChart(); + window.addEventListener('resize', () => { chart?.resize(); }); diff --git a/src/views/components/chartsComponents/StudentSourceChart.vue b/src/views/components/chartsComponents/StudentSourceChart.vue index eac1c40..794bff7 100644 --- a/src/views/components/chartsComponents/StudentSourceChart.vue +++ b/src/views/components/chartsComponents/StudentSourceChart.vue @@ -28,8 +28,8 @@ const props = withDefaults(defineProps(), { chartData: [ - { name: "线下", value: 310, itemStyle: { color: "rgba(147, 219, 255, 1)" } }, - { name: "线上", value: 335, itemStyle: { color: "rgb(79, 214, 169)" } }, + { name: "线下", value: 0, itemStyle: { color: "rgba(147, 219, 255, 1)" } }, + { name: "线上", value: 0, itemStyle: { color: "rgb(79, 214, 169)" } }, ], ringSize: 1, }); @@ -206,6 +206,7 @@ height: 106, }, z: 0, + cursor:"point", origin: [127, 53], keyframeAnimation: [ { diff --git a/src/views/composables/useFetchData.ts b/src/views/composables/useFetchData.ts new file mode 100644 index 0000000..088ef57 --- /dev/null +++ b/src/views/composables/useFetchData.ts @@ -0,0 +1,65 @@ + +import {getRequest} from "@/api/customFetch"; +import { getBigScreenRanking, getGainUrl, getPaymentUrl, getSegmentStatic, getSixStatisticsUrl } from "@/api/fetchUrl"; +import { usePolling,addRequest } from "@/composables/usePolling"; + +export const useFetchAllData = () => { + const paymentData = ref({}) + const getPaymentData = () => { + getRequest(getPaymentUrl(),{},{}).then(resp => { + if(resp.code == 200){ + paymentData.value = JSON.parse(JSON.stringify(resp.result)) + } + }) + }; + addRequest('paymentData',getPaymentData) + provide("paymentData",paymentData) + + const gainData = ref({}) + const getGainData = () => { + getRequest(getGainUrl(),null,{}).then(resp => { + if(resp.code === 200){ + gainData.value = resp.result + } + }) + } + addRequest("getGainData",getGainData) + provide("gainData",gainData) + + const askSectionData = ref({}) + const getAskSectionData = () => { + getRequest(getSegmentStatic(), {}, {}).then((resp) => { + if (resp.code === 200) { + askSectionData.value = resp.result; + } + }); + }; + addRequest("getAskSectionData",getAskSectionData) + provide("askSectionData",askSectionData) + + const chargingRankingData = ref({}) + const getChargingRankingData = () => { + getRequest(getBigScreenRanking(),{},{}).then(resp => { + if(resp.code === 200){ + chargingRankingData.value = resp.result + } + }) + } + addRequest("getChargingRankingData",getChargingRankingData) + provide("chargingRankingData",chargingRankingData) + + const sixStatisticsData = ref({}) + const getSixStaticsData = () => { + getRequest(getSixStatisticsUrl(),{},{}).then(resp => { + if(resp.code === 200){ + sixStatisticsData.value = resp.result + } + }) + } + + addRequest('getSixStaticsData',getSixStaticsData) + provide('sixStatisticsData',sixStatisticsData) + + + usePolling(); +} \ No newline at end of file diff --git a/src/views/home.vue b/src/views/home.vue index e806ddd..535e724 100644 --- a/src/views/home.vue +++ b/src/views/home.vue @@ -1,5 +1,5 @@