Browse Source

app下载网页,协议网页

lizhen_gitee 9 months ago
parent
commit
870b5d6c50

+ 36 - 3
application/index/controller/Index.php

@@ -2,9 +2,10 @@
 
 namespace app\index\controller;
 
-use app\common\controller\Frontend;
-
-class Index extends Frontend
+//use app\common\controller\Frontend;
+use think\Controller;
+use think\Db;
+class Index extends Controller
 {
 
     protected $noNeedLogin = '*';
@@ -16,4 +17,36 @@ class Index extends Frontend
         return $this->view->fetch();
     }
 
+    /**
+     * app下载页
+     * 判断是安卓还是ios
+     */
+    public function appdownload() {
+        /*$this->view->assign('downurl', config("site.apkurl"));
+        return $this->view->fetch();*/
+
+        if(strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone')||strpos($_SERVER['HTTP_USER_AGENT'], 'iPad')){
+            header("Location: ".config('site.ios_downurl'));
+        }else if(strpos($_SERVER['HTTP_USER_AGENT'], 'Android')){
+            //$host = $_SERVER["REQUEST_SCHEME"]."://".$_SERVER["HTTP_HOST"];
+            //header("Location: ".$host."/index/index/download");
+            $this->view->assign('downurl', config("site.android_apkUrl"));
+            return $this->view->fetch();
+        }else{
+            $this->view->assign('downurl', config("site.android_apkUrl"));
+            return $this->view->fetch();
+        }
+    }
+
+    //基础文章网页
+    public function basedata(){
+        $key = input('key','');
+        if(!$key){
+            exit;
+        }
+        $content = Db::name('basedata')->where('key',$key)->find();
+        $this->assign('content',$content['content']);
+        return $this->fetch();
+    }
+
 }

+ 82 - 0
application/index/view/index/appdownload.html

@@ -0,0 +1,82 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+    <meta charset="UTF-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>TKEN下载</title>
+    <script src="../../assets/js/fontSize.js"></script>
+</head>
+<style>
+    .wxtip{background: rgba(0,0,0,0.8); text-align: center; position: fixed; left:0; top: 0; width: 100%; height: 100%; z-index: 998; display: none;}
+    .wxtip-icon{width: 52px; height: 67px; background: url(../../assets/img/weixin-tip.png) no-repeat; display: block; position: absolute; right: 20px; top: 20px;}
+    .wxtip-txt{margin-top: 107px; color: #fff; font-size: 16px; line-height: 1.5;}
+
+    * {
+        margin:0;
+        padding:0;
+    }
+    body {
+        background:#edf0f0;
+        font-family:Helvetica Neue,Helvetica,Arial,sans-serif;
+        font-size:14px;
+        color:#333;
+        padding:0;
+        margin:0;
+    }
+    .page{
+        position: relative;
+        left: 0;
+        top: 0;
+        right: 0;
+        bottom: 0;
+        width: 100vw;
+        height: 100vh;
+        background: url(../../assets/img/download.png) no-repeat center/cover;
+    }
+    .btn{
+        width: 290px;
+        height: 45px;
+        background: linear-gradient(90deg, #8F68DD, #6B7DDB);
+        box-shadow: 0px 1px 2px 0px rgba(126, 114, 220, 0.59);
+        line-height: 45px;
+        text-align: center;
+        font-size: 17px;
+        color: #FFFFFF;
+        border-radius: 35px;
+        bottom:26px;
+        left: 50%;
+        transform: translateX(-50%);
+        position: absolute;
+    }
+</style>
+
+<body >
+<div class="page">
+    <a class="btn" href="{$downurl}"  id="JdownApp">点击下载</a>
+</div>
+<div class="wxtip" id="JweixinTip">
+    <span class="wxtip-icon"></span>
+    <p class="wxtip-txt">点击右上角<br/>选择在浏览器中打开</p>
+</div>
+
+</body>
+<script>
+
+    function weixinTip(ele){
+        var ua = navigator.userAgent;
+        var isWeixin = !!/MicroMessenger/i.test(ua);
+        if(isWeixin){
+            ele.onclick=function(e){
+                window.event? window.event.returnValue = false : e.preventDefault();
+                document.getElementById('JweixinTip').style.display='block';
+            }
+            document.getElementById('JweixinTip').onclick=function(){
+                this.style.display='none';
+            }
+        }
+    }
+    var btn1 = document.getElementById('JdownApp');//下载一
+    weixinTip(btn1);
+</script>

+ 63 - 0
application/index/view/index/basedata.html

@@ -0,0 +1,63 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Document</title>
+    <style>
+        html, body, div, span, applet, object, iframe,
+        h1, h2, h3, h4, h5, h6, p, blockquote, pre,
+        a, abbr, acronym, address, big, cite, code,
+        del, dfn, em, img, ins, kbd, q, s, samp,
+        small, strike, strong, sub, sup, tt, var,
+        b, u, i, center,
+        dl, dt, dd, ol, ul, li,
+        fieldset, form, label, legend,
+        table, caption, tbody, tfoot, thead, tr, th, td,
+        article, aside, canvas, details, embed, 
+        figure, figcaption, footer, header, hgroup, 
+        menu, nav, output, ruby, section, summary,
+        time, mark, audio, video {
+            margin: 0;
+            padding: 0;
+            border: 0;
+            font-size: 100%;
+            font: inherit;
+            vertical-align: baseline;
+            box-sizing: border-box;
+            font-family: Source Han Sans CN;
+        }
+        .page{
+            padding: 15px;
+            font-size: 14px;
+            line-height: 16px;
+            color:#333;
+        }
+    </style>
+</head>
+<body>
+    <div class="page">
+        {$content}
+    </div>
+</body>
+</html>
+<script src="/assets/js/jquery-3.1.1.min.js"></script>
+<script>
+
+    function replaceDetail(){
+        var details = $('.page').html();
+	   //newContent仅是details替换后内容;
+        let newContent = details.replace(/<img[^>]*>/gi, function (match, capture) { //去除三标签
+            match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, '');
+            match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, '');
+            match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, '');
+            return match;
+        });
+        newContent = newContent.replace(/<br[^>]*\/>/gi, '');
+        newContent = newContent.replace(/<img/gi, '<img style="max-width:100%;height:auto;display:block;margin:0 auto;"');
+        $('.page').html('');
+        $('.page').html(newContent);
+    }
+    replaceDetail();
+</script>