Index.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. //科室列表
  21. public function keshi_list(){
  22. $list = Db::name('keshi')->where('is_show',1)->order('weigh','desc')->select();
  23. $this->success(1,$list);
  24. }
  25. //职称列表
  26. public function level_list(){
  27. $list = Db::name('doctor_level')->select();
  28. $this->success(1,$list);
  29. }
  30. //医生列表
  31. //首页推荐,搜索
  32. public function doctor_list(){
  33. $where = [
  34. 'd.status' => 1,
  35. 'd.doctor_status' => 1,
  36. ];
  37. //科室id
  38. $keshi_id = input('keshi_id',0);
  39. if($keshi_id){
  40. $where['d.keshi_id'] = $keshi_id;
  41. }
  42. //职称id
  43. $level_id = input('level_id',0);
  44. if($level_id){
  45. $where['d.level_id'] = $level_id;
  46. }
  47. //关注
  48. $folllow = input('follow',0);
  49. if($folllow){
  50. $my_follow_ids = controller('Userfollow')->my_follow_uids();
  51. $where['d.id'] = ['IN',$my_follow_ids];
  52. }
  53. //搜索
  54. $keyworld = input('keyworld','');
  55. if(!empty($keyworld)){
  56. $where['d.nickname|d.goodat|keshi.name'] = ['LIKE','%'.$keyworld.'%'];
  57. }
  58. //dump($where);
  59. $field = [
  60. 'd.id','d.nickname','d.avatar','d.keshi_id','d.level_id','d.hospital','d.goodat','d.ordernum',
  61. 'keshi.name as keshi_name',
  62. 'level.name as level_name',
  63. ];
  64. $list = Db::name('doctor')->alias('d')
  65. ->field($field)
  66. ->join('doctor_level level','d.level_id = level.id','LEFT')
  67. ->join('keshi','d.keshi_id = keshi.id','LEFT')
  68. ->where($where)->order('d.ordernum desc')->autopage()->select();
  69. $list = list_domain_image($list,['avatar']);
  70. $this->success(1,$list);
  71. }
  72. //医生详情
  73. public function doctor_info(){
  74. $id = input('id',0);
  75. $field = [
  76. 'd.id','d.nickname','d.avatar','d.keshi_id','d.level_id','d.hospital','d.goodat','d.ordernum','d.info',
  77. 'keshi.name as keshi_name',
  78. 'level.name as level_name',
  79. 'info.typing_switch','info.video_switch','info.typing_price','info.video_price',
  80. ];
  81. $info = Db::name('doctor')->alias('d')
  82. ->field($field)
  83. ->join('doctor_level level','d.level_id = level.id','LEFT')
  84. ->join('keshi','d.keshi_id = keshi.id','LEFT')
  85. ->join('doctor_info info','d.id = info.doctor_id','LEFT')
  86. ->where('d.id',$id)->find();
  87. $info = info_domain_image($info,['avatar']);
  88. //是否关注
  89. $info['is_follw'] = $this->is_follow($this->auth->id,$id);
  90. $this->success(1,$info);
  91. }
  92. }