From 651b2a8e1261ac0e14c657f94cee02ab58ff4308 Mon Sep 17 00:00:00 2001 From: "Stormeye.Wu" Date: Wed, 15 Aug 2018 17:01:05 +0800 Subject: [PATCH] =?UTF-8?q?[=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF][?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D]:=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=9C=A8=E8=8E=B7=E5=BE=97token=E4=B9=8B?= =?UTF-8?q?=E5=90=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.js | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/app.js b/app.js index fd00f4a..7484349 100644 --- a/app.js +++ b/app.js @@ -22,31 +22,33 @@ App({ console.log(result) that.globalData.token = result.data.data.token; console.log(that.globalData.token) - } - }) - } - }) - // 获取用户信息 - wx.getSetting({ - success: res => { - if (res.authSetting['scope.userInfo']) { - // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框 - wx.getUserInfo({ - success: res => { - // 可以将 res 发送给后台解码出 unionId - this.globalData.userInfo = res.userInfo - // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回 - // 所以此处加入 callback 以防止这种情况 - if (this.userInfoReadyCallback) { - this.userInfoReadyCallback(res) + // 获取用户信息 + wx.getSetting({ + success: res => { + if (res.authSetting['scope.userInfo']) { + // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框 + wx.getUserInfo({ + success: res => { + // 可以将 res 发送给后台解码出 unionId + this.globalData.userInfo = res.userInfo + + // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回 + // 所以此处加入 callback 以防止这种情况 + if (this.userInfoReadyCallback) { + this.userInfoReadyCallback(res) + } + } + }) + } } - } - }) - } + }) + this.getLocation() + } + }) } }) - this.getLocation() + // setTimeout(() => { // this.globalData.market={ // name:"陕西大悦城"