login($phone,$password); HelpHander::success($ret); } public function autologin(){ $token = input('token'); $userId = input('userId'); if(empty($token) || empty($userId)){ HelpHander::error('登录信息已失效',100200); } $tokeninfo = Db::name('token') ->where('code',$token) ->where('user_id',$userId) ->find(); if(!$tokeninfo){ HelpHander::error('登录信息已失效',100200); } // 检查用户是否被禁用 $user = Db::name('user')->where('id',$userId)->find(); if(!$user || $user['enable'] == 0 || $user['del'] == 1){ HelpHander::error('登录信息已失效',100200); } // 检查点餐用户是否存在 $duser = Db::name('dinner_user')->where('phone',$user['phone'])->where('del',0)->find(); if(!$duser || $duser['enable'] != 1){ HelpHander::error('未注册点餐系统,请联系管理员',100200); } $token = md5($user['id'].'-'.time().rand(1000,9999)); $ret = Db::name('dinner_user')->where('id',$duser['id'])->update([ 'login_time' => date('Y-m-d H:i:s'), 'token' => $token ]); if(!$ret){ HelpHander::error('登录失败',100200); } HelpHander::success(['user_id' => $duser['id'], 'token' => $token]); } public function updatePwd(){ $phone = input('mobile','','trim'); $password = input('newPassword','','trim'); $code = input('code','','trim'); model('User')->forgetPassword($phone,$password,$code); HelpHander::success([],'修改成功'); } }