homeService = new HomeService(); } /** * 获取位置信息,经纬度 */ public function get_location(Request $request){ dd(RedisService::redis()->get('user_location_'.$request->uniqueID)); try { if(!isset($request->latitude) || $request->latitude==""){ throw new Exception("参数错误"); } if(!isset($request->longitude) || $request->longitude==""){ throw new Exception("参数错误"); } if(!isset($request->uniqueID) || $request->uniqueID==""){ throw new Exception("参数错误"); } $user = auth('api')->user(); if(!$user){ RedisService::redis()->SETEX('user_location_' . $request->uniqueID, 600, json_encode(['latitude' => $request->latitude, 'longitude' => $request->longitude])); } }catch (\Exception $exception){ return $this->response->errorForbidden($exception->getMessage()); } return response()->json(['message'=>"请求成功"]); } /** * 返回首页信息 * @param Request $request * @return \Illuminate\Http\JsonResponse|void */ public function home(Request $request){ try { $param['keyword'] = $request->post('keyword','');//关键词,昵称,标签 $param['nearby'] = $request->post('nearby',1);//附近 $param['online'] = $request->post('online',1);//在线 $param['new'] = $request->post('new',1);//新人 $param['latitude'] = $request->post('latitude','30.663436');//纬度 $param['longitude'] = $request->post('longitude','104.072224');//经度 $res = $this->homeService->get_list($param); }catch (\Exception $exception){ return $this->response->errorForbidden($exception->getMessage()); } return response()->json($res); } public function user_detail(Request $request){ try { $res = $this->homeService->user_detail($request->user_id); }catch (\Exception $exception){ return $this->response->errorForbidden($exception->getMessage()); } return response()->json($res); } }