export {default as http} from './http'
export {default as api} from './api'
export {html}


export const getParam = (key, str) => {
    const _s = str ? str : location.href;
    const re = new RegExp(`(?:\\?|#|&)(${key})=([^=&#\\?]+)`, 'ig');
    let found;
    return (found = re.exec(_s)) ? found[2] : null;
}

const html = content => ({__html: htmlDecode(content)})

const htmlDecode = content => {
    let e = document.createElement('div');
    e.innerHTML = content;
    return e.childNodes.length === 0 ? "" : e.childNodes[0].nodeValue;
}


// 判断是否是微信环境 是返回true;否则返回false
export const is_weixin = () => {
    var ua = window.navigator.userAgent.toLowerCase();
    if (ua.match(/MicroMessenger/i) == 'micromessenger') {
        return true;
    }
    return false;
}