首页 / LAYUI / layui流加载及传参
layui流加载及传参
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了layui流加载及传参,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3894字,纯文字阅读大概需要6分钟。
内容图文
<ul class="shop-list ml10 mr10 store_list" id=‘demo‘ style="margin-top:80px;"></ul>
<script type="text/javascript">
layui.use(‘flow‘, function(){
var $ = layui.jquery; //不用额外加载jQuery,flow模块本身是有依赖jQuery的,直接用即可。
var flow = layui.flow;
flow.load({
elem: ‘#demo‘ //指定列表容器
,end:‘没有数据啦o(╥﹏╥)o‘
,done: function(page,next){ //到达临界点(默认滚动触发),触发下一页
var lis = [];
var cate_id = "{$cate_id}";//传的关键字id
var order="{$order}";//传的排序方式
$.get(‘/taochucom/mobile/index.php?app=search&act=store&flow=1&page=‘+page+‘&cate_id=‘+cate_id+‘&order=‘+order, function(res){
res = JSON.parse(res);
//假设你的列表返回在data集合中
layui.each(res.data, function(index, item){
if(item.credit_value>0){
lis.push(‘<li class="mt10" style="background-color:#fff"><dl><dt><a href="mobile/store/‘+item.store_id+‘"><img src="‘+item.store_logo+‘" width="80" height="80" /></a></dt><dd><h3><a href="mobile/store/‘+item.store_id+‘">‘+item.store_name+‘</a></h3><p>‘+item.user_name+‘<span style="position: absolute;right: 10px;color:#fff" class="into">进店</span></p><p>‘+item.region_name+‘</p><p>上架‘+item.goods_count+‘件商品<i><img src="‘+item.credit_image+‘" /></i></p></dd></dl></li>‘);
}else{
lis.push(‘<li class="mt10" style="background-color:#fff"><dl><dt><a href="mobile/store/‘+item.store_id+‘"><img src="‘+item.store_logo+‘" width="80" height="80" /></a></dt><dd><h3><a href="mobile/store/‘+item.store_id+‘">‘+item.store_name+‘</a></h3><p>‘+item.user_name+‘<span style="position: absolute;right: 10px;color:#fff" class="into">进店</span></p><p>‘+item.region_name+‘</p><p>上架‘+item.goods_count+‘件商品<i></i></p></dd></dl></li>‘);
}
});
//console.log(res);//页面打印数据
//执行下一页渲染,第二参数为:满足“加载更多”的条件,即后面仍有分页
//pages为Ajax返回的总页数,只有当前页小于总页数的情况下,才会继续出现加载更多
next(lis.join(‘‘), page < res.pages);
});
}
});
});
</script>
<?php
/*************************流加载***********************/
if($_GET[‘flow‘] == 1){
$stores = $model_store->find(array(
‘conditions‘ => ‘state = ‘ . STORE_OPEN . $condition_id . $conditions,
‘limit‘ =>$page[‘limit‘],
‘order‘ => (empty($_GET[‘order‘]) || !in_array($_GET[‘order‘], $orders)) ? ‘sort_order‘ : $_GET[‘order‘],
‘join‘ => ‘belongs_to_user,has_scategory‘,
‘fields‘ => ‘store.store_id,user_name,store_name,region_name,store_logo,credit_value‘,
‘count‘ => true //允许统计
));
$model_goods = &m(‘goods‘);
foreach ($stores as $key => $store)
{
//店铺logo
empty($store[‘store_logo‘]) && $stores[$key][‘store_logo‘] = Conf::get(‘default_store_logo‘);
//商品数量
$stores[$key][‘goods_count‘] = $model_goods->get_count_of_store($store[‘store_id‘]);
//等级图片
$step = intval(Conf::get(‘upgrade_required‘));
$step < 1 && $step = 5;
$stores[$key][‘credit_image‘] = $this->_view->res_base . ‘/images/‘ . $model_store->compute_credit($store[‘credit_value‘], $step);
}
$result[‘data‘] = array_values($stores);
$page[‘item_count‘]=$model_store->getCount(); //获取统计数据
$this->_format_page($page);
$result[‘pages‘] = $page[‘page_count‘];//总页数
echo json_encode($result);die;
}
/*************************流加载***********************/
$order=(isset($_GET[‘order‘]))?($_GET[‘order‘]):"";
$this->assign(‘order‘,$order);
$this->assign("cate_id",$cate_id);
$this->assign(‘stores‘, $stores);
$this->assign(‘regions‘, $regions);
$this->assign(‘scategorys‘, $scategorys);
$this->assign(‘page_info‘, $page);
/* 配置seo信息 */
$this->_get_curlocal_title(‘search-store‘);
$this->_config_seo($this->_get_seo_info(‘store‘, $cate_id));
$this->display(‘search.store.html‘);
?>
原文:http://www.cnblogs.com/manwk/p/7601503.html
内容总结
以上是互联网集市为您收集整理的layui流加载及传参全部内容,希望文章能够帮你解决layui流加载及传参所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。