You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.5 KiB
44 lines
1.5 KiB
// app.js
|
|
import fetch from './utils/request'
|
|
App({
|
|
onLaunch() {
|
|
// 展示本地存储能力
|
|
const logs = wx.getStorageSync('logs') || []
|
|
logs.unshift(Date.now())
|
|
wx.setStorageSync('logs', logs)
|
|
// 登录
|
|
wx.login({
|
|
success: res => {
|
|
// 发送 res.code 到后台换取 openId, sessionKey, unionId
|
|
}
|
|
})
|
|
this.setNavBarInfo();
|
|
},
|
|
|
|
globalData: {
|
|
userInfo: null,
|
|
navBarHeight: 0, // 导航栏高度
|
|
menuBotton: 0, // 胶囊距底部间距(保持底部间距一致)
|
|
menuRight: 0, // 胶囊距右方间距(方保持左、右间距一致)
|
|
menuHeight: 0, // 胶囊高度(自定义内容可与胶囊高度保证一致)
|
|
menuWidth:0
|
|
},
|
|
fetch,
|
|
|
|
/**
|
|
* @description 设置导航栏信息
|
|
*/
|
|
setNavBarInfo() {
|
|
// 获取系统信息
|
|
const systemInfo = wx.getSystemInfoSync();
|
|
// 胶囊按钮位置信息
|
|
const menuButtonInfo = wx.getMenuButtonBoundingClientRect();
|
|
// 导航栏高度 = 状态栏到胶囊的间距(胶囊距上距离-状态栏高度) * 2 + 胶囊高度 + 状态栏高度
|
|
this.globalData.navBarHeight = (menuButtonInfo.top - systemInfo.statusBarHeight) * 2 + menuButtonInfo.height + systemInfo.statusBarHeight;
|
|
this.globalData.menuBotton = menuButtonInfo.top - systemInfo.statusBarHeight;
|
|
this.globalData.menuRight = systemInfo.screenWidth - menuButtonInfo.right;
|
|
this.globalData.menuHeight = menuButtonInfo.height;
|
|
this.globalData.menuWidth = menuButtonInfo.width;
|
|
}
|
|
})
|