js 平台 判断 分享 判断
主要是判断,小程序或者微信。
var ua = navigator.userAgent.toLowerCase();
if(ua.match(/MicroMessenger/i)=="micromessenger") {
//ios的ua中无miniProgram,但都有MicroMessenger(表示是微信浏览器)
wx.miniProgram.getEnv((res)=>{
if (res.miniprogram) {
//alert("在小程序里");
wx.miniProgram.navigateTo({
url: '/pages/user/my-order/my-money',
})
} else {
//alert("不在小程序里,但在微信里");
window.location.href = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx231ea8dfba02c266&redirect_uri=http%3a%2f%2fapi.bugegaming.com%2fv1.0.6%2fwx%2fgzh%2fpay%2flogin%2fmenu&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect';
}
})
}else{
if (ua.match(/QQ/i) == "qq") {
//alert("qq内置浏览器");
}else {
//alert("不是微信浏览器或手机qq浏览器,例如自带浏览器");
}
}