/* * 全局方法 挂在在vue 原型 提供给页面直接用 * */ import config from '../../config/config.js'; export default { /*获取手机顶部状态栏的高度单位 px*/ getStatusBarHeight(unit='px') { let statusBarHeight = uni.getSystemInfoSync().statusBarHeight; let pages = getCurrentPages(); let curPage = pages[pages.length - 1]; let info = uni.getSystemInfoSync(); let windowHeight = info.windowHeight;//可用区域高度 let screenHeight = info.screenHeight;//屏幕区域高度 if (windowHeight !== screenHeight) { //设置了标题 statusBarHeight = 0; } else {//没有设置标题 需要自定义 } return statusBarHeight + unit; }, /*获取图片路径*/ getImgPath(filename) { let img_path = config.img_path; let path_name = ''; return img_path + filename; }, /*获取图片icon路径*/ getIconPath(filename) { let img_path = config.img_path; let path_name = 'icon/'; return img_path + path_name + filename; } }