export function getNavbarInfo(fn){
    let menuInfo = wx.getMenuButtonBoundingClientRect(); //右上角胶囊信息
    wx.getSystemInfo({
        success : (res) =>{
            fn({
                navTop : res.statusBarHeight, //状态栏高度
                navHeight : res.statusBarHeight + menuInfo.height + (menuInfo.top - res.statusBarHeight)*2 //导航栏高度
            })
        }
    })
}

  
export function DFSImg(path, w, h){
    let baseImg = process.env.IMG_DOMAIN ;


    if (!Array.isArray(baseImg) && (baseImg.indexOf('aliyun') >= 0 || baseImg.indexOf('cdn') >= 0 )) {
        var style = '';
        if (w) style += ',w_' + w;
        if (h) style += ',h_' + h;
        if (style.length > 0) {
          if(path.indexOf('?x-oss-process') == -1){
            path += '?x-oss-process=image/resize,m_pad,limit_0' + style
          }
        }
        if (path.indexOf('http') == 0) {
          return path;
        }
        return baseImg + path;
      } else {
        if (path.indexOf('http') == 0) {
          return path;
        }
        if (path.indexOf('/') != 0) {
          path = '/' + path;
        }
        if (w && h) {
          path += '.' + w + 'x' + h + '.jpg';
        }
        return baseImg[Math.floor(Math.random() * 100) % baseImg.length] + path;
      }
}