| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- namespace App\Http\Controllers\Api;
- use App\Services\HomeService;
- use http\Env\Response;
- use Illuminate\Http\Request;
- use PHPUnit\Util\Exception;
- class HomeController extends Controller
- {
- public $homeService;
- public function __construct()
- {
- $this->homeService = new HomeService();
- }
- /**
- * 获取位置信息,经纬度
- */
- public function get_location(Request $request){
- try {
- if(!isset($request->latitude) || $request->latitude==""){
- throw new Exception("参数错误");
- }
- if(!isset($request->longitude) || $request->longitude==""){
- throw new Exception("参数错误");
- }
- $user = auth('api')->user();
- if(!$user){
- }
- }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);//新人
- $res = $this->homeService->get_list($param);
- }catch (\Exception $exception){
- return $this->response->errorForbidden($exception->getMessage());
- }
- return response()->json($res);
- }
- }
|