Files
tk-mini-program/unpackage/dist/dev/mp-weixin/components/request.js

62 lines
2.1 KiB
JavaScript
Raw Normal View History

2025-05-15 22:24:39 +08:00
"use strict";
const common_vendor = require("../common/vendor.js");
function request(urldata) {
const { url, data, method, header, userInfo } = urldata;
2025-05-30 22:04:45 +08:00
const baseUrl = "http://120.26.251.180:8086/" + url;
2025-05-15 22:24:39 +08:00
if (userInfo) {
2025-05-21 22:52:33 +08:00
return new Promise((resolve, reject) => {
common_vendor.index.getStorage({
key: "userinfo",
success: (res) => {
if (res.data) {
if (res.data.nickName) {
2025-05-15 22:24:39 +08:00
common_vendor.index.request({
url: baseUrl,
data,
method,
header,
success: function(res2) {
2025-05-30 22:04:45 +08:00
common_vendor.index.__f__("log", "at components/request.js:18", "请求成功1", res2.data);
2025-05-15 22:24:39 +08:00
resolve(res2.data);
},
fail: function(res2) {
reject(res2);
}
});
2025-05-21 22:52:33 +08:00
} else {
2025-05-22 22:05:55 +08:00
common_vendor.index.setStorageSync("lastPage", getCurrentPages()[getCurrentPages().length - 1].route);
2025-05-21 22:52:33 +08:00
common_vendor.index.reLaunch({ url: "/pages/UserInformation/UserInformation" });
}
2025-05-15 22:24:39 +08:00
} else {
2025-05-22 22:05:55 +08:00
common_vendor.index.setStorageSync("lastPage", getCurrentPages()[getCurrentPages().length - 1].route);
2025-05-21 22:52:33 +08:00
common_vendor.index.navigateTo({ url: "/pages/login/login" });
2025-05-15 22:24:39 +08:00
}
2025-05-21 22:52:33 +08:00
},
fail: function(res) {
2025-05-22 22:05:55 +08:00
common_vendor.index.setStorageSync("lastPage", getCurrentPages()[getCurrentPages().length - 1].route);
common_vendor.index.navigateTo({ url: "/pages/login/login" });
2025-05-21 22:52:33 +08:00
reject(res);
2025-05-15 22:24:39 +08:00
}
2025-05-21 22:52:33 +08:00
});
2025-05-15 22:24:39 +08:00
});
} else {
return new Promise((resolve, reject) => {
common_vendor.index.request({
url: baseUrl,
data,
method,
header,
success: function(res) {
2025-05-30 22:04:45 +08:00
common_vendor.index.__f__("log", "at components/request.js:49", "请求成功2", res);
2025-05-15 22:24:39 +08:00
resolve(res.data);
},
fail: function(res) {
reject(res);
}
});
});
}
}
exports.request = request;
//# sourceMappingURL=../../.sourcemap/mp-weixin/components/request.js.map