| | |
| | | /** |
| | | * @description 直接请求 |
| | | */ |
| | | directRequest (params) { |
| | | directRequest (params, script, position) { |
| | | if (script) { |
| | | try { |
| | | // eslint-disable-next-line |
| | | let func = new Function('axios', 'Api', 'param', 'position', 'systemType', 'notification', script) |
| | | let promise = func(axios, this, params, position, window.GLOB.systemType, notification) |
| | | |
| | | if (promise instanceof Promise) { |
| | | return promise |
| | | } |
| | | } catch (e) { |
| | | console.warn(e) |
| | | } |
| | | |
| | | return Promise.resolve({ |
| | | status: false, |
| | | message: '自定义脚本执行错误', |
| | | ErrCode: 'E' |
| | | }) |
| | | } |
| | | |
| | | return axios(params) |
| | | } |
| | | |
| | |
| | | method: btn.method || 'post' |
| | | } |
| | | |
| | | if (btn.cross === 'true') { |
| | | if (btn.ContentType) { |
| | | _params.headers = { |
| | | 'Content-Type': btn.ContentType |
| | | } |
| | | } |
| | | |
| | | if (btn.$outerScript) { |
| | | if (JSON.stringify(param) !== '{}') { |
| | | if (btn.stringify === 'qs') { |
| | | _params.data = qs.stringify(param) |
| | | } else { |
| | | _params.data = param |
| | | } |
| | | } |
| | | } else if (btn.cross === 'true') { |
| | | if (JSON.stringify(param) !== '{}') { |
| | | if (btn.stringify === 'qs') { |
| | | _params.data = qs.stringify(param) |
| | |
| | | _params.method = 'post' |
| | | } |
| | | |
| | | if (btn.ContentType) { |
| | | _params.headers = { |
| | | 'Content-Type': btn.ContentType |
| | | } |
| | | } |
| | | |
| | | Api.directRequest(_params).then(res => { |
| | | Api.directRequest(_params, btn.$outerScript, 'outer').then(res => { |
| | | if (typeof(res) !== 'object') { |
| | | let error = '未知的返回结果!' |
| | | |