user home page
This commit is contained in:
parent
434c27dbbd
commit
e6ee8dff79
@ -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');
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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" /}
|
||||
<ul class="fly-list">
|
||||
{volist name="artList" id="art"}
|
||||
{volist name="artList" id="art"}
|
||||
<li>
|
||||
<a href="{:url('user/home',['id'=>$art.user.id])}" class="fly-avatar">
|
||||
<img src="{$art.user.user_img}" alt="{$art.user.name}">
|
||||
@ -24,7 +23,7 @@
|
||||
</h2>
|
||||
<div class="fly-list-info">
|
||||
<a href="{:url('user/home',['id'=>$art.user.id])}" link>
|
||||
<span class="layui-badge layui-bg-green " title="哪个小区">{:getAsing($art.user.area_id) ?: '无'}</span>
|
||||
<span class="layui-badge layui-bg-green " title="哪个小区">{:getAsing($art.user.area_id) ?: '无'}</span>
|
||||
<cite>{$art.user.nickname ?: $art.user.name}</cite>
|
||||
<!--
|
||||
<i class="iconfont icon-renzheng" title="认证信息:XXX"></i>
|
||||
@ -40,15 +39,13 @@
|
||||
</span>
|
||||
</div>
|
||||
<div class="fly-list-badge">
|
||||
{if ($art.is_top == 1)} <span class="layui-badge layui-bg-black" >置顶</span> {/if}
|
||||
{if ($art.is_top == 1)} <span class="layui-badge layui-bg-black" >置顶</span> {/if}
|
||||
{if ($art.is_hot == 1)} <span class="layui-badge layui-bg-red">精帖</span> {/if}
|
||||
</div>
|
||||
</li>
|
||||
{/volist}
|
||||
{/volist}
|
||||
</ul>
|
||||
|
||||
<!-- <div class="fly-none">没有相关数据</div> -->
|
||||
|
||||
<div style="text-align: center" id="page">{$artList|raw}</div>
|
||||
|
||||
</div>
|
||||
|
@ -1,9 +1,9 @@
|
||||
|
||||
{extend name="public/base" /}
|
||||
|
||||
{block name="title"}{$article.title} - {$sysInfo.webname}{/block}
|
||||
{block name="keywords"}{$article.title}-{$article.tags}{/block}
|
||||
{block name="description"}{$article.title}-{:getArtContent($article.content)}{/block}
|
||||
{block name="title"}{$article.title}-{$sysInfo.webname}{/block}
|
||||
{block name="keywords"}{$article.title},{$article.tags}{/block}
|
||||
{block name="description"}{$article.title},{:getArtContent($article.content)}{/block}
|
||||
{block name="column"}{include file="/public/column" /}{/block}
|
||||
{block name="content"}
|
||||
<div class="layui-container">
|
||||
@ -61,7 +61,6 @@
|
||||
<span>{$article.create_time|date='Y-m-d H:d'}</span>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="detail-hits" id="LAY_jieAdmin" data-id="{$article['id']}">
|
||||
<!--span style="padding-right: 10px; color: #FF7200">悬赏:60飞吻</span-->
|
||||
{if(session('user_name')==$article.user.name || $user.auth == 1)}
|
||||
@ -99,7 +98,7 @@
|
||||
<i class="layui-badge fly-badge-vip">VIP3</i-->
|
||||
</a>
|
||||
{if condition="$article.user.id eq $vo.user.id"}
|
||||
<span>(楼主)</span>
|
||||
<span>(贴主)</span>
|
||||
{/if}
|
||||
<!--
|
||||
<span style="color:#5FB878">(管理员)</span>
|
||||
@ -120,35 +119,26 @@
|
||||
|
||||
<div class="jieda-reply">
|
||||
<span class="jieda-zan {if($vo.zan != 0)}zanok{/if}" type="zan">
|
||||
<i class="iconfont icon-zan"></i>
|
||||
<em>{$vo.zan}</em>
|
||||
</span>
|
||||
<span type="reply">
|
||||
<i class="iconfont icon-svgmoban53"></i>
|
||||
回复
|
||||
<i class="iconfont icon-zan"></i><em>{$vo.zan}</em>
|
||||
</span>
|
||||
<span type="reply"><i class="iconfont icon-svgmoban53"></i>回复</span>
|
||||
|
||||
<div class="jieda-admin">
|
||||
{if session('user_id') == $vo.user.id}
|
||||
{if getLimtTime($vo.create_time) < 2}
|
||||
<span type="edit">编辑</span>
|
||||
<span type="del">删除</span>
|
||||
{/if}
|
||||
{else}
|
||||
{if (session('user_id') == $vo.user.id) && (getLimtTime($vo.create_time) < 2) OR $user.auth == 1}
|
||||
<span type="edit">编辑</span>
|
||||
<span type="del">删除</span>
|
||||
{if $vo.cai == 0 && session('user_id') == $article.user_id /}
|
||||
<span class="jieda-accept" type="accept">采纳</span>
|
||||
{/if}
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
{/volist}
|
||||
|
||||
<!-- 无数据时 -->
|
||||
<!-- <li class="fly-none">消灭零回复</li> -->
|
||||
</ul>
|
||||
|
||||
<div style="text-align: center">
|
||||
<div style="text-align: center">
|
||||
{$comments|raw}
|
||||
</div>
|
||||
|
||||
{if condition="$article.is_reply == 1"}
|
||||
|
@ -1,17 +1,13 @@
|
||||
<div class="fly-panel-title fly-filter">
|
||||
|
||||
<a href="{:url('article/cate',['ename' => $Request.param.ename ?:'all' ,'type' => ''])} " {if condition="$type eq ''" } class="layui-this" {/if} >综合</a>
|
||||
<span class="fly-mid"></span>
|
||||
<a href="{:url('article/cate',['ename' => $Request.param.ename ?:'all','type' => 'jie'])} " {if condition="$type eq 'jie'" } class="layui-this" {/if} >已结</a>
|
||||
<span class="fly-mid"></span>
|
||||
<a href="{:url('article/cate',['ename' => $Request.param.ename ?:'all','type' => 'hot'])} " {if condition="$type eq 'hot'" } class="layui-this" {/if} >热帖</a>
|
||||
<span class="fly-mid"></span>
|
||||
<a href="{:url('article/cate',['ename' => $Request.param.ename ?:'all','type' => 'top'])} " {if condition="$type eq 'top'" } class="layui-this" {/if} >精华</a>
|
||||
<a href="{:url('article/cate',['ename' => $Request.param.ename ?:'all' ,'type' => ''])} " {if condition="$type eq ''" } class="layui-this" {/if} >综合</a>
|
||||
<span class="fly-mid"></span>
|
||||
<a href="{:url('article/cate',['ename' => $Request.param.ename ?:'all','type' => 'jie'])} " {if condition="$type eq 'jie'" } class="layui-this" {/if} >已结</a>
|
||||
<span class="fly-mid"></span>
|
||||
<a href="{:url('article/cate',['ename' => $Request.param.ename ?:'all','type' => 'top'])} " {if condition="$type eq 'top'" } class="layui-this" {/if} >热帖</a>
|
||||
<span class="fly-mid"></span>
|
||||
<a href="{:url('article/cate',['ename' => $Request.param.ename ?:'all','type' => 'hot'])} " {if condition="$type eq 'hot'" } class="layui-this" {/if} >精华</a>
|
||||
|
||||
<!--span class="fly-filter-right layui-hide-xs">
|
||||
<a href="" class="layui-this">按最新</a>
|
||||
<span class="fly-mid"></span>
|
||||
<a href="">按热议</a>
|
||||
</span-->
|
||||
<!--span class="fly-filter-right layui-hide-xs"><a href="" class="layui-this">按最新</a>
|
||||
<span class="fly-mid"></span><a href="">按热议</a></span-->
|
||||
</div>
|
||||
|
||||
|
@ -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"}
|
||||
<div class="fly-home fly-panel" style="background-image: url();">
|
||||
@ -16,22 +17,18 @@
|
||||
<span>(该号已被封)</span>
|
||||
-->
|
||||
</h1>
|
||||
|
||||
<p style="padding: 10px 0; color: #5FB878;">认证信息: 作者</p>
|
||||
|
||||
<p class="fly-home-info">
|
||||
<i class="iconfont icon-kiss" title="飞吻"></i><span style="color: #FF7200;">{$u.point} 飞吻</span>
|
||||
<i class="iconfont icon-shijian"></i><span>{$u.create_time|date='Y-m-d'} 加入</span>
|
||||
<i class="iconfont icon-chengshi"></i><span>来自{$user.city}</span>
|
||||
<i class="iconfont icon-chengshi"></i><span>{:session('user_id') ? '来自'.$user.city:'登录查看'}</span>
|
||||
</p>
|
||||
|
||||
<p class="fly-home-sign">({$u.sign ?:'懒得还没有签名'})</p>
|
||||
|
||||
<div class="fly-sns" data-user="">
|
||||
<a href="javascript:;" class="layui-btn layui-btn-primary fly-imActive" data-type="addFriend">加为好友</a>
|
||||
<a href="javascript:;" class="layui-btn layui-btn-normal fly-imActive" data-type="chat">发起会话</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="layui-container">
|
||||
@ -59,7 +56,7 @@
|
||||
<div class="fly-panel">
|
||||
<h3 class="fly-panel-title">{$u.nickname ?? $u.name} 最近的回答</h3>
|
||||
<ul class="home-jieda">
|
||||
{volist name="$reys" id="vo"}
|
||||
{volist name="$reys" id="vo" empty="没有回答任何问题"}
|
||||
<li>
|
||||
<p>
|
||||
<span>{$vo.create_time|date='Y-m-d H-m'}</span>
|
||||
@ -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));
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
{/block}
|
||||
|
Loading…
Reference in New Issue
Block a user