写入云函数后为什么调用不成功?日志里面也没记录
功能:点赞功能
问题:在点赞后,数据库没有记录,云函数没有日志
js代码
//点赞功能
upPickBtn: function (e) {
var that = this
var ind = e.currentTarget.dataset.nowindex
console.log(e.currentTarget.dataset.youid)
console.log(e.currentTarget.dataset.youopenid)
if (this.data.array[ind] == 0)//说明没点赞过
{
var nowup = 'array[' + ind + ']'//设置为点赞过
this.setData({
[nowup]: 1
})
wx.cloud.callFunction({
name: 'add_up_record',
data: {
myid: this.data.userid,
youid: e.currentTarget.dataset.youid,
youopenid: e.currentTarget.dataset.youopenid,
},
success: function (res) {
}
})
wx.cloud.callFunction({
name: 'update_record_vote',
data: {
youid: e.currentTarget.dataset.youid,
},
success: function (res) {
that.search_db()
}
})
}
},
sarch_db: function () {
var that = ths
var index = 0
wx.cloud.callFunction({
name: 'login',
data: {},
success: res => {
console.log(res)
that.setData({
userid: res.result.openid
})
var userid = that.data.userid;
db.collection('My_up').where({//获取自己的点赞列表
myId: userid
}).get({
success: res => {
console.log("res:---------", res)
that.setData({
allyouup: res.data//点赞列表data赋给allyouup
})
for (var i = 0; i < res.data.length; i++) {
allUpId[i] = res.data[i].youId//点赞列表赋给allUpId
}
db.collection('Record_picture').get({
success: res => {
that.setData({
alldata: res.data//所有的用户列表数据
})
for (var i = 0; i < res.data.length; i++) {
allId[i] = res.data[i]._id //所有的用户列表_id
if (allUpId.indexOf(allId[i]) == -1) {
var item = 'array[' + i + ']'
that.setData({
[item]: 0
})
}
else {
var item = 'array[' + i + ']'
that.setData({
[item]: 1
})
}
}
console.log(that.data.array)
}
})
},
})
}
})
}
云函数代码
add_up_record— index.js
云函数 update_record_vote ——index.js文件
在点赞后 会打印用户的openid,和当前评论的_id
数据库My_up里面没有任何记录、云函数里面也没有日志