// pages/sign/sign.js
Page({
    picture() {
        wx.getSetting({
            success: (res) => {
                if (!res.authSetting['scope.userInfo']||!wx.getStorageSync('openid')) {
                   wx.redirectTo({
                       url:"/pages/auth/auth"
                   })
                }else{
                    wx.reLaunch({ 
                        url: '/pages/new-page/index'
                    });

                }
            }
        })
    },
    
    data: {
        title:"我要碳中和", 
        // visit_history:[],  //品牌浏览历史
        // is_iphone:'',//苹果刘海适配
        // statusBarHeight: wx.getSystemInfoSync()['statusBarHeight'],
        // base_info:'',
        // 状态栏高度
        statusBarHeight: wx.getStorageSync('statusBarHeight') + 'px',
        // 导航栏高度
        navigationBarHeight: wx.getStorageSync('navigationBarHeight') + 'px',
        // 胶囊按钮高度
        menuButtonHeight: wx.getStorageSync('menuButtonHeight') + 'px',
        // 导航栏和状态栏高度
        navigationBarAndStatusBarHeight:
          wx.getStorageSync('statusBarHeight') +
          wx.getStorageSync('navigationBarHeight') +
          'px'
    },
 onLoad(){
	 
     const { statusBarHeight, platform } = wx.getSystemInfoSync()
     const { top, height } = wx.getMenuButtonBoundingClientRect()
 
     // 状态栏高度
     wx.setStorageSync('statusBarHeight', statusBarHeight)
     // 胶囊按钮高度 一般是32 如果获取不到就使用32
     wx.setStorageSync('menuButtonHeight', height ? height : 32)
     
     // 判断胶囊按钮信息是否成功获取
     if (top && top !== 0 && height && height !== 0) {
         const navigationBarHeight = (top - statusBarHeight) * 2 + height
         // 导航栏高度
         wx.setStorageSync('navigationBarHeight', navigationBarHeight)
     } else {
         wx.setStorageSync(
           'navigationBarHeight',
           platform === 'android' ? 48 : 40
         )
     }
	 
	 
     },
	 onShow(){
		 this.setData({
			 // 状态栏高度
			 statusBarHeight: wx.getStorageSync('statusBarHeight') + 'px',
			 // 导航栏高度
			 navigationBarHeight: wx.getStorageSync('navigationBarHeight') + 'px',
			 // 胶囊按钮高度
			 menuButtonHeight: wx.getStorageSync('menuButtonHeight') + 'px',
			 // 导航栏和状态栏高度
			 navigationBarAndStatusBarHeight:
			   wx.getStorageSync('statusBarHeight') +
			   wx.getStorageSync('navigationBarHeight') +
			   'px'
		 })
		 
	 }

})