Article.php 1.4 KB

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