ソースを参照

[用户信息][修复]:用户信息获取在获得token之后

tags/2.2.4
Stormeye.Wu 6年前
コミット
651b2a8e12
1個のファイルの変更23行の追加21行の削除
  1. +23
    -21
      app.js

+ 23
- 21
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:"陕西大悦城"


読み込み中…
キャンセル
保存