NIUCLOUD是一款SaaS管理后台框架多应用插件+云编译。上千名开发者、服务商正在积极拥抱开发者生态。欢迎开发者们免费入驻。一起助力发展! 广告
``` let temArr = \[\]; for (var i = 0; i < this.data.images.length; i++) { temArr.push(new Promise((resolve, resject) => { let item = that.data.images\[0\] let suffix = /\\.\\w+$/.exec(item)\[0\] //后缀名 wx.cloud.uploadFile({ cloudPath: new Date().getTime() + suffix, filePath: item, // 文件路径 }).then(res => { that.setData({ fileIds: that.data.fileIds.concat(res.fileID) }) // get resource ID console.log(99999) console.log(res.fileID) resolve() }).catch(error => { // handle error resject() }) })) } Promise.all(temArr).then(res => { db.collection('comment').add({ data: { content: this.data.commentValue, score: this.data.rateScore, movieid: this.data.movieid, fileIds: this.data.fileIds } }).then(res => { wx.hideLoading() wx.showToast({ title: '评价成功!', }) }).catch(err => { wx.hideLoading() wx.showToast({ title: '评价失败!', }) }) }).catch(err => { }); ```