login($this->request->post()); return $this->renderSuccess('', [ 'user_id' => $user_id, 'token' => $model->getToken() ]); } /** * 当前用户详情 */ public function detail() { // 当前用户信息 $userInfo = $this->getUser(); return $this->renderSuccess('', compact('userInfo')); } public function getSession($code) { // 微信登录 获取session_key $app = AppWx::getApp(); $session_key = AppWx::sessionKey($app, $code)['session_key']; return $this->renderSuccess('', compact('session_key')); } /** * 绑定手机号 */ public function bindMobile() { $model = $this->getUser(); $mobile = $model->bindMobile($this->request->post()); if ($mobile) { return $this->renderSuccess('', compact('mobile')); } return $this->renderError('绑定失败'); } /** * 修改用户信息 */ public function updateInfo() { // 当前用户信息 $model = $this->getUser(); if ($model->edit($this->request->post())) { return $this->renderSuccess('修改成功'); } return $this->renderError($model->getError() ?: '修改失败'); } }