소스 검색

[c端小程序][修复]:代码整理

tags/2.2.4
Stormeye.Wu 6 년 전
부모
커밋
101612691e
1개의 변경된 파일27개의 추가작업 그리고 22개의 파일을 삭제
  1. +27
    -22
      app.js

+ 27
- 22
app.js 파일 보기

@@ -22,28 +22,8 @@ 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)
}
}
})
}
}
})
this.getLocation()
that.getUserInfo()
that.getLocation()
}
})
}
@@ -69,6 +49,31 @@ App({
}
})
},
/**
* 获取用户信息
*/
getUserInfo: function() {
// 获取用户信息
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)
}
}
})
}
}
})
},
globalData: {
// token
token: null,


불러오는 중...
취소
저장