"use strict"; const common_vendor = require("../common/vendor.js"); const utils_config = require("./config.js"); const utils_pageUrl = require("./pageUrl.js"); const request = (url, data = {}, method = "post", loading = false, contentType = "application/x-www-form-urlencoded") => { if (loading) { common_vendor.index.showLoading({ title: "加载中", mask: true }); } let token = ""; { const { envVersion } = common_vendor.index.getAccountInfoSync().miniProgram; if (envVersion == "release") { token = common_vendor.index.getStorageSync("AUTH_TOKEN_CASEDATA"); } else { token = common_vendor.index.getStorageSync("DEV_AUTH_TOKEN_CASEDATA"); } } let header = { "content-type": contentType, "Authorization": "Bearer " + token }; return new Promise(function(e, n) { let timestamp = Date.now(); common_vendor.index.request({ data, url: url.indexOf("http") != -1 ? url : encodeURI(utils_config.BASE_URL + url + "?timestamp=" + timestamp), method, sslVerify: false, header: url.indexOf("/manager/getSignature4bing") == -1 ? header : {}, timeout: 1e4, success: async (res) => { var Authorization_token = res.header.Authorization; if (Authorization_token) { { common_vendor.index.setStorageSync("DEV_AUTH_TOKEN_CASEDATA", Authorization_token); } } if (loading) { common_vendor.index.hideLoading(); } if (res.data.code == 200) { e(res); } else if (res.data.code == 201) { common_vendor.index.showModal({ title: "提示", content: "该作品已被删除", showCancel: false, success: function(res2) { if (res2.confirm) { common_vendor.index.navigateBack(); } } }); n(res); } else if (res.data.code == 10007) { common_vendor.index.showToast({ title: "待补充资料", icon: "none" }); let H5url = "https://dev-wx.igandan.com"; if (window.location.href.indexOf("//dev-casedata.igandan.com") == -1) { H5url = "https://wx.igandan.com"; } let link = H5url + "/hcp/perfect?mobile=" + $("#phonenumber").val().trim(); navTo({ url: "/pages/register/register?src=" + link }); n(res); } else if (res.data.code == 10005) { common_vendor.index.showToast({ title: "待审核", icon: "none" }); n(res); } else if (res.data.code == 401 || res.data.code == 403 || res.data.code == 405 || res.data.code == 406) { { let freeList = ["/login/wechat/mobile", "/code/phone", "/login/mobile_login", "/index", "/user/check"]; if (freeList.indexOf(url) == -1) { let page_url = utils_pageUrl.pageUrl(); common_vendor.index.setStorageSync("redirectUrl", page_url); common_vendor.index.navigateTo({ url: "/pages/login/login?redirectUrl=has" }); return false; } } } else if (res.data.code == 500) { common_vendor.index.showToast({ title: res.data.message, icon: "none" }); n(res); } else { common_vendor.index.showToast({ title: res.data.message, icon: "none" }); n(res); } }, fail: function(err) { "request:fail " === err.errMsg && msg("请求数据失败!"), n(err.data); } }); }); }; exports.request = request; //# sourceMappingURL=../../.sourcemap/mp-weixin/utils/request.js.map