|
@@ -6,7 +6,8 @@
|
|
<script src="js/axios.min.js"></script>
|
|
<script src="js/axios.min.js"></script>
|
|
</head>
|
|
</head>
|
|
<body>
|
|
<body>
|
|
-<h1 id="msg"></h1>
|
|
|
|
|
|
+<textarea id="msg" style="width: 100%;" rows="3"></textarea>
|
|
|
|
+<h1 id="tip">2秒内发送</h1>
|
|
<script>
|
|
<script>
|
|
Date.prototype.format = function (fmt) {
|
|
Date.prototype.format = function (fmt) {
|
|
var o = {
|
|
var o = {
|
|
@@ -28,10 +29,39 @@
|
|
}
|
|
}
|
|
return fmt;
|
|
return fmt;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ let longitude;
|
|
|
|
+ let latitude;
|
|
|
|
+ let status = false;
|
|
|
|
+
|
|
navigator.geolocation.getCurrentPosition(function (position) {
|
|
navigator.geolocation.getCurrentPosition(function (position) {
|
|
- let longitude = position.coords.longitude;
|
|
|
|
- let latitude = position.coords.latitude;
|
|
|
|
|
|
+ longitude = position.coords.longitude;
|
|
|
|
+ latitude = position.coords.latitude;
|
|
|
|
+ }, function (error) {
|
|
|
|
+ alert(error.message);
|
|
|
|
+ }, {
|
|
|
|
+ timeout: 90000
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ if (status === false) {
|
|
|
|
+ sendMsg();
|
|
|
|
+ }
|
|
|
|
+ }, 2000)
|
|
|
|
+
|
|
|
|
+ function setTip(str) {
|
|
|
|
+ document.querySelector('#tip').innerHTML = str;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ document.querySelector("#msg").onfocus = function () {
|
|
|
|
+ status = true;
|
|
|
|
+ setTip('点击发送');
|
|
|
|
+ document.querySelector("#tip").onclick = function () {
|
|
|
|
+ sendMsg();
|
|
|
|
+ };
|
|
|
|
+ };
|
|
|
|
|
|
|
|
+ function sendMsg() {
|
|
axios.post("https://api.tianyunperfect.cn/web_history/location_history", {
|
|
axios.post("https://api.tianyunperfect.cn/web_history/location_history", {
|
|
"location_str": "",
|
|
"location_str": "",
|
|
"location_xy": longitude + "-" + latitude,
|
|
"location_xy": longitude + "-" + latitude,
|
|
@@ -40,15 +70,16 @@
|
|
"update_time": new Date().format('yyyy-MM-dd hh:mm:ss')
|
|
"update_time": new Date().format('yyyy-MM-dd hh:mm:ss')
|
|
}).then(res => {
|
|
}).then(res => {
|
|
if (res.data.code === 1) {
|
|
if (res.data.code === 1) {
|
|
- window.close();
|
|
|
|
- document.querySelector("#msg").innerHTML = "OK";
|
|
|
|
|
|
+ // window.close();
|
|
|
|
+ if (longitude === undefined) {
|
|
|
|
+ setTip("发送成功,但是没有经纬度");
|
|
|
|
+ } else {
|
|
|
|
+ setTip("发送成功");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
});
|
|
});
|
|
- }, function (error) {
|
|
|
|
- alert(error.message);
|
|
|
|
- }, {
|
|
|
|
- timeout: 90000
|
|
|
|
- });
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
</script>
|
|
</script>
|
|
</body>
|
|
</body>
|
|
</html>
|
|
</html>
|