You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.0 KiB
JavaScript

4 years ago
// app.js
let utils = require('utils/util');
App({
onLaunch() {
// 获取用户信息
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: {
url: 'http://192.168.1.107:8080/wx/api',
token: '',
code: '',
// 用户状态 2需要提交审核1跳转到禁止访问
status: 2,
// 审核状态0 跳转到正在审核
flag: 0,
userInfo: null,
address: ''
},
utils
})