作者 王晓刚
1 个管道 的构建 通过 耗费 1 秒

音频

@@ -338,7 +338,27 @@ class Member extends WechatBase @@ -338,7 +338,27 @@ class Member extends WechatBase
338 } 338 }
339 $this->success('success'); 339 $this->success('success');
340 } 340 }
341 - public function getCity(){  
342 - $url = "https://restapi.amap.com/v3/geocode/regeo?parameters"; 341 + public function get_city(){
  342 + $longitude = $this->request->param('longitude');
  343 + $latitude = $this->request->param('latitude');
  344 + if(empty($longitude) || empty($latitude)){
  345 + $this->error('404');
  346 + }
  347 + $url = "https://apis.map.qq.com/ws/geocoder/v1/?location= $latitude,$longitude";
  348 + $result = self::http_get($url);
  349 + $data = json_decode($result,true);
  350 + dump($data);
  351 + }
  352 + public static function http_get($url){
  353 + $ch = curl_init();
  354 + curl_setopt($ch, CURLOPT_URL,$url);
  355 + curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
  356 + $result = curl_exec($ch);
  357 + // grab URL, and print
  358 + if(curl_errno($ch)){
  359 + print curl_error($ch);
  360 + }
  361 + curl_close($ch);
  362 + return $result;
343 } 363 }
344 } 364 }
@@ -64,7 +64,6 @@ @@ -64,7 +64,6 @@
64 {include file="public/js" /} 64 {include file="public/js" /}
65 <script src="__CDN__/assets/advertising/mui/mui.min.js"></script> 65 <script src="__CDN__/assets/advertising/mui/mui.min.js"></script>
66 <script src="__CDN__/assets/advertising/mui/mui.picker.min.js"></script> 66 <script src="__CDN__/assets/advertising/mui/mui.picker.min.js"></script>
67 - <script src="__CDN__/assets/advertising/js/qqmap-wx-jssdk.js"></script>  
68 <script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script> 67 <script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
69 <script> 68 <script>
70 $(function(){ 69 $(function(){
@@ -134,16 +133,20 @@ @@ -134,16 +133,20 @@
134 function success(data) { 133 function success(data) {
135 lat = data.latitude; //经度 134 lat = data.latitude; //经度
136 lng = data.longitude; //纬度 135 lng = data.longitude; //纬度
137 - var qqmapsdk = new QQMapWX({  
138 - key: 'PWEBZ-YJVWK-KAYJ2-ATH6Y-I7D35-GZFGU' //这里自己的key秘钥进行填充  
139 - });  
140 - qqmapsdk.reverseGeocoder({  
141 - location: {  
142 - latitude: lat,  
143 - longitude: lng 136 + //保存到用户表
  137 + $.ajax({
  138 + url:"{:url('home/member/get_city')}",
  139 + type:"POST",
  140 + data:{'user_id':user_id,'longitude':lng,'latitude':lat},
  141 + success:function(res){
  142 + if(res.code == 1){
  143 + toast('定位成功');
  144 + }else{
  145 + toast('定位失败');
  146 + }
144 }, 147 },
145 - success: function(res) {  
146 - console.log(res); 148 + error:function(res){
  149 + toast('与服务器断开连接')
147 } 150 }
148 }); 151 });
149 } 152 }