// app.js
App({
// Appdata: {
// height: 0, //胶囊高度
// navheight: 0, //导航栏高度
// right: 0,
// left: 0,
// },
onLaunch() {
// 展示本地存储能力
const logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now())
wx.setStorageSync('logs', logs)
// 获取胶囊按钮的信息
let jiaonang = wx.getMenuButtonBoundingClientRect()
// console.log(jiaonang);
// 设备信息
wx.getSystemInfo({
success: (res) => {
console.log(res);
// 导航栏的高度的计算 胶囊距离顶部的距离- 设备的高度 *2 ==胶囊距离上,下的距离
this.globalData.navheight = (jiaonang.top - res.statusBarHeight) * 2 + res.statusBarHeight + jiaonang.height
this.globalData.height = jiaonang.height
this.globalData.right = res.windowWidth - jiaonang.right
this.globalData.buttom=jiaonang.top-res.statusBarHeight
}
})
// 登录
wx.login({
success: res => {
// 发送 res.code 到后台换取 openId, sessionKey, unionId
}
})
},
globalData: {
小程序胶囊
最新推荐文章于 2024-05-24 09:45:21 发布