panda 1 年之前
父節點
當前提交
137db767ea
共有 1 個文件被更改,包括 13 次插入15 次删除
  1. 13 15
      application/api/controller/Usercenter.php

+ 13 - 15
application/api/controller/Usercenter.php

@@ -2098,11 +2098,8 @@ $resArray['money'] = $money;  //返回给前端的计算结果
             $this->error('您的网络开小差了');
             $this->error('您的网络开小差了');
         }
         }
 
 
-        //找到互关的人,排除
-        //$follow_me = Db::name('user_follow')->where('follow_uid',$this->auth->id)->column('uid');
-        //dump($follow_me);
-        //$my_follow = Db::name('user_follow')->where(['uid'=>$this->auth->id,'follow_uid'=>['IN',$follow_me]])->column('follow_uid');
-        //dump($my_follow);exit;
+        $size = input('size',0,'intval');// 是否查 10 条
+        $size = $size > 0 ? 1 : 0;
 
 
         //给出备选用户
         //给出备选用户
         $map = [
         $map = [
@@ -2127,13 +2124,19 @@ $resArray['money'] = $money;  //返回给前端的计算结果
         }
         }
 
 
         $key = md5(json_encode($map));// 根据搜索条件做Key
         $key = md5(json_encode($map));// 根据搜索条件做Key
-        $lists = Cache::remember("getrandomuser_{$key}",function () use ($map){
-            $lists = Db::name('user')
+        $lists = Cache::remember("getrandomuser_{$key}_{$size}",function () use ($map,$size){
+            $query = Db::name('user')
                 ->field('id,nickname,username,avatar')
                 ->field('id,nickname,username,avatar')
                 ->where($map)
                 ->where($map)
-                ->order('is_active desc, active_time desc')
-                ->page($this->page,100)
-                ->select();
+                ->order('is_active desc, active_time desc');
+
+            if ($size == 1){
+                $query->limit(10);
+            }else{
+                $query->page($this->page,100);
+            }
+
+            $lists = $query->select();
             //$lists = $this->fliter_user($lists,100);
             //$lists = $this->fliter_user($lists,100);
 
 
             $lists = list_domain_image($lists,['avatar,audio_bio']);
             $lists = list_domain_image($lists,['avatar,audio_bio']);
@@ -2155,12 +2158,7 @@ $resArray['money'] = $money;  //返回给前端的计算结果
             }
             }
             return $lists;
             return $lists;
         },60);
         },60);
-
-//        $count = Db::name('user')->where(['is_active' => 1])->count('id');
-//
-//        $return_data['count'] = config('site.randomuser_num') > 0 ? config('site.randomuser_num') + $count : $count;
         $return_data['list'] = $lists;
         $return_data['list'] = $lists;
-
         $this->success('success',$return_data);
         $this->success('success',$return_data);
     }
     }