Sfoglia il codice sorgente

Merge branch 'dev'

joe 4 anni fa
parent
commit
81de22097a

+ 25 - 1
view/xcx/app.js

@@ -118,7 +118,31 @@ App({
   {
     return util.$h;
   },
-  
+
+  setUnread: function(newVal)
+  {
+    this.globalData.unread = newVal
+    this.updateUnread();
+  },
+
+  /**
+   * update unread message tip
+   * @param {int} newval 
+   */
+  updateUnread: function()
+  {
+    if (this.globalData.unread != undefined && this.globalData.unread > 0) {
+      wx.setTabBarBadge({
+        index: 2,
+        text: this.globalData.unread.toString(),
+      });
+    } else {
+      wx.removeTabBarBadge({
+        index: 2,
+      });
+    }
+  },
+
   /*
   * 合并数组
   * @param array list 请求返回数据

+ 1 - 19
view/xcx/pages/index/index.js

@@ -166,25 +166,7 @@ Page({
         that.loadNotifications()
       }, 1000 * 60 * 3)
     })
-    this.updateUnread()
-  },
-
-  /**
-   * update unread message tip
-   * @param {int} newval 
-   */
-  updateUnread: function()
-  {
-    if (app.globalData.unread != undefined && app.globalData.unread > 0) {
-      wx.setTabBarBadge({
-        index: 2,
-        text: app.globalData.unread.toString(),
-      });
-    } else {
-      wx.removeTabBarBadge({
-        index: 2,
-      });
-    }
+    app.updateUnread()
   },
 
   // 加载通知,目前只有跑马灯

+ 4 - 2
view/xcx/pages/message/index.js

@@ -91,8 +91,9 @@ Page({
           unread += 1
         }
       })
-      app.globalData.unread = unread
 
+      app.setUnread(unread)
+      
       that.setData({
         messages: res.data,
         unread: unread
@@ -109,7 +110,8 @@ Page({
         that.setData({
           unread: that.data.unread-1,
         })
-        app.globalData.unread = res.data.unread
+        // app.globalData.unread = res.data.unread
+        app.setUnread(res.data.unread)
       })
       
     }

+ 2 - 1
view/xcx/pages/order_details/index.js

@@ -148,7 +148,8 @@ Page({
     getUserInfo().then(res=>{
       that.data.payMode[1].number = res.data.now_money;
       that.setData({ payMode: that.data.payMode });
-      app.globalData.unread = res.data.notice
+      that.setUnread(res.data.notice)
+      // app.globalData.unread = res.data.notice
     })
   },
   /**

+ 2 - 1
view/xcx/pages/order_list/index.js

@@ -62,7 +62,8 @@ Page({
     getUserInfo().then(res=>{
       that.data.payMode[1].number = res.data.now_money;
       that.setData({ payMode: that.data.payMode});
-      app.globalData.unread = res.data.notice
+      // app.globalData.unread = res.data.notice
+      app.setUnread(res.data.notice)
     });
   },
   /**

+ 2 - 1
view/xcx/pages/user/user.js

@@ -76,7 +76,8 @@ Page({
         orderStatusNum: res.data.orderStatusNum,
         [generalContent]:`您在商城累计消费金额仅差 ${res.data.promoter_price || 0}元即可开通推广权限`
       });
-      app.globalData.unread = res.data.notice
+      // app.globalData.unread = res.data.notice
+      app.setUnread(res.data.notice)
     });
   },
   generalWindow:function(){

+ 2 - 1
view/xcx/pages/user_cash/index.js

@@ -57,7 +57,8 @@ Page({
     var that = this;
     getUserInfo().then(res=>{
       that.setData({ userInfo: res.data });
-      app.globalData.unread = res.data.notice
+      // app.globalData.unread = res.data.notice
+      app.setUnread(res.data.notice)
     });
   },
   swichNav: function (e) {

+ 2 - 1
view/xcx/pages/user_info/index.js

@@ -124,7 +124,8 @@ Page({
             that.setData({userIndex:i});
           }
       }
-      app.globalData.unread = res.data.notice
+      // app.globalData.unread = res.data.notice
+      app.setUnread(res.data.notice)
     });
   },
 

+ 2 - 1
view/xcx/pages/user_money/index.js

@@ -74,7 +74,8 @@ Page({
         userInfo: res.data, 
         recharge_switch: res.data.recharge_switch
       });
-      app.globalData.unread = res.data.notice
+      // app.globalData.unread = res.data.notice
+      app.setUnread(res.data.notice)
     });
   },
   /**

+ 2 - 1
view/xcx/pages/user_payment/index.js

@@ -106,7 +106,8 @@ Page({
     var that = this;
     getUserInfo().then(res=>{
       that.setData({ userinfo: res.data });
-      app.globalData.unread = res.data.notice
+      // app.globalData.unread = res.data.notice
+      app.setUnread(res.data.notice)
     })
   },
   /*

+ 2 - 1
view/xcx/pages/user_spread_user/index.js

@@ -67,7 +67,8 @@ Page({
     var that = this;
     getUserInfo().then(res=>{
       that.setData({ userInfo: res.data });
-      app.globalData.unread = res.data.notice
+      // app.globalData.unread = res.data.notice
+      app.setUnread(res.data.notice)
     });
   },
   /**