Browse Source

Merge branch 'master' of https://gitee.com/linlinjava/litemall

linlinjava 4 years ago
parent
commit
4514653a2c
2 changed files with 15 additions and 19 deletions
  1. 14 18
      litemall-wx/pages/auth/login/login.js
  2. 1 1
      litemall-wx/pages/auth/login/login.wxml

+ 14 - 18
litemall-wx/pages/auth/login/login.js

@@ -24,25 +24,21 @@ Page({
 
   },
   wxLogin: function(e) {
-    if (e.detail.userInfo == undefined) {
-      app.globalData.hasLogin = false;
-      util.showErrorToast('微信登录失败');
-      return;
-    }
-
     user.checkLogin().catch(() => {
-
-      user.loginByWeixin(e.detail.userInfo).then(res => {
-        app.globalData.hasLogin = true;
-
-        wx.navigateBack({
-          delta: 1
-        })
-      }).catch((err) => {
-        app.globalData.hasLogin = false;
-        util.showErrorToast('微信登录失败');
-      });
-
+      wx.getUserProfile({
+        desc: '用于完善会员资料',
+        success: (res) => {
+          user.loginByWeixin(res.userInfo).then(res => {
+            app.globalData.hasLogin = true;
+            wx.navigateBack({
+              delta: 1
+            })
+          }).catch((err) => {
+            app.globalData.hasLogin = false;
+            util.showErrorToast('微信登录失败');
+          });
+        }
+      })
     });
   },
   accountLogin: function() {

+ 1 - 1
litemall-wx/pages/auth/login/login.wxml

@@ -1,6 +1,6 @@
 <view class="container">
   <view class="login-box">
-    <button type="primary" open-type="getUserInfo" class="wx-login-btn" bindgetuserinfo="wxLogin">微信直接登录</button>
+    <button type="primary" open-type="getUserProfile" class="wx-login-btn" bindtap="wxLogin">微信直接登录</button>
     <button type="primary" class="account-login-btn" bindtap="accountLogin">账号登录</button>
   </view>
 </view>