• 微信公众号,获取定位


    <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>
    

      

  • 相关阅读:
    `cd -`
    .git文件夹过大的解决方法
    避免对函数参数的修改
    2020年10月 修改Ant Design Pro底部版权信息的方法
    度目-人脸应用套件 文档中的坑
    "A little like that j-thing"
    Linux安装MySQL后设置密码
    append对len和cap的影响
    s := []int{0, 1, 2, 3, 8: 100}
    Python学习笔记
  • 原文地址:https://www.cnblogs.com/microtiger/p/12955827.html
Copyright © 2020-2023  润新知