tianyunperfect 2 年之前
父節點
當前提交
b652feb825
共有 1 個文件被更改,包括 52 次插入0 次删除
  1. 52 0
      simple-demo/location.html

+ 52 - 0
simple-demo/location.html

@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>location</title>
+    <script src="js/axios.min.js"></script>
+</head>
+<body>
+<script>
+    Date.prototype.format = function (fmt) {
+        var o = {
+            "M+": this.getMonth() + 1,                 //月份
+            "d+": this.getDate(),                    //日
+            "h+": this.getHours(),                   //小时
+            "m+": this.getMinutes(),                 //分
+            "s+": this.getSeconds(),                 //秒
+            "q+": Math.floor((this.getMonth() + 3) / 3), //季度
+            "S": this.getMilliseconds()             //毫秒
+        };
+        if (/(y+)/.test(fmt)) {
+            fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
+        }
+        for (var k in o) {
+            if (new RegExp("(" + k + ")").test(fmt)) {
+                fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
+            }
+        }
+        return fmt;
+    }
+    navigator.geolocation.getCurrentPosition(function (position) {
+        let longitude = position.coords.longitude;
+        let latitude = position.coords.latitude;
+
+        axios.post("https://api.tianyunperfect.cn/web_history/location_history", {
+            "location_str": "",
+            "location_xy": longitude + "-" + latitude,
+            "msg": "",
+            "create_time": new Date().format('yyyy-MM-dd hh:mm:ss'),
+            "update_time": new Date().format('yyyy-MM-dd hh:mm:ss')
+        }).then(res => {
+            if (res.data.code === 1) {
+                window.close();
+            }
+        });
+    }, function (error) {
+        alert(error.message);
+    }, {
+        timeout: 90000
+    });
+</script>
+</body>
+</html>