简单的朋友圈笔记

144 阅读1分钟

1、评论列表

<view class="post-clist" v-if="commentList.length>0">
			
			<view class="post-bro" v-for="(item,index) in commentList" :key="index">
				<view style="display: flex;">
					<image :src="item.memberAvatar" style="width: 72rpx;height: 72rpx;border-radius: 50%;" mode=""></image>
					<view class="pro-right">
						<view style="color: #61698E;font-size: 24rpx;">{{item.memberName}}</view>
						<view class="cloud-time">{{item.createTime}}</view>
						<view style="margin-top: 20rpx;">{{item.content}}</view>
					</view>
				</view>
			</view>
		</view>

输入评论后点击发送,执行addcomment()

addcomment(){
				if(!this.content.length){
					this.$u.toast('评论内容不能为空')
					return
				}
				// 发布评论
				if(this.commentInfo == 0){ 
					this.$u.api.save({                 //调用接口保存
						content:this.content,
						model:3,
						targetId:this.id
					}).then(data=>{
						this.content = ''
						this.getcomment()
						this.getdetail()
					})
				}
				// 评论回复
				if(this.commentInfo == 1){
					this.$u.api.replay({
						commentInfoId:this.commentInfoId,
						content:this.content
					}).then(data=>{
						this.content = ''
						this.getcomment()
					})
				}
				
				
			},

getcomment(),在onLoad()中执行展示列表

2、回复