hot.html 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
  7. <!-- <link rel="stylesheet" href="https://a.amap.com/jsapi_demos/static/demo-center/css/demo-center.css" /> -->
  8. <style>
  9. * {
  10. -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  11. -webkit-tap-highlight-color: transparent;
  12. margin: 0;
  13. padding: 0;
  14. }
  15. .chart {
  16. width: 100vw;
  17. height: 100vh;
  18. }
  19. #container {
  20. margin: 0;
  21. padding: 0;
  22. width: 100vw;
  23. height: 100vh;
  24. }
  25. .title {
  26. text-align: center;
  27. font-size: 16px;
  28. font-weight: bold;
  29. margin: 20px 0;
  30. }
  31. .hot {
  32. width: 100vw;
  33. height: 100vh;
  34. margin: 0 auto;
  35. position: relative;
  36. }
  37. .amap-labels {
  38. width: 100% !important;
  39. }
  40. .tab {
  41. width: 100%;
  42. position: absolute;
  43. top: 5%;
  44. left: 0;
  45. z-index: 9999;
  46. }
  47. .tabCon {
  48. width: 55%;
  49. margin: 0 auto;
  50. outline: none;
  51. text-align: center;
  52. height: 32px;
  53. line-height: 32px;
  54. display: flex;
  55. justify-content: space-around;
  56. }
  57. .tabCon text {
  58. font-size: 14px;
  59. width: 50%;
  60. color: #64efda;
  61. height: 100%;
  62. background-color: #fff;
  63. border: 1px solid #64efda;
  64. }
  65. .tabCon .active {
  66. background: #64efda;
  67. color: #fff;
  68. }
  69. .tabCon text:first-child {
  70. border-top-left-radius: 15px;
  71. border-bottom-left-radius: 15px;
  72. }
  73. .tabCon text:last-child {
  74. border-top-right-radius: 15px;
  75. border-bottom-right-radius: 15px;
  76. }
  77. .drop {
  78. width: 100px;
  79. height: 30px;
  80. position: absolute;
  81. bottom: 5%;
  82. right: 5%;
  83. z-index: 9999;
  84. border-radius: 15px;
  85. background: #64efda;
  86. }
  87. select {
  88. width: 100%;
  89. height: 100%;
  90. border-radius: 50%;
  91. font-size: 14px;
  92. padding-left: 15px;
  93. overflow: hidden;
  94. white-space: nowrap;
  95. text-overflow: ellipsis;
  96. appearance: none;
  97. -moz-appearance: none;
  98. -webkit-appearance: none;
  99. outline: none;
  100. border: none;
  101. background: #64efda;
  102. color: #fff;
  103. }
  104. img {
  105. width: 16px;
  106. height: 16px;
  107. vertical-align: middle;
  108. }
  109. </style>
  110. </head>
  111. <body>
  112. <div class="chart">
  113. <div class="hot">
  114. <div class="tab">
  115. <div class="tabCon">
  116. <text class="active" id="1">扫码热力图</text>
  117. <text id="2">停车热力图</text>
  118. </div>
  119. </div>
  120. <div class="drop">
  121. <select id="choose"></select>
  122. </div>
  123. <div id="container"></div>
  124. </div>
  125. <!-- <div class="user">
  126. <div class="title">用户数据</div>
  127. <div id="user"></div>
  128. </div>
  129. <div class="block"></div>
  130. <div class="orderCount">
  131. <div class="title">订单数据</div>
  132. <div id="orderCount"></div>
  133. </div> -->
  134. </div>
  135. <script src="https://webapi.amap.com/maps?v=1.4.15&key=bd75d5583e6e04663da170715ff52b3d"></script>
  136. <script src="https://a.amap.com/jsapi_demos/static/resource/heatmapData.js"></script>
  137. <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.0/jquery.min.js"></script>
  138. <script src="https://cdn.bootcdn.net/ajax/libs/echarts/4.7.0/echarts.js"></script>
  139. <script>
  140. // let baseUrl = "https://admin.weilaibike.dev.hanyiyun.com/app-api/" //测试
  141. let baseUrl = "https://admin.weilaibike.com/app-api/" //线上
  142. var map = new AMap.Map("container", {
  143. resizeEnable: true,
  144. center: [116.418261, 39.921984],
  145. zoom: 11
  146. });
  147. var heatmap;
  148. setTimeout(() => {
  149. var map = new AMap.Map("container", {
  150. resizeEnable: true,
  151. center: [116.418261, 39.921984],
  152. zoom: 11
  153. });
  154. map.plugin('AMap.Geolocation', function () {
  155. geolocation = new AMap.Geolocation({
  156. enableHighAccuracy: true, //是否使用高精度定位,默认:true
  157. timeout: 10000, //超过10秒后停止定位,默认:无穷大
  158. buttonOffset: new AMap.Pixel(10, 20), //定位按钮与设置的停靠位置的偏移量,默认:Pixel(10, 20)
  159. zoomToAccuracy: true, //定位成功后调整地图视野范围使定位位置及精度范围视野内可见,默认:false
  160. // buttonPosition: 'RB'
  161. });
  162. map.addControl(geolocation);
  163. geolocation.getCurrentPosition();
  164. AMap.event.addListener(geolocation, 'complete', onComplete); //返回定位信息
  165. AMap.event.addListener(geolocation, 'error', onError); //返回定位出错信息
  166. function onComplete(data) {
  167. var str = [];
  168. str.push(data.position.getLat());
  169. str.push(data.position.getLng());
  170. }
  171. });
  172. map.plugin(["AMap.Heatmap"], function () {
  173. //初始化heatmap对象
  174. heatmap = new AMap.Heatmap(map, {
  175. radius: 25, //给定半径
  176. opacity: [0, 0.8],
  177. });
  178. });
  179. // var url = 'https://mp.weixin.qq.com/wxamp/user/manage?action=index&use_role=1&token=1418778091&lang=zh_CN'
  180. $.ajax({
  181. url: baseUrl + 'index',
  182. method: 'GET',
  183. data: {
  184. // token:'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvYWRtaW4ud2VpbGFpYmlrZS5jb21cL2FwcC1hcGlcL2F1dGhcL2xvZ2luIiwiaWF0IjoxNTkwOTk0Mjg3LCJleHAiOjE1OTExNjcwODcsIm5iZiI6MTU5MDk5NDI4NywianRpIjoiaGZ4REtZZDlwMVFJVm55UyIsInN1YiI6MjYsInBydiI6ImM4MjkyMjM4MzVkMTExMzhmMDhhY2U1NmZmYTY2MjhiYzI2ODNjYjUifQ.Ai_n-Wy5r_onKdYfHghcLwaGOeWAQtRF0VbhjSaIcsA',
  185. token:getUrlParam('token')
  186. },
  187. success: function (res) {
  188. var areas = res.wx_area;
  189. for (var i = 0; i < areas.length; i++) {
  190. var $select = $("#choose");
  191. $select.append('<option value=' + areas[i].areaID + ' >' + areas[i].text + '</option>');
  192. }
  193. initData(areas[0].areaID);
  194. }
  195. })
  196. }, 3000);
  197. //解析定位结果
  198. function getUrlParam(name) {
  199. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
  200. var r = window.location.search.substr(1).match(reg); //匹配目标参数
  201. if (r != null) return decodeURIComponent(r[2]); return null; //返回参数值
  202. }
  203. function initData(id) {
  204. // 热力图
  205. console.log('初始化')
  206. $.ajax({
  207. url: baseUrl + 'order/heatMap',
  208. method: 'GET',
  209. data: {
  210. area_id: id,
  211. // area_id: 1
  212. },
  213. success: function (res) {
  214. console.log(res)
  215. // alert(res)
  216. var point = res.start;
  217. heatmap.setDataSet({
  218. data: point,
  219. max: 100
  220. });
  221. }
  222. })
  223. }
  224. //获取区域
  225. //筛选区域
  226. $('#choose').change(function (e) {
  227. var id = $("#choose ").val()
  228. initData(id);
  229. })
  230. // tab切换
  231. $('text').click(function (e) {
  232. console.log(e)
  233. $(this).attr('class', 'active');
  234. $(this).siblings().attr("class", "")
  235. let cur = e.target.id;
  236. $.ajax({
  237. url: baseUrl + 'order/heatMap',
  238. method: 'GET',
  239. data: {
  240. area_id: $("#choose ").val()
  241. },
  242. success: function (res) {
  243. var point = ''
  244. if (cur == 1) {
  245. point = res.start
  246. } else {
  247. point = res.end
  248. }
  249. heatmap.setDataSet({
  250. data: point,
  251. max: 100
  252. });
  253. }
  254. })
  255. })
  256. </script>
  257. </body>
  258. </html>