Index.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. public function index()
  16. {
  17. $this->success('请求成功');
  18. }
  19. /**
  20. * 首页
  21. */
  22. public function home(){
  23. //轮播
  24. $banner = Db::name('banner')->field('id, title, image, url')
  25. ->where('company_id',$this->auth->company_id)
  26. ->where(['status' => 1])
  27. ->order(['weigh' => 'desc', 'id' => 'desc'])
  28. ->select();
  29. $banner = list_domain_image($banner, ['image']);
  30. //负责人
  31. $header = Db::name('user_company')->field('header,header_mobile')
  32. ->where('user_id',$this->auth->id)->find();
  33. //关于我们
  34. $aboutus = Db::name('company')->field('aboutus,aboutus_image')
  35. ->where('id',$this->auth->company_id)->find();
  36. $aboutus = info_domain_image($aboutus,['aboutus_image']);
  37. //最新动态
  38. $zgs_id = 0;
  39. $dongtai = Db::name('dongtai')->field('id,title,image,updatetime')
  40. ->where('company_id','IN',[$this->auth->company_id,$zgs_id])
  41. ->order('id' , 'desc')
  42. ->limit(3)
  43. ->select();
  44. $dongtai = list_domain_image($dongtai, ['image']);
  45. //
  46. $result = [
  47. 'banner' => $banner,
  48. 'header' => $header,
  49. 'aboutus' => $aboutus,
  50. 'dongtai' => $dongtai,
  51. '119' => 119,
  52. ];
  53. $this->success(1, $result);
  54. }
  55. /**
  56. * 关于我们
  57. */
  58. public function aboutus(){
  59. //关于我们
  60. $aboutus = Db::name('company')->field('aboutus,aboutus_image')
  61. ->where('id',$this->auth->company_id)->find();
  62. $aboutus = info_domain_image($aboutus,['aboutus_image']);
  63. $this->success(1, $aboutus);
  64. }
  65. /**
  66. * 维保信息
  67. */
  68. public function weiboinfo(){
  69. $info = Db::name('user_company')->where('user_id',$this->auth->id)->find();
  70. $info = info_domain_image($info,['header_avatar']);
  71. $info['weituo_info'] = $info['weituo'].'消防设施维护保养';
  72. $this->success(1, $info);
  73. }
  74. }