| | |
| | | <span class="filter-label">数据类目:</span> |
| | | <el-select v-model="queryParams.dataCategory" placeholder="全部" clearable> |
| | | <el-option label="全部" value="" /> |
| | | <el-option |
| | | v-for="category in categoryList" |
| | | :key="category" |
| | | :label="getCategoryLabel(category)" |
| | | :value="category" |
| | | <el-option |
| | | v-for="category in categoryList" |
| | | :key="category" |
| | | :label="getCategoryLabel(category)" |
| | | :value="category" |
| | | /> |
| | | </el-select> |
| | | </div> |
| | |
| | | |
| | | <!-- 流水表格 --> |
| | | <div class="table-section"> |
| | | <el-table :data="flowList" stripe style="width: 100%"> |
| | | <el-table :data="flowList" stripe style="width: 100%" :height="440"> |
| | | <el-table-column prop="id" label="序号" width="80" align="center" /> |
| | | <el-table-column prop="dataCategory" label="数据类目" width="120"> |
| | | <template #default="{ row }"> |
| | |
| | | <script setup lang="ts"> |
| | | import { ref, reactive, onMounted, computed } from 'vue' |
| | | import { dayjs, ElMessage } from 'element-plus' |
| | | import { |
| | | ArrowLeft, |
| | | Refresh, |
| | | Setting, |
| | | Close, |
| | | Money, |
| | | Plus, |
| | | Minus, |
| | | Search |
| | | import { |
| | | ArrowLeft, |
| | | Refresh, |
| | | Setting, |
| | | Close, |
| | | Money, |
| | | Plus, |
| | | Minus, |
| | | Search |
| | | } from '@element-plus/icons-vue' |
| | | import pointsApi from '@/api/pointsApi' |
| | | import type { PointsStats, PointsFlow, PointsQueryParams } from '@/types/points' |
| | | import { useUserInfo } from '@/stores/modules/userInfo' |
| | | import { queryUserDetail } from '@/api/userInfo' |
| | | |
| | | // 获取用户信息 store |
| | | const userStore = useUserInfo() |
| | | |
| | | // 积分统计 |
| | | const stats = ref<PointsStats>({ |
| | |
| | | |
| | | // 查询参数 |
| | | const queryParams = reactive<PointsQueryParams>({ |
| | | userId: '1', |
| | | userId: '', |
| | | dataCategory: '', |
| | | dataType: '', |
| | | pageNum: 1, |
| | |
| | | // 获取积分统计 |
| | | const getPointsStats = async () => { |
| | | try { |
| | | const userId = 1; |
| | | const userId = userStore.getUserId || userStore.getUserInfo?.userId |
| | | if (!userId) { |
| | | console.error('无法获取用户ID') |
| | | return |
| | | } |
| | | // 更新查询参数中的 userId |
| | | queryParams.userId = userId.toString() |
| | | const res = await pointsApi.getPersonalPointsStats(userId) |
| | | if (res.code === 200 && res.data) { |
| | | stats.value = res.data |
| | |
| | | // 获取积分流水 |
| | | const getPointsFlow = async () => { |
| | | try { |
| | | const userId = userStore.getUserId || userStore.getUserInfo?.userId |
| | | if (!userId) { |
| | | console.error('无法获取用户ID') |
| | | return |
| | | } |
| | | // 更新查询参数中的 userId |
| | | queryParams.userId = userId.toString() |
| | | const res = await pointsApi.getPersonalPointsFlow(queryParams) |
| | | if (res.code === 200) { |
| | | flowList.value = res.data.list || [] |
| | |
| | | ElMessage.info('关闭全部功能') |
| | | } |
| | | |
| | | onMounted(() => { |
| | | onMounted(async () => { |
| | | // 页面挂载时,检查 userStore 是否已有用户信息 |
| | | let userId = userStore.getUserId || userStore.getUserInfo?.userId |
| | | if (!userId) { |
| | | try { |
| | | const res: any = await queryUserDetail() |
| | | if (res?.code === 200 && res.data) { |
| | | userStore.updateUserDetail(res.data) |
| | | userId = res.data.userId || res.data.id |
| | | } else { |
| | | ElMessage.error(res?.msg || '无法获取用户信息,请先登录') |
| | | return |
| | | } |
| | | } catch (e) { |
| | | console.error('获取用户详情失败:', e) |
| | | ElMessage.error('获取用户信息失败,请稍后重试') |
| | | return |
| | | } |
| | | } |
| | | |
| | | getPointsStats() |
| | | getPointsFlow() |
| | | getCategoryList() |
| | |
| | | cursor: pointer; |
| | | color: #409eff; |
| | | font-size: 18px; |
| | | |
| | | |
| | | &:hover { |
| | | color: #66b1ff; |
| | | } |
| | |
| | | cursor: pointer; |
| | | color: #909399; |
| | | font-size: 16px; |
| | | |
| | | |
| | | &:hover { |
| | | color: #409eff; |
| | | } |
| | |
| | | :deep(.el-select), |
| | | :deep(.el-date-picker) { |
| | | width: 100%; |
| | | |
| | | |
| | | @media (min-width: 768px) { |
| | | width: auto; |
| | | min-width: 120px; |