hGlobal.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. * 全局方法 挂在在vue 原型 提供给页面直接用
  3. * */
  4. import config from '../../config/config.js';
  5. export default {
  6. /*获取手机顶部状态栏的高度单位 px*/
  7. getStatusBarHeight(unit='px') {
  8. let statusBarHeight = uni.getSystemInfoSync().statusBarHeight;
  9. let pages = getCurrentPages();
  10. let curPage = pages[pages.length - 1];
  11. let info = uni.getSystemInfoSync();
  12. let windowHeight = info.windowHeight;//可用区域高度
  13. let screenHeight = info.screenHeight;//屏幕区域高度
  14. if (windowHeight !== screenHeight) { //设置了标题
  15. statusBarHeight = 0;
  16. } else {//没有设置标题 需要自定义
  17. }
  18. return statusBarHeight + unit;
  19. },
  20. /*获取图片路径*/
  21. getImgPath(filename) {
  22. let img_path = config.img_path;
  23. let path_name = '';
  24. return img_path + filename;
  25. },
  26. /*获取图片icon路径*/
  27. getIconPath(filename) {
  28. let img_path = config.img_path;
  29. let path_name = 'icon/';
  30. return img_path + path_name + filename;
  31. }
  32. }