location.html 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>location</title>
  6. <script src="js/axios.min.js"></script>
  7. </head>
  8. <body>
  9. <script>
  10. Date.prototype.format = function (fmt) {
  11. var o = {
  12. "M+": this.getMonth() + 1, //月份
  13. "d+": this.getDate(), //日
  14. "h+": this.getHours(), //小时
  15. "m+": this.getMinutes(), //分
  16. "s+": this.getSeconds(), //秒
  17. "q+": Math.floor((this.getMonth() + 3) / 3), //季度
  18. "S": this.getMilliseconds() //毫秒
  19. };
  20. if (/(y+)/.test(fmt)) {
  21. fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  22. }
  23. for (var k in o) {
  24. if (new RegExp("(" + k + ")").test(fmt)) {
  25. fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  26. }
  27. }
  28. return fmt;
  29. }
  30. navigator.geolocation.getCurrentPosition(function (position) {
  31. let longitude = position.coords.longitude;
  32. let latitude = position.coords.latitude;
  33. axios.post("https://api.tianyunperfect.cn/web_history/location_history", {
  34. "location_str": "",
  35. "location_xy": longitude + "-" + latitude,
  36. "msg": "",
  37. "create_time": new Date().format('yyyy-MM-dd hh:mm:ss'),
  38. "update_time": new Date().format('yyyy-MM-dd hh:mm:ss')
  39. }).then(res => {
  40. if (res.data.code === 1) {
  41. window.close();
  42. }
  43. });
  44. }, function (error) {
  45. alert(error.message);
  46. }, {
  47. timeout: 90000
  48. });
  49. </script>
  50. </body>
  51. </html>