Merge branch 'yueyixin'

This commit is contained in:
2026-05-15 16:20:16 +08:00
commit 6823078c26
2 changed files with 59 additions and 17 deletions

View File

@ -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')
}

View File

@ -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">