|
@@ -13,6 +13,41 @@ class Usercenter extends Api
|
|
|
protected $noNeedLogin = ['test'];
|
|
|
protected $noNeedRight = '*';
|
|
|
|
|
|
+ protected $allowFields = [
|
|
|
+ 'id',
|
|
|
+ 'username',
|
|
|
+ 'nickname',
|
|
|
+ 'truename',//
|
|
|
+
|
|
|
+ 'email',
|
|
|
+ 'mobile',
|
|
|
+ 'avatar',
|
|
|
+ 'real_status',
|
|
|
+ 'gender',
|
|
|
+ 'height',
|
|
|
+ 'weight',
|
|
|
+ 'birthday',
|
|
|
+ 'bio',
|
|
|
+ 'audio_bio',
|
|
|
+
|
|
|
+ 'alipay_account',//
|
|
|
+ 'idcard_status',
|
|
|
+
|
|
|
+ 'longitude',
|
|
|
+ 'latitude',
|
|
|
+ 'cityname',
|
|
|
+ 'photo_images',
|
|
|
+
|
|
|
+ 'education_id',
|
|
|
+ 'hobby_ids',
|
|
|
+ 'job_id',
|
|
|
+ 'marital_id',
|
|
|
+ 'tag_ids',
|
|
|
+ 'wages_id',
|
|
|
+
|
|
|
+ 'hometown_cityid',
|
|
|
+ ];
|
|
|
+
|
|
|
public function test(){
|
|
|
$a = [1,4,10,22,66,36,102,45,23,52,35,76,7];
|
|
|
$b = [1,10,7,102];
|
|
@@ -25,6 +60,58 @@ class Usercenter extends Api
|
|
|
dump(array_flip([]));
|
|
|
}
|
|
|
|
|
|
+ //获取他人用户信息,留下足迹
|
|
|
+ public function getuserinfo(){
|
|
|
+ $uid = input_post('uid',0);
|
|
|
+ $userinfo = Db::name('user')->field($this->allowFields)->where('id',$uid)->find();
|
|
|
+
|
|
|
+ if(!$userinfo){
|
|
|
+ $this->error('不存在的用户');
|
|
|
+ }
|
|
|
+
|
|
|
+ //
|
|
|
+ $userinfo = info_domain_image($userinfo,['avatar','photo_images']);
|
|
|
+
|
|
|
+ $new_data = [
|
|
|
+ 'age' => birthtime_to_age($userinfo['birthday']),
|
|
|
+ 'truename' => $userinfo['idcard_status'] == 1 ? $userinfo['truename'] : '',
|
|
|
+ 'alipay_account' => $userinfo['idcard_status'] == 1 ? $userinfo['alipay_account'] : '',
|
|
|
+ ];
|
|
|
+
|
|
|
+ $userinfo = array_merge($userinfo,$new_data);
|
|
|
+ //枚举
|
|
|
+ $userinfo['education'] = Db::name('enum_education')->where('id',$userinfo['education_id'])->value('name');
|
|
|
+ $userinfo['hobby'] = Db::name('enum_hobby')->where('id','IN',$userinfo['hobby_ids'])->column(['id','name']);
|
|
|
+ $userinfo['job'] = Db::name('enum_job')->where('id',$userinfo['job_id'])->value('name');
|
|
|
+ $userinfo['marital'] = Db::name('enum_marital')->where('id',$userinfo['marital_id'])->value('name');
|
|
|
+ $userinfo['tag'] = Db::name('enum_tag')->where('id','IN',$userinfo['tag_ids'])->column(['id','name']);
|
|
|
+ $userinfo['wages'] = Db::name('enum_wages')->where('id',$userinfo['wages_id'])->value('name');
|
|
|
+
|
|
|
+ //家乡
|
|
|
+ $userinfo['hometown_city'] = Db::name('area')->where('id',$userinfo['hometown_cityid'])->value('name');
|
|
|
+
|
|
|
+ //vip
|
|
|
+ $userinfo['vip_endtime'] = Db::name('user_wallet')->where('user_id',$uid)->value('vip_endtime');
|
|
|
+ $userinfo['is_vip'] = $userinfo['vip_endtime'] > time() ? 1 : 0;
|
|
|
+
|
|
|
+ //是否喜欢和关注
|
|
|
+ $is_follow = Db::name('user_follow')->where(['uid'=>$this->auth->id,'follow_uid'=>$uid])->find();
|
|
|
+ $userinfo['is_follow'] = $is_follow ? 1 : 0;
|
|
|
+
|
|
|
+ $is_like = Db::name('user_like')->where(['uid'=>$this->auth->id,'like_uid'=>$uid])->find();
|
|
|
+ $userinfo['is_like'] = $is_like ? 1 : 0;
|
|
|
+
|
|
|
+ //查看别人信息,就要留下痕迹
|
|
|
+ $data = [
|
|
|
+ 'uid' => $this->auth->id,
|
|
|
+ 'to_uid' => $this->auth->id,
|
|
|
+ ];
|
|
|
+ Db::name('user_visit')->insertGetId($data);
|
|
|
+
|
|
|
+ $this->success('success',$userinfo);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
//同城
|
|
|
public function samecity(){
|
|
|
$gender = input_post('gender','all');
|