产投集团APP-智慧党建系统
资讯模块
1、新增评论回复、评论点赞、取消点赞功能
2、优化回复评论UI
MUI iOS 中点击事件失效的解决办法
当使用委托给一个元素添加click事件时,如果事件是委托到 document 或 body 上,并且委托的元素是默认不可点击的(如 div, span 等),此时 click 事件会失效。这时只需要在对应的css中添加cursor: pointer
html模板
<div class="mui-col-sm-12">
<h5>
<label class="switchLiked" data-isLiked="{{data.isLiked ? 'true' : 'false'}}" data-commentid="{{data.id}}" style="margin-right: 4px;"><img src="../images/dz02.png" style="width: 24px; height: 24px; vertical-align: middle; cursor: pointer;" />{{data.likeCount > 0 ? data.likeCount: ''}}</label>
<label class="repComments" data-commentid="{{data.id}}" data-parentContent="{{data.content}}" data-parentId="{{data.id}}" data-parentCreatorName="{{data.user.name}}" style="padding: 4px 8px; border-radius: 5px; line-height: 26px; background: #f4f5f6; color: #313131;cursor: pointer;">回复 </label>
<label class="delComments" data-commentid="{{data.id}}" style="padding: 4px 8px; border-radius: 5px; line-height: 18px; float: right; color: #6a87af; cursor: pointer;">删除 </label>
</h5>
</div>
js模板
// 评论点赞or取消点赞 switchLiked
(this);
var thtml = ' <img src="../images/dz02.png" style="width: 24px; height: 24px; vertical-align: middle;">';
var commentid = this.getAttribute('data-commentid');
var isLiked = this.getAttribute('data-isLiked') == 'true' ? true : false;
this.setAttribute('data-isLiked', !isLiked);
var likedNum = Number(this.innerText != '' ? this.innerText : 0);
if(!isLiked) { //点赞
ctdj.cms.setComlike(detailid, commentid, function(r) {
if(r.success) {
obj.html(thtml + (likedNum + 1));
}
})
} else { //取消点赞
ctdj.cms.delComunlike(commentid, function(r) {
if(r.success) {
var num = (likedNum - 1) == 0 ? '' : (likedNum - 1);
obj.html(thtml + num);
}
})
}
})