1
0
mirror of https://github.com/ialley-workshop-open/uni-halo.git synced 2026-06-12 13:19:31 +08:00

feat: 文章详情新增评论自动滚动到评论区域

This commit is contained in:
小莫唐尼
2024-12-03 10:04:08 +08:00
parent 93f23696ef
commit df4c58d3e4
3 changed files with 39 additions and 10 deletions
+4
View File
@@ -6,6 +6,10 @@
<text>评论列表</text> <text>评论列表</text>
<text class="count">{{ (result && result.total) || 0 }}</text> <text class="count">{{ (result && result.total) || 0 }}</text>
</view> </view>
<view class="refresh">
<text class="icon iconfont icon-sync-alt text-weight-s text-grey-darken-1"></text>
<text class="text-weight-s text-grey-darken-1 ml-6" style="font-size: 26rpx;" @click="fnGetData">刷新</text>
</view>
</view> </view>
<!-- 内容区域 --> <!-- 内容区域 -->
<view class="comment-list_content"> <view class="comment-list_content">
@@ -210,6 +210,7 @@ export default {
this.isShow = isOpen; this.isShow = isOpen;
if(!isOpen){ if(!isOpen){
this.$emit("on-close", { this.$emit("on-close", {
isSubmit:false,
refresh: false refresh: false
}) })
} }
@@ -217,6 +218,7 @@ export default {
handleClose(refresh = false) { handleClose(refresh = false) {
this.isShow = false; this.isShow = false;
this.$emit("on-close", { this.$emit("on-close", {
isSubmit:true,
refresh: refresh refresh: refresh
}) })
} }
+27 -4
View File
@@ -117,7 +117,7 @@
<!-- 评论展示区域 --> <!-- 评论展示区域 -->
<block v-if="postDetailConfig && postDetailConfig.showComment"> <block v-if="postDetailConfig && postDetailConfig.showComment">
<view v-if="result" class="comment-wrap bg-white mt-24 pa-24 round-4"> <view v-if="result" id="CommentList" class="comment-wrap bg-white mt-24 pa-24 round-4">
<commentList ref="commentListRef" :disallowComment="!result.spec.allowComment" <commentList ref="commentListRef" :disallowComment="!result.spec.allowComment"
:postName="result.metadata.name" :post="result" @on-comment="fnOnComment" :postName="result.metadata.name" :post="result" @on-comment="fnOnComment"
@on-comment-detail="fnOnShowCommentDetail" @on-loaded="fnOnCommentLoaded"> @on-comment-detail="fnOnShowCommentDetail" @on-loaded="fnOnCommentLoaded">
@@ -292,7 +292,9 @@ export default {
isComment: false, isComment: false,
postName: "", postName: "",
title: "" title: ""
} },
commentListScrollTop:0
}; };
}, },
computed: { computed: {
@@ -413,6 +415,7 @@ export default {
this.fnSetPageTitle('文章详情'); this.fnSetPageTitle('文章详情');
this.loading = 'success'; this.loading = 'success';
this.fnHandleSetFlotButtonItems(this.haloConfigs); this.fnHandleSetFlotButtonItems(this.haloConfigs);
this.handleQueryCommentListScrollTop()
}) })
.catch(err => { .catch(err => {
console.log("错误", err) console.log("错误", err)
@@ -469,6 +472,13 @@ export default {
this.commentModal.postName = this.result.metadata.name; this.commentModal.postName = this.result.metadata.name;
this.commentModal.title = "新增评论"; this.commentModal.title = "新增评论";
this.commentModal.show = true; this.commentModal.show = true;
setTimeout(()=>{
uni.pageScrollTo({
scrollTop: this.commentListScrollTop,
duration: 100
})
},300)
}, },
fnOnComment(data) { fnOnComment(data) {
this.commentModal.isComment = data.isComment; this.commentModal.isComment = data.isComment;
@@ -476,8 +486,10 @@ export default {
this.commentModal.title = data.title; this.commentModal.title = data.title;
this.commentModal.show = true; this.commentModal.show = true;
}, },
fnOnCommentModalClose(refresh) { fnOnCommentModalClose({refresh,isSubmit}) {
if (refresh && this.$refs.commentListRef) { console.log("refresh",refresh)
console.log("isSubmit",isSubmit)
if (refresh && isSubmit && this.$refs.commentListRef) {
this.$refs.commentListRef.fnGetData() this.$refs.commentListRef.fnGetData()
} }
this.commentModal.show = false; this.commentModal.show = false;
@@ -957,6 +969,17 @@ export default {
} else { } else {
return this.haloConfigs?.appConfig?.appInfo?.qrCodeImageUrl; return this.haloConfigs?.appConfig?.appInfo?.qrCodeImageUrl;
} }
},
handleQueryCommentListScrollTop(){
if(!this.postDetailConfig) return;
if(!this.postDetailConfig.showComment) return;
this.$nextTick(()=>{
setTimeout(()=>{
uni.createSelectorQuery().in(this).select('#CommentList').boundingClientRect(res => {
this.commentListScrollTop = res.top - 12;
}).exec();
}, 2*1000)
})
} }
} }