0235699曾露 10 часов назад
Родитель
Сommit
1a8ed0c330
1 измененных файлов с 39 добавлено и 8 удалено
  1. 39 8
      nova-pbf/components/home/index.js

+ 39 - 8
nova-pbf/components/home/index.js

@@ -287,10 +287,31 @@ Component({
       // 检查 isPublishing 状态,如果不是 true,需要强制登录
       const isPublishing = this.data.showAI; // showAI 就是 isPublishing 的状态
       
-      // 检查是否需要强制登录
-      const canAccess = await this.checkLoginRequired();
-      if (!canAccess) {
-        return;
+      console.log('📋 isPublishing 状态:', isPublishing);
+      
+      // 如果 isPublishing != true,必须登录才能访问
+      if (!isPublishing) {
+        console.log('⚠️ isPublishing != true,需要强制登录');
+        
+        // 检查用户是否已登录
+        const currentUser = Parse.User.current();
+        const userLogin = wx.getStorageSync('userLogin');
+        const isLoggedIn = currentUser && currentUser.get('mobile') && userLogin;
+        
+        console.log('   当前用户:', currentUser ? currentUser.id : '无');
+        console.log('   手机号:', currentUser?.get('mobile') || '无');
+        console.log('   userLogin:', userLogin || '无');
+        console.log('   登录状态:', isLoggedIn ? '已登录' : '未登录');
+        
+        if (!isLoggedIn) {
+          console.log('❌ 用户未登录,直接跳转到登录页面');
+          login.loginNow();
+          return;
+        }
+        
+        console.log('✅ 用户已登录,允许访问');
+      } else {
+        console.log('✅ isPublishing == true,允许游客访问');
       }
       
       // 标记已访问
@@ -525,11 +546,21 @@ Component({
       
       console.log('最终登录状态:', isLoggedIn ? '已登录' : '未登录');
       
-      // 如果用户未登录,进入游客模式
+      // 检查 isPublishing 状态
+      const isPublishing = wx.getStorageSync('isPublishing');
+      
+      // 如果用户未登录
       if (!isLoggedIn) {
-        console.log('⚠️ 用户未登录,进入游客模式');
-        this.navigateToHomeAsGuest();
-        return;
+        // 只有当 isPublishing == true 时才允许游客模式
+        if (isPublishing === true) {
+          console.log('⚠️ 用户未登录,但 isPublishing == true,进入游客模式');
+          this.navigateToHomeAsGuest();
+          return;
+        } else {
+          console.log('❌ 用户未登录且 isPublishing != true,直接跳转登录页面');
+          login.loginNow();
+          return;
+        }
       }
       
       let token = currentUser.getSessionToken();