74 lines
1.3 KiB
JavaScript
74 lines
1.3 KiB
JavaScript
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
|