const userAgent = navigator.userAgent.toLowerCase()
export const isSupportHtml5Plus = navigator.userAgent.indexOf("Html5Plus") >= 0
export const isQywx = (userAgent.match(/MicroMessenger/i) == 'micromessenger') && (userAgent.match(/wxwork/i) == 'wxwork')  //是否企业微信

export const isIOS = /iphone/gi.test(window.navigator.userAgent)
export function isIphonex () {  // X XS, XS Max, XR
    const xSeriesConfig = [
        {
            devicePixelRatio: 3,
            width: 375,
            height: 812,
        },
        {
            devicePixelRatio: 3,
            width: 414,
            height: 896,
        },
        {
            devicePixelRatio: 2,
            width: 414,
            height: 896,
        },
    ];  // h5
    
    if (typeof window !== 'undefined' && window) {
        if (!isIOS) return false;
        const {devicePixelRatio, screen} = window;
        const {width, height} = screen;
        var exist = xSeriesConfig.filter(item => item.devicePixelRatio === devicePixelRatio && item.width === width && item.height === height);
        if(exist && exist.length>0){
            exist = exist[0]
            // 812 - 641 = 171 + 34
            if(exist.height - document.body.clientHeight < 171){
                // 没有虚拟按键
                return true
            } 
            return false
        }
        return false
        // return xSeriesConfig.some(item => item.devicePixelRatio === devicePixelRatio && item.width === width && item.height === height);
    }
    return false;
}