guhongwei 3 سال پیش
والد
کامیت
a0ce89cfbf
3فایلهای تغییر یافته به همراه18 افزوده شده و 22 حذف شده
  1. 0 1
      app.js
  2. 17 20
      custom-tab-bar/index.js
  3. 1 1
      pages/home/index.wxml

+ 0 - 1
app.js

@@ -20,7 +20,6 @@ App({
             const { errcode, data } = res.data
             if (errcode === 0) {
               this.globalData.wxInfo = data;
-              wx.setStorage({ key: "userInfo", data: null })
             }
           },
           error: err => {

+ 17 - 20
custom-tab-bar/index.js

@@ -34,27 +34,24 @@ Component({
   methods: {
     switchTab(e) {
       const { index, path } = e.currentTarget.dataset;
-      var sessionUser;
-      wx.getStorage({
-        key: 'userInfo',
-        success(res) {
-          sessionUser = res.data;
-        }
-      })
       if (index == 3) {
-        if (sessionUser) {
-          app.globalData.userInfo = sessionUser;
-          wx.switchTab({ url: path })
-        } else {
-          wx.getUserProfile({
-            desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
-            success: (res) => {
-              wx.setStorage({ key: "userInfo", data: res.userInfo })
-              app.globalData.userInfo = res.userInfo;
-              wx.switchTab({ url: path })
-            }
-          })
-        }
+        wx.getStorage({
+          key: 'userInfo',
+          success: function (res) {
+            app.globalData.userInfo = res.data;
+            wx.switchTab({ url: path })
+          },
+          fail: function (res) {
+            wx.getUserProfile({
+              desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
+              success: (res) => {
+                wx.setStorage({ key: "userInfo", data: res.userInfo })
+                app.globalData.userInfo = res.userInfo;
+                wx.switchTab({ url: path })
+              }
+            })
+          }
+        })
       } else {
         wx.switchTab({ url: path })
       }

+ 1 - 1
pages/home/index.wxml

@@ -17,7 +17,7 @@
         </view>
         <view class="info_1">
           <view>运动</view>
-          <view>3621</view>
+          <view>{{step}}</view>
           <view><text class="iconfont icon-icon"></text></view>
         </view>
       </view>