修改删除动态和评论Bug

main
QMZ 1 month ago
parent 4deb0096c9
commit a3dba65371

@ -60,7 +60,7 @@
<script>
import { defineComponent } from 'vue';
import axios from 'axios';
import axios from '@/utils/axiosConfig';
import {getUserId} from '@/token/auth';
@ -73,7 +73,7 @@
},
data() {
return {
userid:0,
userid:1,
showForm: false, //
radio: '日常动态',
form: {
@ -127,6 +127,7 @@
this.$message.error('内容不能为空');
return;
}
const newPost = {
userid:getUserId(),
username: '用户',
@ -137,21 +138,23 @@
likecount: 0,
commentcount: 0,
isfamilystory: this.radio === '家族故事' ? true : false,
postid:999,
};
try {
const response = await axios.post('http://localhost:8082/loveforest/posts/addpost', newPost, {
const response = await axios.post('/posts/addpost', newPost, {
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
});
if(response.data==="增加动态成功!")
if(response.startsWith("增加动态成功!"))
{
const postid = response.replace("增加动态成功!", '').trim();
this.$message.success("增加动态成功!");
newPost.postid=postid;
this.$emit('post-submitted', newPost);
this.form.content = '';
@ -160,7 +163,7 @@
}
else{
this.$message.error(response.data);
console.error(response);
}
} catch (error) {

@ -194,6 +194,7 @@
async loadData() {
try {
this.userid= getUserId();
//
await this.fllowlist();
await this.loadhotpost();
@ -358,7 +359,7 @@
try {
const response = await axios.get(`/comments/postid=${postid}`);
this.checkPosts[index].comments = response;
//user
this.checkPosts[index].isCommentsVisible = !this.checkPosts[index].isCommentsVisible;
} catch (error) {
@ -381,13 +382,15 @@
'Accept': 'application/json'
}
});
if (response=== "评论成功!") {
if (response.startsWith ("评论成功!")) {
this.$message.success("评论成功!");
const id = response.replace("评论成功!", '').trim();
this.checkPosts[index].comments.push({
username: '用户名',//user
postid: postid,
content: commentText
content: commentText,
commentid:id,
userid:this.userid
});
this.checkPosts[index].commentCount += 1;
}

Loading…
Cancel
Save