success = false; $e->message = 'ok'; $e->codeDuration = 70; $action = $this->request->get('action'); if ('login' == $action) { } else { } $e->success = true; return $this->renderJson($e); } /** * 注册界面 * @return string */ public function actionRegister() { $e = new stdClass(); $e->success = false; $e->message = 'ok'; $name = $this->request->post('name'); $mobile = $this->request->post('mobile'); $code = $this->request->post('code'); $img = $this->request->post('img'); if (empty($name)) { $e->message = '车厂名称必填'; return $this->renderJson($e); } if (!Utils::isPhone($mobile)) { $e->message = '手机号码格式不对'; return $this->renderJson($e); } if (empty($code)) { $e->message = '验证码必填'; return $this->renderJson($e); } if (empty($img)) { $e->message = '请上传营业执照'; return $this->renderJson($e); } // 校验验证码 // 检查车厂名称是否注册了 // 检查手机号码是否注册了 echo $name.'_'.$mobile.'_'.$code.'_'.$img; $e->success = true; return $this->renderJson($e); } /** * @return string */ public function actionLogin() { $e = new stdClass(); $e->success = false; $e->message = 'ok'; $mobile = $this->request->post('mobile'); $code = $this->request->post('code'); if (!Utils::isPhone($mobile)) { $e->message = '手机号码格式不对'; return $this->renderJson($e); } if (empty($code)) { $e->message = '验证码必填'; return $this->renderJson($e); } // 校验验证码 // 检查车厂名称是否注册了 // 检查手机号码是否注册了 $e->success = true; $userInfo = \domain\user\models\User::findOne(1); $this->processLogin($userInfo); return $this->renderJson($e); } /** * 处理用户登录逻辑 * @param User $userEntity * @return bool|void */ protected function processLogin($userEntity) { if(!($userEntity instanceof User)) { AppLog::debug("processLogin: 返回 UserEntity 失败"); return false; } /** * 登陆时间为7000秒,目前微信API的access token 的 expires_in 为 7200秒 */ if(Yii::$app->getUser()->login($userEntity, 7000)) { return true; } return false; } }