这期内容当中小编将会给大家带来有关使用uni-app怎么实现一个点赞评论功能,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。
html
<view class="toolbar"> <view class="timestamp">{{item.timetype}}</view> <!-- 点赞 如果islove==1,图片变为点赞的图片--> <view class="like" @tap="like(index,item.id)"> <image :src="item.islove==1?'../../static/images/lllllike.png':'../../static/images/llike.png'"></image> </view> <!-- 评论 --> <view class="comment" @tap="comment(index,item.id)"> <image src="../../static/images/pinglun.png"></image> </view> </view> <!-- 赞/评论区 --> <view class="post-footer"> <!-- 点赞区 --> <view class="footer_content" v-if="item.lovelist.length>0"> <image class="liked" src="../../static/images/likelike.png"></image> <text class="nickname" v-for="(love,love_index) of item.lovelist" :key="love_index">{{love.name}},</text> </view> <!-- 评论区 --> <view class="footer_content" v-if="item.community_on.length>0" v-for="(comment,comment_index) in item.community_on" :key="comment_index"> <text class="comment-nickname">{{comment.nickname}}: <text class="comment-content">{{comment.content}}</text></text> </view> <!-- 当评论发送成功之后实时渲染出来评论列表--> <view class="footer_content" v-if="commentStatus && index==commentIndex"> <text class="comment-nickname">{{realtimename}}: <text class="comment-content">{{realtimecontent}}</text></text> </view> </view>
// 点赞 like(index,communityId) { if (this.community[index].islove == 0) { this.community[index].islove = 1; this.community[index].lovelist.push( {name:this.userinfo.nickname,vipid:this.userinfo.id} ) this.likeImport(communityId) } else { this.community[index].islove = 0; this.community[index].lovelist.splice(this.community[index].lovelist.indexOf(this.userinfo.nickname), 1) this.likeImport(communityId) } }, // 点赞接口 likeImport(id) { app.vipidRequest({ url: 'Vip/community_love', data: { id: id }, header: { 'content-type': 'application/x-www-form-urlencoded', }, method: 'POST', success:(res) => { if(res.data.status) { } else { console.log(res.data) } } }) },
// 点击评论 comment(index,communityId) { this.showInput = true; //调起input框 this.focus = true; // 对焦 this.communityId = communityId }, // 点击发送 send_comment: function(message) { this.commentStatus = true this.commentIndex = index this.realtimecontent = message.content this.realtimename = this.userinfo.nickname app.vipidRequest({ url: 'Vip/community_on', data: { id: this.communityId, content: message.content, type: 1 }, header: { 'content-type': 'application/x-www-form-urlencoded', }, method: 'POST', success:(res) => { if(res.data.status) { this.getCommunity() // 整个页面数据刷新 this.init_input() this.commentStatus = false // 临时渲染评论的列表隐藏 this.realtimecontent = '' this.realtimename = '' this.input_placeholder = '评论'; } else { console.log(res.data) } } }) } // 取消评论/评论完成输入框状态值 init_input() { this.showInput = false; this.focus = false; this.input_placeholder = '评论'; this.is_reply = false; },
上述就是小编为大家分享的使用uni-app怎么实现一个点赞评论功能了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注创新互联成都网站设计公司行业资讯频道。
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
本文名称:使用uni-app怎么实现一个点赞评论功能-创新互联
本文地址:https://www.cdcxhl.com/article32/cscesc.html
成都网站建设公司_创新互联,为您提供小程序开发、外贸建站、商城网站、定制开发、服务器托管、网站改版
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联