Base.php 936 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2017 https://www.sapixx.com All rights reserved.
  4. * @license Licensed (http://www.apache.org/licenses/LICENSE-2.0).
  5. * @author pillar<ltmn@qq.com>
  6. * 小程序公共API服务
  7. */
  8. namespace app\ais\controller\api;
  9. use app\common\controller\Api;
  10. use app\ais\model\AisStore;
  11. use app\ais\model\AisCity;
  12. use think\facade\Request;
  13. class Base extends Api{
  14. protected $header;
  15. protected $lbs;
  16. protected $citycode;
  17. /**
  18. * 初始化API并读取城市或你的经纬度
  19. * @return void
  20. */
  21. public function initialize() {
  22. parent::initialize();
  23. $header_lbs = Request::header('request-lbs');
  24. if(!empty($header_lbs)){
  25. $lbs = explode('/',$header_lbs);
  26. $location = new \stdClass();
  27. $location->lng = $lbs[0] ?: 0;
  28. $location->lat = $lbs[1] ?: 0;
  29. $this->lbs = $location;
  30. }
  31. }
  32. }