Commit f8a0ed11 by limin

兼容多个codekey

1 parent efefd45f
{ {
"name": "glsx-common", "name": "glsx-common",
"version": "1.4.6", "version": "1.4.7",
"description": "glsx common", "description": "glsx common",
"main": "./dist/glsx-common.js", "main": "./dist/glsx-common.js",
"private": false, "private": false,
......
...@@ -47,13 +47,14 @@ Http.prototype.create = function () { ...@@ -47,13 +47,14 @@ Http.prototype.create = function () {
this.service.interceptors.response.use( this.service.interceptors.response.use(
({ data: res, config: { returnAll } }) => { ({ data: res, config: { returnAll } }) => {
const { const {
response: { code_key = 'code', errId = 'errId', code_success_value = '0', data_key = 'data', errId_logout_value }, response: { code_key, errId = 'errId', code_success_value = '0', data_key = 'data', errId_logout_value },
alert alert
} = this.customer } = this.customer
if (returnAll || !alert) { if (returnAll || !alert) {
return res return res
} }
let code = res[code_key] let codekey = Array.isArray(code_key) ? code_key.find(key => res.hasOwnProperty(key)) : code_key
let code = res[codekey]
let errValue = res[errId] let errValue = res[errId]
// 特殊的code处理,可以增加 // 特殊的code处理,可以增加
switch (code + '') { switch (code + '') {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!