request.js
977 字节
"use strict";
var common_vendor = require("../common/vendor.js");
const baseURL = "http://health.shs.broing.cn";
const request = (options) => {
return new Promise((resolve, reject) => {
common_vendor.index.request({
url: baseURL + options.url,
method: options.method || "GET",
data: options.data || {},
header: {
"token": common_vendor.index.getStorageSync("token") || ""
},
success: (res) => {
console.log(res, common_vendor.index.getStorageSync("token"));
if (res.data.code == 1) {
resolve(res.data.data);
} else {
if (res.data.code == 401) {
common_vendor.index.navigateTo({
url: "/pages/login/login"
});
common_vendor.index.clearStorageSync();
}
reject(res.data.msg);
}
},
fail: (err) => {
console.log(err);
reject(err);
}
});
});
};
exports.request = request;