import request from '../utils/request.js' class uploadImg extends request { static async uploadCommentImgs(tempFilePaths) { wx.showLoading({ title: '上传图片中...', mask: true }); var uploads = []; tempFilePaths.forEach((item, i) => { uploads[i] = request.upload(`${this.BASE_URL}Common/upload`, 'image', item) } ); var imgUrls = []; Promise.all(uploads).then(res => { //图片上传完成 // resolve(res) console.log(res) wx.hideLoading() res.forEach(function (item) { imgUrls.push(item.data.url) }) return imgUrls; }).catch(err => { // reject(err) console.log(err) wx.hideLoading() wx.showToast({ title: '上传失败请重试', icon: 'none' }) }) } static async uploadAvatar(tempFilePaths) { wx.showLoading({ title: '上传图片中...', mask: true }); const res = await request.upload(`${this.BASE_URL}Common/upload`, 'image', tempFilePaths) console.log(res) wx.hideLoading() return res.data.url } } export default uploadImg