Commit 636a6a0e authored by liwei's avatar liwei

修改了评论功能

parent b4833a23
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
'top': '210rpx', 'top': '210rpx',
'width': '447rpx', 'width': '447rpx',
'height': '375rpx' 'height': '375rpx'
}" v-model="dataList" @query="queryList" :fixed="false" @onRefresh="onRefresh" auto-show-back-to-top="true"> }" v-model="dataList" @query="queryList" :fixed="false" auto-show-back-to-top="true">
<view v-if="currentIndex == '2'"> <view v-if="currentIndex == '2'">
<u-tabs ref="tabs" :list="topicList" font-size="30" :current="current" @click="tabClick" <u-tabs ref="tabs" :list="topicList" font-size="30" :current="current" @click="tabClick"
:activeStyle="{ :activeStyle="{
...@@ -106,14 +106,6 @@ ...@@ -106,14 +106,6 @@
}, },
}, },
methods: { methods: {
// 下拉刷新被触发
onRefresh() {
// 告知z-paging下拉刷新结束,这样才可以开始下一次的下拉刷新
setTimeout(() => {
// 1.5秒之后停止刷新动画
this.reload()
}, 1500)
},
//tab标签点击 //tab标签点击
tabClick({id}) { tabClick({id}) {
this.topicId = id this.topicId = id
...@@ -129,6 +121,8 @@ ...@@ -129,6 +121,8 @@
name: item.topicName name: item.topicName
}; };
}); });
//初始化话题id 锁到第一个话题
this.topicId = this.topicList[0].id
}) })
}, },
// 接收父组件传过来的刷新列表要求 // 接收父组件传过来的刷新列表要求
...@@ -138,7 +132,7 @@ ...@@ -138,7 +132,7 @@
this.$refs.paging && this.$refs.paging.reload(); this.$refs.paging && this.$refs.paging.reload();
}) })
}, },
//分页查询方法 //分页查询方法 下拉刷新或滚动到底部
queryList(pageNo, pageSize) { queryList(pageNo, pageSize) {
const params = { const params = {
page:pageNo, page:pageNo,
......
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
<!-- 左上角搜索--> <!-- 左上角搜索-->
<u-navbar bgColor="white" :placeholder="true"> <u-navbar bgColor="white" :placeholder="true">
<view class="u-nav-slot" slot="left" @click="screen"> <view class="u-nav-slot" slot="left" @click="screen">
<image :src="baseUrl+'/index/screen.png'" class="img" mode="aspectFill"></image> <!-- <image :src="baseUrl+'/index/screen.png'" class="img" mode="aspectFill"></image>-->
<view class="text">搜索</view> <!-- <view class="text">搜索</view>-->
</view> </view>
</u-navbar> </u-navbar>
......
...@@ -18,143 +18,81 @@ ...@@ -18,143 +18,81 @@
<div class="c-left"> <div class="c-left">
<image :src="info.avatarUrl"></image> <image :src="info.avatarUrl"></image>
</div> </div>
<div class="c-right"> <div class="c-right" @click="()=>reply(info)">
<div class="c-name"> <div class="c-name">
{{ info.memNickName }} {{ info.memNickName }}
</div> </div>
<div class="c-comment">{{ info.content }}</div> <div class="c-comment">{{ info.content }}</div>
<div class="c-actions"> <div class="c-actions">
<div class="c-time">{{ info.createDate }}</div> <div class="c-time">{{ info.createDate }}</div>
<!-- <div class="action-item">--> <div class="action-item">
<!-- <image--> <image
<!-- :src="baseUrl+'/article/104.png'"--> :src="baseUrl+'/article/104.png'"
<!-- @click="btnComment(info)"--> @click="btnComment(info)"
<!-- ></image>--> ></image>
<!-- <text>--> <text>
<!-- {{ info.replyCount }}--> {{ info.commentCount }}
<!-- </text>--> </text>
<!-- </div>--> </div>
<!-- <div class="action-item">--> <div class="action-item">
<!-- <image--> <image
<!-- @click="btnPrarse(info)"--> @click="btnPrarse(info)"
<!-- :src="info.isLike == '0'--> :src="info.isLike == '0'
<!-- ? baseUrl+'/article/105.png'--> ? baseUrl+'/article/105.png'
<!-- : baseUrl+'/article/105-no.png'--> : baseUrl+'/article/105-no.png'
<!-- "--> "
<!-- ></image>--> ></image>
<!-- {{ info.likeCount }}--> {{ info.likeCount }}
<!-- </div>--> </div>
</div> </div>
<!-- <div v-if="info.childrenCommentInfos.length > 0">--> <view>
<!-- <div v-if="info.contentAll">--> <view
<!-- <view class="comment">--> class="comment"
<!-- <div class="c-left">--> v-for="(children, index) in info.childrenCommentList"
<!-- <image :src="info.childrenCommentInfos[0].avatar"></image>--> :key="children.businessId"
<!-- </div>--> >
<!-- <div class="c-right">--> <view class="c-left">
<!-- <div class="c-name">--> <image :src="children.avatarUrl"></image>
<!-- {{ info.childrenCommentInfos[0].nickName }}--> </view>
<!-- <div style="color: #333; margin-top: 10rpx">-->
<!-- 回复-->
<!-- <text class="replyer">-->
<!-- {{ info.childrenCommentInfos[0].beRepliedName }}:-->
<!-- </text>-->
<!-- <text class="c-comment">-->
<!-- {{ info.childrenCommentInfos[0].content }}-->
<!-- </text>-->
<!-- </div>-->
<!-- </div>-->
<!-- <div class="c-actions">-->
<!-- <div class="c-time">-->
<!-- {{ info.childrenCommentInfos[0].createTime }}-->
<!-- </div>-->
<!-- <div class="action-item">-->
<!-- <image-->
<!-- @click="btnPrarse(info.childrenCommentInfos[0])"-->
<!-- :src="-->
<!-- children.praise-->
<!-- ? baseUrl+'/article/105.png'-->
<!-- : baseUrl+'/article/105-no.png'-->
<!-- "-->
<!-- ></image>-->
<!-- {{ info.childrenCommentInfos[0].likesNumber }}-->
<!-- </div>-->
<!-- <div class="action-item">-->
<!-- <image-->
<!-- :src="baseUrl+'/article/104.png'"-->
<!-- @click="btnComment(info.childrenCommentInfos[0])"-->
<!-- ></image>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<!-- </view>-->
<!-- </div>-->
<!-- <div v-else>--> <view class="c-right" @click="()=>reply(children)">
<!-- <view--> <view class="c-name">
<!-- class="comment"--> {{ children.memNickName }}
<!-- v-for="children in info.childrenCommentInfos"--> <view style="color: #333; margin-top: 10rpx">
<!-- :key="children.id"--> 回复
<!-- >--> <text class="replyer">{{ children.commentedMemNickName }}</text>
<!-- <div class="c-left">--> <text class="c-comment">{{ children.content }}</text>
<!-- <image :src="children.avatar"></image>--> </view>
<!-- </div>--> </view>
<view class="c-actions">
<!-- <div class="c-right">--> <view class="c-time">{{ children.createDate }}</view>
<!-- <div class="c-name">--> <view class="action-item">
<!-- {{ children.nickName }}-->
<!-- <div style="color: #333; margin-top: 10rpx">-->
<!-- 回复-->
<!-- <text class="replyer">{{ children.beRepliedName }}</text>-->
<!-- <text class="c-comment">{{ children.content }}</text>-->
<!-- </div>-->
<!-- </div>-->
<!-- <div class="c-actions">-->
<!-- <div class="c-time">{{ children.createTime }}</div>-->
<!-- <div class="action-item">-->
<!-- <image-->
<!-- @click="btnPrarse(children)"-->
<!-- :src="-->
<!-- children.praise-->
<!-- ? baseUrl+'/article/105.png'-->
<!-- : baseUrl+'/article/105-no.png'-->
<!-- "-->
<!-- ></image>-->
<!-- {{ children.likesNumber }}-->
<!-- </div>-->
<!-- <div class="action-item">-->
<!-- <image--> <!-- <image-->
<!-- :src="baseUrl+'/article/104.png'"--> <!-- :src="baseUrl+'/article/104.png'"-->
<!-- @click="btnComment(children)"--> <!-- @click="btnComment(children)"-->
<!-- ></image>--> <!-- ></image>-->
<!-- </div>--> <!-- {{ children.replyCount }}-->
<!-- </div>--> </view>
<!-- </div>--> <view class="action-item">
<!-- </view>--> <image
<!-- </div>--> @click="btnPrarse(children)"
<!--&lt;!&ndash; <div class="more">&ndash;&gt;--> :src="
<!--&lt;!&ndash; <div&ndash;&gt;--> children.praise
<!--&lt;!&ndash; style="color: #b6ea7a"&ndash;&gt;--> ? baseUrl+'/article/105.png'
<!--&lt;!&ndash; v-show="info.contentAll"&ndash;&gt;--> : baseUrl+'/article/105-no.png'
<!--&lt;!&ndash; @click="changeAllFun(info)"&ndash;&gt;--> "
<!--&lt;!&ndash; >&ndash;&gt;--> ></image>
<!--&lt;!&ndash; 展开剩余{{ info.childrenCommentInfos.length - 1 }}条回复&ndash;&gt;--> {{ children.likeCount }}
<!--&lt;!&ndash; </div>&ndash;&gt;--> </view>
<!--&lt;!&ndash; <div v-show="!info.contentAll"></div>&ndash;&gt;--> </view>
<!--&lt;!&ndash; <div&ndash;&gt;--> </view>
<!--&lt;!&ndash; v-show="!info.contentAll"&ndash;&gt;--> </view>
<!--&lt;!&ndash; style="color: #b6ea7a"&ndash;&gt;--> </view>
<!--&lt;!&ndash; @click="changeAllFun(info)"&ndash;&gt;-->
<!--&lt;!&ndash; >&ndash;&gt;-->
<!--&lt;!&ndash; 收起&ndash;&gt;-->
<!--&lt;!&ndash; </div>&ndash;&gt;-->
<!--&lt;!&ndash; </div>&ndash;&gt;-->
<!-- </div>-->
</div> </div>
</view> </view>
<view class="bottom"> <view class="bottom">
<u--input <u--input
placeholder="走心,说点好听的....." :placeholder="commentPlaceholder"
border="surround" border="surround"
v-model="commentValue" v-model="commentValue"
@confirm="handleEnter" @confirm="handleEnter"
...@@ -200,6 +138,8 @@ export default{ ...@@ -200,6 +138,8 @@ export default{
}, },
data () { data () {
return { return {
//评论输入框提示
commentPlaceholder:'走心,说点好听的.....',
//图片路径 //图片路径
baseUrl: this.$IMG_URL, baseUrl: this.$IMG_URL,
//评论值 //评论值
...@@ -207,7 +147,11 @@ export default{ ...@@ -207,7 +147,11 @@ export default{
//动态id //动态id
articleId:'', articleId:'',
//动态详情 //动态详情
articleInfo:{} articleInfo:{},
//被评论人
commentedUserId:null,
//上级评论ID
parentId:null,
} }
}, },
onLoad(params){ onLoad(params){
...@@ -215,6 +159,19 @@ export default{ ...@@ -215,6 +159,19 @@ export default{
this.getArticleDetail() this.getArticleDetail()
}, },
methods: { methods: {
reply(value){
this.commentPlaceholder = '回复 ' + value.memNickName + ':'
//设置被评论人id
this.commentedUserId = value.commentedUserId
//设置上级评论id 加这个逻辑是为了保证永远只有两层结构
if (value.parentId == null){
//点击的第一层评论
this.parentId = value.businessId
} else {
//点击的第二层评论
this.parentId = value.parentId
}
},
//评论回车事件 //评论回车事件
handleEnter(value){ handleEnter(value){
const token = uni.getStorageSync("token") const token = uni.getStorageSync("token")
...@@ -234,8 +191,10 @@ export default{ ...@@ -234,8 +191,10 @@ export default{
} }
this.commentValue = '' this.commentValue = ''
const params = { const params = {
articleId: this.articleInfo.businessId, articleId: this.articleInfo.businessId,//动态id
commentContent:value commentContent:value,//评论内容
commentedUserId:this.commentedUserId ,//被评论人ID
parentId:this.parentId//上级评论ID
} }
comment(params).then(res=>{ comment(params).then(res=>{
if (res.data.code == 200){ if (res.data.code == 200){
...@@ -249,6 +208,9 @@ export default{ ...@@ -249,6 +208,9 @@ export default{
icon: 'none' icon: 'none'
}) })
}) })
this.commentPlaceholder = '走心,说点好听的.....'
this.commentedUserId = null
this.parentId = null
}, },
getArticleDetail(){ getArticleDetail(){
articleDetail(this.articleId).then(res=>{ articleDetail(this.articleId).then(res=>{
...@@ -293,6 +255,14 @@ export default{ ...@@ -293,6 +255,14 @@ export default{
getOssUrl(item.avatarId).then(res =>{ getOssUrl(item.avatarId).then(res =>{
item.avatarUrl = res.data.data item.avatarUrl = res.data.data
}) })
//处理子评论头像
if (item.childrenCommentList.length > 0 ){
item.childrenCommentList.forEach(children => {
getOssUrl(children.avatarId).then(resp => {
children.avatarUrl = resp.data.data
})
})
}
}) })
} }
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment