rabin 7 years ago
parent
commit
a3e39577f5
2 changed files with 95 additions and 9 deletions
  1. 1 1
      web/page/origin.py
  2. 94 8
      web/templates/mobile/origin/index.html

+ 1 - 1
web/page/origin.py

@@ -50,7 +50,7 @@ class index_path(Load):
 	def get(self):
 		Origin.init(self)
 
-		self.data['list'] = self.service('common').list('farm_work_land_pic', search={'farm_id':self.data['info']['farm_id'], 'land_id':self.data['info']['land_id']})
+		self.data['list'] = self.service('common').list('farm_work_land_pic', search={'farm_id':self.data['info']['farm_id'], 'land_id':self.data['info']['land_id']}, page={'num':1})
 		if self.data['list']:
 			for key, value in enumerate(self.data['list']):
 				self.data['list'][key]['cdates'] = Demeter.date(value['cdate'], '%Y-%m-%d')

+ 94 - 8
web/templates/mobile/origin/index.html

@@ -3,6 +3,7 @@
 <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">
@@ -28,16 +29,101 @@
             </dl>
         </section>
     </section>
-    <section class="m-wrapper">
-        {% for v in data['list'] %}
-        <section class="img-wrap">
-            <img src="{{v['pic']}}" width="100%" />
-            <p>{{v['cdates']}}</p>
-        </section>
+    <section class="m-wrapper" id="dever-list">
+        <div >
+            {% for v in data['list'] %}
+            <section class="img-wrap">
+                <img src="{{v['pic']}}" width="100%" />
+                <p>{{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 class="loading-more"><i></i>加载中...</section>
     </section>
 
-{%include '../inc/script.html'%}
 </body>
 </html>