Index.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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,header_avatar')
  32. ->where('user_id',$this->auth->id)->find();
  33. $header = info_domain_image($header,['header_avatar']);
  34. $header['jishuguifan'] = localpath_to_netpath(config('site.user_index_jishuguifan'));
  35. $header['caozuoguifan'] = localpath_to_netpath(config('site.user_index_caozuoguifan'));
  36. //关于我们
  37. $aboutus = Db::name('company')->field('aboutus,aboutus_image')
  38. ->where('id',$this->auth->company_id)->find();
  39. $aboutus = info_domain_image($aboutus,['aboutus_image']);
  40. //最新动态
  41. $zgs_id = 0;
  42. $dongtai = Db::name('dongtai')->field('id,title,image,updatetime')
  43. ->where('company_id','IN',[$this->auth->company_id,$zgs_id])
  44. ->order('id' , 'desc')
  45. ->limit(3)
  46. ->select();
  47. $dongtai = list_domain_image($dongtai, ['image']);
  48. //
  49. $result = [
  50. 'banner' => $banner,
  51. 'header' => $header,
  52. 'aboutus' => $aboutus,
  53. 'dongtai' => $dongtai,
  54. 'huojing' => 119,
  55. 'headermobile' => $header['header_mobile'],
  56. 'im_kefu' => 'c'.$this->auth->company_id,
  57. ];
  58. $this->success(1, $result);
  59. }
  60. /**
  61. * 关于我们
  62. */
  63. public function aboutus(){
  64. //关于我们
  65. $aboutus = Db::name('company')->field('aboutus,aboutus_image')
  66. ->where('id',$this->auth->company_id)->find();
  67. $aboutus = info_domain_image($aboutus,['aboutus_image']);
  68. $this->success(1, $aboutus);
  69. }
  70. /**
  71. * 维保信息
  72. */
  73. public function weiboinfo(){
  74. $info = Db::name('user_company')->where('user_id',$this->auth->id)->find();
  75. $info = info_domain_image($info,['header_avatar']);
  76. $info['weituo_info'] = $info['weituo'].'消防设施维护保养';
  77. $this->success(1, $info);
  78. }
  79. }