thinkphp搜索实现
视图:
<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搜索实现的更多相关文章
- ThinkPHP搜索框需要注意的事项
1.当搜索成功后需要用到分页的时候,form表单需要用get传参 2.编码方式 当编码方式不正确的时候,使用分页类改变分页,会使搜索框里面的内容乱码 改变编码方式的方法 第一种:header(&quo ...
- thinkphp搜索排序
- ThinkPHP的异步搜索
因为公司的后台框架采用了Ajax异步处理,控制器的方法,有时候会被多个连接所重复调用,虽然这个很符合OOP开发思想,但是为了维护这个框架,付出的汗水也是很大的. 说下正题了: 我在后台的搜索框调用了优 ...
- ThinkPHP之中getlist方法实现数据搜索功能
自己在ThinkPHP之中的model之中书写getlist方法,其实所谓的搜索功能无非就是数据库查询之中用到的like %string%,或者其他的 字段名=特定值,这些sql语句拼接在and语句 ...
- Thinkphp+Ajax带关键词搜索列表无刷新分页实例
Thinkphp+Ajax带关键词搜索列表无刷新分页实例,两个查询条件,分页和搜索关键字,懂的朋友还可以添加其他分页参数. 搜索#keyword和加载内容区域#ajax_lists <input ...
- Thinkphp 3.2 中词分词 加权搜索
原文地址:http://www.cnblogs.com/kekukele/p/4544349.html 前段时间,利用业余时间做了一个磁力搜索的网站Btdog,其中使用到了简单的中文分词与加权搜索,在 ...
- ThinkPHP - CURD增删改查 - 实例 - 搜索功能
模板代码: /** * 搜索数据 * @return 无返回值 */ public function search(){ //判断并接收参数 //姓名 if ( isset($_POST['usern ...
- thinkphp做搜索功能
一般后台都需要做一些搜索功能,直接上图. 至于前端页面大家自己设计.
- thinkphp 使用paginate分页搜索带参数
最近做项目发现使用paginate分页,搜索的时候点下一页搜索条件就变没了,所以在网上找了找一些方法,有的说是使用Page类,但是用习惯了paginate,再用Page不习惯,找到了一个方法,可以使用 ...
随机推荐
- SSM框架集成Redis
SSM-Spring+SpringMVC+Mybatis框架相信大家都很熟悉了,但是有的时候需要频繁访问数据库中不变或者不经常改变的数据,就会加重数据库的负担,这时我们就会想起Redis Redis是 ...
- HDU 3915 Game (高斯消元)
题意:有n堆石子,每个人只能从某一堆至少拿走一个,不能拿者败.问事先拿走某些堆的石子,使得先手必败. 析:将石子拆成二进制,未知数为1表示保留该堆石子,为0表示事先拿走该堆石子.最后求自由变元的数目, ...
- 【Qt文档阅读】Window and Dialog Widgets
Window and Dialog Widgets 没有嵌入到父控件中的控件(widget)称之为窗口(window).通常窗口带有边框和标题栏. Windows通常集成到桌面环境中,并且在某种程度上 ...
- 浅谈js模块加载方式(初级)
1.简介: 前端模块化开发日渐鼎盛,如何将零散的插件或者是普通的js脚本文件统一管理及引用,是众多开发者共同的目标.本人是从事.net开发的,最近对前端的一些东西特别的感兴趣,也会尝试的夹杂一点自己 ...
- 2010辽宁省赛E(Bellman_Ford最短路,状态压缩DP【三进制】)
#include<bits/stdc++.h>using namespace std;const int inf=0x3f3f3f3f;struct node{ int v,z,d, ...
- SpringMVC 思想介绍
MVC 思想简介 博客园好像不支持发布markdown的时序图, 如果你会markdown并且不太熟悉Springmvc执行流程, 照着图在Markdown上面敲一遍执行流程,这是我经历过的最快的记忆 ...
- Linux表面工作
https://www.cnblogs.com/welhzh/p/5899875.html 1.显示文本文件的内容 /etc/issue #登录前提示 /etc/motd #登录后提示 ssh ...
- JMETER断言:终极指南
你想要: 检查服务器响应是否包含特定字符串, 或验证服务器返回了HTTP 200 OK, 或者检查json字段的值(使用类似JsonPath$.store..price). 断言是要走的路. 问题是: ...
- java 集合解析
Set集合,放的元素不能重复,请问它的判断重不重复是怎么实现的? 比如说:ArrayList 和 Vector 是用数组的方式存储的Set里的 hashSet 和TreeSet是用什么方式存储的?怎么 ...
- POJ1048 Follow My Logic
题目来源:http://poj.org/problem?id=1048 题目大意: 给定一个逻辑电路,求其逻辑输出.电路含一个或多个输入,以及一些双输入的与门/或门组成.电路图以下面形式的ASCII码 ...