From f29a96ac3cf82e0dc06e1b3874ab2abed2ebaeaa Mon Sep 17 00:00:00 2001
From: 15179599649 <zhangyiyao89@qq.com>
Date: Mon, 08 Jan 2024 14:46:00 +0800
Subject: [PATCH] '完善内容'
---
src/views/message/index.vue | 47 +++++++++++++++++++++++++----------------------
1 files changed, 25 insertions(+), 22 deletions(-)
diff --git a/src/views/message/index.vue b/src/views/message/index.vue
index 1d3e505..18a6eb1 100644
--- a/src/views/message/index.vue
+++ b/src/views/message/index.vue
@@ -54,8 +54,8 @@
<van-uploader :after-read="(file) => afterread(file, index)" multiple>
<img src="images/pic.png" class="pic" />
</van-uploader>
- <img src="images/anonymous.png" class="anonymous" @click="SubmitComment(1,item)" />
- <div class="notanonymous" v-show="isshownotnm" @click="SubmitComment(2,item)">
+ <img src="images/anonymous.png" class="anonymous" @click="SubmitComment(1,item,index)" />
+ <div class="notanonymous" v-show="isshownotnm" @click="SubmitComment(2,item,index)">
<img src="images/notanonymous.png" />
</div>
</div>
@@ -83,7 +83,9 @@
return {
isshownotnm: true,
messageData: [],
- pageswitch: { current: 1, size: 10, descs: "update_time" }
+ pageswitch: { current: 1, size: 5, descs: "update_time" },
+ scrollBottom: "",
+ lastscrollBottom: ""
};
},
@@ -102,22 +104,22 @@
mounted() {},
methods: {
getScroll(event) {
- let scrollBottom =
+ this.scrollBottom =
event.target.scrollHeight -
event.target.scrollTop -
event.target.clientHeight;
- if (scrollBottom < 200) {
- this.pageswitch.size += 10;
- this.current.current += 1;
- this.getmessagelist(this.pageswitch);
+ if (this.scrollBottom < 200) {
+ if (this.lastscrollBottom > this.scrollBottom) {
+ this.pageswitch.current += 1;
+ this.getmessagelist();
+ }
}
+ this.lastscrollBottom = this.scrollBottom;
},
// 获取数据
getmessagelist() {
leaveWordslist(this.pageswitch).then(res => {
- const mergedArray = this.messageData.concat(res.data.data.records);
- this.messageData = mergedArray;
- this.messageData.forEach((item, indexto) => {
+ res.data.data.records.forEach((item, indexto) => {
if (item.imageUrls != "") {
item.imageUrls = item.imageUrls.split(",");
}
@@ -129,6 +131,8 @@
});
}
});
+ const mergedArray = this.messageData.concat(res.data.data.records);
+ this.messageData = mergedArray;
let kehuarray = [];
if (localStorage.getItem("tokensave") == "111") {
this.messageData.forEach((item, indexto) => {
@@ -140,11 +144,8 @@
}
});
},
- handScroll(event) {
- console.log(event);
- },
// 提交评论:1匿名提交,2不匿名提交
- SubmitComment(key, item) {
+ SubmitComment(key, item, index) {
if (item.inputValue == undefined && item.imageDatatoup == undefined) {
this.$toast.fail("请输入留言内容");
} else {
@@ -162,12 +163,14 @@
toData.userDept = localStorage.getItem("dept_name");
toData.userPost = localStorage.getItem("post_name");
}
- leaveWords(toData).then(res => {
- if (res.data.code == 200) {
- this.$toast.success("评论成功");
- this.getmessagelist();
- }
- });
+ item.children.push(toData);
+ console.log(this.messageData);
+ // leaveWords(toData).then(res => {
+ // if (res.data.code == 200) {
+ // this.$toast.success("评论成功");
+ // this.getmessagelist();
+ // }
+ // });
}
},
// 删除图片
@@ -226,7 +229,7 @@
<style scoped lang="scss">
.boxliuyan {
- height: 100%;
+ height: 100vh;
overflow: auto;
.Stay {
width: 100%;
--
Gitblit v1.9.3