function chooseAvatar() {
uni.chooseImage({
count: 1, //默认9
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
sourceType: ['album'], //从相册选择
success: res => {
iconFile.value = res.tempFiles[0]
}
});
}
function chooseBackground() {
uni.chooseImage({
count: 1, //默认9
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
sourceType: ['album'], //从相册选择
success: res => {
backgroundFile.value = res.tempFiles[0]
}
});
}
export const postForm = (url: string, formData: AnyObject, files: any): Promise<Result> => {
const header = {authentication: uni.getStorageSync('authentication')}
return new Promise((resolve, reject) => {
uni.showLoading({title: '加载中', mask: true}).then()
setTimeout(() => {
uni.hideLoading()
}, 5000)
debugger
uni.uploadFile({
url: baseUrl + url,
files: files,
formData: formData,
header: header,
success: (res: UploadFileSuccessCallbackResult) => {
console.log(res)
},
fail: (err: GeneralCallbackResult) => {
uni.showToast({
title: err.errMsg,
icon: "none"
}).then()
reject(err)
},
complete: () => {
uni.hideLoading()
},
})
})
}
1***@163.com
- 发布:2024-08-30 14:12
- 更新:2024-08-30 14:15
- 阅读:201