請問老師顯示評價失敗是什么情況呢?
之前按老師視頻寫是可以提交成功的,數據庫里有一條記錄。過了一個多月打開代碼再試就怎么都提交不上了,一直顯示提交失敗,圖片有提交上去,但集合里沒有記錄。麻煩老師您看看
// 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)
});
}
})
},
2020-02-12
其實只要把這兩個單詞翻譯過來就知道是什么了:沒有權限。
2020-02-12
2020-02-11
沒有錯誤信息是因為代碼對錯誤沒有處理,要在catch中打印出信息。
2020-02-11
麻煩老師啦?
2020-02-11
請看下調試器的控制臺中是否有錯誤信息。如果沒有,就在catch中輸出下錯誤信息。