From 83d5b2be8fdf0ac0b59cacf6b344c8815ab4d040 Mon Sep 17 00:00:00 2001
From: seatonwan9
Date: 星期二, 02 九月 2025 19:58:11 +0800
Subject: [PATCH] 提交源码

---
 src/views/pointsManage/personal/index.vue |   79 +++++++++++++++++++++++++++++----------
 1 files changed, 58 insertions(+), 21 deletions(-)

diff --git a/src/views/pointsManage/personal/index.vue b/src/views/pointsManage/personal/index.vue
index 4ee14ac..6d0bfd5 100644
--- a/src/views/pointsManage/personal/index.vue
+++ b/src/views/pointsManage/personal/index.vue
@@ -58,11 +58,11 @@
               <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>
@@ -103,7 +103,7 @@
 
         <!-- 娴佹按琛ㄦ牸 -->
         <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 }">
@@ -145,18 +145,23 @@
 <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>({
@@ -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()
@@ -332,7 +369,7 @@
         cursor: pointer;
         color: #409eff;
         font-size: 18px;
-        
+
         &:hover {
           color: #66b1ff;
         }
@@ -354,7 +391,7 @@
           cursor: pointer;
           color: #909399;
           font-size: 16px;
-          
+
           &:hover {
             color: #409eff;
           }
@@ -548,7 +585,7 @@
         :deep(.el-select),
         :deep(.el-date-picker) {
           width: 100%;
-          
+
           @media (min-width: 768px) {
             width: auto;
             min-width: 120px;

--
Gitblit v1.8.0