feat: 添加首页统计数据接口对接
This commit is contained in:
parent
96fe22b0f1
commit
16df533a31
|
|
@ -15,3 +15,18 @@ export const editAccountPass = (params: any) => {
|
|||
return request.post('/user/editAccountPass', { ...params })
|
||||
}
|
||||
|
||||
// 获取首页统计数据
|
||||
export interface DashboardData {
|
||||
agent_count: number
|
||||
user_count: number
|
||||
today_user_count: number
|
||||
today_recharge_amount: string
|
||||
today_withdraw_amount: number
|
||||
total_recharge_amount: number
|
||||
total_withdraw_amount: number
|
||||
}
|
||||
|
||||
export async function getUserIndex(): Promise<DashboardData> {
|
||||
return await request.get<DashboardData>('/user/index')
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,31 +15,58 @@
|
|||
<Agent v-else />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { UserFilled } from '@element-plus/icons-vue'
|
||||
import { getStorage } from '@/utils/storage'
|
||||
import Agent from './components/view/index.vue'
|
||||
import { getUserIndex } from '@/api/modules/dashboard'
|
||||
|
||||
defineOptions({
|
||||
name: 'Dashboard'
|
||||
})
|
||||
import { UserFilled } from '@element-plus/icons-vue'
|
||||
|
||||
import { getStorage } from '@/utils/storage'
|
||||
import Agent from './components/view/index.vue'
|
||||
|
||||
//控制id切换页面渲染
|
||||
const userId = getStorage('userInfo')?.id
|
||||
|
||||
const cardData = [
|
||||
{ label: '代理总数', value: 100, icon: UserFilled },
|
||||
{ label: '今日新增代理总数', value: 100, icon: UserFilled },
|
||||
{ label: '客户总数', value: 100, icon: UserFilled },
|
||||
{ label: '今日新增客户总数', value: 100, icon: UserFilled },
|
||||
{ label: '今日存款', value: 100, icon: UserFilled },
|
||||
{ label: '总存款', value: 100, icon: UserFilled },
|
||||
{ label: '今日盈利', value: 100, icon: UserFilled },
|
||||
{ label: '总盈利', value: 100, icon: UserFilled },
|
||||
{ label: '今日取款', value: 100, icon: UserFilled },
|
||||
{ label: '总取款', value: 100, icon: UserFilled }
|
||||
]
|
||||
const cardData = ref([
|
||||
{ label: '代理总数', value: 0, icon: UserFilled },
|
||||
{ label: '用户总数', value: 0, icon: UserFilled },
|
||||
{ label: '今日新增用户', value: 0, icon: UserFilled },
|
||||
{ label: '今日充值金额', value: '0', icon: UserFilled },
|
||||
{ label: '今日提现金额', value: 0, icon: UserFilled },
|
||||
{ label: '总充值金额', value: 0, icon: UserFilled },
|
||||
{ label: '总提现金额', value: 0, icon: UserFilled }
|
||||
])
|
||||
|
||||
// 获取首页统计数据
|
||||
const fetchDashboardData = async () => {
|
||||
try {
|
||||
const res = await getUserIndex()
|
||||
if (res) {
|
||||
const { agent_count, user_count, today_user_count, today_recharge_amount,
|
||||
today_withdraw_amount, total_recharge_amount, total_withdraw_amount } = res
|
||||
|
||||
cardData.value = [
|
||||
{ label: '代理总数', value: agent_count, icon: UserFilled },
|
||||
{ label: '用户总数', value: user_count, icon: UserFilled },
|
||||
{ label: '今日新增用户', value: today_user_count, icon: UserFilled },
|
||||
{ label: '今日充值金额', value: today_recharge_amount, icon: UserFilled },
|
||||
{ label: '今日提现金额', value: today_withdraw_amount, icon: UserFilled },
|
||||
{ label: '总充值金额', value: total_recharge_amount, icon: UserFilled },
|
||||
{ label: '总提现金额', value: total_withdraw_amount, icon: UserFilled }
|
||||
]
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取首页数据失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
if (userId === 1) {
|
||||
fetchDashboardData()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
|
|
|||
Loading…
Reference in New Issue