zhaojs
2023-07-31 8dcfae4fff98fbbb19ff46bd9750f25bc56801a9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<template>
    <view class="content">
        <view @click="openTuer()">点击跳转大返官</view>
 
        <a :href="tourl">test:</a>
    </view>
</template>
 
<script>
    export default {
        data() {
            return {
                timer:null,
                tourl: 'dafanguan://{"url":"/pages/rankinglist/common_act?t_url=http://appapitest.ushopvip.com/html/freebuy.html","totype":"0"}'
            }
        },
        onLoad() {
        },
        methods: {
            openTuer() {
                if (this.isBlackApp()) {
                    uni.showToast({
                        title: '请复制此链接,至浏览器中打开',
                        icon: 'none'
                    });
                } else {
                    // 不是头部APP就直接打开
                    this.openApp();
                }
            },
            openApp() {
                //这里需要有个安卓和ios平台的判断分别取不同的SchemeURL
                this.jumpApp(this.tourl); //此函数负责打开APP的,scheme协议地址由安卓端跟ios端提供
                this.noApp(); //此函数负责如果没有打开APP或没有安装APP时跳转的地址处理
            },
            isBlackApp() {
                var u = navigator.userAgent.toLowerCase();
                return /micromessenger/i.test(u) || u.indexOf("weibo") > -1 || u.indexOf("qq") > -1 || u.indexOf(
                    'mqqbrowser') > -1;
            },
            jumpApp(t)
            {
                window.location.href=t;
            },
            noApp() {
                //这里需要有个安卓和ios平台的判断分别取不同的下载地址
              var t = Date.now(),r = "你的app下载地址";
              this.timer = setTimeout(function() {
                return Date.now() - t > 2200
                  ? (clearTimeout(this.timer), !1)
                  : !document.webkitHidden && !document.hidden && void (location.href = r);
              }, 2000);
            }
 
        }
    }
</script>
 
<style>
    .content {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }
 
</style>