Base.php 971 B

123456789101112131415161718192021222324252627282930313233
  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\allwin\controller\api;
  9. use app\common\controller\Api;
  10. use think\facade\Request;
  11. class Base extends Api{
  12. protected $header;
  13. protected $lng; //经度
  14. protected $lat; //纬度
  15. protected $qqgps;
  16. /**
  17. * 初始化API并读取城市或你的经纬度,把QQ经纬度转换成百度经纬度
  18. * @return void
  19. */
  20. public function initialize() {
  21. parent::initialize();
  22. $header = Request::header();
  23. if(!empty($header['request-gps'])){
  24. $qq = explode('/',$header['request-gps']);
  25. $this->lat = empty($qq[0])? 0 : $qq[0];
  26. $this->lng = empty($qq[1])? 0 : $qq[1];
  27. $this->qqgps = txMap_to_bdMap($this->lat,$this->lng);
  28. }
  29. }
  30. }