Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
肖康
/
cloudSystem
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
97cca548
authored
May 18, 2021
by
肖康
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
x
parent
ac3ecbf2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
16 deletions
src/ajax/index.js
view/js/app.js
src/ajax/index.js
View file @
97cca548
...
...
@@ -39,25 +39,15 @@ export const http = (method, url, param,loading) => {
transformRequest
:
[
function
(
param
)
{
return
qs
.
stringify
(
param
);
}],
// headers: {
// 'Authorization': 'Bearer ' + token
// },
// headers: {'Content-Type': 'application/json;charset=UTF-8', 'Authorization': 'Bearer ' + token},
headers
:
{
"Content-Type"
:
"application/x-www-form-urlencoded;charset=UTF-8"
,
"Access-Control-Allow-Origin"
:
false
,
'Authorization'
:
'Bearer '
+
token
},
loading
:(
loading
?
false
:
true
)
};
// param.token=token
// if(url!="/auth/cp"&&url!="/auth/login"){
// console.log(url)
// config.headers={
// 'Authorization': 'Bearer ' + token
// }
if
(
url
!=
"/auth/cp"
&&
url
!=
"/auth/login"
){
config
.
headers
=
{
'Authorization'
:
'Bearer '
+
token
}
//
}
}
// post请求时需要设定Content-Type
if
(
method
==
'post'
||
method
==
'POST'
)
{
config
.
data
=
param
;
...
...
view/js/app.js
View file @
97cca548
...
...
@@ -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 _axios.default.defaults.withCredentials = false; // 不携带cookie\n //loading 默认加载loading 传1 不加载\n\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 // headers: {'Content-Type': 'application/json;charset=UTF-8', 'Authorization': 'Bearer ' + token},\n headers: {\n \"Content-Type\": \"application/x-www-form-urlencoded;charset=UTF-8\",\n \"Access-Control-Allow-Origin\": false,\n 'Authorization': 'Bearer ' + token\n },\n loading: loading ? false : true\n }; // param.token=token\n // if(url!=\"/auth/cp\"&&url!=\"/auth/login\"){\n // console.log(url)\n // config.headers={\n // 'Authorization': 'Bearer ' + token\n // }\n // }\n // post请求时需要设定Content-Type
\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 _axios.default.defaults.withCredentials = false; // 不携带cookie\n //loading 默认加载loading 传1 不加载\n\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
loading: loading ? false : true\n }; // param.token=token\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?"
);
/***/
}),
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment