vue h5点击跳转主流手机应用商店app下载页

html:

<div class="btn_open" @click="openApp">打开APP</div>

script:

data () {

    return {

      brands : {

        "IPHONE": "IPHONE|IPAD|IPOD|IOS",

        "OPPO": "OPPO",

        "VIVO": "VIVO",

        "HONOR": "HONOR",

        "HUAWEI": "HUAWEI",

        "XIAOMI": "XIAOMI|REDMI",

        "360": "1801-A01|1707-A01|1509-A00",

        "SAMSUNG": "SAMSUNG"

      },

      hasOwnProp:'',

      userAgent:'',

      os:'',

      brand:''

    }

openApp(){

    let device_type = navigator.userAgent;//获取userAgent信息

    let ua_pub = window.navigator.userAgent;

    let u = navigator.userAgent;

    let isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端

    let ua = window.navigator.userAgent.toLowerCase();

    let isWeixin = ua.indexOf('micromessenger') !== -1;

    let href = window.location.href;

    if (isWeixin)

    {

        window.location.href = "https://a.app.qq.com/o/simple.jsp?pkgname=包名";

        return true;

    }

    else if(ua_pub.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)){

        return

        // window.location.href = 'https://itunes.apple.com/cn/app/%E8%B6%A3%E5%90%AC%E5%B0%8F%E8%AF%B4-%E6%9C%89%E5%A3%B0%E5%B0%8F%E8%AF%B4%E6%87%92%E4%BA%BA%E5%90%AC%E4%B9%A6%E7%A5%9E%E5%99%A8/id1440140641?mt=8'

    }else {

        if(ua.match(/MicroMessenger/i) === 'micromessenger' && isAndroid) {

            //应用宝

            window.location.href ='https://a.app.qq.com/o/simple.jsp?pkgname=包名';

            $('body,html').animate({scrollTop:0},300);

        }

        if(href.indexOf('dym') !== -1) {   大姨妈渠道

            // alert('dym')

            return

        }else {

            if (device_type.indexOf('HUAWEI') > -1) {

                // alert('huawei')

                window.location.href = "market://details?id=包名"

            } else if (device_type.indexOf('OPPO') > -1||device_type.indexOf('Oppo') > -1) {

                window.location.href = "market://details?id=包名"

            } else if (device_type.indexOf('vivo') > -1) {

                window.location.href = "vivoMarket://details?id=包名"

            } else if (device_type.indexOf('MI') > -1 || device_type.indexOf('Mi') > -1 ) {

                // alert('xiaomi')

                window.location.href = "mimarket://details?id=包名"

            } else if (device_type.indexOf('baidu') > -1) {

                window.location.href = "https://a.app.qq.com/o/simple.jsp?pkgname=包名"

            } else if (device_type.indexOf('360') > -1) {

                window.location.href = "intent://details?id=包名#Intent;package=包名;scheme=market;end;"

            } else {  ///其他安卓手机

                window.location.href = "https://a.app.qq.com/o/simple.jsp?pkgname=包名"

            }

        }

    }

}

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值