location.ftl 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <#assign title="${tittle!''}证"/>
  2. <#include "/home/frag.head.ftl" />
  3. <div class="weui-tab">
  4. <div class="weui-tab__bd">
  5. <div class="weui-tab__bd-item weui-tab__bd-item--active">
  6. <div class="page__bd">
  7. <header class="user-header">
  8. <br/>
  9. <br/>
  10. <br/>
  11. <br/>
  12. <p class="user-title-long-two">正在获取当前定位信息</p>
  13. <br/>
  14. <br/>
  15. <br/>
  16. </header>
  17. <br/>
  18. <#-- <div class="weui-form__opr-area">-->
  19. <#-- <a class="weui-btn weui-btn_primary" href="javascript:;" onclick="map();" id="map">定位</a>-->
  20. <#-- </div>-->
  21. </div>
  22. </div>
  23. </div>
  24. </div>
  25. </div>
  26. </body>
  27. <#include "/home/frag.foot2.ftl" />
  28. <script>
  29. $(document).ready(function () {
  30. map();
  31. })
  32. function map() {
  33. $.ajax({
  34. url: '/wx/jsApiConfig',
  35. type: "get",
  36. data: {
  37. "url": location.href.split('#')[0]
  38. },
  39. success: function (data) {
  40. // alert(JSON.stringify(data.data))
  41. wx.config({
  42. debug: false,
  43. appId: data.data.appId,
  44. timestamp: data.data.timestamp,
  45. nonceStr: data.data.nonceStr,
  46. signature: data.data.signature,
  47. jsApiList: [
  48. // 所有要调用的 API 都要加到这个列表中
  49. 'getLocation'
  50. ]
  51. });
  52. wx.ready(function () {
  53. wx.checkJsApi({
  54. jsApiList: [
  55. 'getLocation'
  56. ],
  57. success: function (res) {
  58. if (res.checkResult.getLocation == false) {
  59. alert('你的微信版本太低,不支持微信JS接口,请升级到最新的微信版本!');
  60. return;
  61. }
  62. getLocation();
  63. }
  64. });
  65. wx.error(function(res){
  66. alert("接口调取失败")
  67. });
  68. });
  69. },
  70. });
  71. }
  72. function getLocation() {
  73. wx.getLocation({
  74. type: 'wgs84',
  75. success: function (res) {
  76. <#--var geocoder = new qq.maps.Geocoder({-->
  77. <#-- complete: function (result) {-->
  78. <#-- // alert(result.detail.addressComponents.district)-->
  79. <#-- // alert(JSON.stringify(result.detail.address))-->
  80. <#-- window.location.href = "${url}" + res.longitude + "%2C" + res.latitude + "%26address%3D" + result.detail.address + "${moreUrl}";-->
  81. <#-- }-->
  82. <#--})-->
  83. <#--var coord = new qq.maps.LatLng(res.latitude, res.longitude)-->
  84. <#--// alert(coord);-->
  85. <#--geocoder.getAddress(coord)-->
  86. window.location.href = "${url}" + res.longitude + "%2C" + res.latitude + "%26address%3D" + "${moreUrl}";
  87. // alert(JSON.stringify(coord));
  88. <#--window.location.href = "${url}" + res.longitude + "%2C" + res.latitude + "${moreUrl}";-->
  89. },
  90. cancel: function (res) {
  91. alert('用户拒绝授权获取地理位置');
  92. }
  93. });
  94. }
  95. </script>