authService = $authService; $this->memberService = $memberService; $this->smsService = $smsService; $this->registerService = $registerService; $this->memberInfoRepository = $memberInfoRepository; $this->smsRepository = $smsRepository; } public function loginByAccount(AuthValidatorRequest $request) { if (!$member=$this->authService->loginByAccount($request->account, $request->password, $request->autoLogin)) { return $this->sendErrorResponse("用户名或密码错误"); } if ($member->status == 0) { Auth::guard('web-member')->logout(); return $this->sendErrorResponse("你的账号处于封禁状态, 请联系管理员"); } return $this->sendSuccessResponse(['redirect_url'=>url($request->session()->pull('url.intended', route('hardware.aio.index')))]); } public function login() { return view('app.hardware.aio.login'); } public function account() { return view('app.hardware.aio.account'); } public function card() { return view('app.hardware.aio.card'); } public function check(Request $request) { $cardno = $request->cardno; if (!$cardno) { throw new ResponseException('身份证读取失败!'); } $memberInfo = MemberInfo::where(['id_card'=>$cardno])->first(); if (!$memberInfo && config('aix.system.register.register.close_reg') == 0) { return $this->sendSuccessResponse(['status'=>0,'id_card'=>$cardno]); } elseif(!$memberInfo && config('aix.system.register.register.close_reg') == 1) { return $this->sendSuccessResponse(['status'=>-1]); } $member = Member::find($memberInfo->uid); $this->authService->login($member, 1); return $this->sendSuccessResponse(['status'=>1,'redirect_url'=>url($request->session()->pull('url.intended', route('hardware.aio.index')))]); } public function register(Request $request) { if($request->ajax()) { if(config('aix.system.register.register.close_reg') == 1) { throw new ResponseException('网站暂停会员注册,请稍后再次尝试!'); }else{ return $this->sendSuccessResponse(['redirect_url'=>url($request->session()->pull('url.intended', route('hardware.aio.register')))]); } } $data = $request->all(); return view('app.hardware.aio.register',['data'=>$data]); } public function logout() { $this->authService->logout(); return redirect(route('hardware.aio.index')); } public function loginMobile(AuthValidatorRequest $request) { if (empty($this->smsRepository->getSmsStatus())) { return $this->sendErrorResponse("error",["info"=>"短信发送失败,网站短信通道未开启"],200); } $this->memberService->loginMobile($request->mobile, $request->type); $this->smsService->sendAuthSms($request->mobile, Smser::TEMPLATE_AUTH_LOGIN); return $this->sendSuccessResponse('发送成功!'); } public function loginMobileRe(AuthValidatorRequest $request) { if (empty($this->smsRepository->getSmsStatus())) { return $this->sendErrorResponse("error",["info"=>"短信发送失败,网站短信通道未开启"],200); } $res = $this->registerService->checkUnique($request->type,'mobile',$request->mobile); if(!$res){ throw new ResponseException('该手机号已被其它账号绑定'); } $this->smsService->sendAuthSms($request->mobile, Smser::TEMPLATE_AUTH_LOGIN); return $this->sendSuccessResponse('发送成功!'); } public function loginMobileCreate(AuthValidatorRequest $request) { $mobile_code = $request->mobile_code; $mobile = $request->mobile; $checkAuthSms = $this->smsService->checkAuthSms($mobile, Smser::TEMPLATE_AUTH_LOGIN, $mobile_code); if (!$checkAuthSms) { throw new ResponseException('验证码错误!'); } $user = Member::where(['mobile'=>$mobile])->first(); $this->authService->login($user, 1); return $this->sendSuccessResponse(['redirect_url'=>url($request->session()->pull('url.intended', route('hardware.aio.index')))]); } public function registerMobile(AuthValidatorRequest $request) { $mobile_code = $request->mobile_code; $mobile = $request->mobile; if(config('aix.system.register.register.close_reg') == 1) { throw new ResponseException('网站暂停会员注册,请稍后再次尝试!'); } $checkAuthSms = $this->smsService->checkAuthSms($mobile, Smser::TEMPLATE_AUTH_LOGIN, $mobile_code); if (!$checkAuthSms) { throw new ResponseException('验证码错误!'); } DB::beginTransaction();//检查数据库事务 try { $member = $this->memberService->registerMobile($mobile); if($request->id_card){ $memberinfo['id_card'] = $request->id_card; $memberinfo['uid'] = $member->id; $memberinfo['sex'] = $request->sex; $memberinfo['realname'] = $request->name; $memberinfo['phone'] = $request->mobile; $memberinfo['id_card'] = $request->id_card; $memberinfo['card_t_cn'] = 306; $memberinfo['birthday'] = get_birthday($request->id_card); $this->memberInfoRepository->createInfo($memberinfo); } DB::commit(); $this->authService->login($member, 1); return $this->sendSuccessResponse(['redirect_url'=>url($request->session()->pull('url.intended', route('hardware.aio.resume.create')))]); }catch (\Exception $e) { DB::rollback(); throw new ResponseException($e->getMessage()); } } }