| | |
| | | axios.interceptors.request.use((config) => { |
| | | if (config.url.includes('LoginAndRedirect') || config.url.includes('getjsonresult') || config.url.includes('wxNativePay')) { |
| | | config.data = qs.stringify(config.data) |
| | | } else if (config.url.includes('Upload') || config.url.includes('doupload') || config.url.includes('dopreload')) { |
| | | } else if (config.url.includes('doupload') || config.url.includes('dopreload')) { |
| | | config.headers = { 'Content-Type': 'multipart/form-data' } |
| | | } else if (config.method === 'post' && config.data) { |
| | | config.data = JSON.stringify(config.data) |
| | |
| | | return Promise.resolve(response.data) |
| | | } |
| | | }, (error) => { |
| | | if (error && error.response) { |
| | | notification.error({ |
| | | className: 'notification-custom-error', |
| | | bottom: 0, |
| | | message: '状态码-' + error.response.status + ',请联系管理员', |
| | | placement: 'bottomRight', |
| | | duration: 15 |
| | | }) |
| | | let response = error.response |
| | | |
| | | if (response) { |
| | | if (!response.data || !response.data.errors) { // 过滤旷视报错信息 |
| | | notification.error({ |
| | | className: 'notification-custom-error', |
| | | bottom: 0, |
| | | message: '状态码-' + response.status + ',请联系管理员', |
| | | placement: 'bottomRight', |
| | | duration: 15 |
| | | }) |
| | | } |
| | | return Promise.reject(response) |
| | | } else { |
| | | return Promise.reject() |
| | | } |
| | | return Promise.reject(error.response) |
| | | }) |
| | | |
| | | class Api { |
| | |
| | | url: '/webapi/dostar', |
| | | method: 'post', |
| | | data: param |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 微信业务请求 |
| | | */ |
| | | wxAccessToken () { |
| | | let _url = document.location.origin + '/' + window.GLOB.service + 'wxpay/getaccesstoken' |
| | | if (process.env.NODE_ENV !== 'production') { |
| | | _url = document.location.origin + '/wxpay/getaccesstoken' |
| | | } |
| | | |
| | | return new Promise(resolve => { |
| | | if (window.GLOB.accessToken.accessTime && (parseInt(new Date().getTime() / 1000) - window.GLOB.accessToken.accessTime < 30)) { |
| | | resolve(window.GLOB.accessToken) |
| | | } else { |
| | | window.GLOB.accessToken = {} |
| | | axios({ |
| | | url: _url, |
| | | method: 'get' |
| | | }).then(res => { |
| | | if (res.oa_access_token || res.mini_access_token) { |
| | | window.GLOB.accessToken.accessTime = parseInt(new Date().getTime() / 1000) |
| | | window.GLOB.accessToken.oa_access_token = res.oa_access_token |
| | | window.GLOB.accessToken.mini_access_token = res.mini_access_token |
| | | } |
| | | resolve(res) |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 微信业务请求 |
| | | */ |
| | | wxNginxRequest (url, method, param) { |
| | | let _url = window.GLOB.location + '/' + url |
| | | if (process.env.NODE_ENV === 'production') { |
| | | _url = document.location.origin + '/' + url |
| | | } |
| | | if (/^http:\/\/(qingqiumarket.cn|cloud.mk9h.cn|sso.mk9h.cn)/.test(_url)) { |
| | | _url = window.GLOB.location + ':8080/' + url |
| | | if (process.env.NODE_ENV === 'production') { |
| | | _url = document.location.origin + ':8080/' + url |
| | | } |
| | | } else if (/^https:\/\/(qingqiumarket.cn|cloud.mk9h.cn|sso.mk9h.cn)/.test(_url)) { |
| | | _url = window.GLOB.location + ':8443/' + url |
| | | if (process.env.NODE_ENV === 'production') { |
| | | _url = document.location.origin + ':8443/' + url |
| | | } |
| | | } |
| | | |
| | | if (param) { |
| | | return axios({ |
| | | url: _url, |
| | | method, |
| | | data: param |
| | | }) |
| | | } |
| | | |
| | | return axios({ |
| | | url: _url, |
| | | method |
| | | }) |
| | | } |
| | | |
| | |
| | | |
| | | let url = '/webapi/dologon/s_visitor_login' |
| | | if (window.GLOB.mainSystemApi) { |
| | | // url = window.GLOB.mainSystemApi.replace(/\/webapi(.*)/, '/webapi/dologon/s_visitor_login') |
| | | param.rduri = window.GLOB.mainSystemApi.replace(/\/webapi(.*)/, '/webapi/dologon/s_visitor_login') |
| | | } |
| | | |
| | |
| | | if (isCloud) { |
| | | param.debug = 'Y' |
| | | if (options.cloudServiceApi) { |
| | | // url = options.cloudServiceApi.replace(/\/webapi(.*)/, '/webapi/dologon') |
| | | param.rduri = options.cloudServiceApi.replace(/\/webapi(.*)/, '/webapi/dologon') |
| | | } |
| | | } else if (window.GLOB.mainSystemApi) { |
| | | if (options.sysType !== 'cloud' && window.GLOB.systemType !== 'production') { |
| | | param.linkurl = window.GLOB.linkurl |
| | | } |
| | | // url = window.GLOB.mainSystemApi.replace(/\/webapi(.*)/, '/webapi/dologon') |
| | | param.rduri = window.GLOB.mainSystemApi.replace(/\/webapi(.*)/, '/webapi/dologon') |
| | | } |
| | | |
| | |
| | | param.LoginUID = sessionStorage.getItem('CloudLoginUID') || param.LoginUID || '' |
| | | } |
| | | |
| | | // 待优化,增加是否支持跨域请求 |
| | | // let url = '/webapi/dostars' |
| | | // if (param.rduri) { |
| | | // url = param.rduri |
| | | // delete param.rduri |
| | | // } |
| | | let url = '/webapi/dostars' |
| | | if (param.rduri && /\/dostars/.test(param.rduri)) { |
| | | url = param.rduri |
| | | delete param.rduri |
| | | } |
| | | |
| | | param = this.encryptParam(param) |
| | | |
| | | return axios({ |
| | | url: `/webapi/dostars${param.func ? '/' + param.func : ''}`, |
| | | url: `${url}${param.func ? '/' + param.func : ''}`, |
| | | method: 'post', |
| | | data: param |
| | | }) |
| | |
| | | * @description 获取微信支付二维码 |
| | | */ |
| | | getWxNativePay (param) { |
| | | let _url = document.location.origin + '/' + window.GLOB.service + 'wxpay/wxNativePay' |
| | | if (process.env.NODE_ENV !== 'production') { |
| | | _url = document.location.origin + '/wxpay/wxNativePay' |
| | | } |
| | | |
| | | return axios({ |
| | | url: '/wxpay/wxNativePay', |
| | | url: _url, |
| | | method: 'post', |
| | | data: param |
| | | }) |