Article.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\Db;
  5. use addons\epay\library\Service;
  6. /**
  7. * 首页产品文章
  8. */
  9. class Article extends Api
  10. {
  11. protected $noNeedLogin = ['lists'];
  12. protected $noNeedRight = ['*'];
  13. public function lists()
  14. {
  15. $where = ['is_show'=>1];
  16. $list = Db::name('article')->field('content',true)->where($where)->order('weigh desc')->autopage()->select();
  17. $list = list_domain_image($list,['images','video_file','video_image']);
  18. if(!empty($list)){
  19. foreach($list as $key => &$item){
  20. $item['showdate'] = date('Y-m-d H:i',$item['showtime']);
  21. }
  22. }
  23. $this->success(1,$list);
  24. }
  25. public function info(){
  26. $id = input('id',0);
  27. $info = Db::name('article')->where('is_show',1)->where('id',$id)->find();
  28. if(!$info){
  29. $this->error('文章找不到了');
  30. }
  31. $info = info_domain_image($info,['images','video_file','video_image']);
  32. $info['showdate'] = date('Y-m-d H:i',$info['showtime']);
  33. $this->success(1,$info);
  34. }
  35. }