prizeAction(e){
var that = this
if(app.globalData.userInfo == null){
wx.navigateTo({
url: '/pages/auth/auth',
})
}else{
console.log('dianzanid',that.data.id)
db.collection('actions').doc(that.data.id).get({
success(res){
var action = res.data
var tag = false
var index
for(var i in action.prizeList){
if(action.prizeList[i].openid == app.globalData.openid){
tag = true
index = i
break
}
}
if(tag){
action.prizeList.splice(index,1)
console.log(action)
db.collection('actions').doc(that.data.id).update({
data:{
prizeList:action.prizeList,
prizeList_length:action.prizeList.length
},
success(res){
console.log("旧人",res)
wx.showToast({
title: '取消成功',
})
that.getDetail()
}
})
}else{
var user = {}
user.nickName = app.globalData.userInfo.nickName
user.faceImg = app.globalData.userInfo.avatarUrl
user.openid = app.globalData.openid
action.prizeList.push(user)
console.log(action.prizeList)
db.collection('actions').doc(that.data.id).update({
data:{
prizeList:action.prizeList,
prizeList_length:action.prizeList.length
},
success(res){
console.log("新人",res)
wx.showToast({
title: '点赞成功',
})
that.getDetail()
}
})
}
}
})
}
},