视图:

<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. hbase->Mapreduce->hbase

    Hbase对Mapreduce API进行了扩展,方便Mapreduce任务读写HTable数据. package taglib.customer; import java.io.IOExceptio ...

  2. ubuntu14.04装完系统更新后桌面挂了

    一开始是只显示个鼠标什么都没有,ctrl-alt-1切到控制台下,把lightdm重启下再进去,多了两个桌面图标,但是顶栏和侧栏都没有,也就是根本没法运行其它程序. 但是幸好桌面右键菜单里有一个“在控 ...

  3. JavaEE资源

    JavaEE资源   http://bbs.itheima.com/forum.php?mod=forumdisplay&fid=183

  4. vue.js基础学习(1)

    一:v-cloak:解决浏览器闪烁,编译过程中不会显示,直到编译结束才显示. 用法:[v-cloak] { display: none;} <div v-cloak> {{ message ...

  5. AutoCAD 2014 在Server 2008 中 十字光标很慢

    另外,请在你们的Windows Server上增加如下注册表: On      both Windows Server 2008 R2 and Windows Server 2012 create E ...

  6. 《Linux内核设计与实现》读书笔记(二)- 内核开发的准备

    在尝试内核开发之前,需要对内核有个整体的了解. 主要内容: 获取内核源码 内核源码的结构 编译内核的方法 内核开发的特点 1. 获取内核源码 内核是开源的,所有获取源码特别方便,参照以下的网址,可以通 ...

  7. (JAVA)String类型的逻辑语句编译

    项目中遇到了动态配置条件触发相应事件的需求,需要根据String类型的逻辑语句,以及动态获取的数据,计算数据对应的结果,java实现.解决思路及代码实现如下,有需要的同学请自取. 一.需求提取 根据需 ...

  8. cf831D(dp)

    题目链接: http://codeforces.com/contest/831/problem/D 题意: 有 n 个人和 k 把钥匙, 数组 a 为 n 个人的初始位置, 数组 b 为 k 把钥匙的 ...

  9. Spring MVC 参数的绑定方法

    在Spring MVC中,常见的应用场景就是给请求的Url绑定参数.本篇就介绍两种最最基本的绑定参数的方式: 基于@RequestParam 这种方法一般用于在URL后使用?添加参数,比如: @Req ...

  10. xml 的使用和解析 及解析工具

    xml 一.xml简介 1. 什么是xml XML:Extensiable Markup Language,可扩展标记语言.和HTML有语法相似之处,也有作用上的不同: 和html相似: 都是由一堆标 ...