Browse Source

协议,app下载页,版本控制接口

lizhen_gitee 5 tháng trước cách đây
mục cha
commit
b464c8a6c3

+ 18 - 23
application/api/controller/Baseconfig.php

@@ -24,30 +24,25 @@ class Baseconfig extends Api
     }
 
 
-    /**
-     * 获取安卓版本更新信息
-     */
-    public function getandroidEdition() {
-        // 获取二维码
-        $is_force = config("site.android_is_force");
-        $apkUrl = config("site.android_apkUrl");
-        $apkName = config("site.android_apkName");
-        $desc = config("site.android_desc");
-        $versionCode = config("site.android_versionCode");
-        $this->success("获取成功!",["versionCode"=>$versionCode,"isForceUpdate"=>$is_force,"apkUrl"=>$apkUrl,"apkName"=>$apkName,"desc"=>$desc]);
-    }
+    //用户端版本
+    public function user_app_version(){
+        $config = [
+            'android_update_num'     => config('site.user_android_update_num'),     //android版本迭代号
+            'android_update_version' => config('site.user_android_update_version'), //android展示版本号
+            'android_download_url'   => config('site.user_android_download_url'),   //android下载链接
+            'android_update_force'   => config('site.user_android_update_force'),   //android是否强制更新
+            'android_update_title'   => config('site.user_android_update_title'),   //android更新标题
+            'android_update_info'    => config('site.user_android_update_info'),    //android更新描述
+            'ios_update_num'         => config('site.user_ios_update_num'),         //ios版本迭代号
+            'ios_update_version'     => config('site.user_ios_update_version'),     //ios展示版本号
+            'ios_download_url'       => config('site.user_ios_download_url'),       //ios下载链接
+            'ios_update_force'       => config('site.user_ios_update_force'),       //ios是否强制更新
+            'ios_update_title'       => config('site.user_ios_update_title'),       //ios更新标题
+            'ios_update_info'        => config('site.user_ios_update_info'),        //ios更新描述
+            'ios_pay_sandbox'        => config('site.user_ios_pay_sandbox'),        //ios支付是否正式
+        ];
 
-    /**
-     * 获取ios版本更新信息
-     */
-    public function getiosEdition() {
-        // 获取二维码
-        $is_force = config("site.iso_is_force");
-        $apkUrl = config("site.ios_downurl");
-        $apkName = config("site.iso_appname");
-        $desc = config("site.iso_desc");
-        $versionCode = config("site.iso_versioncode");
-        $this->success("获取成功!",["versionCode"=>$versionCode,"isForceUpdate"=>$is_force,"apkUrl"=>$apkUrl,"apkName"=>$apkName,"desc"=>$desc]);
+        $this->success('success',$config);
     }
 
     //启动广告图

+ 15 - 0
application/extra/site.php

@@ -28,6 +28,8 @@ return array (
     'user' => '会员配置',
     'example' => '示例分组',
     'website' => '全站基础配置',
+    'userandroid' => '用户端安卓版本',
+    'userios' => '用户端苹果版本',
   ),
   'mail_type' => '1',
   'mail_smtp_host' => 'smtp.qq.com',
@@ -44,4 +46,17 @@ return array (
   ),
   'apisite_switch' => '1',
   'apisite_notice' => '全站维护中',
+  'user_android_update_num' => '1',
+  'user_android_update_version' => '1.0.0',
+  'user_android_download_url' => 'http://baidu.com',
+  'user_android_update_force' => '1',
+  'user_android_update_title' => '发现新版本',
+  'user_android_update_info' => '我是一条描述',
+  'user_ios_update_num' => '1',
+  'user_ios_update_version' => '1.0.0',
+  'user_ios_download_url' => 'http://apple.com',
+  'user_ios_update_force' => '1',
+  'user_ios_update_title' => '新的版本',
+  'user_ios_update_info' => '界是你没有挽过的船新版本',
+  'user_ios_pay_sandbox' => '0',
 );

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

@@ -2,9 +2,9 @@
 
 namespace app\index\controller;
 
-use app\common\controller\Frontend;
-
-class Index extends Frontend
+use think\Controller;
+use think\Db;
+class Index extends Controller
 {
 
     protected $noNeedLogin = '*';
@@ -16,4 +16,32 @@ class Index extends Frontend
         return $this->view->fetch();
     }
 
+    /**
+     * app下载页
+     * 判断是安卓还是ios
+     */
+    public function appdownload() {
+
+        if(strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone')||strpos($_SERVER['HTTP_USER_AGENT'], 'iPad')){
+            header("Location: ".config('site.user_ios_download_url'));
+        }else if(strpos($_SERVER['HTTP_USER_AGENT'], 'Android')){
+            $this->view->assign('downurl', config("site.user_android_download_url"));
+            return $this->view->fetch();
+        }else{
+            $this->view->assign('downurl', config("site.user_android_download_url"));
+            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>APP下载</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:80px;
+        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,  sub, sup, tt, var,
+        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>

BIN
public/assets/img/download.png


BIN
public/assets/img/weixin-tip.png


+ 14 - 0
public/assets/js/fontSize.js

@@ -0,0 +1,14 @@
+!(function(win, doc) {
+   	function setFontSize() {
+   		var docEl = doc.documentElement;
+   		var winWidth = docEl.clientWidth;
+   		doc.documentElement.style.fontSize = (winWidth / 375) * 10 + 'px';
+   	}
+   	var userAgent = navigator.userAgent;
+	win.addEventListener('resize', function() {
+   		if (navigator.userAgent !== userAgent) {
+   			location.reload();
+   		}
+   	}) 
+	setFontSize();
+   }(window, document));