|
|
|
@ -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) {
|
|
|
|
|