<!DOCTYPE html>
<html>
<head>
    {%include '../inc/header.html'%}
	<link href="{{static_url('mobile/css/index.css')}}" rel="stylesheet">
    {%include '../inc/script.html'%}
</head>
<body>
    <section class="m-wrapper">
        {%include 'menu.html'%}
        {% if data['info']['pic'] %}
        <section class="banner">
            <img src="{{data['info']['pic']}}" width="100%">
        </section>
        {% end %}
        <section class="li-1">
            <dl>
                <dt><i class="ico ico1"></i></dt>
                <dd class="tit">{{data['info']['name']}}</dd>
                <dd>批次：{{data['info']['number']}}号</dd>
            </dl>
            <dl>
                <dt><i class="ico ico2"></i></dt>
                <dd class="tit">{{data['farm']['name']}}</dd>
                <dd>{{data['farm']['address']}}<br>{{data['farm']['tel']}}</dd>
            </dl>
            <dl>
                <dt><i class="ico ico3"></i></dt>
                <dd class="tit green">{{data['zhou']}}天</dd>
                <dd>{{data['info']['zzdates']}}种植 ~ {{data['info']['csdates']}}采收</dd>
            </dl>
        </section>
    </section>
    {% if 'pic' in data and data['pic'] %}
    <section class="m-wrapper">
        <div >
            <section class="img-wrap">
                <img src="{{pic['value']}}" width="100%" />
                <p style="display:none;">{{pic['cdates']}}</p>
            </section>
        </div>
    </section>
    {% end %}
    <section class="m-wrapper" id="dever-list">
        <div >
            {% for v in data['list'] %}
            <section class="img-wrap">
                <img src="{{v['pic']}}" width="100%" />
                <p style="display:none;">{{v['cdates']}}</p>
            </section>
            {% end %}
        </div>

        {% if data['page']['total'] > 1 %}
        {%set current = int(data['page']['current']) %}
        {% if current > 1 %}
        {%set prev = current-1 %}
        {% else %}
        {%set prev = 1 %}
        {% end %}

        {% if current > data['page']['total'] %}
        {%set next = data['page']['total'] %}
        {% else %}
        {%set next = current+1 %}
        {% end %}
        {%set url = '/origin?id=' + data['info']['id'] %}
        {% if '?' in url %}
        {%set cUrl = url +'&page=' %}
        {% else %}
        {%set cUrl = url +'?page=' %}
        {% end %}

        <section class="loading-more paging" {% if next != data['page']['total']%}link="{{cUrl}}{{next}}"{% end %} dever-list="#dever-list"><i></i>加载中...</section>
        <script>
        //瀑布流分页
        var _Dever_Page = 
        {
            name : '.paging',
            Init : function()
            {
                if ($(this.name).length) {
                    var self = this;
                    $(window).scroll(function() {  
                        if ($(window).scrollTop() >= $(document).height() - $(window).height()) {
                            self.Start(self.name);
                        }
                    });
                }
            }

            ,Start : function(page)
            {
                page = page ? page : this.name;
                if ($(page).length) {
                    $(page).hide();
                    var url = $(page + ':last').attr('link');
                    if (url) {
                        $(".loading-more").show();
                        var key = $(page).attr('dever-list');
                        $.get(url, function(t) {
                            t = '<div>' + t + '</div>';
                            var c = $(t).find(key).html();
                            if (c) {
                                $(key).append(c);
                                $(".loading-more").hide();
                                var l = $(t).find(page).attr('link');
                                $(page).attr('link', l);
                            }
                        });
                    }
                }
            }
            
            ,Ajax : function(e)
            {
                var self = this;
                e.find('a').each(function() {
                    var url = $(this).attr('href');
                    
                    $(this).attr('href', 'javascript:;');
                    
                    $(this).unbind('click').bind('click', function() {
                        $.get(url.replace('callback', ''), function(t) {
                            e.html(t);
                            self.Ajax(e);
                        });
                    });
                });
            }
        }
        $(function()
        {
            _Dever_Page.Init();
        });
        </script>
        {% end %}
    </section>

</body>
</html>
