Ver Fonte

fix: modify permission logic

wangyuan há 2 anos atrás
pai
commit
c27400121c
2 ficheiros alterados com 15 adições e 28 exclusões
  1. 1 1
      api/request.js
  2. 14 27
      pages/my/my.js

+ 1 - 1
api/request.js

@@ -20,7 +20,7 @@ export const wxRequest = (url,data) => {
             mask: true
           })
         } else {
-          if (response.data.code !== '200') {
+          if (response.data.code !== '100') {
             wx.showToast({
               title: response.data.msg || '请求错误!',
               icon: 'error',

+ 14 - 27
pages/my/my.js

@@ -75,22 +75,14 @@ Page({
         desc:"授权信息",
         success:function(res){
           if(res.userInfo){
-            that.setData({
-              name:res.userInfo.nickName,
-              avatarUrl:res.userInfo.avatarUrl,
-              pageLogin: true
-            })
-            app.globalData.userInfo.login = true
+            that.loginFn(res.userInfo)
           }
         },
       })
     }
   },
-
-  /**
-   * 生命周期函数--监听页面显示
-   */
-  onShow() {
+  loginFn (userInfo) {
+    var that = this
     wx.login({
       success (res) {
         if (res.code) {
@@ -99,26 +91,21 @@ Page({
           }
           ittLogin(data).then(res => {
             console.log(res,'then login');
+            app.globalData.userInfo.login = true
+            that.setData({
+              name: userInfo.nickName,
+              avatarUrl: userInfo.avatarUrl,
+              pageLogin: true
+            })
           })
         }
       }
     })
-    return
-    wx.login({
-      success (res) {
-        if (res.code) {
-          //发起网络请求
-          let data = {
-            code: res.code
-          }
-          itt.postLogin('http://itt.chl6zk.store/api/user/login/v1', data, function (res) {
-            console.log(res, 'itt my');
-          })
-        } else {
-          console.log('登录失败!' + res.errMsg)
-        }
-      }
-    })
+  },
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow() {
     this.setData({
       pageLogin: app.globalData.userInfo.login
     })