wxml
<view class='right' bindtap="uin" data-id="{{src}}" wx:if="{{praise == true}}">
<image class="img" src="../../img/din.png"/>
</view>
<view class='right' bindtap="uin" data-id="{{src}}" wx:else="{{praise == false}}">
<image class="img" src="../../img/weizan.png"/>
</view>
js
uin:function(e){
var that = this;
var id = e.currentTarget.dataset.id;
var uren = wx.getStorageSync('uren');
wx.request({
url: 'http://localhost/index.php/ShowCode?id='+id+'&u_id='+uren,
success(res){
var pra = res.data.name;
console.log(pra);
if(res.data.code == 200){
wx.showToast({
title: '点赞成功',
icon: 'success',
duration: 1500
})
that.setData({
praise:true
})
}else{
wx.showToast({
title: '点赞取消',
icon: 'error',
duration: 1500
})
that.setData({
praise:false
})
}
}
})
},