소스 검색

始宁农业小程序:农事天地

panyong 1 년 전
부모
커밋
146deb6052
3개의 변경된 파일57개의 추가작업 그리고 31개의 파일을 삭제
  1. 22 11
      htmldev/shiningWxMini/pages/home/home.js
  2. 22 13
      htmldev/shiningWxMini/pages/mine/mine.js
  3. 13 7
      htmldev/shiningWxMini/pages/partner/partner.js

+ 22 - 11
htmldev/shiningWxMini/pages/home/home.js

@@ -53,6 +53,10 @@ Page({
    * 生命周期函数--监听页面加载
    */
   async onLoad(options) {
+    app.fetchUserDataCallback = () => {
+      this.setShopStatus()
+      this.setTabBarList()
+    }
     this.fetchLunboList()
     await this.fetchProductCategoryList()
     if (this.data.searchForm.category_id) {
@@ -70,17 +74,8 @@ Page({
    * 生命周期函数--监听页面显示
    */
   onShow() {
-    const { shop_status } = app.globalData.userInfo
-
-    this.getTabBar().init()
-
-    if (shop_status === 1 && this.getTabBar().data.list.findIndex(item => item.pagePath === 'pages/news/news') === -1) {
-      this.getTabBar().setData({ list: app.globalData.tabBarList })
-    }
-
-    this.setData({
-      shop_status: shop_status === 1 ? shop_status : 0
-    })
+    this.setShopStatus()
+    this.setTabBarList()
   },
 
   /**
@@ -328,5 +323,21 @@ Page({
         }
       }
     })
+  },
+  setShopStatus() {
+    const { shop_status } = app.globalData.userInfo
+
+    this.setData({
+      shop_status: shop_status === 1 ? shop_status : 0
+    })
+  },
+  setTabBarList() {
+    const { shop_status } = app.globalData.userInfo
+
+    this.getTabBar().init()
+
+    if (shop_status === 1 && this.getTabBar().data.list.findIndex(item => item.pagePath === 'pages/news/news') === -1) {
+      this.getTabBar().setData({ list: app.globalData.tabBarList })
+    }
   }
 })

+ 22 - 13
htmldev/shiningWxMini/pages/mine/mine.js

@@ -33,6 +33,10 @@ Page({
    * 生命周期函数--监听页面加载
    */
   onLoad(options) {
+    app.fetchUserDataCallback = () => {
+      this.setUserInfo()
+      this.setTabBarList()
+    }
     app.fetchSystemConfigCallback = () => {
       this.setKefu()
     }
@@ -53,18 +57,8 @@ Page({
    * 生命周期函数--监听页面显示
    */
   onShow() {
-    const { shop_status } = app.globalData.userInfo
-
-    this.getTabBar().init()
-    this.setData({
-      sessionId: wx.getStorageSync(sessionStorageKey),
-      userInfo: app.globalData.userInfo
-    })
-
-    if (shop_status === 1 && this.getTabBar().data.list.findIndex(item => item.pagePath === 'pages/news/news') === -1) {
-      this.getTabBar().setData({ list: app.globalData.tabBarList })
-    }
-
+    this.setUserInfo()
+    this.setTabBarList()
     this.setKefu()
   },
 
@@ -332,7 +326,22 @@ Page({
     const { kefu_phone } = app.globalData.objSystemConfig
 
     this.setData({
-      kefu: kefu_phone
+      kefu: kefu_phone || ''
     })
+  },
+  setUserInfo() {
+    this.setData({
+      sessionId: wx.getStorageSync(sessionStorageKey),
+      userInfo: app.globalData.userInfo
+    })
+  },
+  setTabBarList() {
+    const { shop_status } = app.globalData.userInfo
+
+    this.getTabBar().init()
+
+    if (shop_status === 1 && this.getTabBar().data.list.findIndex(item => item.pagePath === 'pages/news/news') === -1) {
+      this.getTabBar().setData({ list: app.globalData.tabBarList })
+    }
   }
 })

+ 13 - 7
htmldev/shiningWxMini/pages/partner/partner.js

@@ -18,6 +18,9 @@ Page({
    * 生命周期函数--监听页面加载
    */
   onLoad(options) {
+    app.fetchUserDataCallback = () => {
+      this.setTabBarList()
+    }
     this.fetchOrderList()
   },
 
@@ -32,13 +35,7 @@ Page({
    * 生命周期函数--监听页面显示
    */
   onShow() {
-    const { shop_status } = app.globalData.userInfo
-
-    this.getTabBar().init()
-
-    if (shop_status === 1 && this.getTabBar().data.list.findIndex(item => item.pagePath === 'pages/news/news') === -1) {
-      this.getTabBar().setData({ list: app.globalData.tabBarList })
-    }
+    this.setTabBarList()
   },
 
   /**
@@ -88,5 +85,14 @@ Page({
     wx.navigateTo({
       url: '/pages/businessDetail/businessDetail?shop_id=' + item.id
     })
+  },
+  setTabBarList() {
+    const { shop_status } = app.globalData.userInfo
+
+    this.getTabBar().init()
+
+    if (shop_status === 1 && this.getTabBar().data.list.findIndex(item => item.pagePath === 'pages/news/news') === -1) {
+      this.getTabBar().setData({ list: app.globalData.tabBarList })
+    }
   }
 })