RegionController.php 866 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace app\api\controller;
  3. use app\api\logic\RegionLogic;
  4. use app\api\validate\RegionValidate;
  5. /**
  6. * index
  7. * Class IndexController
  8. * @package app\api\controller
  9. */
  10. class RegionController extends BaseApiController
  11. {
  12. public array $notNeedLogin = ['index'];
  13. /**
  14. * 获取省市区
  15. * @return \think\response\Json
  16. */
  17. public function index()
  18. {
  19. $result = RegionLogic::getRegionList();
  20. return $this->data($result);
  21. }
  22. /**
  23. * 获取当前定位
  24. * @return \think\response\Json
  25. */
  26. public function get_address_location()
  27. {
  28. $params = (new RegionValidate())->goCheck('location');
  29. $result = RegionLogic::getLocation($params);
  30. if (false === $result) {
  31. return $this->fail(RegionLogic::getError());
  32. }
  33. return $this->data($result);
  34. }
  35. }