判断当前设备是ios还是安卓
function isIOS() { // ios终端
return !!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
}
function isAndroid() { // android终端
return navigator.userAgent.indexOf('Android') > -1 || navigator.userAgent.indexOf('Adr') > -1;
}
跳转默认应用商店
if(!this.isApp && !this.isIos) { // android
window.location.replace(`mimarket://details?id=com.xxx.xxx`)
}else if(!this.isApp && this.isIos){ // ios
window.location.replace(`itms-appss://apps.apple.com/cn/app/id0000000000`)
}
常见机型应用市场跳转方式
- 华为:
appmarket://details?id=<PackageName>
- vivo::
vivoMarket://details?id=<PackageName>
- 应用宝 直接下载:
tmast://appdetails?pname=<PackageName>
- 百度 搜狗 网页:
http://market.android.com/details?id=<PackageName>
- 金立 网页:
http://m.appgionee.com/marketdetail?id=<PackageName>
- 小米:
mimarket://details?id=<PackageName>
- 联想:
http://market.lenovomm.com/details?id=<PackageName>
- 安智市场:
anzhimarket://details?id=<PackageName>
- 魅族:
mstore://details?package_name=<PackageName>
- 三星:
samsungapps://ProductDetail/${packageName}
const huaweiChal="appmarket://details?id=<PackageName>"; // 华为
const vivoChal="vivoMarket://details?id=<PackageName>"; // vivo
const qqChal="tmast://appdetails?pname=<PackageName>"; // 应用宝 直接下载
const baiduChal="http://market.android.com/details?id=<PackageName>"; // 百度 搜狗 网页
const jinliChal="http://m.appgionee.com/marketdetail?id=<PackageName>"; // 金立 网页
const xiaomiChal="mimarket://details?id=<PackageName>"; // 小米
const lenovoChal="http://market.lenovomm.com/details?id=<PackageName>"; // 联想
const anzhiChal="anzhimarket://details?id=<PackageName>"; // 安智市场
const meizuChal="mstore://details?package_name=<PackageName>"; // 魅族
const samsungChal = `samsungapps://ProductDetail/${packageName}`; // 三星
常见应用商店包名
- 小米应用商店
const PACKAGE_MI_MARKET = "com.xiaomi.market";
const MI_MARKET_PAGE = "com.xiaomi.market.ui.AppDetailActivity";
- 魅族应用商店
const PACKAGE_MEIZU_MARKET = "com.meizu.mstore";
const MEIZU_MARKET_PAGE = "com.meizu.flyme.appcenter.activitys.AppMainActivity";
- VIVO应用商店
const PACKAGE_VIVO_MARKET = "com.bbk.appstore";
const VIVO_MARKET_PAGE = "com.bbk.appstore.ui.AppStoreTabActivity";
- OPPO应用商店
const PACKAGE_OPPO_MARKET = "com.oppo.market";
const OPPO_MARKET_PAGE = "a.a.a.aoz";
- 华为应用商店
const PACKAGE_HUAWEI_MARKET = "com.huawei.appmarket";
const HUAWEI_MARKET_PAGE = "com.huawei.appmarket.service.externalapi.view.ThirdApiActivity";
- ZTE应用商店
const PACKAGE_ZTE_MARKET = "zte.com.market";
const ZTE_MARKET_PAGE = "zte.com.market.view.zte.drain.ZtDrainTrafficActivity";
- 360手机助手
const PACKAGE_360_MARKET = "com.qihoo.appstore";
const PACKAGE_360_PAGE = "com.qihoo.appstore.distribute.SearchDistributionActivity";
- 酷市场 – 酷安网
const PACKAGE_COOL_MARKET = "com.coolapk.market";
const COOL_MARKET_PAGE = "com.coolapk.market.activity.AppViewActivity";
- 应用宝
const PACKAGE_TENCENT_MARKET = "com.tencent.android.qqdownloader";
const TENCENT_MARKET_PAGE = "com.tencent.pangu.link.LinkProxyActivity";
- PP助手
const PACKAGE_ALI_MARKET = "com.pp.assistant";
const ALI_MARKET_PAGE = "com.pp.assistant.activity.MainActivity";
// 低版本可能是 com.pp.assistant.activity.PPMainActivity
- 豌豆荚
const PACKAGE_WANDOUJIA_MARKET = "com.wandoujia.phoenix2";
// 低版本可能是 com.wandoujia.jupiter.activity.DetailActivity
//UCWEB
const PACKAGE_UCWEB_MARKET = "com.UCMobile";
跳转应用商店:
goAppStore() {
let ua = navigator.userAgent;
let isAndroid = ua.indexOf("Android") > -1 || ua.indexOf("Linux") > -1; //android终端
let isIOS = !!ua.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
let hidden = window.document.hidden || window.document.mozHidden || window.document.msHidden || window.document.webkitHidden;
if (typeof hidden === undefined || hidden === false) {
if (isAndroid) {
// 跳转 安卓应用市场地址
} else if (isIOS) {
// 跳转 app store 地址
}
}
},
注:微信禁止直接打开APP 这个功能,建议跳转到应用宝。文章来源:https://www.toymoban.com/news/detail-519899.html
判断是否是微信
function isWeixin(){
return /MicroMessenger|WeXin|WeChat/g.test(navigator.userAgent)
}
拓展阅读:文章来源地址https://www.toymoban.com/news/detail-519899.html
- H5获取手机设备信息、app版本信息、ip地址
到了这里,关于【笔记】H5跳转手机应用商店(指定应用页/第三方应用商店)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!