微擎框架下拉分页(使用js模板引擎)
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模板引擎)的更多相关文章
- laravel 框架 下拉分页
<!doctype html><html lang="en"><head> <meta charset="UTF-8" ...
- think php 框架下拉分页
//以对象的形式获取数据库$data变量的信息,将lastPage()传输至页面 $lastpage = $data->lastPage(); $this->assign('lastpag ...
- 使用新一代js模板引擎NornJ提升React.js开发体验
当前的前端世界中有很多著名的开源javascript模板引擎如Handlebars.Nunjucks.EJS等等,相信很多人对它们都并不陌生. js模板引擎的现状 通常来讲,这些js模板引擎项目都有一 ...
- tab切换中的滚动条下拉分页带来的问题
相信做过tab切换中滚动条下拉分页的童鞋都知道,我们在用scroll方法来做滚动条下拉分页的时候,都是有bug,切换中间的内容会互相影响,为了解决这个问题,我总结了2种方法: 1.方法一: <! ...
- 小书MybatisPlus第4篇-表格分页与下拉分页查询
本文为mybatis系列文档的第4篇,前三篇请访问下面的网址. 小书MybatisPlus第1篇-整合SpringBoot快速开始增删改查 小书MybatisPlus第2篇-条件构造器的应用及总结 小 ...
- PhoneGap或者Cordova框架下实现Html5中JS调用Android原生代码
PhoneGap或者Cordova框架下实现Html5中JS调用Android原生代码 看看新闻网>看引擎>开源产品 0人收藏此文章, 发表于8小时前(2013-09-06 00:39) ...
- 非常实用的select下拉框-Select2.js
在Web开发中,Select下拉框是常用的输入组件.由于原生的Select几乎很难通过CSS样式控制.一些好看的Select下拉框就只能通过模拟来实现.PHP程序员雷雪松给大家推荐一筐款不错的Sele ...
- 学习在requirejs下如何使用underscore.js模板
近期在学习underscore.js 这个小而美的js库,是前端 MVC 框架backbone依赖库,他的模板方法主要应用场景是ajax交互过程到页面需要大量的字符串拼接,这部分如果一旦不够仔细就很容 ...
- Epii.js 一个极其简单的Js模板引擎
Epii.js 简约而不简单的Js模板引擎 Epii.js 简约而不简单的JavaScript模板引擎 # 特性 一个轻量级模板引擎,可快速实现数据与ui绑定(数据变动,UI自动变动),快速实现事件绑 ...
随机推荐
- Github上 vue-element-admin项目配置
Github对应地址 https://github.com/PanJiaChen/vue-element-admin 其中git为最新版本才支持github 的 clone代码 步骤如下 # clo ...
- Python: json模块实例详解
ref:https://www.jianshu.com/p/e29611244810 https://www.cnblogs.com/qq78292959/p/3467937.html https:/ ...
- JVM总结-虚拟机加载类
从 class 文件到内存中的类,按先后顺序需要经过加载.链接以及初始化三大步骤.其中,链接过程中同样需要验证:而内存中的类没有经过初始化,同样不能使用.那么,是否所有的 Java 类都需要经过这几步 ...
- FileInputStream与FileOutputStream 复制文件例子代码
try { File sourceFile = new File("C:\\Users\\prize\\Desktop\\Demo1\\盗墓笔记7.txt");//创建源文件 In ...
- Maven传递依赖的范围
calsspath:仅加载本工程中的配置文件 classpath*:既要加载本工程中配置文件,也要加载jar包中的配置文件
- C# 反射常见用法
定义: 反射是.NET中的重要机制,通过反射,可以在运行时获得程序或程序集中每一个类型(包括类.结构.委托.接口和枚举等)的成员和成员的信息.有了反射,即可对每一个类型了如指掌.另外我还可以直接创建对 ...
- 运行官方mysql 镜像
sudo docker run -it -d --restart unless-stopped -p 13306:3306 -h mysql --name mysql -e MYSQL_ROOT_PA ...
- springMVC源码学习地址
springmvc工作原理以及源码分析(基于spring3.1.0) 感谢作者 宏愿, 在此记录下,以便学习 SpringMVC源码分析(1):分析DispatcherServlet.doDispa ...
- react-native获取设备信息app版本信息,react-native-device-info
安装 yarn add react-native-device-info react-native link react-native-device-info link 之后就可以直接使用了,ios ...
- HTML一般标签
<title>无标题文档</title> </head> <body bgcolor="#33CC33" background=" ...