Article.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace app\wap\controller;
  3. use app\admin\model\article\Article as ArticleModel;
  4. use app\wap\model\wap\ArticleCategory;
  5. use think\Db;
  6. /**
  7. * 文章分类控制器
  8. * Class Article
  9. * @package app\wap\controller
  10. */
  11. class Article extends WapBasic {
  12. public function index($cid = ''){
  13. $title = '新闻列表';
  14. if($cid){
  15. $cateInfo = ArticleCategory::where('status',1)->where('is_del',0)->where('id',$cid)->find()->toArray();
  16. if(!$cateInfo) return $this->failed('文章分类不存在!');
  17. $title = $cateInfo['title'];
  18. }
  19. $this->assign(compact('title','cid'));
  20. return $this->fetch();
  21. }
  22. public function video_school()
  23. {
  24. return $this->fetch();
  25. }
  26. public function guide()
  27. {
  28. return $this->fetch();
  29. }
  30. public function visit($id = '')
  31. {
  32. $content = ArticleModel::where('status',1)->where('hide',0)->where('id',$id)->find();
  33. if(!$content || !$content["status"]) return $this->failed('此文章已经不存在!');
  34. $content["content"] = Db::name('articleContent')->where('nid',$content["id"])->value('content');
  35. //增加浏览次数
  36. $content["visit"] = $content["visit"] + 1;
  37. ArticleModel::where('id',$id)->update(["visit"=>$content["visit"]]);
  38. $this->assign(compact('content'));
  39. return $this->fetch();
  40. }
  41. }