Quellcode durchsuchen

fix: modify user authorization judgment

wangyuan vor 2 Jahren
Ursprung
Commit
50678898fd
1 geänderte Dateien mit 16 neuen und 14 gelöschten Zeilen
  1. 16 14
      pages/my/my.js

+ 16 - 14
pages/my/my.js

@@ -68,20 +68,22 @@ Page({
    * 获取用户信息
    */
   getUserProfile() {
-    var that = this;
-    wx.getUserProfile({
-      desc:"授权信息",
-      success:function(res){
-        if(res.userInfo){
-          that.setData({
-            name:res.userInfo.nickName,
-            avatarUrl:res.userInfo.avatarUrl,
-            pageLogin: true
-          })
-          app.globalData.userInfo.login = true
-        }
-      },
-    })
+    if (this.data.avatarUrl == '') {
+      var that = this;
+      wx.getUserProfile({
+        desc:"授权信息",
+        success:function(res){
+          if(res.userInfo){
+            that.setData({
+              name:res.userInfo.nickName,
+              avatarUrl:res.userInfo.avatarUrl,
+              pageLogin: true
+            })
+            app.globalData.userInfo.login = true
+          }
+        },
+      })
+    }
   },
 
   /**