模拟朋友圈实时点赞及评论功能
点赞思路:点击的时候,使用push(点赞)以及slice(取消赞)方法处理数组,并且调用点赞接口
评论思路:点击的时候,写多一个评论列表,当点击发送的时候commentStatus=true,且索引等于点击的索引。同时调用获取评论列表的接口
html
<view class="toolbar"> <view class="timestamp">{{item.timetype}}</view> <!-- 点赞 如果islove==1,图片变为点赞的图片--> <view class="like" @tap="like(index,item.id)"> <image :src="/UploadFiles/2021-04-02/item.islove==1">// 点赞 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; },以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
暂无“uni-app实现点赞评论功能”评论...
更新动态
20240515
20240515
- dnf110满级了去哪里刷史诗
- 群星2024《龙年精逊纯银CD[WAV+CUE]
- 刘月宁《扬琴独奏-木兰辞变奏曲》[FLAC+CUE]
- 萧萧.2006-IM萧萧【海蝶】【WAV+CUE】
- 这也太香了!《剑星》推出1:4比例活肤战衣雕像
- Steam官方确认:限制《地狱潜者2》上架国家是索尼决定
- 亚当兰伯特踢馆《歌手》登热搜 网友:那英压力巨大
- 群星《当我跑步时我什么都不想 影视原声带》[320K/MP3][34.72MB]
- 群星《当我跑步时我什么都不想 影视原声带》[24bit 48kHz][FLAC/分轨][187.21MB]
- 韩红/陈萨《沉默的光影》[320K/MP3][101.74MB]
- 吳雨霏.2015-霏凡精选2CD【金牌大风】【WAV+CUE】
- 丁欣睿.2023-宜享受太阳雨【StreetVoice】【FLAC分轨】
- 群星.1993-宝丽金真的爱你3CD【宝丽金】【WAV+CUE】
- dnf110满级后平民去哪打装备
- dnf110自定义史诗和固定史诗区别