请问老师显示评价失败是什么情况呢?
之前按老师视频写是可以提交成功的,数据库里有一条记录。过了一个多月打开代码再试就怎么都提交不上了,一直显示提交失败,图片有提交上去,但集合里没有记录。麻烦老师您看看
// pages/maijia/maijia.js
const db=wx.cloud.database();
Page({
/**
* 页面的初始数据
*/
data: {
detail:{},
content1:'',
content2: '',
content3: '',
images:[],
fileIds:[]
},
inChange:function(event) {
this.setData({
content1:event.detail
});
},
onChange:function(event) {
this.setData({
content2: event.detail
});
},
toChange:function(event) {
this.setData({
content3: event.detail
});
},
submit:function(){
console.log(this.data.content1, this.data.content2, this.data.content3)
let promiseArr=[];
for(let i=0;i<this.data.images.length;i++){
promiseArr.push(new Promise((reslove,reject)=>{
let item=this.data.images[i];
let suffix=/\.\w+$/.exec(item)[0];
wx.cloud.uploadFile({
cloudPath:new Date().getTime()+suffix,
filePath:item,
success:res=>{
console.log(res.fileID)
this.setData({
fileIds:this.data.fileIds.concat(res.fileID)
});
reslove();
},
fail:console.error
})
}));
}
Promise.all(promiseArr).then(res=>{
db.collection('shangpinziliao').add({
data:{
content1:this.data.content1,
content2: this.data.content2,
content3: this.data.content3,
fileIds: this.data.fileIds,
}
}).then(res=>{
wx.showToast({
title:'提交成功',
})
}).catch(err=>{
wx.hideLoading();
wx.showToast({
title:'提交失败'
})
})
});
},
uploadImg:function(){
wx.chooseImage({
count: 9,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success:res=>{
// tempFilePath可以作为img标签的src属性显示图片
const tempFilePaths = res.tempFilePaths
console.log(tempFilePaths);
this.setData({
images: this.data.images.concat(tempFilePaths)
});
}
})
},