|
@@ -1,3 +1,4 @@
|
|
|
|
+// 引用 https://web.tianyunperfect.cn/simple/js/util.js
|
|
function lt(obj) {
|
|
function lt(obj) {
|
|
console.table(JSON.parse(JSON.stringify(obj)));
|
|
console.table(JSON.parse(JSON.stringify(obj)));
|
|
}
|
|
}
|
|
@@ -6,11 +7,6 @@ function deepClone(obj) {
|
|
return JSON.parse(JSON.stringify(obj))
|
|
return JSON.parse(JSON.stringify(obj))
|
|
}
|
|
}
|
|
|
|
|
|
-const app = {
|
|
|
|
- baseUrl: "http://www.tianyunperfect.cn:3000/mock/75",
|
|
|
|
- // baseUrl: "http://127.0.0.1:8089",
|
|
|
|
-};
|
|
|
|
-
|
|
|
|
Date.prototype.format = function (fmt) {
|
|
Date.prototype.format = function (fmt) {
|
|
const o = {
|
|
const o = {
|
|
"M+": this.getMonth() + 1, //月份
|
|
"M+": this.getMonth() + 1, //月份
|
|
@@ -41,15 +37,34 @@ axios.interceptors.response.use(function (response) {
|
|
return Promise.reject(error);
|
|
return Promise.reject(error);
|
|
});
|
|
});
|
|
|
|
|
|
-function my_alert(string) {
|
|
|
|
- $("body").prepend($(`<div id="my_alert_danger" class="my_alert alert alert-danger">${string}</div>`))
|
|
|
|
- setTimeout(()=>{
|
|
|
|
- $("#my_alert_danger").remove();
|
|
|
|
- },2000)
|
|
|
|
|
|
+// 提醒
|
|
|
|
+function my_tip(string) {
|
|
|
|
+ const div = document.createElement("div");
|
|
|
|
+ div.setAttribute("id", "my_alert_danger");
|
|
|
|
+ div.setAttribute("style", "position: fixed; width: 30%; margin-left: 30%; z-index: 2000;");
|
|
|
|
+ div.innerHTML = string;
|
|
|
|
+
|
|
|
|
+ document.body.prepend(div);
|
|
|
|
+
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ const element = document.getElementById("my_alert_danger");
|
|
|
|
+ if (element) {
|
|
|
|
+ element.parentNode.removeChild(element);
|
|
|
|
+ }
|
|
|
|
+ }, 2000)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// 发送同步请求 let a = sendSyncRequest("https://httpbin.tianyunperfect.cn/ip","GET",1)
|
|
|
|
+function sendSyncRequest(url, method, data) {
|
|
|
|
+ const xhr = new XMLHttpRequest();
|
|
|
|
+ xhr.open(method, url, false);
|
|
|
|
+
|
|
|
|
+ if (method === 'POST' || method === 'PUT') {
|
|
|
|
+ xhr.setRequestHeader('Content-Type', 'application/json');
|
|
|
|
+ xhr.send(JSON.stringify(data));
|
|
|
|
+ } else {
|
|
|
|
+ xhr.send();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return JSON.parse(xhr.responseText);
|
|
}
|
|
}
|
|
-function my_success(string) {
|
|
|
|
- $("body").prepend($(`<div id="my_alert_success" class="my_alert alert alert-success">${string}</div>`))
|
|
|
|
- setTimeout(()=>{
|
|
|
|
- $("#my_alert_success").remove();
|
|
|
|
- },2000)
|
|
|
|
-}
|
|
|