代码拉取完成,页面将自动刷新
同步操作将从 Kevin/微信小程序demo 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
//app.js
App({
onLaunch: function () {
this.getStatusBarHeight()
// 获取用户信息
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 以防止这种情况
this.handleReady(res)
},
fail: () => {
this.handleReady(false)
}
})
} else {
this.handleReady(false)
}
},
fail: () => {
this.handleReady(false)
}
})
},
handleReady(data) {
if (this.userInfoReadyCallback) {
this.userInfoReadyCallback(data)
} else {
this.globalData.isReady = true
}
},
/**
* 获取标题栏和状态栏高度,使用自定义标题时需要
*/
getStatusBarHeight() {
try {
const res = wx.getSystemInfoSync()
this.globalData.statusBarHeight = res.statusBarHeight
if (res.system.indexOf('ios') >= 0) {
res.titleBarHeight = 32 + 6 * 2
} else {
res.titleBarHeight = 32 + 8 * 2
}
this.globalData.titleBarHeight = res.titleBarHeight
return res
} catch (e) {
return null;
}
},
globalData: {
isReady: false,
userInfo: null
}
})
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。