视图:

<html lang="zh-cn"><head> <meta charset="UTF-8">
<title>测试</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="yes" name="apple-touch-fullscreen">
<meta content="telephone=no,email=no" name="format-detection">
<link rel="stylesheet" href="{$Think.config.img_site}weixin/mui/css/mui.min.css" />
<style>
.top-container{height: 101px;background-color: #0E5B74;position: relative;padding-right: 15px;overflow: hidden;}
.top-container .avatar.index{padding: 0;height: 70px;width: 70px;}
.top-container .avatar{float: left;margin: 16px 15px;width: 60px;height: 60px;padding: 5px;background-color: #0799ff;border-radius: 50px;position: relative;}
.top-container .avatar.index img{height: 71px;width: 71px;border-radius: 40px;}
.top-container .avatar img{height: 60px;width: 60px;border-radius: 30px;}
.top-container .account-info{padding: 20px 70px 0 0;text-align: center;overflow: hidden;height: 76px;}
.top-container .account-info .name{color: #fff;}
.top-container .account-info .name{font-size: 20px;color: #fff;text-overflow: ellipsis;white-space: nowrap;}
.top-container .account-info .desc{color: #aaa;}
.top-container .account-info .desc{color: #607fa6;margin-top: 10px;font-size: 14px;line-height: 24px;height: 24px;width: 100%;overflow: hidden;white-space: nowrap;}
.button-follow-container{position: absolute;bottom: 10px;right: 15px;padding: 0;}
.top-container .account-info .desc{color: #aaa;}
.top-container .account-info .desc{color: #aaa;margin-top: 10px;font-size: 14px;line-height: 24px;height: 24px;width: 100%;overflow: hidden;white-space: nowrap;}
.button-follow-container{position: absolute;bottom: 10px;right: 15px;padding: 0;}
.button-follow-container img{height: 18px;width: 64px;}
.article-item{border-bottom: 1px #e9e9e9 solid;clear: both;overflow: hidden;}
.article-item a{color: #111;display: block;height: 73px;}
.item-cover{float: left;margin: 7px 10px 5px 10px;width: 80px;text-align: center;border: 0;overflow: hidden;height: 60px;background: #e0e0e0;}
.item-cover img{width: 80px;height: 60px;}
.item-summary{padding: 7px 10px 7px 5px;overflow: hidden;min-height: 48px;}
.item-title{min-height: 30px;max-height: 40px;line-height: 20px;overflow: hidden;word-wrap: break-word;word-break: break-all;}
.item-text{margin-top: 5px;font-size: 12px;color: #808080;text-overflow: ellipsis;white-space: nowrap;overflow: hidden;}
.item-text .item-text-right{float: right;padding-left: 20px;}
span.mui-icon{font-size: 14px;color: #007aff;margin-left: -15px;padding-right: 10px;}
.mui-off-canvas-right{color: #fff;}
.title{margin:25px 15px 10px;}
.weui-footer{color:#999999;font-size:14px;text-align: center;margin-bottom:60px;margin-top:10px;}
.weui-footer p{padding:0;margin:0;}
.weui-footer a {color: #586C94;}
.weui-footer__link {display: inline-block; vertical-align: top;margin: 0 .32em;position: relative;font-size: 14px;}
.weui-footer__text {padding: 0 .34em; font-size: 12px;}
/*底部*/
.foot{position:fixed;bottom: 0;left: 0;right: 0;background: rgba(0,135,251,0.9);height:50px;color: #fff;font-size: 13px;}
.foot .people{width: 43%;float: left;border-right:1px solid #37a1fc;height: 50px;}
.foot .people .people_tx{width: 40px;height: 40px;display: inline-block;border: 1px solid #fff;border-radius: 50%;margin-top: 4px;margin-left: 10px;float: left;}
.foot .people .people_tx img{width: 100%;border-radius: 50%;height: 100%;}
.foot .people .font{float: left;margin-left: 10px;margin-top: 10px;}
.foot .people .font small{font-size: 10px;}
.foot .phone{width:28%;float:left;border-right:1px solid #37a1fc;height: 50px;text-align: center;padding-top: 15px;line-height:18px;}
.foot .weizhan{width:28%;float: left;height: 50px;text-align:center;padding-top: 15px;line-height:18px;}
.foot .phone img,.foot .weizhan img{width: 20px;}
.foot a{color:#fff;}

</style>
</head>
<body>
<div id="offCanvasWrapper" class="mui-off-canvas-wrap mui-draggable mui-slide-in">
<aside id="offCanvasSide" class="mui-off-canvas-right">
<div id="offCanvasSideScroll" class="mui-scroll-wrapper">
<div class="mui-scroll">
<div class="title" id="offCanvasHide" >图文</div>
<ul class="mui-table-view mui-table-view-chevron mui-table-view-inverted">
<volist name="news" id="vo"><li class="mui-table-view-cell"><a class="mui-navigate-right">{$vo.name}</a></li></volist>
</ul>
<form action="http://m.baoxianbox.cn/index.php?c=Index&a=lis" method="post">
<div class="mui-input-row mui-search">
<input type="search" placeholder="输入关键字搜索内容" name="key" class="mui-input-clear"/>
</div>
</form>
</div>
</div>
</aside>
<div class="mui-inner-wrap">
<header class="mui-bar mui-bar-nav">
<a class="mui-action-back mui-icon mui-icon-back mui-pull-left"></a>
<span id="offCanvasShow" class="mui-icon mui-action-menu mui-icon-bars mui-pull-right"></span>
<h1 class="mui-title">文章</h1>
</header>
<div id="offCanvasContentScroll" class="mui-content mui-scroll-wrapper">
<div class="mui-scroll">
<div class="mui-content-padded">

<?php if(!$search){
$name="list";
}else{
$name="search";
}
?>
<volist name="$name" id="vo">

<div class="article-item">
<a href="/?a=weixin&uid={$_GET['uid']}&id={$vo.id}">
<div class="item-cover"><img src="{:tomedia($vo['thumb'])}"></div>
<div class="item-summary"><div class="item-title">{$vo.title}</div><div class="item-text">{:date("m-d H:i", $vo['createtime'])}<span class="item-text-right">{$vo.click}</span></div></div>
</a></div></volist>
</div>
</div>
</div>
</div>
</div>
<script src="{$Think.config.img_site}weixin/mui/js/mui.min.js"></script>
<script src="{$Think.config.img_site}weixin/js/jquery-1.7.2.min.js"></script>
<script>
mui.init({pullRefresh: {container: '#offCanvasContentScroll',up: {contentrefresh: '正在加载...',callback: pullupRefresh}}});
mui('body').on('tap','a',function(){document.location.href=this.href;});
//侧滑容器父节点
var offCanvasWrapper = mui('#offCanvasWrapper');
//主界面容器
var offCanvasInner = offCanvasWrapper[0].querySelector('.mui-inner-wrap');
//菜单容器
var offCanvasSide = document.getElementById("offCanvasSide");
//移动效果是否为整体移动
var moveTogether = false;
//侧滑容器的class列表,增加.mui-slide-in即可实现菜单移动、主界面不动的效果;
var classList = offCanvasWrapper[0].classList;
//变换侧滑动画移动效果;
document.getElementById('offCanvasShow').addEventListener('tap', function() {offCanvasWrapper.offCanvas('show');});
document.getElementById('offCanvasHide').addEventListener('tap', function() {offCanvasWrapper.offCanvas('close');});
//主界面和侧滑菜单界面均支持区域滚动;
mui('#offCanvasSideScroll').scroll();
mui('#offCanvasContentScroll').scroll();
//实现ios平台的侧滑关闭页面;
if (mui.os.plus && mui.os.ios) {
offCanvasWrapper[0].addEventListener('shown', function(e) { //菜单显示完成事件
plus.webview.currentWebview().setStyle({'popGesture': 'none'});
});
offCanvasWrapper[0].addEventListener('hidden', function(e) { //菜单关闭完成事件
plus.webview.currentWebview().setStyle({'popGesture': 'close'});
});
}
var count=2;
function pullupRefresh() {
setTimeout(function() {
mui('#offCanvasContentScroll').pullRefresh().endPullupToRefresh((++count >30)); //参数为true代表没有更多数据了。
var table = document.body.querySelector('.mui-content-padded');
var cells = document.body.querySelectorAll('.article-item');
mui.post("/api.php?c=home&a=newsfrom",{page:count},function(res){
if(res.err == 0){
var datas=res.data;var $li='';
for(var i = 0; i < datas.length; i++){
var data = datas[i];
var div = document.createElement('div');
div.className = 'article-item';
div.innerHTML = "<a href=\"/?a=weixin&uid={$_GET['uid']}&id=" + data.id + '"><div class="item-cover"><img src="' + data.thumb + '"></div><div class="item-summary"><div class="item-title">' + data.title + '</div><div class="item-text">' + data.createtime + '<span class="item-text-right">阅读:' + data.click + '</span></div></div></a>';
table.appendChild(div);}
}
else{mui.toast('列表内容获取失败!'); }},'json');

}, 1500);
}

mui(".sea2").addEventListener("tap",function(){
var table1 = document.body.querySelector('.mui-content-padded');
var sea = mui('.sea')[0].value;
mui.post("http://m.baoxianbox.cn/index.php?c=Index&a=lis",{p:sea},function(res){
if(res.err == 0){
$(".mui-content-padded").hide();
var datas=res.data;var $li='';
for(var i = 0; i < datas.length; i++){
var data = datas[i];
var div = document.createElement('div');
div.className = 'article-item';
div.innerHTML = "<a href=\"/?a=weixin&uid={$_GET['uid']}&id=" + data.id + '"><div class="item-cover"><img src="' + data.thumb + '"></div><div class="item-summary"><div class="item-title">' + data.title + '</div><div class="item-text">' + data.createtime + '<span class="item-text-right">阅读:' + data.click + '</span></div></div></a>';
table1.appendChild(div);}
}
else{mui.toast('列表内容获取失败!'); }},'json');
})

</script>
<div style="display:none;"><script src="https://s13.cnzz.com/z_stat.php?id=1262667763&web_id=1262667763" language="JavaScript"></script></div>
</body></html>

控制器:

public function lis()
{ $user = M('members')->find($_GET['uid']);
if(empty($_SESSION['topid'])){$_SESSION['topid']=$user['topid'];$_SESSION['firid']=$_GET['uid'];$_SESSION['secid']=$user['firid'];}
$list = M('article')->where("ischeck=1")->limit(10)->order('id desc')->select();
$news = M('category')->where("class='news'")->select();
$study = M('category')->where("class='study'")->select();
$this->assign('news', $news);
$this->assign('study', $study);
$this->assign('list',$list);
$this->assign('user',$user);

if($_POST['key']){
$key = $_POST['key'];
$map['title|content'] = array('like','%'.$key .'%');
$res1 = M('article')->where($map )->select();
$this->assign('search', $res1);
}

$this->display();
}

thinkphp搜索实现的更多相关文章

  1. ThinkPHP搜索框需要注意的事项

    1.当搜索成功后需要用到分页的时候,form表单需要用get传参 2.编码方式 当编码方式不正确的时候,使用分页类改变分页,会使搜索框里面的内容乱码 改变编码方式的方法 第一种:header(&quo ...

  2. thinkphp搜索排序

  3. ThinkPHP的异步搜索

    因为公司的后台框架采用了Ajax异步处理,控制器的方法,有时候会被多个连接所重复调用,虽然这个很符合OOP开发思想,但是为了维护这个框架,付出的汗水也是很大的. 说下正题了: 我在后台的搜索框调用了优 ...

  4. ThinkPHP之中getlist方法实现数据搜索功能

    自己在ThinkPHP之中的model之中书写getlist方法,其实所谓的搜索功能无非就是数据库查询之中用到的like  %string%,或者其他的 字段名=特定值,这些sql语句拼接在and语句 ...

  5. Thinkphp+Ajax带关键词搜索列表无刷新分页实例

    Thinkphp+Ajax带关键词搜索列表无刷新分页实例,两个查询条件,分页和搜索关键字,懂的朋友还可以添加其他分页参数. 搜索#keyword和加载内容区域#ajax_lists <input ...

  6. Thinkphp 3.2 中词分词 加权搜索

    原文地址:http://www.cnblogs.com/kekukele/p/4544349.html 前段时间,利用业余时间做了一个磁力搜索的网站Btdog,其中使用到了简单的中文分词与加权搜索,在 ...

  7. ThinkPHP - CURD增删改查 - 实例 - 搜索功能

    模板代码: /** * 搜索数据 * @return 无返回值 */ public function search(){ //判断并接收参数 //姓名 if ( isset($_POST['usern ...

  8. thinkphp做搜索功能

    一般后台都需要做一些搜索功能,直接上图. 至于前端页面大家自己设计.

  9. thinkphp 使用paginate分页搜索带参数

    最近做项目发现使用paginate分页,搜索的时候点下一页搜索条件就变没了,所以在网上找了找一些方法,有的说是使用Page类,但是用习惯了paginate,再用Page不习惯,找到了一个方法,可以使用 ...

随机推荐

  1. python 列表中 [[], [], []] 和 3*[[]]差异

    问: What's the difference between "[[], [], []]" and "3*[[]]" ? 答: [[], [], []] m ...

  2. 怀旧系列(1)----FBasic

    小时候,老爸斥巨资给我买了一台小霸王学习机.玩遍了所有游戏后,里面有个F-Basic语言,黑乎乎的,一点也不好玩.直到杰兄从学校带回一本BASIC语言,才知道这玩意儿还可以编辑**图案.由于没有人指导 ...

  3. RFC 2119中几个关键字的翻译

    RFC2119定义了规范文档中,英文要求的关键动词,但中文中还没有明确的词,我的建议如下: requirement类,表示没有例外地遵守或一定出现的情况, MUST.MUST NOT.必须,必须不 S ...

  4. Sharepoint2013商务智能学习笔记之使用Current User Filter筛选Excel 数据(六)

    Sharepoint自带的filter可以和Excel Web Access互动,下面将制作一个Demo,使用Current User Filter根据当前登录用户自动筛选Excel. 第一步,用Ex ...

  5. AOP常用注解

    1.@Aspect 配置切面Bean,和<bean.../>元素进行配置无区别,一样支持依赖注入来配置属性值: 如果启动了Spring的"零配置"特性,一样可以让Spr ...

  6. 反射实现增删改查(DAO层)——插入数据

    先贴出代码,后续补充自己的思路.配置文件.使用方式: /** * 插入数据 */ @Override public void addObject(Object object, String table ...

  7. elasticsearch 聚合查询

    1. 按照 tags 字段 进行分组 GET /ecommerce/product/_search{ "size": 0,  "aggs": {    &quo ...

  8. jQuery点击弹出层,弹出模态框,点击模态框消失

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 3 ...

  9. Mol Cell Proteomics. |赵赟| 全面地分析个人尿蛋白质组学的变化揭示出不同的性别变化

    大家好,本周分享的是发表在Molecular & Cellular Proteomics上的一篇关于人的尿蛋白质组学的文章,题目是Comprehensive analysis of indiv ...

  10. 与pocket 对接技术文档

    同步每日新增用户接口(kwai 提供) 注释:该接口 每天0点(北京时间)之后 向kwai服务器同步前一天  新增的IMEI号 url:http://m.kwai.com/rest/o/pocket/ ...