From f5754414796bd77314fb11e3f1f4c020caa6d3fd Mon Sep 17 00:00:00 2001 From: zhao Date: Wed, 12 Feb 2020 15:08:52 +0800 Subject: [PATCH] sign --- README.md | 18 ++++++++++++------ app/common/model/Article.php | 2 +- app/index/controller/Article.php | 9 +++++---- app/index/controller/FriendLink.php | 13 ------------- app/index/controller/Sign.php | 8 +++----- view/index/article/detail.html | 10 +++++----- view/index/sign/lists.html | 6 +++--- 7 files changed, 29 insertions(+), 37 deletions(-) delete mode 100644 app/index/controller/FriendLink.php diff --git a/README.md b/README.md index f427ffe..109b685 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,14 @@ # TaoLer -版本: TaoLer 1.0.0 -日期: 2020.1.1 -官网: http://www.aieok.com +版本:TaoLer 1.0.0 +日期:2020.1.1 +官网:http://www.aieok.com + +#### 项目地址 + +gitee https://www.gitee.com/toogee/Taoler +github https://www.github.com/taoser/TaoLer + #### 介绍 1. 采用动态密码加密,相同密码在入库时具有唯一性,即使管理员也无法破解,用户信息安全牢固。 @@ -28,9 +34,9 @@ 1. git下载:https://gitee.com/toogee/TaoLer 2. 官网下载:http://www.aieok.com -3. 解压后,项目域名部署为public目录对外访问,首页安装,访问http://www.youdomain.com可自动跳转到/install.php/index,,如果重新安装需要删除根目录下install.lock。 -4. 安装前需要先建立好数据库(需求:数据库连接地址,数据库用户名,数据库密码,数据库端口,数据库名称) -5. 安装过程注意记录好设置的管理员用户名和密码,默认admin/123456。前后台的管理员密码一致。安装好后,前后端管理员是分开的,前端主要对文章内容的审查,置顶等操作。 +3. 解压后,项目绑定域名为public目录对外访问,首次安装,访问域名http://www.youdomain.com可自动跳转到/install.php/index进行引导安装,重新安装需删除根目录下install.lock。 +4. 安装前需要先创建mysql数据库(准备:数据库连接地址,数据库用户名,数据库密码,数据库端口,建好在数据库名) +5. 请牢记安装设置的管理员用户名和密码,默认admin/123456。前后台的管理员密码一致。前后端管理员账户是独立的,前端主要对文章内容的审查管理等操作。 #### 使用说明 diff --git a/app/common/model/Article.php b/app/common/model/Article.php index f34125f..5d9f11c 100644 --- a/app/common/model/Article.php +++ b/app/common/model/Article.php @@ -31,7 +31,7 @@ class Article extends Model //文章关联评论 public function comments() { - return $this->hasMany('Comment','article_id','id'); + return $this->hasMany(Comment::class); } //文章关联用户 diff --git a/app/index/controller/Article.php b/app/index/controller/Article.php index e87c8e2..5c0870c 100644 --- a/app/index/controller/Article.php +++ b/app/index/controller/Article.php @@ -92,10 +92,10 @@ class Article extends BaseController } //文章详情页 - public function detail($id = 1) + public function detail($id) { //获取文章ID - $id = Request::param('id'); + //$id = Request::param('id'); //查询文章 $article = ArticleModel::field('id,title,content,status,cate_id,user_id,is_top,is_hot,is_reply,pv,jie,create_time')->where('status',1)->with([ 'cate' => function($query){ @@ -104,7 +104,8 @@ class Article extends BaseController 'user' => function($query){ $query->field('id,name,nickname,user_img,area_id'); } - ])->withCount(['comments'])->find($id); + ])->find($id); + $comments = $article->comments()->where('status',1)->select(); $article->inc('pv')->update(); /* @@ -129,7 +130,7 @@ class Article extends BaseController //通用右栏 $ad_comm = Db::name('slider')->where('slid_status',1)->where('delete_time',0)->where('slid_type',2)->whereTime('slid_over','>=',time())->select(); - View::assign(['article'=>$article,'artHot'=>$artHot,'ad_art'=>$ad_article,'ad_comm'=>$ad_comm]); + View::assign(['article'=>$article,'comments'=>$comments,'artHot'=>$artHot,'ad_art'=>$ad_article,'ad_comm'=>$ad_comm]); return View::fetch(); } diff --git a/app/index/controller/FriendLink.php b/app/index/controller/FriendLink.php deleted file mode 100644 index 3ea973c..0000000 --- a/app/index/controller/FriendLink.php +++ /dev/null @@ -1,13 +0,0 @@ -uid = session('user_id'); - } public function lists() { //总榜 - $totallist = Db::name('user_sign')->alias('s')->join('user u', 's.uid=u.id', 'LEFT')->field('s.uid,s.id,max(s.days) as days,u.name as name,u.user_img as user_img')->group('s.uid')->order('days desc')->limit(20)->select(); + $list = Db::name('user_sign')->alias('s')->leftJoin('user u', 's.uid=u.id')->field('uid,s.id as id,max(days) as days,name,user_img')->group('uid')->order('days desc')->limit(20)->select(); $time = time(); $start_stime = strtotime(date('Y-m-d 0:0:0', $time)) - 1; $end_stime = strtotime(date('Y-m-d 23:59:59', $time)) + 1; @@ -70,7 +69,7 @@ class Sign extends BaseController $score = $todayData['will_getscore']; $date=date('Ymd'); $msg=''; - $teshudate=['20180215','20180216','20180217','20180218','20180219','20180220','20180221']; + $teshudate=['20200214','20200501','20201001']; //签到奖励 if(in_array($date,$teshudate)){ $randnum=rand(1,99); @@ -89,9 +88,8 @@ class Sign extends BaseController } return json(['code'=>200,'score'=>$score,'days'=>$days,'msg'=>$msg]); - // exit('{"code":200,"score":"' . $score . '","days":"' . $days . '"}'); } else { - exit('{"code":-1,"msg":"签到失败,请刷新后重试!"}'); + return json(['code'=>-1,'msg'=>'签到失败,请刷新后重试!']); } } } diff --git a/view/index/article/detail.html b/view/index/article/detail.html index 718e6cc..ae04918 100644 --- a/view/index/article/detail.html +++ b/view/index/article/detail.html @@ -43,7 +43,7 @@ - {$article.comments_count} + {$comments->count()} {$article.pv} @@ -84,7 +84,7 @@