Browse Source

feat:wxsfenjihuo

徐福静0235668 1 day ago
parent
commit
ae8cea1fda

+ 31 - 3
src/app/custom-wxwork-auth-guard.ts

@@ -97,7 +97,11 @@ export const CustomWxworkAuthGuard: CanActivateFn = async (route, state) => {
     let userInfo;
     try {
       userInfo = await wxAuth.getUserInfo();
-      console.log('✅ 获取用户信息成功:', userInfo?.name);
+      console.log('✅ 获取用户信息成功:', {
+        name: userInfo?.name,
+        userid: userInfo?.userid,
+        cid
+      });
     } catch (err) {
       console.log('⚠️ 需要授权,跳转到激活页面');
       // 需要授权,跳转到激活页面
@@ -113,13 +117,37 @@ export const CustomWxworkAuthGuard: CanActivateFn = async (route, state) => {
     
     // 检查用户是否已激活
     const profile = await wxAuth.currentProfile();
-    
+    console.log('🔎 currentProfile 查询结果:', {
+      id: profile?.id,
+      isActivated: profile?.get?.('isActivated')
+    });
+
     if (!profile || !profile.get('isActivated')) {
+      // 回退:直接按 userid 查询 Profile,避免因未登录或缓存导致的取数失败
+      try {
+        const Parse = FmodeParse.with('nova');
+        const q = new Parse.Query('Profile');
+        q.equalTo('userid', userInfo.userid);
+        const p2 = await q.first();
+        console.log('🔎 回退 Profile 查询结果:', {
+          id: p2?.id,
+          isActivated: p2?.get?.('isActivated')
+        });
+        if (p2 && p2.get('isActivated')) {
+          // 已激活:执行自动登录并放行
+          await wxAuth.autoLogin(userInfo);
+          console.log('✅ 回退校验通过(已激活),允许访问');
+          return true;
+        }
+      } catch (e) {
+        console.warn('⚠️ 回退 Profile 查询异常:', e);
+      }
+
       console.log('⚠️ 用户未激活,跳转到激活页面');
       await router.navigate(['/wxwork', cid, 'activation']);
       return false;
     }
-    
+
     // 用户已激活,自动登录
     await wxAuth.autoLogin(userInfo);
     

+ 12 - 0
src/modules/profile/pages/profile-activation/profile-activation.component.html

@@ -194,6 +194,13 @@
             </button>
           }
         </div> -->
+        @if (surveyCompleted) {
+          <div class="card-footer">
+            <button class="btn-primary" (click)="goToDashboard()">
+              进入工作台
+            </button>
+          </div>
+        }
       </div>
     }
 
@@ -269,6 +276,11 @@
             进入工作台
           </button>
         </div> -->
+        <div class="card-footer">
+          <button class="btn-primary" (click)="goToDashboard()">
+            进入工作台
+          </button>
+        </div>
       </div>
     }