mall-app-t/peach/platform/index.js

74 lines
1.3 KiB
JavaScript
Raw Normal View History

2024-05-22 15:42:13 +08:00
import share from './share'
const device = uni.getSystemInfoSync()
/**
* @author Ankkaya
* @description 标题栏高度
* @param {Type} -
* @returns {Type}
*/
function getNavBar() {
return device.statusBarHeight + 44
}
const navBar = getNavBar()
/**
* @author Ankkaya
* @description 胶囊高度
* @param {Type} -
* @returns {Type}
*/
function getCapsule() {
// #ifdef MP
let capsule = uni.getMenuButtonBoundingClientRect()
if (!capsule) {
capsule = {
bottom: 56,
height: 32,
left: 278,
right: 365,
top: 24,
width: 87,
}
}
return capsule
// #endif
// #ifndef MP
return {
bottom: 56,
height: 32,
left: 278,
right: 365,
top: 24,
width: 87,
}
// #endif
}
const capsule = getCapsule()
/**
* @author Ankkaya
* @description 判断网络状态
* @param {Type} -
* @returns {Type}
*/
async function checkNetwork() {
const networkStatus = await uni.getNetworkType()
if (networkStatus.networkType == 'none') {
return Promise.resolve(false)
}
return Promise.resolve(true)
}
const _platform = {
device,
share,
navBar,
capsule,
checkNetwork,
}
export default _platform