chache/packageA/utils/request.js
2024-01-22 18:48:00 +08:00

67 lines
1.8 KiB
JavaScript

!(function () {
function e() {
var e = ((65536 * (1 + Math.random())) | 0).toString(16).substring(1);
return e + e + "-" + e + "-" + e + "-" + e + "-" + e + e + e;
}
function t() {
return new Date().getTime().toString();
}
Object.defineProperty(exports, "__esModule", { value: !0 });
var n = "https://car.bigfishfarming.com/api";
(exports.getRequest = function (o, r, i) {
var a = n + o;
i || (i = {});
var u = wx.getStorageSync("userInfo");
return (
(r.uuid = e()),
(r.timestamp = t()),
new Promise(function (e, t) {
wx.request({
url: a,
method: "get",
data: Object.assign(r, u),
header: {
"Content-Type": "application/x-www-form-urlencoded",
api_key: "HPHZgKnywMe1Vifk",
},
success: function (t) {
e(t.data);
},
fail: function (e) {
t(e);
},
complete: function () {},
});
})
);
}),
(exports.postRequest = function (o, r, i) {
var a = n + o;
i || (i = {});
var u = wx.getStorageSync("userInfo");
return (
(r.uuid = e()),
(r.timestamp = t()),
console.log(r),
new Promise(function (e, t) {
wx.request({
url: a,
method: "post",
data: Object.assign(r, u),
header: {
"Content-Type": "application/x-www-form-urlencoded",
api_key: "HPHZgKnywMe1Vifk",
},
success: function (t) {
console.log(t.data), e(t.data);
},
fail: function (e) {
t(e);
},
complete: function () {},
});
})
);
});
})();