Skip to content

Commit

Permalink
fix: 修复uploader组件编译xhr报错的问题 (#916)
Browse files Browse the repository at this point in the history
* fix: 修改inputnumber微信小程序的带小数点的键盘

* fix: 修复uploader组件编译xhr报错的问题
  • Loading branch information
junjun666 authored Apr 17, 2023
1 parent 3f2919b commit 83b5148
Showing 1 changed file with 32 additions and 36 deletions.
68 changes: 32 additions & 36 deletions src/packages/uploader/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,44 +83,40 @@ export class UploaderTaro extends Upload {
}
uploadTaro(uploadFile: Function, env: string) {
const options = this.options
if (env === 'WEB') {
this.upload()
if (options.beforeXhrUpload) {
options.beforeXhrUpload(uploadFile, options)
} else {
if (options.beforeXhrUpload) {
options.beforeXhrUpload(uploadFile, options)
} else {
const uploadTask = uploadFile({
url: options.url,
filePath: options.taroFilePath,
fileType: options.fileType,
header: {
'Content-Type': 'multipart/form-data',
...options.headers,
}, //
formData: options.formData,
name: options.name,
success(response: { errMsg: any; statusCode: number; data: string }) {
if (options.xhrState == response.statusCode) {
options.onSuccess?.(response, options)
} else {
options.onFailure?.(response, options)
}
},
fail(e: any) {
options.onFailure?.(e, options)
},
})
options.onStart?.(options)
uploadTask.progress(
(res: {
progress: any
totalBytesSent: any
totalBytesExpectedToSend: any
}) => {
options.onProgress?.(res, options)
const uploadTask = uploadFile({
url: options.url,
filePath: options.taroFilePath,
fileType: options.fileType,
header: {
'Content-Type': 'multipart/form-data',
...options.headers,
}, //
formData: options.formData,
name: options.name,
success(response: { errMsg: any; statusCode: number; data: string }) {
if (options.xhrState == response.statusCode) {
options.onSuccess?.(response, options)
} else {
options.onFailure?.(response, options)
}
)
}
},
fail(e: any) {
options.onFailure?.(e, options)
},
})
options.onStart?.(options)
uploadTask.progress(
(res: {
progress: any
totalBytesSent: any
totalBytesExpectedToSend: any
}) => {
options.onProgress?.(res, options)
}
)
}
}
}

0 comments on commit 83b5148

Please sign in to comment.