小程序胶囊

// 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: {
    // userInfo: null,
    height: 0, //胶囊高度
    navheight: 0, //导航栏高度
    right: 0,
    left: 0,
    buttom:0
  }
})
const app = getApp()
Page({

    /**
     * 页面的初始数据
     */
    data: {
        height:app.globalData.height,  //胶囊高度
        navheight:app.globalData.navheight ,   //导航栏高度
        right:app.globalData.right,
        left:0, 
        buttom:app.globalData.buttom
    },
 })
<view class="nav" style="height:{{navheight}}px;background-color: red;">
    <view class="nav-box" style="height:{{height}}px; min-height:{{heigth}}px;bottom:{{buttom}}px;line-height: {{height}}px;margin-top: {{navheight-buttom*2-height}}px;">
        <view class="bbb" style="background:rgb(236, 231, 231);height: {{height}}px;">
            <!-- <view style="height: {{height}}px;background-color: blue;line-height: {{height}}px;"><input type="text" placeholder="12312" class="input"  style="border: 1px solid red;" /></view> -->
            <!-- <view>1</view> -->
            <input type="text" placeholder="12312" class="input"  style="border: 1px solid red;" />
        </view>
        <!-- <view style="background:white;" >13213</view> -->
    </view>
</view>

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值