inleft
2022-03-02 e33959d3ca88b9fae5f6fe1048c8a1f7751e6f21
commit | author | age
2f9d3c 1 <template>
I 2     <div>
3         <div class="visitInfo">
ec97e0 4             <a-form-model ref="myForm" layout="inline" :rules="rules" :model="form" :label-col="labelCol"
I 5                 :wrapper-col="wrapperCol">
6                 <a-form-model-item label="昵称" prop="nickName">
7                     <a-input v-model="form.nickName" placeholder="需填..">
2f9d3c 8                     </a-input>
I 9                 </a-form-model-item>
ec97e0 10                 <a-form-model-item label="邮箱" prop="eMail">
I 11                     <a-input v-model="form.eMail" placeholder="..仅后台可见">
2f9d3c 12                     </a-input>
I 13                 </a-form-model-item>
ec97e0 14                 <a-form-model-item label="主页" prop="homePage">
I 15                     <a-input v-model="form.homePage" placeholder="https:// or http://">
2f9d3c 16                     </a-input>
I 17                 </a-form-model-item>
18
19             </a-form-model>
20         </div>
21         <div class="replyMsgInfo" v-if="showReplyMsgInfo">
ec97e0 22             <div>{{msgInfo.useName}} </div>
I 23             <div style="padding: 0px 3px;"> : </div>
24             <div>
25                 <span v-html="msgInfo.userComment.replace(/\n/g, '<br>')"></span>
26             </div>
2f9d3c 27         </div>
I 28         <a-comment>
29             <div slot="content">
30                 <a-form-item>
ec97e0 31                     <a-textarea :rows="4" v-model="form.visitorContent" :placeholder="replyHolder" />
2f9d3c 32                 </a-form-item>
I 33                 <div>
ec97e0 34                     <a-button html-type="submit" type="primary" v-if="!showReplyMsgInfo" @click="send()"
I 35                         :disabled="isSending">
2f9d3c 36                         高低整两句
I 37                     </a-button>
ec97e0 38                     <a-button html-type="submit" type="primary" v-else @click="send()" :disabled="isSending">
2f9d3c 39                         回复Ta
I 40                     </a-button>
41                 </div>
42
43                 <div>
ec97e0 44                     <a-checkbox style="margin-left: 8px;" v-if="!showReplyMsgInfo" v-model="form.isSecretMsg">
I 45                         悄悄说..<span class="myTip">(仅登录后可查看)</span>
2f9d3c 46                     </a-checkbox>
ec97e0 47                     <!-- <a-checkbox v-model="form.isReceiveMail">
2f9d3c 48                         接收邮件回复通知
ec97e0 49                     </a-checkbox> -->
2f9d3c 50                 </div>
I 51             </div>
52         </a-comment>
53     </div>
54 </template>
55
56 <script>
ec97e0 57     import {
I 58         blogCommentAdd
59     } from '../../api/blogArticleComment.js'
60
2f9d3c 61     export default {
I 62         methods: {
63             getMsgInfo(param) {
64                 this.msgInfo = param;
65                 this.showReplyMsgInfo = true;
ec97e0 66                 this.replyHolder = "@" + this.msgInfo.useName;
I 67             },
68             send(articleId) {
69                 console.log(this.msgInfo);
70                 if (this.form.nickName === "") {
71                     this.$message.info("怎么称呼..")
72                     return
73                 }
74
75                 if (this.form.visitorContent === "") {
76                     this.$message.info("你可能需要说点什么..")
77                     return
78                 }
79
80                 var res;
81                 this.$refs.myForm.validate(valid => {
82                     if (valid) {
83                         //this.$message.info("校验通过")
84                         res = true;
85                     } else {
86                         this.$message.info("校验失败")
87                         res = false;
88                     }
89                 });
90
91                 let commentType = (articleId == null || articleId == undefined) ? 1 : 2;
92                 this.isSending = true;
93
94                 blogCommentAdd({
95                     parentId: this.msgInfo.parentId,
96                     replyId: this.msgInfo.replyId,
97                     "visitorId": "1",
98                     "isReceiveMail": 0,
99                     "articleId": articleId,
100                     "commentType": commentType,
101                     "authStatus": this.form.isSecretMsg ? 2 : 1,
102                     // "isReceiveMail": this.form.isReceiveMail ? 1 : 0,
103                     "visitorEmail": this.form.eMail,
104                     "visitorHomePage": this.form.homePage,
105                     "visitorNickName": this.form.nickName,
106                     "commentContent": this.form.visitorContent,
107                 }).then((res) => {
108                     this.isSending = false;
109                     console.log(111);
110                     if (res.code == 200) {
111                         console.log(111);
112                         this.$message.info("已送达,审核通过后显示..")
113                     } else {
114                         this.$notification.error({
115                             message: '好像哪里不对劲..',
116                             description: res.message,
117                             placement: 'bottomRight'
118                         });
119                     }
120                 }).catch((error) => {
121                     this.$message.error("请求失败")
122                     this.isSending = false;
123                 })
124                 // setTimeout(() => {
125                 //     this.$message.info("发送成功")
126                 //     this.isSending = false;
127                 // }, 3000);
128
2f9d3c 129             }
I 130         },
ec97e0 131
2f9d3c 132         data() {
I 133             return {
ec97e0 134                 isSending: false,
I 135                 replyHolder: "",
2f9d3c 136                 msgInfo: {
I 137                     useName: "",
138                     userComment: "",
ec97e0 139                     parentId: 0,
I 140                     replyId: 0
2f9d3c 141                 },
I 142                 showReplyMsgInfo: false,
143                 labelCol: {
144                     span: 6,
145                     offset: 0,
146                 },
147                 wrapperCol: {
148                     span: 15,
149                     offset: 0
150                 },
151                 form: {
ec97e0 152                     nickName: "",
I 153                     eMail: "",
154                     homePage: "",
155                     isReceiveMail: false,
156                     isSecretMsg: false,
157                     visitorContent: "",
158                     parentId: 0,
159                     replyId: 0
2f9d3c 160                 },
ec97e0 161                 rules: {
I 162                     "nickName": [{
163                         message: '怎么称呼?',
164                     }, {
165                         trigger: 'blur',
166                         max: 20,
167                         message: '你的名字也太长了..'
168                     }],
169                     "eMail": [{
170                         trigger: 'blur',
171                         pattern: /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/,
172                         message: '邮箱格式不正确'
173                     }, {
174                         trigger: 'blur',
175                         max: 50,
176                         message: '邮箱不要超过50字符..'
177                     }],
178                     "homePage": [{
179                         trigger: 'blur',
180                         pattern: /^((https|http)?:\/\/)[^\s]+/,
181                         message: '仅支持 https | http'
182                     }, {
183                         trigger: 'blur',
184                         max: 50,
185                         message: '网址不要超过50字符..'
186                     }]
187                 },
2f9d3c 188             }
I 189         }
190     }
191 </script>
192
193 <style lang="less">
194     .replyMsgInfo {
ec97e0 195         display: flex;
e33959 196         border-radius: 4px;
ec97e0 197         box-shadow: 0px 9px 10px 0 rgba(0, 0, 0, 0.24), 1px 3px 15px 0 rgba(0, 0, 0, 0.19);
e33959 198         padding: 20px 25px 20px;
ec97e0 199         margin-left: 15px;
I 200         margin-top: 10px;
2f9d3c 201     }
I 202 </style>