|
@@ -69,7 +69,42 @@ class Usercenter extends Api
|
|
|
|
|
|
//附近
|
|
|
public function nearuser(){
|
|
|
-
|
|
|
+ $gender = input_post('gender','all');
|
|
|
+ $agemin = input_post('agemin',0);
|
|
|
+ $agemax = input_post('agemax',100);
|
|
|
+
|
|
|
+ $map = [
|
|
|
+ 'user.status' => 1,
|
|
|
+ //'user.cityname' => $this->auth->cityname,
|
|
|
+ 'user.id' => ['neq',$this->auth->id],
|
|
|
+ 'user.longitude' => ['between',[$this->auth->longitude - 0.1,$this->auth->longitude + 0.1]],
|
|
|
+ 'user.latitude' => ['between',[$this->auth->latitude - 0.01,$this->auth->latitude + 0.01]],
|
|
|
+ ];
|
|
|
+ if($gender != 'all'){
|
|
|
+ $map['user.gender'] = $gender;
|
|
|
+ }
|
|
|
+
|
|
|
+ $map['user.birthday'] = ['between',[time() - $agemax * 31536000,time() - $agemin * 31536000]];
|
|
|
+
|
|
|
+ //dump($map);
|
|
|
+ $field = [
|
|
|
+ 'user.id','user.username','user.nickname','user.birthday','user.height','user.longitude','user.latitude','user.avatar','user.audio_bio','user.bio','user.gender'
|
|
|
+ ];
|
|
|
+
|
|
|
+ $list = Db::name('user')->alias('user')->field($field)->where($map)->orderRaw('rand()')->autopage()->select();
|
|
|
+ //dump($list);exit;
|
|
|
+
|
|
|
+ $list = list_domain_image($list,['avatar']);
|
|
|
+
|
|
|
+ foreach($list as $key => $one){
|
|
|
+ $one['age'] = birthtime_to_age($one['birthday']);
|
|
|
+ $one['distance'] = $this->calc_map_distance([$this->auth->longitude,$this->auth->latitude],[$one['longitude'],$one['latitude']]);
|
|
|
+
|
|
|
+ $list[$key] = $one;
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->success('success',$list);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|