| | |
| | | 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('doupload') || config.url.includes('dopreload')) { |
| | | } else if (/\/doupload|\/dopreload|\/upload/.test(config.url)) { |
| | | config.headers = { 'Content-Type': 'multipart/form-data' } |
| | | } else if (config.method === 'post' && config.data) { |
| | | config.data = JSON.stringify(config.data) |
| | |
| | | } |
| | | |
| | | /** |
| | | * @description oss文件上传 |
| | | */ |
| | | fileOssUpload (param) { |
| | | let _url = window.GLOB.location + '/file/oss/upload' |
| | | if (process.env.NODE_ENV === 'production') { |
| | | _url = document.location.origin + '/file/oss/upload' |
| | | } |
| | | if (/^http:\/\/(qingqiumarket.cn|cloud.mk9h.cn|sso.mk9h.cn)/.test(_url)) { |
| | | _url = window.GLOB.location + ':8080/file/oss/upload' |
| | | if (process.env.NODE_ENV === 'production') { |
| | | _url = document.location.origin + ':8080/file/oss/upload' |
| | | } |
| | | } else if (/^https:\/\/(qingqiumarket.cn|cloud.mk9h.cn|sso.mk9h.cn)/.test(_url)) { |
| | | _url = window.GLOB.location + ':8443/file/oss/upload' |
| | | if (process.env.NODE_ENV === 'production') { |
| | | _url = document.location.origin + ':8443/file/oss/upload' |
| | | } |
| | | } |
| | | |
| | | return axios({ |
| | | url: _url, |
| | | method: 'post', |
| | | data: param |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 获取微信支付二维码 |
| | | */ |
| | | getWxNativePay (param) { |
| | |
| | | maxFile: null, |
| | | rduri: '', |
| | | limit: 2, |
| | | compress: false, |
| | | compress: 'false', |
| | | fileType: 'text', |
| | | showprogress: false, |
| | | filelist: [] |
| | |
| | | |
| | | let accept = '' |
| | | let accepts = null |
| | | let compress = false |
| | | let compress = config.compress || 'false' |
| | | let maxFile = config.maxfile && config.maxfile > 0 ? config.maxfile : null |
| | | if (config.compress === 'true' || config.compress === 'base64') { |
| | | compress = true |
| | | if (compress === 'true' || compress === 'base64') { |
| | | accepts = ['.jpg', '.png', '.gif', '.jpeg'] |
| | | accept = accepts.join(',') |
| | | if (config.compress === 'base64') { |
| | | if (compress === 'base64') { |
| | | maxFile = 1 |
| | | } |
| | | } else if (config.suffix) { |
| | |
| | | percent: 0 |
| | | }) |
| | | |
| | | if (compress) { |
| | | if (compress === 'true' || compress === 'base64') { |
| | | let reader = new FileReader() |
| | | let fileSize = file.size / 1024 / 1024 |
| | | let compressRate = 0.9 |
| | |
| | | |
| | | reader.readAsDataURL(file) |
| | | return false |
| | | } else if (compress === 'oss') { |
| | | let _param = new FormData() |
| | | _param.append('multipartFile', file) |
| | | _param.append('UserID', sessionStorage.getItem('UserID') || '') |
| | | |
| | | Api.fileOssUpload(_param).then(res => { |
| | | if (res.status) { |
| | | if (res.urlPath) { |
| | | let path = (/^\/\//.test(res.urlPath) ? 'https:' : '') + res.urlPath |
| | | this.onUpdate(path) |
| | | this.setState({ |
| | | percent: 100 |
| | | }, () => { |
| | | setTimeout(() => { |
| | | this.setState({ |
| | | showprogress: false, |
| | | percent: 0 |
| | | }) |
| | | }, 200) |
| | | }) |
| | | } else { |
| | | this.onFail('文件上传失败!') |
| | | } |
| | | } else { |
| | | this.onFail(res.message || '文件上传失败!') |
| | | } |
| | | }) |
| | | |
| | | return false |
| | | } |
| | | |
| | | // 兼容性的处理 |
| | |
| | | } else if (type === 'fileupload') { |
| | | if (this.record.compress === 'true') { |
| | | shows.push('limit', 'rduri', 'proRduri') |
| | | } else { |
| | | } else if (this.record.compress !== 'base64') { |
| | | shows.push('suffix') |
| | | } |
| | | if (this.record.miniSet === 'custom') { |