Index.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. $keyword = input('keyword','');
  55. if(!empty($keyword)){
  56. $where['d.nickname|d.goodat|keshi.name'] = ['LIKE','%'.$keyword.'%'];
  57. if($this->auth->isLogin()){
  58. Db::name('user_search')->insertGetId(['user_id'=>$this->auth->id,'keyword'=>$keyword]);
  59. }
  60. }
  61. //dump($where);
  62. $field = [
  63. 'd.id','d.nickname','d.avatar','d.keshi_id','d.level_id','d.hospital','d.goodat','d.ordernum',
  64. 'keshi.name as keshi_name',
  65. 'level.name as level_name',
  66. ];
  67. $list = Db::name('doctor')->alias('d')
  68. ->field($field)
  69. ->join('doctor_level level','d.level_id = level.id','LEFT')
  70. ->join('keshi','d.keshi_id = keshi.id','LEFT')
  71. ->where($where)->order('d.ordernum desc')->autopage()->select();
  72. $list = list_domain_image($list,['avatar']);
  73. $this->success(1,$list);
  74. }
  75. //医生详情
  76. public function doctor_info(){
  77. $id = input('id',0);
  78. $field = [
  79. 'd.id','d.nickname','d.avatar','d.keshi_id','d.level_id','d.hospital','d.goodat','d.ordernum','d.info',
  80. 'keshi.name as keshi_name',
  81. 'level.name as level_name',
  82. 'info.typing_switch','info.video_switch','info.typing_price','info.video_price',
  83. ];
  84. $info = Db::name('doctor')->alias('d')
  85. ->field($field)
  86. ->join('doctor_level level','d.level_id = level.id','LEFT')
  87. ->join('keshi','d.keshi_id = keshi.id','LEFT')
  88. ->join('doctor_info info','d.id = info.doctor_id','LEFT')
  89. ->where('d.id',$id)->find();
  90. $info = info_domain_image($info,['avatar']);
  91. //是否关注
  92. $info['is_follw'] = $this->is_follow($this->auth->id,$id);
  93. $this->success(1,$info);
  94. }
  95. }