Uservisit.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\Db;
  5. /**
  6. * 访问足迹
  7. */
  8. class Uservisit extends Api
  9. {
  10. protected $noNeedLogin = [];
  11. protected $noNeedRight = ['*'];
  12. //我的访问列表
  13. public function my_visit_list(){
  14. $list = Db::name('user_visit')
  15. ->alias('visit')
  16. ->join('user','visit.to_uid = user.id','LEFT')
  17. ->field('user.id,user.nickname,user.avatar,visit.updatetime')
  18. ->where('visit.uid',$this->auth->id)
  19. ->order('visit.updatetime desc')->autopage()->select();
  20. $list = list_domain_image($list,['avatar']);
  21. foreach($list as $key => &$val){
  22. //时间
  23. $val['createtime_text'] = get_last_time($val['updatetime']);
  24. unset($val['updatetime']);
  25. }
  26. $number = Db::name('user_visit')->alias('visit')
  27. ->where('visit.uid',$this->auth->id)
  28. ->count();
  29. $result = [
  30. 'list' => $list,
  31. 'number' => $number,
  32. 'is_vip' => $this->is_vip($this->auth->id),
  33. ];
  34. $this->success('success',$result);
  35. }
  36. //访问我的人列表,消除无痕
  37. public function visit_me_list(){
  38. $list = Db::name('user_visit')
  39. ->alias('visit')
  40. ->join('user','visit.uid = user.id','LEFT')
  41. ->field('user.id,user.nickname,user.avatar,visit.updatetime')
  42. ->where('visit.to_uid',$this->auth->id)
  43. ->order('visit.updatetime desc')->autopage()->select();
  44. $list = list_domain_image($list,['avatar']);
  45. foreach($list as $key => &$val){
  46. //时间
  47. $val['createtime_text'] = get_last_time($val['updatetime']);
  48. unset($val['updatetime']);
  49. }
  50. $number = Db::name('user_visit')->alias('visit')
  51. ->where('visit.to_uid',$this->auth->id)
  52. ->count();
  53. $result = [
  54. 'list' => $list,
  55. 'number' => $number,
  56. 'is_vip' => $this->is_vip($this->auth->id),
  57. ];
  58. $this->success('success',$result);
  59. }
  60. //查看某人
  61. public function visit_one(){
  62. //放到usercenter/getuserinfo里了
  63. }
  64. }