js判断是微信端还是企业微信端

function isPCFun() {
    var isMobile = navigator.userAgent.match(
        /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i
    ); // 是否移动端
    var isWx = /micromessenger/i.test(navigator.userAgent); // 是否微信
    var isComWx = /wxwork/i.test(navigator.userAgent); // 是否企业微信
    let platform = '';
    if (isComWx && isMobile) {
        platform = '移动端企业微信';
    } else if (isComWx && !isMobile) {
        platform = 'PC端企业微信';
    } else if (isWx && isMobile) {
        platform = '移动端微信';
    } else if (isWx && !isMobile) {
        platform = 'PC端微信';
    }
    return platform;
}

你可能感兴趣的:(js,微信公众号,javascript,微信,企业微信)