添加收藏取消藏
onFavorite:function(e){
var that=this;
console.log(e.currentTarget.dataset.key)
var key=e.currentTarget.dataset.key, //监听触发事件的节点 数据库节点 钥匙
value=e.currentTarget.dataset.value,
list=that.data.list;
if(vlaue.isfav == 1){
value.isfav = 0
}else{
value.isfav =1;
}
var newdata = list.map(function(item){
if (item.key == key){
item.value.isfav = value.isfav;
}
return item;
});
hotapp.post(key.value, function(res){
console.log(res);
that.setData({list:newdata}); //更新数据
})
},