sxgq的项目
由于策划方案漏洞太多 时间太紧 上线之后大量的更改
今天就做了一个tab、切换改变div内容的效果
前台页面如下
<!DOCTYPE html>
<!--[if lt IE 7]>
<html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>
<html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>
<html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<title>{:get_opinion('title')}</title>
<link rel="stylesheet" href="//at.alicdn.com/t/font_1453258457_4916425.css">
<link rel="stylesheet" href="//at.alicdn.com/t/font_1453188046_8937805.css" />
<include file="Public:head"/>
{:hook('pageHeader', "")}
</head>
<body>
{:hook('userHeader', "")}
{:W('Widget/menuHead')}
<div class="globalBg clearfix">
<div class="centerWrapper ">
<div class="main">
<div class="crumb">
{$breadcrumbs}
</div>
<div class="main_content">
<div><img src="__GPUBLIC__/images/mainTop.jpg" alt="" /></div>
<!-- <div class="main_intro">
<div class="search">
<input type="text" placeholder="输入企业关键字进行搜索" id="input_search" value='{$keyword}'/>
<span><i class="iconfont icon-search" id="search" style="cursor:pointer;"></i></span>
</div>
</div> -->
<div class="main_intro clearfix">
<div class="filter clearfix">
<div class="filter_hd on">全部</div>
<ul class="filter_bd clearfix fl">
<li id="hj" class="on"><a href="#">会计事务所</a></li>
<li id="pg">评估公司</li>
<li id="pb">发行人</li>
<li id="ls">律师事务所</li>
<li id="tj">推荐会员</li>
<li id="jl">战略会员</li>
<li id="db">担保机构</li>
</ul>
</div>
<div class="searchInput fl search">
<input type="text" placeholder="输入会员编码或企业关键字进行搜索" id="input_search" value="{$keyword}">
</div>
<div class="searchBtn fl">
<span><i class="iconfont icon-search" id="search"></i></span>
</div>
</div>
<div class="main_list">
<ul>
<volist class="changeto" name="cat" id="v">
<li><a href="{$url}&id={$v.id}">{$v.corporate_name}<span class="main_list_time fr">{$v.identities_type}</span></a></li>
</volist>
</ul>
<!-- 加载下一页 -->
<div class="main_loadMore"><i class="iconfont icon-chakan01" id='nextpage'></i></div>
</div>
</div>
</div>
<div class="side">
<div><img src="__PUBLIC__/gqjyzx/images/sideBar_member.jpg" alt="" /></div>
<ul class="sideMenu">
<li><a class="on" href="{:U('Home/member_center/memberlist')}">会员列表</a></li>
</ul>
</div>
</div>
</div>
<include file="Public:bottom"/>
<include file="Public:foot"/>
{:hook('pageFooter', "")}
<script src="__GPUBLIC__/plugins/SuperSlide/jquery.SuperSlide.2.1.1.js"></script>
<script src="__GPUBLIC__/scripts/effect.js"></script>
</body>
<script>
//实现tab切换
$('#pg').click(function() {
var kwd='评估公司';
//jQuery.post( url, [data], [callback], [type] )
$.post('{:U("Home/member_center/memberlist")}',{k:kwd},function date(msg){
$('.main_list').html(msg);
});
});
$('#pb').click(function() {
var kwd='发行人';
$.post('{:U("Home/member_center/memberlist")}',{k:kwd},function date(msg){
$('.main_list').html(msg);
});
});
$('#ls').click(function() {
var kwd='律师事务所';
$.post('{:U("Home/member_center/memberlist")}',{k:kwd},function date(msg){
$('.main_list').html(msg);
});
});
$('#tj').click(function() {
var kwd='推荐会员';
//jQuery.post( url, [data], [callback], [type] )
$.post('{:U("Home/member_center/memberlist")}',{k:kwd},function date(msg){
$('.main_list').html(msg);
});
});
$('#jl').click(function() {
var kwd='战略会员';
//jQuery.post( url, [data], [callback], [type] )
$.post('{:U("Home/member_center/memberlist")}',{k:kwd},function date(msg){
$('.main_list').html(msg);
});
});
$('#db').click(function() {
var kwd='担保机构';
$.post('{:U("Home/member_center/memberlist")}',{k:kwd},function date(msg){
$('.main_list').html(msg);
});
});
$('#hj').click(function() {
var kwd='会计事务所';
$.post('{:U("Home/member_center/memberlist")}',{k:kwd},function date(msg){
$('.main_list').html(msg);
});
});
</script>
<script>
$(document).ready(function(){
var all = {$coolpage};
var nextp = {$nextpg};
//搜索获得的总数
var searchall = {$searchall};
$("#nextpage").click(function(){
//加载下一页
var kws=$('#input_search').val();
if(kws==''){
$.get('{:U("Home/member_center/nextpg")}',{p:nextp},function(data){
$('.main_list ul').append(data);
nextp += 1;
if(nextp == all){
alert("已经是最后一页");
$("#nextpage").unbind('click');
};
});
}else{
$.get('{:U("Home/member_center/nextpg")}' , {p:nextp,k:encodeURI(kws)},function(data){
$('.main_list ul').append(data);
nextp += 1;
if(nextp == searchall){
alert("已经是最后一页");
$("#nextpage").unbind('click');
};
});
}
});
//搜素功能
$("#search").click(function(){
var keywords=$('#input_search').val();
if(keywords==''){
alert('请输入关键字');
return false;
}else{
var url='{:U("Home/member_center/memberlist")}';
window.location.href=url+'&keywords='+keywords;
}
"Tab.html"
});
});
</script>
</html>
后台页面如下
<?php
/**
* 会员 专区 控制器模块
* File: MemberCenterController.class.php
* User: rpengWang
* Date: 16-1-21
*/
namespace Home\Controller;
use Common\Logic\MemberCenterLogic;
use Common\Util\File;
use Common\Util\GreenPage;
use Think\Hook;
use Think\Model;
class MemberCenterController extends HomeBaseController
{
/**
* 会员专区列表
*/
public function memberlist()
{
if(!I('post.k')){
//搜索功能
$keywords=I('get.keywords');
$where['corporate_name']=array('like',"%{$keywords}%");
$obj=new MemberCenterLogic();
//获得总数
$count=$obj->countAll();
$Page = new GreenPage($count, get_opinion('PAGER'));
$limit = $Page->firstRow . ',' . $Page->listRows;
//传入内容url
$url=U('Home/member_center/memberonelist');
$this->assign('url',$url);
//传入分类
$breadcrumbs = gget_breadcrumbs('cats',15);
$this->assign('breadcrumbs', $breadcrumbs);
$this->assign('nextpg',$Page->nowPage+1);
$this->assign('coolpage',$Page->totalPages);
$cat = $obj->getList($limit,$where);
//获得数组的长度
$searchall=count($cat);
$this->assign('searchall',$searchall);
$this->assign('keyword',$keywords);
$this->assign('cat',$cat);
$this->display('Archive/viplist');
}else{
$kwhere=I('post.k');
$obj1=new MemberCenterLogic();
$where=array('identities_type'=>$kwhere);
$list=$obj1->getList($limit,$where);
//拼接字符串
$a="<ul>";
foreach($list as $v){
$a.="<li>";
$a.="<a href=".U('Home/member_center/memberonelist').'&id='.$v['id'].">";
$a.="{$v['corporate_name']}";
$a.="<span class='main_list_time fr'>";
$a.="{$v['identities_type']}</span>";
$a.="</a>";
$a.="</li>";
}
$a.="<div class='main_loadMore'>";
$a.="<i class='iconfont icon-chakan01' id='nextpage'>";
$a.="</i>";
$a.="</div>";
$a.="</ul>";
echo $a;//返回msg
}
}
/**
* 加载下一页的内容
*/
public function nextpg(){
$keywords=I('get.k');
$keywords = urldecode($keywords);
$where['corporate_name']=array('like',"%{$keywords}%");
$obj=new MemberCenterLogic();
$count=$obj->countAll();
$Page = new GreenPage($count, get_opinion('PAGER'));
$limit = $Page->firstRow . ',' . $Page->listRows;
$cat = $obj->getList($limit,$where);
//传入内容url
$url=U('Home/member_center/memberonelist');
$this->assign('url',$url);
$this->assign('cat',$cat);
$this->display('Archive/nextpg');
}
/**
* 会员内容单页面显示
*/
public function memberonelist(){
$id=I('get.id');
$where=array('id'=>"{$id}");
$obj=new MemberCenterLogic();
$listone=$obj->getList(0,$where);
//传入分类
$breadcrumbs = gget_breadcrumbs('cats',14);
$this->assign('breadcrumbs', $breadcrumbs);
$this->assign('lone',$listone);
$this->display('Archive/vipdetail');
}
}
用的greencms的后台做的 基于tp3.2开发的 整体程序乱的一塌糊涂 自省中