27
This commit is contained in:
+26
-4
@@ -129,17 +129,39 @@ export const upload = (files,data,onProgress) =>{
|
||||
onProgress = data;
|
||||
data = {};
|
||||
}
|
||||
data.data = data.data ? data.data : {};
|
||||
let headers = {};
|
||||
if(data.token){
|
||||
headers = data.headers;
|
||||
delete data.headers;
|
||||
}
|
||||
headers = {
|
||||
...headers,
|
||||
client:uni.getSystemInfoSync().osName,
|
||||
token:uni.getStorageSync("BusinessToken"),
|
||||
operationID: (Math.random() * 36).toString(36).slice(2) + new Date().getTime().toString(),
|
||||
// #ifdef APP-PLUS
|
||||
ClientVersion:plus.runtime.versionCode,
|
||||
// #endif
|
||||
// #ifndef APP-PLUS
|
||||
ClientVersion:350,
|
||||
// #endif
|
||||
}
|
||||
console.log(typeof files);
|
||||
let url = "/user/upload";
|
||||
if(data.url){
|
||||
url = data.url;
|
||||
delete data.url;
|
||||
}
|
||||
url= config.getRegisterUrl()+url;
|
||||
return new Promise((resolve,reject)=>{
|
||||
var u = uni.uploadFile({
|
||||
url: config.getRegisterUrl()+(data?.url || "/user/upload"),
|
||||
url: url,
|
||||
filePath: files,
|
||||
//files:files.length > 1 ? files : files[0],
|
||||
name: "file",
|
||||
formData:data,
|
||||
header:{
|
||||
token:uni.getStorageSync("BusinessToken"),
|
||||
},
|
||||
header:headers,
|
||||
success({data,errMsg}){
|
||||
console.log(data);
|
||||
data = JSON.parse(data);
|
||||
|
||||
Reference in New Issue
Block a user