File tree Expand file tree Collapse file tree 3 files changed +52
-5
lines changed
components/article-comment-commit Expand file tree Collapse file tree 3 files changed +52
-5
lines changed Original file line number Diff line number Diff line change 1
1
/*
2
2
* @Date : 2021-12-27 22:45:05
3
- * @LastEditTime : 2021-12-28 20:03:55
3
+ * @LastEditTime : 2021-12-29 00:05:23
4
4
* @FilePath : \imooc-blog\api\user.js
5
5
*/
6
6
import request from "@/utils/request" ;
@@ -25,3 +25,14 @@ export function userFollow(data) {
25
25
data,
26
26
} ) ;
27
27
}
28
+
29
+ /**
30
+ * 发表评论
31
+ */
32
+ export function userArticleComment ( data ) {
33
+ return request ( {
34
+ url : "/user/article/comment" ,
35
+ method : "POST" ,
36
+ data,
37
+ } ) ;
38
+ }
Original file line number Diff line number Diff line change 1
1
<!--
2
2
* @Date: 2021-12-28 21:08:55
3
- * @LastEditTime: 2021-12-28 21:35:02
3
+ * @LastEditTime: 2021-12-29 00:06:10
4
4
* @FilePath: \imooc-blog\components\article-comment-commit\article-comment-commit.vue
5
5
-->
6
6
<template >
25
25
</template >
26
26
27
27
<script >
28
+ import { userArticleComment } from " @/api/user" ;
28
29
export default {
29
30
name: " article-comment-commit" ,
31
+ props: {
32
+ articleId: {
33
+ type: String ,
34
+ required: true ,
35
+ },
36
+ },
30
37
data () {
31
38
return {
32
39
value: " " ,
@@ -43,7 +50,24 @@ export default {
43
50
/**
44
51
* 发送按钮点击事件
45
52
*/
46
- onBtnClick () {},
53
+ async onBtnClick () {
54
+ // 展示加载框
55
+ uni .showLoading ({
56
+ title: " 加载中" ,
57
+ });
58
+ // 异步处理即可
59
+ await userArticleComment ({
60
+ articleId: this .articleId ,
61
+ content: this .value ,
62
+ });
63
+ uni .showToast ({
64
+ title: " 发表成功" ,
65
+ icon: " success" ,
66
+ mask: true ,
67
+ });
68
+ // 发表成功之后的回调
69
+ this .$emit (" success" );
70
+ },
47
71
},
48
72
};
49
73
</script >
Original file line number Diff line number Diff line change 1
1
<!--
2
2
* @Date: 2021-12-25 14:04:11
3
- * @LastEditTime: 2021-12-28 21:32:45
3
+ * @LastEditTime: 2021-12-29 00:07:22
4
4
* @FilePath: \imooc-blog\subpkg\pages\blog-detail\blog-detail.vue
5
5
-->
6
6
<template >
58
58
<article-operate @commitClick =" onCommit" />
59
59
<!-- 输入评论的popup -->
60
60
<uni-popup ref =" popup" type =" bottom" @change =" onCommitPopupChange" >
61
- <article-comment-commit v-if =" isShowCommit" />
61
+ <article-comment-commit
62
+ v-if =" isShowCommit"
63
+ :articleId =" articleId"
64
+ @success =" onSendSuccess"
65
+ />
62
66
</uni-popup >
63
67
</view >
64
68
</page-meta >
@@ -197,6 +201,14 @@ export default {
197
201
}, 200 );
198
202
}
199
203
},
204
+ /**
205
+ * 发表评论成功
206
+ */
207
+ onSendSuccess () {
208
+ // 关闭弹出层
209
+ this .$refs .popup .close ();
210
+ this .isShowCommit = false ;
211
+ },
200
212
},
201
213
};
202
214
</script >
You can’t perform that action at this time.
0 commit comments