import config from './index.js' const request = {} const headers = {} let responseType = 'json' request.api = (url, data, method='post', type=1) => { switch (type){ case 1: responseType = 'blob' break; default: const token = uni.getStorageSync('token'); headers['Authorization'] = `Bearer ${ this.$store.state.token? this.$store.state.token : token }` headers['TENANT-ID'] = this.$store.getters.userInfo.tenant_id break; } return uni.request({ url: config.baseUrl + url, method, data: data, dataType: 'json', responseType: responseType, header: headers }).then(res => { if(typeof(res[1]) == 'undefined'){ return false } if (res[1].data && res[1].statusCode == 200) { return res[1].data } else { throw res[1].data } }).catch(parmas => { console.log(res)       switch (parmas.code) {         case 401:           uni.clearStorageSync()           break         default:           return Promise.reject()           break       }   }) } export default request