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

音频

... ... @@ -338,7 +338,27 @@ class Member extends WechatBase
}
$this->success('success');
}
public function getCity(){
$url = "https://restapi.amap.com/v3/geocode/regeo?parameters";
public function get_city(){
$longitude = $this->request->param('longitude');
$latitude = $this->request->param('latitude');
if(empty($longitude) || empty($latitude)){
$this->error('404');
}
$url = "https://apis.map.qq.com/ws/geocoder/v1/?location= $latitude,$longitude";
$result = self::http_get($url);
$data = json_decode($result,true);
dump($data);
}
public static function http_get($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
$result = curl_exec($ch);
// grab URL, and print
if(curl_errno($ch)){
print curl_error($ch);
}
curl_close($ch);
return $result;
}
}
\ No newline at end of file
... ...
... ... @@ -64,7 +64,6 @@
{include file="public/js" /}
<script src="__CDN__/assets/advertising/mui/mui.min.js"></script>
<script src="__CDN__/assets/advertising/mui/mui.picker.min.js"></script>
<script src="__CDN__/assets/advertising/js/qqmap-wx-jssdk.js"></script>
<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
<script>
$(function(){
... ... @@ -134,16 +133,20 @@
function success(data) {
lat = data.latitude; //经度
lng = data.longitude; //纬度
var qqmapsdk = new QQMapWX({
key: 'PWEBZ-YJVWK-KAYJ2-ATH6Y-I7D35-GZFGU' //这里自己的key秘钥进行填充
});
qqmapsdk.reverseGeocoder({
location: {
latitude: lat,
longitude: lng
//保存到用户表
$.ajax({
url:"{:url('home/member/get_city')}",
type:"POST",
data:{'user_id':user_id,'longitude':lng,'latitude':lat},
success:function(res){
if(res.code == 1){
toast('定位成功');
}else{
toast('定位失败');
}
},
success: function(res) {
console.log(res);
error:function(res){
toast('与服务器断开连接')
}
});
}
... ...