Browse Source

feat: 消息首页置顶点击相关 tabbar 判断

zhangyuhan 2 years ago
parent
commit
dd95ba9c35
1 changed files with 26 additions and 14 deletions
  1. 26 14
      src/web/staticres/common-module/messageCenter/js/index.js

+ 26 - 14
src/web/staticres/common-module/messageCenter/js/index.js

@@ -108,7 +108,7 @@ var vm = new Vue({
               //链接中如果是www.jianyu360.cn域名,微信中会唤起app,该用window.open
               window.open(url)
             } else {
-              location.href = url
+              _this.goLinkAndCheckTabbar(url)
             }
           }
         }
@@ -134,6 +134,22 @@ var vm = new Vue({
         success:function () {}
       })
     },
+    // 检查 tabbar 跳转
+    goLinkAndCheckTabbar (toLink) {
+      // 检查是否 tabbar 页面
+      const tabbarKey = utils.checkNowInAppTabbarPage(toLink)
+      if (tabbarKey) {
+        try {
+          // 刷新对应 tabbar 并切换
+          JyObj.refreshAppointTab(tabbarKey,1)
+          JyObj.skipAppointTab(tabbarKey)
+        } catch (e) {
+          console.warn(e)
+        }
+      } else {
+        location.href = toLink
+      }
+    },
     // 置顶消息跳转
     msgClick(url, num, ids, type, logid) {
       this.clickMesg(logid)
@@ -150,23 +166,19 @@ var vm = new Vue({
           }
         }
       } else {
-        if (appType == 'android') {
-          if (!num) {
-            this.topRead(ids, url.androidUrl, type, wxType)
-          } else {
-            if (url.androidUrl) {
-              location.href = url.androidUrl
-            }
+
+        let toLink = appType == 'android' ? url.androidUrl : url.iosUrl
+        if (toLink) {
+          if (toLink[0] !== '/') {
+            toLink = '/' + toLink
           }
-        } else {
           if (!num) {
-            this.topRead(ids, url.iosUrl, type, wxType)
-          } else {
-            if (url.iosUrl) {
-              location.href = url.iosUrl
-            }
+            this.topRead(ids, toLink, type, wxType)
+            return
           }
+          this.goLinkAndCheckTabbar(toLink)
         }
+        return
       }
     },
     // 置顶消息展开,收起