Commit a170f952 authored by 蔡闯's avatar 蔡闯

登入接口修改

parent 0f6567b9
......@@ -42,20 +42,10 @@ class Login extends BaseController
$res['uid'] = $uid;
$res['phone'] = $phone;
$res['pwd'] = empty($userInfo['password']) ? 0 :1;
//查询该用户是否绑定了房间,如果有,则返回上一次绑定的房间
$userBind = Db::name('house_user_bind')->where(['uid'=>$uid,'status'=>1,'is_lately_login'=>1])->field('house_user_bind_id,village_id,vacancy_id')->find();
if($userBind){
$res['userBindInfo'] = $userBind;
} else {
//查询是否有房间
$userBind = Db::name('house_user_bind')->where(['uid'=>$uid,'status'=>1])->field('house_user_bind_id,village_id,vacancy_id')->find();
if($userBind){
$res['userBindInfo'] = $userBind;
Db::name('house_user_bind')->where(['uid'=>$uid,'status'=>1])->save(['is_lately_login'=>1]);
} else {
$res['userBindInfo'] = (Object)[];
}
}
$res['userBindInfo'] = $this->findOnlyRoom($uid);
return $this->returnJson($res);
} else{
......@@ -79,15 +69,38 @@ class Login extends BaseController
$res['uid'] = $userInfo['uid'];
$res['phone'] = $phone;
$res['pwd'] = empty($userInfo['password']) ? 0 :1;
//查询该用户是否绑定了房间,如果有,则返回上一次绑定的房间
$res['userBindInfo'] = $this->findOnlyRoom($userInfo['uid']);
Common::synUserData($userInfo['uid'],$phone);
return $this->returnJson($res,200);
} else {
return $this->returnJson([],'密码不正确!','400');
}
}
return $this->returnJson([],'参数错误,请检查!','400');
}
//查询是否有房间唯一,如果唯一返回
public function findOnlyRoom($uid) {
//查询该用户是否绑定了房间,如果有,则返回上一次绑定的房间
$userBind = Db::name('house_user_bind')->where(['uid'=>$uid,'status'=>1,'is_lately_login'=>1])->field('house_user_bind_id,village_id,vacancy_id')->find();
if($userBind){
return $userBind;
} else {
//查询是否有房间
$userBind = Db::name('house_user_bind')->where(['uid'=>$uid,'status'=>1])->field('house_user_bind_id,village_id,vacancy_id')->find();
if($userBind){
return $userBind;
Db::name('house_user_bind')->where(['uid'=>$uid,'status'=>1])->save(['is_lately_login'=>1]);
} else {
return (Object)[];
}
}
}
//发送短信验证码
public function sendCode() {
$phone = Request::param('phone');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment