objMUserCenterLogin = new MUserCenterLogin(); $this->SmsVerification = new SmsVerification(); } /** * 用户中心登陆 */ public function login() { //接收参数 $params = $this->request->getRawJson(); if(empty($params)){ parent::sendOutput('参数为空', ErrorCode::$paramError); } $userData = [ 'mobile' => isset($params['mobile']) ? trim($params['mobile']) : '', 'password' => isset($params['password']) ? $params['password'] : '', ]; //校验参数 foreach($userData as $key => $value){ if(empty($value) && $value !== 0){ parent::sendOutput($key.'参数错误', ErrorCode::$paramError); } } //source判断登录来源 1:后台管理员,员工 2:供应商 3:商户 $userData['source'] = isset($params['source']) ? $params['source'] : 1; $result = $this->objMUserCenterLogin->login($userData); if ($result->isSuccess()) { parent::sendOutput($result->getData()); } else { parent::sendOutput($result->getData(), $result->getErrorCode()); } } /** * 选择企业后生成AUTHORIZATION */ public function createToken() { $params = $this->request->getRawJson(); if(empty($params)){ parent::sendOutput('参数为空', ErrorCode::$paramError); } $userInfo = [ 'id' => isset($params['userCenterId']) ? $params['userCenterId'] : '', ]; foreach($userInfo as $key => $value){ if(empty($value)){ parent::sendOutput($key.'参数错误', ErrorCode::$paramError); } } $result = $this->objMUserCenterLogin->createToken($userInfo); parent::sendOutput($result); } }