fix(ns-login): 修复H5页面在微信App中点击登录无反应的问题
This commit is contained in:
@@ -379,6 +379,36 @@ export default {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 判断是否在微信小程序的web-view中打开H5
|
||||
* @returns {boolean} 是否在微信小程序的web-view中
|
||||
*/
|
||||
isWeChatMiniProgram() {
|
||||
const userAgent = navigator.userAgent.toLowerCase();
|
||||
|
||||
// 微信小程序的web-view User-Agent会包含以下特征之一
|
||||
const miniProgramIndicators = [
|
||||
'miniprogram', // 普通微信小程序
|
||||
'wxwork', // 企业微信小程序
|
||||
'micromessenger/[0-9]+\.[0-9]+\.[0-9]+ nettype/wifi wxwebviewtype/1'
|
||||
];
|
||||
|
||||
return miniProgramIndicators.some(indicator => {
|
||||
if (typeof indicator === 'string' && indicator.includes('/')) {
|
||||
// 正则表达式匹配
|
||||
const regex = new RegExp(indicator, 'i');
|
||||
return regex.test(userAgent);
|
||||
}
|
||||
return userAgent.includes(indicator);
|
||||
});
|
||||
},
|
||||
/**
|
||||
* 判断是否在微信浏览器中打开H5(非小程序的web-view)
|
||||
* @returns {boolean} 是否在微信浏览器中打开的H5
|
||||
*/
|
||||
isWeChatBrowser() {
|
||||
return isWeiXin() && !isWeChatMiniProgram();
|
||||
},
|
||||
/**
|
||||
* 显示消息提示框
|
||||
* @param {Object} params 参数
|
||||
|
||||
Reference in New Issue
Block a user