安卓下载 ios跳转应用商店
<template>
<view class="identify box_h">
<view class="txt-word">
<view class="txt">请选择以下端:</view>
</view>
<view class="dis-flex justify-center btn-box flex-column">
<view class="dis-flex justify-center">
<view class="btn" @click="downClick(1)">
<view class="txt">Android端</view>
</view>
</view>
<view class="dis-flex justify-center">
<view class="btn btn1" @click="downClick(2)">
<view class="txt">IOS端</view>
</view>
</view>
</view>
</view>
</template>
主要代码
<script setup>
import {
ref
} from "vue";
import {
onLoad
} from '@dcloudio/uni-app'
onLoad(()=>{
})
//判断是否是微信浏览器
const isWeixin = () => {
let ua = navigator.userAgent.toLowerCase();
return ua.indexOf('micromessenger') !== -1;
};
//判断ios
const isIos = () => {
let ua = navigator.userAgent.toLowerCase();
console.log( ua,ua.indexOf('iphone') > -1 , ua.indexOf('mac os') > -1)
return ua.indexOf('iphone') > -1 || ua.indexOf('mac os') > -1;
};
function downClick(index) {
if (isWeixin()) {
// 微信浏览器时点击弹出提示,其他浏览器直接触发下载
alert('请点击右上角按钮, 选择使用浏览器打开');
} else {
if(index==1){
window.location.href = 'https://xxx.apk';
}else if(index==2){
window.location.href = 'http://apps.apple.com/cn/app/id'+xxxx;//xxxx是ios appid
}
}
}
</script>