时间:2021-07-01 10:21:17 帮助过:33人阅读
注意:添加灰色背景处,关于ajax传值,和js的判断
1 登陆后控制器处理:判断是否登陆并传递用户信息
class IndexController extends HomeBaseController { //登录 public function index() { $id=I("get.id"); $users_model=M("Users"); $user=$users_model->where(array("id"=>$id))->find(); if(empty($user)){ $this->error("查无此人!"); } $this->assign($user); $this->display(":index"); } function is_login(){ if(sp_is_user_login()){ $this->ajaxReturn(array("status"=>1,"user"=>sp_get_current_user())); }else{ $this->ajaxReturn(array("status"=>0,"info"=>"此用户未登录!")); } }
。。。。。。
2 登陆前后主页导航栏的 登陆和未登录 的显示
<div id="main-menu-user"> <div class='userout user' > <ul class="nav navbar-nav navbar-right"> <li> <a href="{:u('user/register/index')}" data-toggle="dropdown">注册a> li> ul> <ul class="nav navbar-nav navbar-right"> <li> <a href="{:u('user/login/index')}" data-toggle="dropdown">登陆a> li> ul> <ul class="nav navbar-nav navbar-right" style="margin-top:10px"> <li > <img src="__TMPL__/Public/img/headicon.png" class="headicon"/> li> ul> div> <div class="userlogin user" > <ul class="nav navbar-nav navbar-right"> <li> <a href="{:u('user/index/logout')}" data-toggle="dropdown">退出a> li> ul> <ul class="nav navbar-nav navbar-right"> <li> <a href="{:u('user/center/index')}" data-toggle="dropdown" class="user-nicename">a> li> ul> <ul class="nav navbar-nav navbar-right" style="margin-top:10px"> <li > <img src="" class="headicon"/> li> ul> div>div>
3 登陆后,js对box的操作