极光魔链web版,兼容微信浏览器代码分享

(172) 2024-04-17 10:01:09

只需把配置的短链地址替换代码中的“你的魔链地址”即可

<!DOCTYPE html>

<html lang="en">
<head>
    <meta charset=utf-8"utf-8" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="description" id="description" content="test" />
    <title></title>
    <link href="#" rel="shortcut icon" id="icon" type="image/x-icon" />
    <style>
        html{
            height:100%;
        }
        .mw-page {
            display: none;
            opacity: 0;
        }
    </style>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/appapi/static/styles/main.css" tppabs="https://o8ci6tgz8.qnssl.com/mlink/1.0.0/static/styles/main.css" />

    <script type="text/javascript">
        /*<![CDATA[*/
        var recalc = function () {
            var clientWidth =  document.documentElement.clientWidth>480?480: document.documentElement.clientWidth;
            var height=clientWidth/750*1334;
            document.body.style.height=height+'px';
        };
        ;(function (doc, win, undefined) {
            resizeEvt = 'orientationchange' in win? 'orientationchange' : 'resize';

            if (doc.addEventListener === undefined) return;
            win.addEventListener(resizeEvt, recalc, false);
            doc.addEventListener('DOMContentLoaded', recalc, false)
        })(document, window);

        function onImgLoaded(elem) {
            elem.style.display = 'block';
        }

        function onImgError(elem) {
            elem.style.display = 'none';
        }
        /*]]>*/

    </script>

</head>
<body class="official-page">
<script>
    recalc()
</script>
<!--...Loading...-->
<section class="mw-page loading show">
    <div class="mw-page-cont">
        <div style="
	position: absolute;
    top: 40%;
    left: 0;
    width: 100%;
    text-align: center;
    z-index: 999;
    }">
            <div class="mw-page-footer" style="bottom: 20%;">
                <a id="btnOpenApp" href="javascript:void(0)" class="mw-button mw-open-app">打开App</a>
            </div>
        </div>
    </div>
</section>

<!--服务器或网络错误...-->
<section class="mw-page server-error">
    <div class="mw-page-cont">
        <h3>服务暂时不可用</h3>

        <div class="blue tips">
            <p>由于网络原因, 此服务暂时不可用</p>
        </div>
    </div>

    <div class="mw-page-footer">
        <a href="javascript:void(0);" onclick="document.location.reload()" class="mw-button">刷新试试</a>
    </div>
</section>

<!--浏览器不支持Scheme...-->
<section class="mw-page scheme-notsupported">
    <div class="mw-page-cont">
        <h3>宝宝心里苦, 浏览器过不去了</h3>

        <div class="blue tips">
            <p>若您已安装 <span class="app-name"></span>, 请退出浏览器,在手机桌面上打开<span class="app-name"></span>.</p>
            <p>若您没有安装<span class="app-name"></span>, 请点击下面按钮下载.</p>
        </div>
    </div>

    <div class="mw-page-footer">
        <a href="javascript:void(0);" class="mw-button">前往应用市场下载</a>
    </div>
</section>


<!--倒计时-->
<section class="mw-page scheme-redirecting">
    <div class="mw-page-cont table">
        <div class="middle">
            <div class="app-icon" style="background: none">
                <img onload="onImgLoaded(this)" onerror="onImgError(this)" />
            </div>
            <h4 class="app-name"></h4>
            <a href="javascript:void(0);" class="mw-button mw-open-app">打开App</a>
            <a href="javascript:void(0);" class="mw-button2 mw-open-download">下载app</a>
        </div>
    </div>

</section>

<!--此短链不支持iOS/Android设备,请修改配置.-->
<section class="mw-page setting-error">
    <div class="mw-page-cont">
        <!--<div class="middle">-->
        <!--<div class="app-icon">-->
        <!--<img onload="onImgLoaded(this)" onerror="onImgError(this)" />-->
        <!--</div>-->
        <!--<h4 class="app-name"></h4>-->
        <!--</div>-->
        <h3></h3>
        <div class="tips blue">此短链不支持iOS/Android设备,请在后台完善配置.</div>
    </div>
</section>

<!--通用提示.-->
<section class="mw-page mw-alert">
    <div class="mw-page-cont table">
        <div class="middle">
            <h3></h3>
            <div class="tips blue"></div>
        </div>
    </div>
</section>

<!--需要使用按钮才能跳转的页面:如Scheme\UniversalLink.-->
<section class="mw-page redirect-with-button">
    <div class="mw-page-cont table">
        <div class="middle">
            <div class="app-icon">
                <img onload="onImgLoaded(this)" onerror="onImgError(this)" />
            </div>
            <h4 class="app-name"></h4>
        </div>
    </div>
    <div class="mw-page-footer">
        <a href="javascript:void(0);" class="mw-button mw-open-app">打开App</a>
    </div>
</section>

<!--Universal Link Download-->
<section class="mw-page universal-link-download">
    <div class="mw-page-cont table">
        <div class="middle">
            <div class="app-icon">
                <img onload="onImgLoaded(this)" onerror="onImgError(this)" />
            </div>
            <h4 class="app-name"></h4>
            <p>如果下拉页面没有反应,那可能是:</p>
            <ol>
                <li>您没有安装 <span class="app-name"></span>;</li>
                <li>您设备上的 <span class="app-name"></span> 不是最新版本;</li>
            </ol>
        </div>
    </div>
    <div class="mw-page-footer">
        <a href="javascript:void(0);" class="mw-button">前往应用市场下载App</a>
    </div>
</section>

<!--用户自定义内容-->
<section class="mw-page custom-content">
    <div class="mw-page-cont">
        <h1 class="mw-cc-title"></h1>
        <figure class="mw-cc-banner">
            <a href="javascript:void(0);" class="mw-open-app">
                <img onload="onImgLoaded(this)" onerror="onImgError(this)" />
            </a>
        </figure>
        <div class="content"></div>
    </div>

    <div class="mw-page-footer fixed">
        <div class="app-info">
            <div class="app-icon logo">
                <img onload="onImgLoaded(this)" onerror="onImgError(this)" />
            </div>
            <h4 class="app-name"></h4>
        </div>
        <div class="btns">
            <a href="javascript:void(0);" class="mw-button mw-open-app">打开APP</a>
        </div>
    </div>

</section>

<!--在Safari中打开.-->
<section class="mw-page openinbrowser ios default">
    <div class="mw-page-cont">
        <div class="tips"></div>
        <div class="app-icon logo">
            <img onload="onImgLoaded(this)" onerror="onImgError(this)" />
        </div>
    </div>
</section>

<!--在浏览器中打开.-->
<section class="mw-page openinbrowser android default">
    <div class="mw-page-cont">
        <div class="tips"></div>
        <div class="app-icon logo">
            <img onload="onImgLoaded(this)" onerror="onImgError(this)" />
        </div>
    </div>
</section>

<!--在浏览器中打开.应对微信,只在ios9以上微信中展示-->
<section class="mw-page openinbrowser-ios9-wechat android default">
    <div class="tips" style="     height: 100%;     width: 100%;     background-size: cover;     z-index: 1;     position: fixed;     lefT: 0;     top: 0;     background-position: center;     background-repeat: no-repeat; ">
        <div class="mw-page-cont table">
            <div class="middle">
                <div class="app-icon" style="width: 8em;height: 8em;">
                    <img />
                </div>
                <h4 class="app-name" style="font-size: 1em"></h4>
                <div class="btns">
                    <a href="javascript:void(0);" mlink-handling="true" class="mw-button mw-open-app">立即下载</a>
                </div>
            </div>
        </div>

    </div>
</section>

<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script src="https://static.jmlk.co/scripts/dist/jmlink.min.js"></script>

<script>

    new JMLink({
        jmlink:"你的魔链地址",
        // jmlink:"{$jm_link}",
        button: document.querySelector('a#btnOpenApp'),
        autoLaunchApp : true,
        downloadWhenUniversalLinkFailed: true,
        inapp : true,
        params: {
        },
    });



</script>
<script>
    /*<![CDATA[*/


    // var _hmt = _hmt || [];
    // (function() {
    //     var hm = document.createElement("script");
    //     hm.src = "../../hm.baidu.com/hm.js-7683ec131caf209fe25e561b3b0578b2"/*tpa=https://hm.baidu.com/hm.js?7683ec131caf209fe25e561b3b0578b2*/;
    //     var s = document.getElementsByTagName("script")[0];
    //     s.parentNode.insertBefore(hm, s);
    // })();

    // 重置微信菜单
    try {
        var preventDl = new Mlink.Uri(document.location.href).getParam('resetWeixinMenu');
        if (preventDl) {
            Mlink.loadScript(
                "https://res.wx.qq.com/open/js/jweixin-1.0.0.js",
                "https://o8ci6tgz8.qnssl.com/mlink/1.0.0/static/js/wx-jssdk-init.52e9791d.js"
            ).then(function () {
                initWxJSSDK({
                    //                        signatureUrl: '',
                    //                        url: document.location.href,
                    checkApiSuccess: function () {
                        wx.showAllNonBaseMenuItem();
                        wx.showOptionMenu();
                        wx.showMenuItems({
                            menuList: [
                                'menuItem:openWithQQBrowser',
                                'menuItem:openWithSafari',
                                "menuItem:share:appMessage",
                                "menuItem:share:timeline",
                                "menuItem:share:qq",
                                "menuItem:share:weiboApp"
                            ]
                        });
                    }
                });
            });
        }
    } catch (e) {
        console.log(e);
    }

    var isAutoRedirect=true
    var autoUl=false
    try{
        var preventDl = new Mlink.Uri(document.location.href).getParam('noautoredirect');
        if(preventDl==='true'){
            isAutoRedirect=false
        }
    }catch (err){

    }

    /*
    * ios11 支持universal link 的直接跳转,无弹窗,所以加此参数,如果遇到此参数且满足ul跳转的条件,则直接跳转universallink
    * */
    try{
        if(new Mlink.Uri(document.location.href).getParam('autoul')){
            autoUl=true
        }
    }catch (err){

    }

    new Mlink({
        mlink: document.location.href,
        button: [
            document.getElementById('universalLink'),
            document.getElementById('universalTextLink'),
            document.querySelectorAll('.mw-open-app')
        ],
        autoRedirect: true,
        isAutoRedirect:!isAutoRedirect,
        autoUl:autoUl
    });




    /**
     * 如果短链接中含有 mw_sd(skip detect),值为true,则直接转跳下载页
     *@ziko
     * */
    var  UA = navigator.userAgent;
    var  Uri= new Mlink.Uri(location.href);
    var isSd=Uri.getParam('mw_sd');
    if(isSd){
        var shorturlKey = location.pathname.replace('/','');
        var mlink=new Mlink({},false);
        var http;

        var shorturl = 'https://' + Mlink.env.ulHost + '/su/' + shorturlKey+location.search;
        var ios= UA.match(new RegExp(/iPhone OS|iPad; CPU OS/g)) || false
        var android= UA.match(new RegExp(/Android/g)) || false;
        mlink.loadData(true, shorturl, {doNotTracking: true}).then(function (data) {

            var landingPage = data.landingPage;
            var downloadUrl = ios ? data.iosDownloadUrl : data.androidDownloadUrl;
            var pageUrl = '';

            if (landingPage) {
                var params;
                params = new Mlink.Uri(location.href).getParams();
                pageUrl =new  Mlink.Uri(landingPage).setParams(params).toString();
            }
            setTimeout(function(){
                Mlink.location(data.jumpType === 'LANDING_PAGE' ? pageUrl : downloadUrl)

            },300)


        });
    }

    /*]]>*/


</script>
<!-- <a style="display: none;" key ="590fd38aefbfb0435b66355b" logo_size="124x47" logo_type="business" href="http://www.anquan.org" ><script src="//static.anquan.org/static/outer/js/aq_auth.js"></script></a> -->
</body>
</html>

THE END

发表回复