浏览代码

添加应用到桌面H5

heyang 3 年之前
父节点
当前提交
6903519ac4

+ 137 - 0
microserviceUserH5/static/css/webOnServer.css

@@ -0,0 +1,137 @@
+@media screen and (max-width: 750px) {
+  html {
+    font-size: calc(100vw / 7.5);
+  }
+}
+
+@media screen and (min-width: 750px) {
+  html {
+    font-size: calc(450px / 7.5);
+  }
+}
+
+html, body, div, ul, li, p {
+  padding: 0;
+  margin: 0;
+}
+
+ul, li {
+  list-style: none;
+}
+
+.container{
+  width: 7.5rem;
+  height: 100vh;
+  background: #F2F2F2;
+  margin: 0 auto;
+}
+
+.title{
+  width: 100%;
+  text-align: center;
+  font-size: 0.4rem;
+  padding-top: 1.2rem;
+}
+
+.middle{
+  display: flex;
+}
+
+.phone{
+  width: 2.58rem;
+  height: 5.2rem;
+  margin: 0.72rem 0 0 0.76rem;
+  position: relative;
+}
+
+.arrow{
+  width: 1.3rem;
+  height: 0.48rem;
+  position: absolute;
+  right: -0.9rem;
+  bottom: 2.26rem;
+}
+
+.arrow-img{
+  width: 100%;
+  height: 100%;
+}
+
+.img{
+  width: 100%;
+  height: 100%;
+}
+
+.app{
+  margin: 1.8rem 0 0 0.84rem;
+}
+
+.app-img{
+  width: 2rem;
+  height: 2rem;
+  border-radius: 0.38rem;
+}
+
+.app-text{
+  width: 2rem;
+  font-size: 0.32rem;
+}
+
+.footer-wrap{
+  position: fixed;
+  bottom: 0.84rem;
+  left: 50%;
+  margin-left: -2.99rem;
+  width: 5.98rem;
+  height: 1.6rem;
+  background-color: #FFFFFF;
+  box-shadow: 0 0.04rem 0.24rem 0 #D4DAE4;
+  border-radius: 0.2rem;
+}
+
+.top{
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  margin-top: 0.3rem;
+}
+
+.top-text{
+  font-size: 0.28rem;
+}
+
+.download-img{
+  width: 0.34rem;
+  height: 0.44rem;
+  margin-left: 0.14rem;
+}
+
+.bottom{
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  margin-top: 0.1rem;
+}
+
+.add-img{
+  width: 0.36rem;
+  height: 0.36rem;
+  margin-left: 0.14rem;
+}
+
+.left-text{
+  font-size: 0.28rem;
+}
+
+.right-text{
+  font-size: 0.28rem;
+}
+
+.down-img{
+  width: 0.42rem;
+  height: 0.28rem;
+  position: absolute;
+  left: 50%;
+  bottom: -0.56rem;
+  margin-left: -0.21rem;
+}

二进制
microserviceUserH5/static/img/webOnServer/arrow.png


+ 95 - 0
microserviceUserH5/vcloud/webOnServer.html

@@ -0,0 +1,95 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+    <meta name="apple-mobile-web-app-capable" content="yes">
+    <meta name="apple-mobile-web-app-status-bar-style" content="black">
+    <meta content="text/html charset=UTF-8" http-equiv="Content-Type" />
+    <meta charset="UTF-8">
+	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
+	<link rel="icon" href="../static/img/favicon2.ico" type="img/x-ico">
+	<link rel="stylesheet" href="../static/css/webOnServer.css">
+    <!--快捷方式默认图标:icon-->
+    <title>双子星</title>
+    <!--快捷方式默认标题:name-->
+</head>
+
+<body>
+    <div class="container">
+        <div class="title">添加应用到桌面</div>
+        <div class="middle">
+            <div class="phone">
+                <img class="img" src="../static/img/webOnServer/phone.png" />
+                <div class="arrow">
+                    <img class="arrow-img" src="../static/img/webOnServer/arrow.png" />
+                </div>
+            </div>
+            <div class="app">
+                <img class="app-img" src="" />
+                <div class="app-text"></div>
+            </div>
+        </div>
+        <a href="" id="qbt" style="display: none;"></a>
+        <!--快捷方式参数url:url-->
+        <span id="msg"></span>
+        <div class="footer-wrap">
+            <div class="top">
+                <span class="top-text">点击下方工具栏上的</span>
+                <img class="download-img" src="../static/img/webOnServer/download.png" />
+            </div>
+            <div class="bottom">
+                <span class="left-text">并选择</span>
+                <img class="add-img" src="../static/img/webOnServer/add.png" />
+                <span class="right-text">“添加到主屏幕”</span>
+            </div>
+            <img class="down-img" src="../static/img/webOnServer/down.png" />
+        </div>
+    </div>
+</body>
+<script src="https://s3.pstatp.com/cdn/expire-1-M/jquery/3.1.1/jquery.min.js"></script>
+<script>
+    (function ($) {
+        $.extend({
+            urlGet: function () {
+                var aQuery = window.location.href.split("?");  //取得Get参数
+                var aGET = new Array();
+                if (aQuery.length > 1) {
+                    var aBuf = aQuery[1].split("&");
+                    for (var i = 0, iLoop = aBuf.length; i < iLoop; i++) {
+                        var aTmp = aBuf[i].split("=");  //分离key与Value
+                        aGET[aTmp[0]] = aTmp[1];
+                    }
+                }
+                return aGET;
+            }
+        })
+
+        var GET = $.urlGet(); //获取URL的Get参数
+        var account = GET['account'];
+        var phoneID = GET['phoneID'];
+        var appID = GET['appID'];
+        var icon = GET['icon'];
+        var name = decodeURI(GET['name']);
+        
+        $(document).attr("title",name);
+        var url = "shuangzixingiOSApp://h5/microserviceUserH5/vcloud/shortcut/webOnServer.html?"
+        var href_srt = decodeURI("account="+account+"&phoneID="+phoneID+"&appID="+appID+"&icon="+icon+"&name="+name)
+        $("#qbt").attr("href",url+href_srt)
+        $("link[rel='apple-touch-icon']").attr("href",icon)
+
+        if (window.navigator.standalone == true) {
+            var lnk = document.getElementById("qbt").click();
+            // todo 点击快捷方式 打开app引导页 样式
+        }
+        else {
+            const appImg = document.getElementsByClassName("app-img")[0];
+            const appText = document.getElementsByClassName("app-text")[0];
+            appImg.src= icon;
+            appText.innerText = name || '';
+            // todo 添加快捷方式引导页 样式
+        }
+
+    })(jQuery);
+</script>
+
+</html>