import baseUrl from "./baseUrl.js" export function uploadImage (urls,) { return new Promise( (resovle, reject) =>{ let urlArr = [] for(let i = 0; i < urls.length; i ++){ uni.uploadFile({ url: baseUrl + '/file/upload', fileName: 'file', header: { 'content-type': 'multipart/form-data' }, fileType: "image", // 必填 filePath: urls[i], success: (res) => { urlArr.push(res.data) if( urls.length == urlArr.length){ uni.hideLoading(); uni.showToast({ title: '上传成功', icon: 'success', duration: 2000 }); resovle(urlArr) } }, fail: (err) =>{ console.log('--------') console.log(err) uni.showToast({ title: '上传失败', icon: 'error', duration: 2000 }); uni.hideLoading(); uni.showModal({ title: '提示', content: err.msg, }); resovle([]) }, complete: () => { } }); } }) }