1.需要分页的页面,引入一下文件

<script language="javascript" src="\addons\{$_GPC['m']}\template\mobile\js/require.js"></script><!--分页相关-->
<script language="javascript" src="\addons\{$_GPC['m']}\template\mobile\js/config.js"></script><!--分页相关-->
<style type="text/css">
.credit_list {height:40px; width:94%; background:#fff; padding:10px 3%;margin-top:5px;}
.credit_list .info {height:40px; width:70%; float:left; font-size:16px; color:#666; line-height:20px; text-align:left;}
.credit_list .info span {font-size:14px; color:#999;}
.credit_list .num {height:40px; border-left:1px solid #eaeaea; width:20%;line-height:40px; float:right; text-align:right; font-size:16px; color:#666;}
.credit_list .num span {font-size:14px; color:#999;}
.credit_tab {height:30px; margin:5px; border:1px solid #ff6801; border-radius:5px; overflow:hidden;font-size:13px;background:#fff;padding-right: -2px;}
.credit_nav {height:30px; width:50%; background:#fff; color:#666; text-align:center; line-height:30px; float:left;}
.credit_navon {color:#fff; background:#ff6801;}
.credit_no {height:100px; width:100%; margin:50px 0px 60px; color:#ccc; font-size:12px; text-align:center;}
#credit_loading { padding:10px;color:#666;text-align: center;}
</style>

====================================

发起请求

<script language="javascript">

require(['core','tpl'],function(core,tpl){//分页相关请求
core.init({
siteUrl: "{$_W['siteroot']}",
baseUrl: "{$_SERVER['REQUEST_URI']}"
});

})
</script>

========================================

循环,注意最外面div的id

<div class="weui-form-preview" id="container">
<script id='tpl_log' type='text/html'>
<%each list as log v%>

<div class="weui-form-preview__hd">
<div class="weui-form-preview__item">
<label class="weui-form-preview__label">预约活动</label>
<em class="weui-form-preview__value"><%log.yybt%></em>
</div>
</div>
<div class="weui-form-preview__bd">

<%each log.ziduan as zklog zv%>
<div class="weui-form-preview__item">
<label class="weui-form-preview__label"><%zklog.title%></label>
<span class="weui-form-preview__value"><%log[zv].data%></span>
</div>

<%/each%>
</div>
</div><br>

<%/each%>
</script>

========================

js代码,红色为页面模板名称

<script id='tpl_empty' type='text/html'>
<div class="credit_no"><i class="fa fa-file-text-o" style="font-size:100px;"></i><br><span style="line-height:18px; font-size:16px;">暂无信息</span></div>
</script>
<script language="javascript">
var page = 1;
var scrolled = false;
var current_type = "{php echo intval($_GPC['type'])}";
require(['tpl', 'core'], function (tpl, core) {

function bindScroller(){
var loaded = false;
var stop = true;

$(window).scroll(function () {
if (loaded) {
return;
}
totalheight = parseFloat($(window).height()) + parseFloat($(window).scrollTop());
if ($(document).height() <= totalheight) {

if (stop == true) {
stop = false; scrolled = true;
$('#container').append('<div id="credit_loading" class="credit_loading_zzjz"><i class="fa fa-spinner fa-spin"></i> 正在加载...</div>');
setTimeout(function(){
$(".credit_loading_zzjz").remove()
},2000);

page++;
core.json('wdyy', {type:current_type,page: page}, function (json) {
stop = true;
var morejson = json;
$('#credit_loading').remove();
$("#container").append(tpl('tpl_log',morejson.result));
if (morejson.result.list.length < morejson.result.pagesize) {
$("#container").append('<div id="credit_loading">已经加载完全部记录</div>');
loaded = true;
$(window).scroll = null;
return;
}
}, true);
}
}
});
}
function getLog(type) {
$('.weui-navbar__item').removeClass('weui-bar__item_on');
$('.weui-navbar__item[data-type=' + type + ']').addClass('weui-bar__item_on');
core.json('wdyy', {type:type,page: page}, function (json) {
if (json.result.list.length <= 0) {
$('#container').html(tpl('tpl_empty'));
return;
}
$('#container').html(tpl('tpl_log', json.result));
bindScroller();
}, true);
}
$('.weui-navbar__item').unbind('click').click(function () {
page = 1; current_type = $(this).data('type')
getLog(current_type);

});
getLog(current_type);
})
</script>

2.php页面

public function show_json($status = 1, $return = null)
{//分页的函数
$ret = array(
'status' => $status
);
if ($return) {
$ret['result'] = $return;
}
die(json_encode($ret));
}

=================================================

页码定义

$page=(int)($_GET['page']);
if(empty($page)||!isset($page)){
$page=1;
}
$pagesize=10;

返回方式

if ($_W['isajax']) {

$this->show_json(1, array(
'pagesize'=>$pagesize,
'list' => $xmlist
));
}

===============

3.其他文件云盘下载链接: http://pan.baidu.com/s/1gf5VgqB 密码: dhus(有多余的文件么有删除掉)

4.core cofig  那几个js文件里面有一些路径要改一下的

《完》

微擎框架下拉分页(使用js模板引擎)的更多相关文章

  1. laravel 框架 下拉分页

    <!doctype html><html lang="en"><head> <meta charset="UTF-8" ...

  2. think php 框架下拉分页

    //以对象的形式获取数据库$data变量的信息,将lastPage()传输至页面 $lastpage = $data->lastPage(); $this->assign('lastpag ...

  3. 使用新一代js模板引擎NornJ提升React.js开发体验

    当前的前端世界中有很多著名的开源javascript模板引擎如Handlebars.Nunjucks.EJS等等,相信很多人对它们都并不陌生. js模板引擎的现状 通常来讲,这些js模板引擎项目都有一 ...

  4. tab切换中的滚动条下拉分页带来的问题

    相信做过tab切换中滚动条下拉分页的童鞋都知道,我们在用scroll方法来做滚动条下拉分页的时候,都是有bug,切换中间的内容会互相影响,为了解决这个问题,我总结了2种方法: 1.方法一: <! ...

  5. 小书MybatisPlus第4篇-表格分页与下拉分页查询

    本文为mybatis系列文档的第4篇,前三篇请访问下面的网址. 小书MybatisPlus第1篇-整合SpringBoot快速开始增删改查 小书MybatisPlus第2篇-条件构造器的应用及总结 小 ...

  6. PhoneGap或者Cordova框架下实现Html5中JS调用Android原生代码

    PhoneGap或者Cordova框架下实现Html5中JS调用Android原生代码 看看新闻网>看引擎>开源产品 0人收藏此文章, 发表于8小时前(2013-09-06 00:39) ...

  7. 非常实用的select下拉框-Select2.js

    在Web开发中,Select下拉框是常用的输入组件.由于原生的Select几乎很难通过CSS样式控制.一些好看的Select下拉框就只能通过模拟来实现.PHP程序员雷雪松给大家推荐一筐款不错的Sele ...

  8. 学习在requirejs下如何使用underscore.js模板

    近期在学习underscore.js 这个小而美的js库,是前端 MVC 框架backbone依赖库,他的模板方法主要应用场景是ajax交互过程到页面需要大量的字符串拼接,这部分如果一旦不够仔细就很容 ...

  9. Epii.js 一个极其简单的Js模板引擎

    Epii.js 简约而不简单的Js模板引擎 Epii.js 简约而不简单的JavaScript模板引擎 # 特性 一个轻量级模板引擎,可快速实现数据与ui绑定(数据变动,UI自动变动),快速实现事件绑 ...

随机推荐

  1. WPF c# 定时器

    //定时查询-定时器 DispatcherTimer dispatcherTimer = new DispatcherTimer(); dispatcherTimer.Tick += (s, e) = ...

  2. 通俗理解caller和callee

    caller 返回一个调用当前函数的引用: callee 返回一个正在被执行函数的引用: 举个例子: 当前有函数 a() 直接使用了caller 方法: b() 直接使用了callee方法: ca() ...

  3. Ruby学习笔记7: 添加身份验证(adding Authentication)

    我们已经完成了Category & Product页面内容的增删改查,再加入一个身份验证即可成为一个较完整的Rails App了.本文就来完成这个任务. We now need to give ...

  4. (1)Linux操作系统的安装

    1.安装Vmware Workstation 如何判断Vmware是否安装成功? 我的电脑控制面板 --> 网络和Internet --> 查看网络状态和任务 --> 更改适配器设置 ...

  5. elk收集windows日志

    参考网站:https://www.secpulse.com/archives/55636.html https://blog.csdn.net/qq_38094271/article/details/ ...

  6. FLEX中一组基于button的组件

    <?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="ht ...

  7. 远程桌面连接MySQL遇到的问题及解决方法总结

    背景提要:想用Delphi做一个可以连接Mysql数据库的桌面应用程序.其中遇到了一些让自己很苦恼的问题.因为自己是新手,Delphi用的不熟,FireDAC这个连接数据库里控件更是没有接触过,对安装 ...

  8. spring 的 切片Aspect 最常用记录方法执行时间

    /** * */ package com.icil.esolution.aspect; import java.util.Date; import org.aspectj.lang.Proceedin ...

  9. react-native获取设备信息app版本信息,react-native-device-info

    安装 yarn add react-native-device-info react-native link react-native-device-info link 之后就可以直接使用了,ios ...

  10. E2040 Declaration terminated incorrectly - System.ZLib.hpp(310) ZLIB_VERSION

    [bcc32 Error] System.ZLib.hpp(310): E2040 Declaration terminated incorrectly  Full parser context    ...