Browse Source

增加页面跳转

liudan 1 month ago
parent
commit
e668f3166d
1 changed files with 24 additions and 12 deletions
  1. 24 12
      src/pages/tabBar/login/login.vue

+ 24 - 12
src/pages/tabBar/login/login.vue

@@ -216,9 +216,7 @@ export default {
                                                 data: res.result,
                                                 success: function () {
                                                     setTimeout(() => {
-                                                        uni.switchTab({
-                                                            url: '/pages/tabBar/home/home'
-                                                        });
+                                                        that.redirectAfterLogin();
                                                     }, 1000);
                                                 }
                                             });
@@ -241,9 +239,7 @@ export default {
                                                 },
                                                 () => {
                                                     setTimeout(() => {
-                                                        uni.switchTab({
-                                                            url: '/pages/tabBar/home/home'
-                                                        });
+                                                        that.redirectAfterLogin();
                                                     }, 1000);
                                                 }
                                             );
@@ -745,9 +741,7 @@ export default {
                                     let TIMInfo = Cache.get('TIMInfo') || {};
                                     if (TIMInfo.loginStatus !== 'Y') {
                                         messageUtil.loginTim(() => {
-                                            uni.redirectTo({
-                                                url: '/pages/tabBar/home/home'
-                                            });
+                                            that.redirectAfterLogin();
                                         });
                                     }
                                 }
@@ -860,9 +854,7 @@ export default {
                                     },
                                     () => {
                                         setTimeout(() => {
-                                            uni.switchTab({
-                                                url: '/pages/tabBar/home/home'
-                                            });
+                                            that.redirectAfterLogin();
                                         }, 1000);
                                     }
                                 );
@@ -964,6 +956,26 @@ export default {
             console.log(e.detail.encryptedData);
         },
 
+        /**
+         * 登录成功后根据 groupID 跳转
+         * 有 groupID 跳工作台(workbench),其余跳主页(home)
+         */
+        redirectAfterLogin: function () {
+            let userData = Cache.get('userData') || {};
+            let targetUrl = (userData.groupID == 352) ? '/pages/staticPages/workbench/workbench' : '/pages/tabBar/home/home';
+            if (userData.groupID) {
+                // workbench 非 tabBar 页面,使用 reLaunch 跳转
+                uni.reLaunch({
+                    url: targetUrl
+                });
+            } else {
+                // home 为 tabBar 页面,使用 switchTab 跳转
+                uni.switchTab({
+                    url: targetUrl
+                });
+            }
+        },
+
         hidePage: function (e, _dataset) {
             /* ---处理dataset begin--- */
             this.handleDataset(e, _dataset);