Jelajahi Sumber

fix: pre-login entry flow - fix page order, remove stale resetTabBar, fix goShop nav, add auto-login refresh

User 3 bulan lalu
induk
melakukan
dbf887cf70

+ 2 - 0
cfc-frontend/App.vue

@@ -49,6 +49,8 @@ export default {
           if (res && res.data) {
             this.saveLoginInfo(res.data)
             console.log('openid自动登录成功')
+            // 刷新页面到登录态
+            uni.reLaunch({ url: '/pages/index/index' })
             return
           }
         }

+ 15 - 15
cfc-frontend/pages.json

@@ -1,42 +1,42 @@
 {
   "pages": [
-    // ===== 主包:入口页 + TabBar 页 + 必须在主包的页面 =====
+    // ===== 入口页 + TabBar 页面(必须在主包,第一项为小程序首页)=====
     {
-      "path": "pages/discover/index",
+      "path": "pages/index/index",
       "style": {
-        "navigationBarTitleText": "发现"
+        "navigationBarTitleText": "首页"
       }
     },
     {
-      "path": "pages/login/login",
+      "path": "pages/index/child-index",
       "style": {
-        "navigationBarTitleText": "登录",
-        "navigationStyle": "custom"
+        "navigationBarTitleText": "首页"
       }
     },
     {
-      "path": "pages/user-edit/user-edit",
+      "path": "pages/index/parent-index",
       "style": {
-        "navigationBarTitleText": "完善信息"
+        "navigationBarTitleText": "首页"
       }
     },
-    // ===== TabBar 页面(必须在主包)=====
+    // ===== 主包:其他页面 =====
     {
-      "path": "pages/index/index",
+      "path": "pages/discover/index",
       "style": {
-        "navigationBarTitleText": "首页"
+        "navigationBarTitleText": "发现"
       }
     },
     {
-      "path": "pages/index/child-index",
+      "path": "pages/login/login",
       "style": {
-        "navigationBarTitleText": "首页"
+        "navigationBarTitleText": "登录",
+        "navigationStyle": "custom"
       }
     },
     {
-      "path": "pages/index/parent-index",
+      "path": "pages/user-edit/user-edit",
       "style": {
-        "navigationBarTitleText": "首页"
+        "navigationBarTitleText": "完善信息"
       }
     },
     {

+ 1 - 11
cfc-frontend/pages/discover/index.vue

@@ -148,15 +148,10 @@ export default {
     }
   },
   onShow() {
-    this.resetTabBar()
     this.loadProducts()
     this.loadFeaturedArticles()
   },
   methods: {
-    resetTabBar() {
-      uni.setTabBarItem({ index: 1, text: '发现' })
-      uni.setTabBarItem({ index: 2, text: '商城' })
-    },
     loadProducts() {
       this.loading = true
       const params = { page: 1, size: 10 }
@@ -177,12 +172,7 @@ export default {
       this.loadProducts()
     },
     goShop() {
-      const token = uni.getStorageSync('token')
-      if (token) {
-        uni.switchTab({ url: '/pages/shop/index' })
-      } else {
-        uni.redirectTo({ url: '/pages/shop/index' })
-      }
+      uni.navigateTo({ url: '/pages/shop/index' })
     },
     goDetail(id) {
       const token = uni.getStorageSync('token')

+ 1 - 1
cfc-frontend/pages/index/index.vue

@@ -229,7 +229,7 @@ export default {
       this.loadProducts()
     },
     goShop() {
-      uni.switchTab({ url: '/pages/shop/index' })
+      uni.navigateTo({ url: '/pages/shop/index' })
     },
     goDetail(id) {
       uni.navigateTo({ url: '/pages/discover/product-detail/product-detail?id=' + id })