From bfbb1ea3c6bb2dd7db064fb189290a1bfcf6c9cd Mon Sep 17 00:00:00 2001
From: seatonwan9
Date: 星期四, 28 八月 2025 02:14:48 +0800
Subject: [PATCH] 提交源码

---
 src/views/pointsManage/personal/index.vue |   43 ++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 40 insertions(+), 3 deletions(-)

diff --git a/src/views/pointsManage/personal/index.vue b/src/views/pointsManage/personal/index.vue
index 4ee14ac..1449cf4 100644
--- a/src/views/pointsManage/personal/index.vue
+++ b/src/views/pointsManage/personal/index.vue
@@ -157,6 +157,11 @@
 } 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>({
@@ -168,7 +173,7 @@
 
 // 鏌ヨ鍙傛暟
 const queryParams = reactive<PointsQueryParams>({
-  userId: '1',
+  userId: '',
   dataCategory: '',
   dataType: '',
   pageNum: 1,
@@ -208,7 +213,13 @@
 // 鑾峰彇绉垎缁熻
 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
@@ -233,6 +244,13 @@
 // 鑾峰彇绉垎娴佹按
 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 || []
@@ -300,7 +318,26 @@
   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()

--
Gitblit v1.8.0