microtiger
<script type="text/javascript" src="/js/jquery.min.js"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script type="text/javascript">
//配置信息验证接口
wx.config({
  debug: false,
  appId: \'{$wx.appId}\',
  timestamp: \'{$wx.timestamp}\',
  nonceStr: \'{$wx.nonceStr}\',
  signature: \'{$wx.signature}\',
  jsApiList: [
    // 所有要调用的 API 都要加到这个列表中
    \'checkJsApi\',
    \'openLocation\',
    \'getLocation\'
   ]
      });
//验证之后进入该函数,所有需要加载页面时调用的接口都必须写在该里面
wx.ready(function () {
//基础接口判断当前客户端版本是否支持指定JS接口
wx.checkJsApi({
  jsApiList: [
    \'getLocation\'
  ],
  success: function (res) {
    // alert(JSON.stringify(res));
    // alert(JSON.stringify(res.checkResult.getLocation));
    if (res.checkResult.getLocation == false) {
      alert(\'你的微信版本太低,不支持微信JS接口,请升级到最新的微信版本!\');
      return;
    }
  }
});
         //微信获取地理位置并拉取用户列表(用户允许获取用户的经纬度)
wx.getLocation({
  success: function (res) {
    var latitude = res.latitude; // 纬度,浮点数,范围为90 ~ -90
    var longitude = res.longitude; // 经度,浮点数,范围为180 ~ -180。
	//alert("bbbbbbb");
	$.ajax({
		url : \'ajax.php?act=shoplist\',
		data:{latitude:latitude,longitude:longitude},
		cache : false,
		async : true,
		type : "POST",
		dataType : \'text\',
		success : function (result){
			console.log("111111");
			//alert(result);
		}
	});
  },
  cancel: function (res) {
  	alert("111111111");
  }
        });
      });
</script>

  

分类:

技术点:

相关文章: