作者 景龙
1 个管道 的构建 通过 耗费 1 秒

增加退出登录功能

... ... @@ -11,8 +11,8 @@
return [
// 应用调试模式
'app_debug' => true,
'app_debug' => false,
// 应用Trace
'app_trace' => true,
'app_trace' => false,
];
\ No newline at end of file
... ...
... ... @@ -112,7 +112,16 @@ class LoginController extends HomeBaseController
//首页个人中心
public function info(){
return $this->fetch();
$login = cmf_is_user_login();
if($login) {
return $this->fetch();
}
}
//退出登录
public function logout(){
cmf_update_current_user(NULL);
$this->apiResponse(1,'退出成功!');
}
//首页个人中心修改头像
... ... @@ -157,7 +166,10 @@ class LoginController extends HomeBaseController
//个人中心编辑页面
public function editInfo(){
return $this->fetch();
$login = cmf_is_user_login();
if($login) {
return $this->fetch();
}
}
//个人中心编辑提交
... ... @@ -186,23 +198,25 @@ class LoginController extends HomeBaseController
//我的收藏列表
public function myCollection(){
$limit = $this->limit;
$uid = cmf_get_current_user_id();
$login = cmf_is_user_login();
if($login) {
$limit = $this->limit;
$uid = cmf_get_current_user_id();
// $collectionModel = new CollectionModel();
// $res = $collectionModel
// ->where(['uid'=>$uid])
// ->field('id,post_id,category_name,city_name,post_url')
// ->order('id desc')
// ->paginate($limit);
$res = Db::name('collection')
->alias('c')
->join('portal_post p','c.post_id = p.id')
->where(['c.uid'=>$uid,'p.delete_time'=>0])
->field('c.id,c.category_name,c.city_name,c.post_url,p.post_title,p.post_excerpt,p.post_favorites')
->order('c.id desc')
->paginate($limit);
$data = $res->toArray();
$page = $res->render();
$res = Db::name('collection')
->alias('c')
->join('portal_post p','c.post_id = p.id')
->where(['c.uid'=>$uid,'p.delete_time'=>0])
->field('c.id,c.category_name,c.city_name,c.post_url,p.post_title,p.post_excerpt,p.post_favorites')
->order('c.id desc')
->paginate($limit);
$data = $res->toArray();
$page = $res->render();
// $post_ids = array_unique(array_column($data['data'],'post_id'));
// $data1 = Db::name('portal_post')
// ->whereIn('id',$post_ids)
... ... @@ -223,9 +237,10 @@ class LoginController extends HomeBaseController
// }
// }
// }
$this->assign('res',$data['data']);
$this->assign('page',$page);
return $this->fetch();
$this->assign('res',$data['data']);
$this->assign('page',$page);
return $this->fetch();
}
}
//搜索列表
... ...
... ... @@ -50,6 +50,13 @@
</div>
<span>我的收藏</span>
</div>
<!--退出登录-->
<div class="Collection clearfix" id="logout">
<div class="Collection_icon">
<img style="width:21px;height:21px;" src="__TMPL__/public/assets/images/logout.png" alt="">
</div>
<span>退出登录</span>
</div>
</div>
<div class="Keep">
... ...
... ... @@ -10,7 +10,7 @@
}
.personal_center {
width: 487px;
height: 330px;
height: 390px;
background: rgba(255, 255, 255, 1);
box-shadow: 0px 32px 36px 2px rgba(0, 0, 0, 0.04);
border-radius: 20px;
... ...
... ... @@ -170,6 +170,25 @@ $(function() {
}
});
});
//退出登录
$('#logout').click(function() {
$.ajax({
type: 'POST',
url: "/portal/login/logout",
data: {
},
dataType: 'json',
success: function(data) {
console.log(data);
if (data.code == 1) {
mask(data.msg);
window.location.href = '/';
} else {
mask(data.msg);
}
}
});
});
//关于我们
$('#about_us,#about_us1').click(function() {
window.location.href = '/portal/index/aboutUs';
... ...
... ... @@ -56,6 +56,14 @@
我的收藏
</div>
</div>
<div class="index_ninth_one" id="logout">
<div class="index_ninth_one_img">
<img src="__TMPL__/public/assets/images/logout.png" alt="" />
</div>
<div class="index_ninth_one_title">
退出登录
</div>
</div>
</div>
<div class="index_ninth_photo">
<notempty name="user.avatar">
... ...
... ... @@ -206,6 +206,26 @@ $(function() {
}
});
});
//退出登录
$('#logout').click(function() {
$.ajax({
type: 'POST',
url: "/portal/login/logout",
data: {
},
dataType: 'json',
success: function(data) {
console.log(data);
if (data.code == 1) {
mask(data.msg);
window.location.href = '/';
} else {
mask(data.msg);
}
}
});
});
//关于我们
$('#about_us,#about_us1').click(function() {
window.location.href = '/portal/index/aboutUs';
... ...