first commit
This commit is contained in:
61
unpackage/dist/dev/mp-weixin/api/http.js
vendored
Normal file
61
unpackage/dist/dev/mp-weixin/api/http.js
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../common/vendor.js");
|
||||
const utils_fun = require("../utils/fun.js");
|
||||
const proxyObj = {
|
||||
// 开发版
|
||||
development: "https://apidjk.jitujt.com",
|
||||
// development: 'http://192.168.1.62:48080',
|
||||
// development: 'http://192.168.1.191:48080',
|
||||
// 正式版
|
||||
production: "https://apidjk.jitujt.com"
|
||||
};
|
||||
const http = ({ url, params, method }) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
let Authorization = common_vendor.index.getStorageSync("Authorization") || "";
|
||||
let header = {
|
||||
Authorization,
|
||||
"Tenant-id": "134"
|
||||
};
|
||||
common_vendor.index.request({
|
||||
url: proxyObj["development"] + url,
|
||||
data: params || {},
|
||||
method: method || "POST",
|
||||
header,
|
||||
success: (res) => {
|
||||
const data = res.data;
|
||||
if (data.code == 401 || res.statusCode == 401) {
|
||||
common_vendor.index.removeStorageSync("Authorization");
|
||||
common_vendor.index.removeStorageSync("userInfo");
|
||||
common_vendor.index.showModal({
|
||||
title: "提示",
|
||||
content: `${Authorization ? "登录失效" : "你还未登录"},是否前往登录?`,
|
||||
success: function(res2) {
|
||||
if (res2.confirm) {
|
||||
common_vendor.index.navigateTo({
|
||||
url: "/pages/login/login"
|
||||
});
|
||||
} else if (res2.cancel) {
|
||||
common_vendor.index.clearStorageSync();
|
||||
common_vendor.index.__f__("log", "at api/http.ts:50", "用户点击取消");
|
||||
}
|
||||
}
|
||||
});
|
||||
reject(data);
|
||||
return;
|
||||
}
|
||||
if (data.code === 0) {
|
||||
resolve(data.data || null);
|
||||
} else {
|
||||
utils_fun.toast(data.msg);
|
||||
reject(data);
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
exports.http = http;
|
||||
exports.proxyObj = proxyObj;
|
||||
//# sourceMappingURL=../../.sourcemap/mp-weixin/api/http.js.map
|
||||
Reference in New Issue
Block a user