| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- // app.js
- App({
- onLaunch() {
- // 展示本地存储能力
- const logs = wx.getStorageSync('logs') || []
- logs.unshift(Date.now())
- wx.setStorageSync('logs', logs)
-
- // 登录
- wx.login({
- success: res => {
- // 发送 res.code 到后台换取 openId, sessionKey, unionId
- }
- })
- wx.getSystemInfo({
- success: res => {
-
- // 手机系统状态栏高度
- wx.setStorageSync('statusBarHeight', res.statusBarHeight)
-
- const platform = res.platform
- const menu = wx.getMenuButtonBoundingClientRect()
-
- //menu为胶囊,判断是否能读到胶囊位置,读不到则用具体一般数值表示
- if (menu) {
- wx.setStorageSync('menu', menu)
-
- // 导航栏高度
- wx.setStorageSync('navBarHeight', menu.height+(menu.top-res.statusBarHeight) *2 )
-
- // 状态栏加导航栏
-
- wx.setStorageSync('navStatusBarHeight', res.statusBarHeight+ menu.height+(menu.top-res.statusBarHeight) *2 )
-
-
- }else{
- wx.setStorageSync('menu', null)
-
- // 导航栏高度
- wx.setStorageSync('navBarHeight', platform === 'android' ? 48 : 44)
-
- // 状态栏加导航栏
-
- wx.setStorageSync('navStatusBarHeight', res.statusBarHeight+ (platform === 'android' ? 48 : 44) )
-
- }
-
- }, fail(err) {
- console.log(err);
- }
- })
- },
- globalData: {
- userInfo: null
- }
- })
|