<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>{{$config['doc_name']}}</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">

    <link rel="stylesheet" href="http://cdn.cmlphp.com/framework_layui/css/layui.css">
    <style type="text/css">
        .swift_nav{position:fixed;z-index:100000;bottom:15px;left:15px;width:50px;height:50px;line-height:50px;border-radius:2px;text-align:center;background-color:rgba(0,0,0,.7);color:#fff;}.mobile .nav_shade{content:'';position:fixed;top:0;bottom:0;left:0;right:0;background-color:rgba(0,0,0,.8);z-index:999;}.header{z-index:1000;width:100%;background-color:#393D49;}.logo{display:inline-flex;line-height:60px;color:white;font-size:20px;margin-right:20px;}.top-nav{position:absolute;top:0;right:0;}.left-nav,.doc-body{font-size:14px;min-height:300px;}.left-nav .layui-nav-item{width:auto;}.left-nav .layui-elem-quote{width:165px;border-left-color:#009688;font-size:18px;}.left-nav{display:inline-block;width:220px;padding:30px 0 20px;vertical-align:top;z-index:666;overflow:auto;}.left-nav dl.layui-nav-child{max-height:550px;overflow:auto;}.doc-body{display:inline-block;width:895px;padding:20px 0 10px 20px;}.fix .left-nav{position:fixed;top:0;}.fix .doc-body{margin-left:220px;}@media screen and (max-width:750px){.swift_nav{display:block !important;}.layui-main{width:auto;margin:0 10px;}.logo{left:10px;}.left-nav{position:fixed;left:-260px;}.doc-body{width:100%;padding:0;margin-left:0;overflow:auto;}.fix .doc-body{margin-left:0;}.layui-table{word-wrap:break-word;table-layout:fixed;}.layui-code-view{word-wrap:break-word;word-break:break-all;}}.mobile .left-nav{left:0;top:0;padding-top:0;z-index:1009;}.h1,.h2,.h3,.h4{padding-bottom:5px;margin-bottom:10px;color:#393D49;font-size:28px;font-weight:300;}.h1{border-bottom:1px solid #eee;margin-bottom:20px;line-height:60px;padding-bottom:10px;}.h2{font-size:20px;}.h3{font-size:18px;}.h4{font-size:16px;}fieldset legend{margin:15px 0;}
    </style>
</head>
<body>

<div class="layui-header header">
    <div class="layui-main">
        <span class="logo">{{$config['doc_name']}}</span>
        <ul class="layui-nav top-nav">

            <li class="layui-nav-item">
                版本:
            </li>
            {{loop $result $version $item}}
                <li class="layui-nav-item"><a href="#{{echo str_replace('.', '_', $version);}}">{{$version}}</a></li>
            {{/loop}}
        </ul>
    </div>
</div>

<div class="layui-main top">
    <div class="left-nav">
        <blockquote class="layui-elem-quote">目录</blockquote>
        <ul class="layui-nav layui-nav-tree">
            <li class="layui-nav-item">
                <a href="#overview-intro">约定说明</a>
                <dl class="layui-nav-child">
                    <dd><a href="#overview-sign">接口地址及秘钥</a></dd>
                    <dd><a href="#overview-format">接口基本格式</a></dd>
                    <dd><a href="#overview-other">其它约定</a></dd>
                    <dd><a href="#overview-code">响应code说明</a></dd>
                </dl>
            </li>

            <!--           <li class="layui-nav-item layui-this"><a href="#interface_definition">接口定义</a></li>-->

            {{loop $result $version  $item }}
                <li class="layui-nav-item">
                    <a href="#{{echo str_replace('.', '_', $version);}}">{{$version}}版本接口</a>
                    <dl class="layui-nav-child">
                        {{loop $item $method $api }}
                            <dd><a href="#{{echo str_replace('.', '_', $version)."_{$method}";}}" title="{{$method}} {{$api['desc']}}">{{$method}} {{$api['desc']}}</a></dd>
                        {{/loop}}
                    </dl>
                </li>
            {{/loop}}
        </ul>
    </div>

    <div class="doc-body">
        <h1 class="h1">约定说明</h1>
        <span id="overview-intro" style="height:0;"></span>

        <fieldset class="layui-elem-field layui-field-title">
            <legend id="overview-sign">接口地址及秘钥:</legend>
            <blockquote class="layui-elem-quote layui-quote-nm">
                <ol>
                    <li><b>接口地址:</b> {{$config['api_url']}}</li>
                    <li><b>密钥:</b> 线下发送</li>
                </ol>
            </blockquote>
        </fieldset>

        <fieldset class="layui-elem-field layui-field-title">
            <legend id="overview-format">接口基本格式</legend>
            <table class="layui-table">
                <thead>
                <tr>
                    <th>类型</th>
                    <th colspan="2">数据</th>
                    <th>是否必选</th>
                    <th>说明</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <th scope="row">数据格式</th>
                    <td colspan="2">Application/json</td>
                    <td>Y</td>
                    <td>http 数据类型</td>
                </tr>
                <tr>
                    <th scope="row">请求方法</th>
                    <td colspan="2">POST</td>
                    <td>Y</td>
                    <td>http发送方法</td>
                </tr>
                <tr>
                    <th scope="row" rowspan="{{echo (isset($config['use_nonce']) && $config['use_nonce']) ? 7 : 6;}}">请求内容</th>
                    <td rowspan="{{echo (isset($config['use_nonce']) && $config['use_nonce']) ? 5 : 4;}}">system</td>
                    <td>version</td>
                    <td>Y</td>
                    <td>{{$version}}</td>
                </tr>
                <tr>
                    <td>sign</td>
                    <td>Y</td>
                    <td>md5(key+time) 签名</td>
                </tr>
                <tr>
                    <td>time</td>
                    <td>Y</td>
                    <td>UTC 时间戳, 自 1970 年 1 月 1 日起计算的时间，单位为秒</td>
                </tr>
                <tr>
                    <td>from</td>
                    <td>Y</td>
                    <td>来源,跟密钥相对应，线下发送</td>
                </tr>
                {{if isset($config['use_nonce']) && $config['use_nonce']}}
                <tr>
                    <td>nonce</td>
                    <td>Y</td>
                    <td>唯一的不重复的随机串</td>
                </tr>
                {{/if}}
                <tr>
                    <td>method</td>
                    <td>1-1</td>
                    <td>Y</td>
                    <td>方法</td>
                </tr>
                <tr>
                    <td>params</td>
                    <td colspan="3">详细的参数</td>
                </tr>
                </tbody>
            </table>

            <h4 class="h4">请求示例:</h4>
            <div>
                <blockquote class="layui-elem-quote">
                    在本示例中请求的是V1版本的接口。来源是ios。请求的接口是1-1。参数有3个分别是username、password、nickname
                </blockquote>

                <pre class="layui-code">
{
    "system": {
        "version":"V1",
        "from": "ios",
        "sign": "a101f236d049b9ad80e012113e59f9bc",
{{if isset($config['use_nonce']) && $config['use_nonce']}}
        "nonce": "1445482366:fdoielnx",
{{/if}}
        "time": "1445482366"
    },
    "method": "1-1",
    "params": {
        "username" : "test001@163.com",
        "password" : "123456",
        "nickname" : "我是测试账号1"
    }
}
                </pre>
            </div>
        </fieldset>

        <fieldset class="layui-elem-field layui-field-title">
            <legend id="overview-other">其它约定</legend>
            <blockquote class="layui-elem-quote">
                {{loop $config['convention_desc'] $ctitle $cdesc}}
                    <li>
                        <b>{{$ctitle}}:</b> {{echo str_replace('<pre>', '<pre class="layui-code">', $cdesc);}}
                    </li>
                {{/loop}}
            </blockquote>
        </fieldset>

        <fieldset class="layui-elem-field layui-field-title">
            <legend id="overview-code">响应code说明</legend>

            <table class="layui-table">
                <thead>
                <tr>
                    <th>code</th>
                    <th>说明</th>
                </tr>
                </thead>
                <tbody>
                {{loop $config['code'] $code $means }}
                    <tr>
                        <td>{{$code}}</td>
                        <td>{{$means}}</td>
                    </tr>
                {{/loop}}
                </tbody>
            </table>
        </fieldset>

        <h1 class="h1" id="interface_definition">接口定义</h1>

        {{loop $result $version $item }}
            <fieldset class="layui-elem-field layui-field-title">
                <legend>版本: {{$version}}</legend>
                <span id="{{echo str_replace('.', '_', $version);}}" style="height:0;"></span>

                {{loop $item $method $api}}
                    <blockquote class="layui-elem-quote" id="{{echo str_replace('.', '_', $version)."_{$method}";}}">
                        <b>{{$method}}</b>：{{$api['desc']}}
                    </blockquote>

                    <blockquote class="layui-elem-quote layui-quote-nm">
                        <h2 class="h2">接口定义：</h2>
                        <table class="layui-table">
                            <tr>
                                <th></th>
                                <th>字段名</th>
                                <th>格式</th>
                                <th>是否必填</th>
                                <th>说明</th>
                            </tr>
                            {{loop $api['params'] $pk $pv }}
                                <tr>
                                    {{if $pk == 0}} <td rowspan="{{echo count($api['params']);}}">params</td> {{/if}}
                                    <td>{{$pv[1]}}</td>
                                    <td>{{$pv[0]}}</td>
                                    <td>{{$pv[3]}}</td>
                                    <td>{{$pv[2]}}</td>
                                </tr>
                            {{/loop}}
                        </table>

                        <h2 class="h2">代码示例:</h2>

                        <h3 class="h3">Request:</h3>
                        <pre class="layui-code">{{$api['req']}}</pre>

                        <h3 class="h3">Response:</h3>
                        <h4 class="h4">成功:</h4>
                        <pre class="layui-code">{{$api['success']}}</pre>

                        <h4 class="h4">失败:</h4>
                        <pre class="layui-code">{{$api['error']}}</pre>

                    </blockquote>
                {{/loop}}
            </fieldset>
        {{/loop}}
    </div>
</div>

<div class="layui-hide swift_nav">
    <i class="layui-icon">&#xe602;</i>
</div>

<div class="nav_shade"></div>

<script src="http://cdn.cmlphp.com/framework_jquery.1.11.3.js" type="text/javascript"></script>
<script src="http://cdn.cmlphp.com/framework_layui/layui.js" type="text/javascript"></script>
<script type="text/javascript">
    layui.use(['element','jquery','code','util'],function(){var $=layui.jquery;layui.code({title:'Json',about:false});$('.swift_nav').on('click',function(){$('body').addClass('mobile')});$('.nav_shade').on('click',function(){$('body').removeClass('mobile')});layui.util.fixbar();var main=$('.top'),scroll=function(){var stop=$(window).scrollTop();if($(window).width()<=750)return;if(stop>61){if(!main.hasClass('fix')){main.addClass('fix')}}else{if(main.hasClass('fix')){main.removeClass('fix')}}stop=null};scroll();$(window).on('scroll',scroll);

        +function($){'use strict';function ScrollSpy(element,options){var process=$.proxy(this.process,this);this.$body=$('body');this.$scrollElement=$(element).is('body')?$(window):$(element);this.options=$.extend({},ScrollSpy.DEFAULTS,options);this.selector=(this.options.target||'')+' .layui-nav-child dd > a';this.offsets=[];this.targets=[];this.activeTarget=null;this.scrollHeight=0;this.$scrollElement.on('scroll.bs.scrollspy',process);this.refresh();this.process()}ScrollSpy.VERSION='3.3.0';ScrollSpy.DEFAULTS={offset:10};ScrollSpy.prototype.getScrollHeight=function(){return this.$scrollElement[0].scrollHeight||Math.max(this.$body[0].scrollHeight,document.documentElement.scrollHeight)};ScrollSpy.prototype.refresh=function(){var offsetMethod='offset';var offsetBase=0;if(!$.isWindow(this.$scrollElement[0])){offsetMethod='position';offsetBase=this.$scrollElement.scrollTop()}this.offsets=[];this.targets=[];this.scrollHeight=this.getScrollHeight();var self=this;this.$body.find(this.selector).map(function(){var $el=$(this);var href=$el.data('target')||$el.attr('href');var $href=/^#./.test(href)&&$(href);return($href&&$href.length&&$href.is(':visible')&&[[$href[offsetMethod]().top+offsetBase,href]])||null}).sort(function(a,b){return a[0]-b[0]}).each(function(){self.offsets.push(this[0]);self.targets.push(this[1])})};ScrollSpy.prototype.process=function(){var scrollTop=this.$scrollElement.scrollTop()+this.options.offset;var scrollHeight=this.getScrollHeight();var maxScroll=this.options.offset+scrollHeight-this.$scrollElement.height();var offsets=this.offsets;var targets=this.targets;var activeTarget=this.activeTarget;var i;if(this.scrollHeight!=scrollHeight){this.refresh()}if(scrollTop>=maxScroll){return activeTarget!=(i=targets[targets.length-1])&&this.activate(i)}if(activeTarget&&scrollTop<offsets[0]){this.activeTarget=null;return this.clear()}for(i=offsets.length;i--;){activeTarget!=targets[i]&&scrollTop>=offsets[i]&&(!offsets[i+1]||scrollTop<=offsets[i+1])&&this.activate(targets[i])}};ScrollSpy.prototype.activate=function(target){this.activeTarget=target;this.clear();var selector=this.selector+'[data-target="'+target+'"],'+this.selector+'[href="'+target+'"]';var active=$(selector).parents('dd').addClass('layui-this').parents('li').addClass('layui-nav-itemed');active.trigger('activate.bs.scrollspy')};ScrollSpy.prototype.clear=function(){$(this.selector).parentsUntil(this.options.target,'.layui-this').removeClass('layui-this');$('li.layui-nav-itemed').removeClass('layui-nav-itemed')};function Plugin(option){return this.each(function(){var $this=$(this);var data=$this.data('bs.scrollspy');var options=typeof option=='object'&&option;if(!data)$this.data('bs.scrollspy',(data=new ScrollSpy(this,options)));if(typeof option=='string')data[option]()})}var old=$.fn.scrollspy;$.fn.scrollspy=Plugin;$.fn.scrollspy.Constructor=ScrollSpy;$.fn.scrollspy.noConflict=function(){$.fn.scrollspy=old;return this}}($);

        var windowDom=$(window),bodyDom=$(document.body);bodyDom.scrollspy({target:".left-nav"});windowDom.on("load",function(){bodyDom.scrollspy("refresh")})});

</script>

</body>
</html>