diff --git a/app/index/controller/Article.php b/app/index/controller/Article.php index 33c469f..8a60322 100644 --- a/app/index/controller/Article.php +++ b/app/index/controller/Article.php @@ -114,7 +114,7 @@ class Article extends BaseController ])->find($id); Cache::set('article_'.$id,$article,3600); } - $comments = $article->comments()->where('status',1)->select(); + $comments = $article->comments()->where('status',1)->paginate(10); $article->inc('pv')->update(); $pv = Db::name('article')->field('pv')->where('id',$id)->value('pv'); diff --git a/app/index/controller/User.php b/app/index/controller/User.php index 82e1756..ba7e971 100644 --- a/app/index/controller/User.php +++ b/app/index/controller/User.php @@ -7,7 +7,6 @@ use think\exception\ValidateException; use think\facade\Db; use think\facade\Request; use think\facade\Session; -use think\facade\Cookie; use think\facade\Cache; use think\facade\View; use app\common\model\Article; @@ -24,8 +23,7 @@ class User extends BaseController //用户中心 public function index() { - //$this->isLogin(); - $user['user_id'] = session::get('user_id'); + $user['user_id'] = Session::get('user_id'); $username = session::get('user_name'); return view(); @@ -74,12 +72,12 @@ class User extends BaseController { if(Request::isAjax()){ $data = Request::only(['user_id','email','nickname','sex','city','sign']); - $validate = new \app\common\validate\User(); + $validate = new \app\common\validate\User; $result = $validate->scene('Set')->check($data); if(!$result){ $this->error($validate->getError()); } else { - $user = new \app\common\model\User(); + $user = new \app\common\model\User; $result = $user->setNew($data); if($result==1){ return ['code'=>0,'msg'=>'资料更新成功','url'=>'/index/user/set']; @@ -133,20 +131,16 @@ class User extends BaseController } //个人页 - public function home() + public function home($id) { - $userID = input('id'); - Session::get('user_id'); //用户 - $u = Db::name('user')->field('name,nickname,city,sex,sign,user_img,point,create_time')->find($userID ?: Session::get('user_id')); + $u = Db::name('user')->field('name,nickname,city,sex,sign,user_img,point,create_time')->cache(true)->find($id); //用户发贴 - $arts = Db::name('user')->alias('u')->join('article a','u.id = a.user_id')->field('u.id,a.id,a.title,a.pv,a.is_hot,a.create_time,a.delete_time')->where('a.delete_time',0)->where('a.user_id',input('id') ?: Session::get('user_id'))->select(); + $arts = Db::name('user')->alias('u')->join('article a','u.id = a.user_id')->field('u.id,a.id,a.title,a.pv,a.is_hot,a.create_time,a.delete_time')->where('a.delete_time',0)->where('a.user_id',$id)->cache(true)->select(); //用户回答 - $reys = Db::name('comment')->alias('c')->join('article a','c.article_id = a.id')->field('a.id,a.title,c.content,c.create_time,c.delete_time')->where('a.delete_time',0)->where('c.user_id',input('id') ?: Session::get('user_id'))->select(); + $reys = Db::name('comment')->alias('c')->join('article a','c.article_id = a.id')->field('a.id,a.title,c.content,c.create_time,c.delete_time')->where(['a.delete_time'=>0,'c.delete_time'=>0])->where('c.user_id',$id)->cache(true)->select(); - View::assign('u',$u); - View::assign('arts',$arts); - View::assign('reys',$reys); + View::assign(['u'=>$u,'arts'=>$arts,'reys'=>$reys]); return View::fetch(); } @@ -177,7 +171,7 @@ class User extends BaseController if(!$res){ return $this->error($validate->getError()); } - $user = new \app\common\model\User(); + $user = new \app\common\model\User; $result = $user->setpass($data); if($result == 1) { Session::clear(); diff --git a/view/index/article/cate.html b/view/index/article/cate.html index d455c62..580dff2 100644 --- a/view/index/article/cate.html +++ b/view/index/article/cate.html @@ -1,4 +1,3 @@ - {extend name="public/base" /} {block name="title"}{$Request.param.ename|getCateName}-{$sysInfo.webname}{/block} {block name="keywords"}{$Request.param.ename|getCateName},{$sysInfo.webname}{/block} @@ -13,7 +12,7 @@ {include file="public/filter" /} -
+
+ {$comments|raw}
{if condition="$article.is_reply == 1"} diff --git a/view/index/public/filter.html b/view/index/public/filter.html index 0454242..fa07204 100644 --- a/view/index/public/filter.html +++ b/view/index/public/filter.html @@ -1,17 +1,13 @@
- - 综合 - - 已结 - - 热帖 - - 精华 + 综合 + + 已结 + + 热帖 + + 精华 - +
diff --git a/view/index/user/home.html b/view/index/user/home.html index 3d3ada8..88c9a35 100644 --- a/view/index/user/home.html +++ b/view/index/user/home.html @@ -1,5 +1,6 @@ {extend name="public/base" /} -{block name="title"}{$u.nickname ?: $u.name}的主页 - {$sysInfo.webname}{/block} +{block name="title"}{$u.nickname ?: $u.name}的主页-{$sysInfo.webname}{/block} +{block name="description"}{$u.sign}{/block} {block name="column"}{/block} {block name="content"}
@@ -16,22 +17,18 @@ (该号已被封) --> -

认证信息: 作者

-

{$u.point} 飞吻 {$u.create_time|date='Y-m-d'} 加入 - 来自{$user.city} + {:session('user_id') ? '来自'.$user.city:'登录查看'}

-

({$u.sign ?:'懒得还没有签名'})

-
@@ -59,7 +56,7 @@

{$u.nickname ?? $u.name} 最近的回答

    - {volist name="$reys" id="vo"} + {volist name="$reys" id="vo" empty="没有回答任何问题"}
  • {$vo.create_time|date='Y-m-d H-m'} @@ -81,7 +78,7 @@ layui.cache.page = 'jie'; layui.cache.user = { username: '{$user.name??'游客'}' - ,uid: {$user.id ? 168*$user.id : -1} + ,uid: {$user.id ? $user.id : -1} ,avatar: '{if condition="$user['user_img'] neq ''"}/uploads/{$user['user_img']}{else /}/static/res/images/avatar/00.jpg{/if}' ,experience: 83 ,sex: '{if condition="$user['sex'] eq 0"}男{else/}女{/if}' @@ -94,12 +91,13 @@ }).use(['fly', 'face'], function(){ var $ = layui.$ ,fly = layui.fly; - //如果你是采用模版自带的编辑器,你需要开启以下语句来解析。 + //如果你是采用模版自带的编辑器,你需要开启以下语句来解析。 $('.detail-body').each(function(){ var othis = $(this), html = othis.html(); othis.html(fly.content(html)); }); + }); {/block}