态势感知平台-武汉市开源生态建设-统计概览1 接口对接

This commit is contained in:
d266377
2026-01-29 16:55:18 +08:00
parent e51e9a2176
commit 3eef874bb8

View File

@@ -1,36 +1,98 @@
<template> <template>
<div class="stats-glass-bar"> <div class="stats-glass-bar">
<div class="stat-node"> <div class="stat-node">
<span class="stat-value">1000W+</span> <span class="stat-value">{{ hmDevelopers }}</span>
<span class="stat-desc">鸿蒙开发者</span> <span class="stat-desc">鸿蒙开发者</span>
</div> </div>
<div class="stat-separator"></div> <div class="stat-separator"></div>
<div class="stat-node"> <div class="stat-node">
<span class="stat-value">60W+</span> <span class="stat-value">{{ hmCertificationDevelopers }}</span>
<span class="stat-desc">鸿蒙认证开发者</span> <span class="stat-desc">鸿蒙认证开发者</span>
</div> </div>
<div class="stat-separator"></div> <div class="stat-separator"></div>
<div class="stat-node"> <div class="stat-node">
<span class="stat-value">1W+</span> <span class="stat-value">{{ whHmCertificationDevelopers }}</span>
<span class="stat-desc">武汉鸿蒙认证开发者</span> <span class="stat-desc">武汉鸿蒙认证开发者</span>
</div> </div>
<div class="stat-separator"></div> <div class="stat-separator"></div>
<div class="stat-node"> <div class="stat-node">
<span class="stat-value">728</span> <span class="stat-value">{{ hmProjects }}</span>
<span class="stat-desc">鸿蒙开源项目</span> <span class="stat-desc">鸿蒙开源项目</span>
</div> </div>
<div class="stat-separator"></div> <div class="stat-separator"></div>
<div class="stat-node"> <div class="stat-node">
<span class="stat-value">600+</span> <span class="stat-value">{{ hmCompanies }}</span>
<span class="stat-desc">鸿蒙开源企业</span> <span class="stat-desc">鸿蒙开源企业</span>
</div> </div>
</div> </div>
</template> </template>
<script> <script lang="ts" setup>
export default { import { ref, onMounted } from 'vue';
name: "StatsBar" import { hmStatsBarPage3 } from '@/api/jyh/situation';
}
// 定义响应式数据
const hmDevelopers = ref<string>('加载中...');
const hmCertificationDevelopers = ref<string>('加载中...');
const whHmCertificationDevelopers = ref<string>('加载中...');
const hmProjects = ref<string>('加载中...');
const hmCompanies = ref<string>('加载中...');
// 加载状态
const loading = ref(true);
// 格式化数字的工具函数
const formatNumber = (num: number, unit: string = ''): string => {
if (num >= 100000000) {
return (num / 100000000).toFixed(1) + '亿';
} else if (num >= 10000) {
return (num / 10000).toFixed(1) + '万';
} else if (num >= 1000) {
return (num / 1000).toFixed(1) + '千';
}
return num.toString();
};
// 获取统计数据
const fetchStats = async () => {
try {
loading.value = true;
const response = await hmStatsBarPage3();
if (response.code === 200 && response.data) {
const { developer, certificationDeveloper, wuhanCertificationDeveloper, project, company } = response.data;
// 格式化数据显示
hmDevelopers.value = `${formatNumber(developer)}+`;
hmCertificationDevelopers.value = `${formatNumber(certificationDeveloper)}+`;
whHmCertificationDevelopers.value = `${formatNumber(wuhanCertificationDeveloper)}+`;
hmProjects.value = `${formatNumber(project)}`;
hmCompanies.value = `${formatNumber(company)}+`;
} else {
console.error('获取鸿蒙统计数据失败:', response.msg || '未知错误');
// 设置默认值
hmDevelopers.value = '1000万+';
hmCertificationDevelopers.value = '60万+';
whHmCertificationDevelopers.value = '1万+';
hmProjects.value = '728';
hmCompanies.value = '600+';
}
} catch (error) {
console.error('获取鸿蒙统计数据异常:', error);
// 设置默认值
hmDevelopers.value = '1000万+';
hmCertificationDevelopers.value = '60万+';
whHmCertificationDevelopers.value = '1万+';
hmProjects.value = '728';
hmCompanies.value = '600+';
} finally {
loading.value = false;
}
};
onMounted(() => {
fetchStats();
});
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>