zhaojs
2023-08-02 acba9f7ea0506e3df39055f3ae25283b943792fe
h5/apph5/pages/index/index.vue
@@ -1,6 +1,8 @@
<template>
   <view class="content">
      <view @click="openTuer()">点击跳转大返官</view>
      <a :href="tourl">test:</a>
   </view>
</template>
@@ -8,22 +10,47 @@
   export default {
      data() {
         return {
            title: 'Hello'
            timer:null,
            tourl: 'dafanguan://{"url":"/pages/rankinglist/common_act?t_url=http://appapitest.ushopvip.com/html/freebuy.html","totype":"0"}'
         }
      },
      onLoad() {
      var data={
         actid:'sdfsdf',
         dat:{
            nvt:1,
            ist:'3235'
         }
      }
      this.$http.post('/api/activity/getRankingList',data).then(res=>{
      })
      },
      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);
         }
      }
   }
@@ -37,22 +64,4 @@
      justify-content: center;
   }
   .logo {
      height: 200rpx;
      width: 200rpx;
      margin-top: 200rpx;
      margin-left: auto;
      margin-right: auto;
      margin-bottom: 50rpx;
   }
   .text-area {
      display: flex;
      justify-content: center;
   }
   .title {
      font-size: 36rpx;
      color: #8f8f94;
   }
</style>
</style>