Commit 0f85be64 by 肖康

x

parent d7abb6f1
Showing with 3 additions and 1 deletions
......@@ -44,9 +44,11 @@ export const http = (method, url, param,loading) => {
loading:(loading?false:true)
};
if(url!="/auth/cp"&&url!="/auth/login"){
console.log(url)
config.headers={
'Authorization': 'Bearer ' + token
}
}
// post请求时需要设定Content-Type
if (method == 'post'||method == 'POST') {
......
......@@ -10428,7 +10428,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _nod
/***/ (function(module, exports, __webpack_require__) {
"use strict";
eval("\n\nvar _interopRequireDefault = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/interopRequireDefault */ \"./node_modules/@babel/runtime/helpers/interopRequireDefault.js\").default;\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.http = exports.NODE_ENVS = void 0;\n\nvar _axios = _interopRequireDefault(__webpack_require__(/*! axios */ \"./node_modules/axios/index.js\"));\n\nvar _qs = _interopRequireDefault(__webpack_require__(/*! qs */ \"./node_modules/qs/lib/index.js\"));\n\nvar _tool = _interopRequireDefault(__webpack_require__(/*! ../tool */ \"./src/tool/index.js\"));\n\n/**\r\n * 封装axios的通用请求\r\n * @param {string} method get\\post\\put\\delete\r\n * @param {string} url 请求的接口URL\r\n * @param {object} param 传的参数,没有则传空对象\r\n */\nconst envs = \"test\";\nlet NODE_ENVS = \"/\";\nexports.NODE_ENVS = NODE_ENVS;\n\nswitch (envs) {\n case 'development':\n //开发环境\n exports.NODE_ENVS = NODE_ENVS = 'http://192.168.2.164:8080';\n break;\n\n case 'test':\n //测试环境\n exports.NODE_ENVS = NODE_ENVS = 'http://cloud.liexindev.net';\n break;\n\n case 'production':\n //线上环境\n exports.NODE_ENVS = NODE_ENVS = '/';\n break;\n}\n\nconst http = (method, url, param, loading) => {\n //loading 默认加载loading 传1 不加载\n param = param && typeof param === 'object' ? param : {};\n let token = _tool.default.getCookie('token') || '';\n const config = {\n url: `${NODE_ENVS}${url}`,\n method: method,\n transformRequest: [function (param) {\n return _qs.default.stringify(param);\n }],\n // headers: {\n // 'Authorization': 'Bearer ' + token\n // },\n loading: loading ? false : true\n };\n\n if (url != \"/auth/cp\" && url != \"/auth/login\") {\n config.headers = {\n 'Authorization': 'Bearer ' + token\n };\n } // post请求时需要设定Content-Type\n\n\n if (method == 'post' || method == 'POST') {\n config.data = param;\n } else if (method === 'get' || method == 'GET') {\n config.params = param;\n }\n\n return (0, _axios.default)(config);\n};\n\nexports.http = http;\n\n//# sourceURL=webpack:///./src/ajax/index.js?");
eval("\n\nvar _interopRequireDefault = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/interopRequireDefault */ \"./node_modules/@babel/runtime/helpers/interopRequireDefault.js\").default;\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.http = exports.NODE_ENVS = void 0;\n\nvar _axios = _interopRequireDefault(__webpack_require__(/*! axios */ \"./node_modules/axios/index.js\"));\n\nvar _qs = _interopRequireDefault(__webpack_require__(/*! qs */ \"./node_modules/qs/lib/index.js\"));\n\nvar _tool = _interopRequireDefault(__webpack_require__(/*! ../tool */ \"./src/tool/index.js\"));\n\n/**\r\n * 封装axios的通用请求\r\n * @param {string} method get\\post\\put\\delete\r\n * @param {string} url 请求的接口URL\r\n * @param {object} param 传的参数,没有则传空对象\r\n */\nconst envs = \"test\";\nlet NODE_ENVS = \"/\";\nexports.NODE_ENVS = NODE_ENVS;\n\nswitch (envs) {\n case 'development':\n //开发环境\n exports.NODE_ENVS = NODE_ENVS = 'http://192.168.2.164:8080';\n break;\n\n case 'test':\n //测试环境\n exports.NODE_ENVS = NODE_ENVS = 'http://cloud.liexindev.net';\n break;\n\n case 'production':\n //线上环境\n exports.NODE_ENVS = NODE_ENVS = '/';\n break;\n}\n\nconst http = (method, url, param, loading) => {\n //loading 默认加载loading 传1 不加载\n param = param && typeof param === 'object' ? param : {};\n let token = _tool.default.getCookie('token') || '';\n const config = {\n url: `${NODE_ENVS}${url}`,\n method: method,\n transformRequest: [function (param) {\n return _qs.default.stringify(param);\n }],\n // headers: {\n // 'Authorization': 'Bearer ' + token\n // },\n loading: loading ? false : true\n };\n\n if (url != \"/auth/cp\" && url != \"/auth/login\") {\n console.log(url);\n config.headers = {\n 'Authorization': 'Bearer ' + token\n };\n } // post请求时需要设定Content-Type\n\n\n if (method == 'post' || method == 'POST') {\n config.data = param;\n } else if (method === 'get' || method == 'GET') {\n config.params = param;\n }\n\n return (0, _axios.default)(config);\n};\n\nexports.http = http;\n\n//# sourceURL=webpack:///./src/ajax/index.js?");
/***/ }),
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment