Index.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 = 1;
  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. // $kefu_id = Db::name('pc_admin')->where('company_id',$this->auth->company_id)->order('is_kefu desc,id asc')->value('id');
  50. $kefu_id = $this->auth->company_id;
  51. //
  52. $result = [
  53. 'banner' => $banner,
  54. 'header' => $header,
  55. 'aboutus' => $aboutus,
  56. 'dongtai' => $dongtai,
  57. 'huojing' => 119,
  58. 'headermobile' => $header['header_mobile'],
  59. 'im_kefu' => 'kefu_'.$kefu_id,
  60. ];
  61. $this->success(1, $result);
  62. }
  63. /**
  64. * 关于我们
  65. */
  66. public function aboutus(){
  67. //关于我们
  68. $aboutus = Db::name('company')->field('aboutus,aboutus_image')
  69. ->where('id',$this->auth->company_id)->find();
  70. $aboutus = info_domain_image($aboutus,['aboutus_image']);
  71. $this->success(1, $aboutus);
  72. }
  73. /**
  74. * 维保信息
  75. */
  76. public function weiboinfo(){
  77. $info = Db::name('user_company')->where('user_id',$this->auth->id)->find();
  78. $info = info_domain_image($info,['header_avatar']);
  79. $info['weituo_info'] = $info['weituo'].'消防设施维护保养';
  80. $this->success(1, $info);
  81. }
  82. }