Index.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\Db;
  5. /**
  6. * 首页接口
  7. */
  8. class Index extends Api
  9. {
  10. protected $noNeedLogin = [''];
  11. protected $noNeedRight = [''];
  12. /**
  13. * 首页
  14. *
  15. */
  16. public function index()
  17. {
  18. $this->success('请求成功');
  19. }
  20. public function home(){
  21. //轮播
  22. $banner = Db::name('banner')->field('id, title, image, url')
  23. ->where('company_id',$this->auth->company_id)
  24. ->where(['status' => 1])
  25. ->order(['weigh' => 'desc', 'id' => 'desc'])
  26. ->select();
  27. $banner = list_domain_image($banner, ['image']);
  28. //负责人
  29. $header = Db::name('user_company')->field('header,header_mobile')
  30. ->where('user_id',$this->auth->id)->find();
  31. $header = info_domain_image($header,['header_mobile']);
  32. //关于我们
  33. $aboutus = Db::name('company')->field('aboutus,aboutus_image')
  34. ->where('id',$this->auth->company_id)->find();
  35. $aboutus = info_domain_image($aboutus,['header_mobile']);
  36. //最新动态
  37. $zgs_id = 0;
  38. $dongtai = Db::name('dongtai')
  39. ->where('company_id','IN',[$this->auth->company_id,$zgs_id])
  40. ->order('id' , 'desc')
  41. ->limit(3)
  42. ->select();
  43. $dongtai = list_domain_image($dongtai, ['image']);
  44. //
  45. $result = [
  46. 'banner' => $banner,
  47. 'header' => $header,
  48. 'aboutus' => $aboutus,
  49. 'dongtai' => $dongtai,
  50. '119' => 119,
  51. ];
  52. $this->success(1, $result);
  53. }
  54. }