| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- export const getPlatform = function() {
- let platForm = undefined
- // #ifdef H5
- platForm = 'H5'
- //#endif
- // #ifdef APP-PLUS
- platForm = 'APP'
- //#endif
- // #ifdef APP-PLUS-NVUE
- platForm = 'APP'
- //#endif
- // #ifdef APP-NVUE
- platForm = 'APP'
- //#endif
- // #ifdef MP-WEIXIN
- platForm = 'MP-WEIXIN'
- //#endif
- // #ifdef MP-ALIPAY
- platForm = 'MP-ALIPAY'
- //#endif
- // #ifdef MP-BAIDU
- platForm = 'MP-BAIDU'
- //#endif
- // #ifdef MP-TOUTIAO
- platForm = 'MP-TOUTIAO'
- //#endif
- return platForm
- }
- export const isWx = function() {
- //#ifdef H5
- let ua = window.navigator.userAgent.toLowerCase()
- if (ua.indexOf('micromessenger') !== -1) {
- return true
- } else {
- return false
- }
- //#endif
- // #ifndef H5
- return false
- // #endif
- }
- /**
- * 获取小程序胶囊居中对齐的高度
- */
- export const getNavHeight = function () {
- let platForm = getPlatform();
- if (platForm === 'MP-WEIXIN') {
- let res = uni.getSystemInfoSync();
- let menuButtonInfo = uni.getMenuButtonBoundingClientRect();
- let navHeight =
- menuButtonInfo.height + (menuButtonInfo.top - res.statusBarHeight) * 2;
- return navHeight
- } else {
- return 44;
- }
- }
- /**
- * 手机顶部高度
- */
- export const getPhoneTopHeight = function () {
- let platForm = getPlatform();
- if (platForm === 'MP-WEIXIN') {
- let height = uni.getSystemInfoSync().statusBarHeight;
- return height
- } else {
- return 0;
- }
- }
|