From 1169d092f3c0976a9af3dc79c3feb8057da17146 Mon Sep 17 00:00:00 2001
From: inleft <inleft@qq.com>
Date: Mon, 15 Aug 2022 18:45:38 +0800
Subject: [PATCH] 评论表情添加

---
 src/components/mini/box13-reply.vue |  159 +++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 125 insertions(+), 34 deletions(-)

diff --git a/src/components/mini/box13-reply.vue b/src/components/mini/box13-reply.vue
index cf40807..8d8309d 100644
--- a/src/components/mini/box13-reply.vue
+++ b/src/components/mini/box13-reply.vue
@@ -8,19 +8,25 @@
 					</a-input>
 				</a-form-model-item>
 				<a-form-model-item label="邮箱" prop="eMail">
-					<a-input v-model="form.eMail" placeholder="..仅后台可见">
+					<a-input v-model="form.eMail" placeholder="保密项(选填)">
 					</a-input>
 				</a-form-model-item>
 				<a-form-model-item label="主页" prop="homePage">
 					<a-input v-model="form.homePage" placeholder="https:// or http://">
 					</a-input>
 				</a-form-model-item>
-
+				<a-form-model-item label="认证"
+					v-show="form.nickName=='inleft'||form.nickName=='笔墨'||form.nickName=='阿墨'">
+					<a-input v-model="form.authCode" autocomplete='new-password' type="password" placeholder="我的授权码">
+					</a-input>
+				</a-form-model-item>
 			</a-form-model>
 		</div>
+
 		<div class="replyMsgInfo" v-if="showReplyMsgInfo">
-			<div>{{msgInfo.useName}} </div>
-			<div style="padding: 0px 3px;"> : </div>
+			<div>
+				{{msgInfo.useName}}<span style="padding: 0px 3px;"> : </span>
+			</div>
 			<div>
 				<span v-html="msgInfo.userComment.replace(/\n/g, '<br>')"></span>
 			</div>
@@ -28,38 +34,63 @@
 		<a-comment>
 			<div slot="content">
 				<a-form-item>
-					<a-textarea :rows="4" v-model="form.visitorContent" :placeholder="replyHolder" />
+					<a-textarea :rows="4" v-model="form.visitorContent" :placeholder="replyHolder"
+						class="OwO-textarea" />
 				</a-form-item>
+				<div class="OwO"></div>
+
 				<div>
-					<a-button html-type="submit" type="primary" v-if="!showReplyMsgInfo" @click="send()"
-						:disabled="isSending">
+					<a-button html-type="submit" type="primary" @click="send()" v-if="!showReplyMsgInfo"
+						:disabled="isSending || $attrs.isAllowedComment==0">
 						高低整两句
 					</a-button>
-					<a-button html-type="submit" type="primary" v-else @click="send()" :disabled="isSending">
+					<a-button html-type="submit" type="primary" v-else @click="send()"
+						:disabled="isSending || $attrs.isAllowedComment==0">
 						回复Ta
 					</a-button>
+					<span class="myTip" v-if="$attrs.isAllowedComment==0">很遗憾,评论已关闭</span>
 				</div>
 
 				<div>
-					<a-checkbox style="margin-left: 8px;" v-if="!showReplyMsgInfo" v-model="form.isSecretMsg">
+					<a-checkbox v-model="form.isReceiveMail">
+						接收邮件回复通知
+					</a-checkbox>
+					<a-checkbox v-if="!showReplyMsgInfo" v-model="form.isSecretMsg">
 						悄悄说..<span class="myTip">(仅登录后可查看)</span>
 					</a-checkbox>
-					<!-- <a-checkbox v-model="form.isReceiveMail">
-						接收邮件回复通知
-					</a-checkbox> -->
 				</div>
 			</div>
 		</a-comment>
 	</div>
+
 </template>
 
 <script>
 	import {
 		blogCommentAdd
 	} from '../../api/blogArticleComment.js'
+	import md5 from 'js-md5';
+
+	import 'owo/dist/OwO.min.css';
+	import OwO from 'owo/dist/OwO.min.js';
+	// import OwO from '/public/OWO.js';
+
+
+	const VisitorDataKey = "visitorData.inleft.com"
 
 	export default {
-		props: ["articleId"],
+		mounted() {
+			var OwO_demo = new OwO({
+				logo: 'OωO表情',
+				container: document.getElementsByClassName('OwO')[0],
+				target: document.getElementsByClassName('OwO-textarea')[0],
+				api: './OwO.json',
+				// api: 'http://diygod.github.io/OwO/demo/OwO.json',
+				position: 'down',
+				width: '100%',
+				maxHeight: '250px'
+			});
+		},
 		methods: {
 			getMsgInfo(param) {
 				this.msgInfo = param;
@@ -67,7 +98,6 @@
 				this.replyHolder = "@" + this.msgInfo.useName;
 			},
 			send() {
-				console.log(this.msgInfo);
 				if (this.form.nickName === "") {
 					this.$message.info("怎么称呼..")
 					return
@@ -75,6 +105,11 @@
 
 				if (this.form.visitorContent === "") {
 					this.$message.info("你可能需要说点什么..")
+					return
+				}
+
+				if (this.form.isReceiveMail && this.form.eMail == "") {
+					this.$message.info("如果是想接收通知的话,你可能需要填上一个邮箱..")
 					return
 				}
 
@@ -88,29 +123,53 @@
 						res = false;
 					}
 				});
-				var articleId=this.$attrs.acticleId;
-				console.log(articleId);
 
+				if (this.form.nickName == 'inleft' || this.form.nickName == '笔墨' || this.form.nickName == '阿墨') {
+					if (this.form.authCode == null || this.form.authCode == "") {
+						this.$message.info("不要成为我,你就是真的自己..")
+						return
+					}
+				}
+
+
+				var articleId = this.$attrs.articleId;
 				let commentType = (articleId == null || articleId == undefined) ? 1 : 2;
-				this.isSending = true;
 
+				//记录最新访客信息
+				if (this.form.visitorId == 1) {
+					var today = new Date();
+					var year = today.getFullYear() + "";
+					var month = today.getMonth() + 1 + "";
+					var date = today.getDate() + "";
+					var num = "";
+					for (var i = 0; i < 4; i++) {
+						num = num + Math.floor(Math.random() * 9) + "";
+					}
+					this.form.visitorId = year + (month > 10 ? month : '0' + month) + date + num
+				}
+
+				localStorage.setItem(VisitorDataKey, JSON.stringify(this.form))
+
+				this.isSending = true;
 				blogCommentAdd({
 					parentId: this.msgInfo.parentId,
 					replyId: this.msgInfo.replyId,
-					"visitorId": "1",
-					"isReceiveMail": 0,
+					"visitorId": this.form.visitorId,
 					"articleId": articleId,
 					"commentType": commentType,
 					"authStatus": this.form.isSecretMsg ? 2 : 1,
-					// "isReceiveMail": this.form.isReceiveMail ? 1 : 0,
+					"isReceiveMail": this.form.isReceiveMail ? 1 : 0,
 					"visitorEmail": this.form.eMail,
 					"visitorHomePage": this.form.homePage,
 					"visitorNickName": this.form.nickName,
 					"commentContent": this.form.visitorContent,
+					"authCode": this.form.authCode != null && this.form.authCode != "" ? md5(this.form.authCode) :
+						''
 				}).then((res) => {
 					this.isSending = false;
 					if (res.code == 200) {
-						this.$message.info("已送达,审核通过后显示..")
+						this.$emit("sendMsg");
+						this.$message.info("信息已送达..")
 					} else {
 						this.$notification.error({
 							message: '好像哪里不对劲..',
@@ -131,6 +190,31 @@
 		},
 
 		data() {
+			let tempVisitorData = localStorage.getItem(VisitorDataKey);
+			let vistorData = {
+				nickName: "",
+				eMail: "",
+				homePage: "",
+				isReceiveMail: false,
+				isSecretMsg: false,
+				visitorContent: "",
+				parentId: 0,
+				replyId: 0,
+				visitorId: 1,
+				authCode: ''
+			};
+
+			if (tempVisitorData != null && tempVisitorData != undefined) {
+				tempVisitorData = JSON.parse(tempVisitorData);
+				vistorData.nickName = tempVisitorData.nickName;
+				vistorData.eMail = tempVisitorData.eMail;
+				vistorData.homePage = tempVisitorData.homePage;
+				vistorData.isReceiveMail = tempVisitorData.isReceiveMail;
+				vistorData.isSecretMsg = tempVisitorData.isSecretMsg;
+				vistorData.visitorId = tempVisitorData.visitorId;
+				vistorData.authCode = tempVisitorData.authCode;
+			}
+
 			return {
 				isSending: false,
 				replyHolder: "",
@@ -149,16 +233,7 @@
 					span: 15,
 					offset: 0
 				},
-				form: {
-					nickName: "",
-					eMail: "",
-					homePage: "",
-					isReceiveMail: false,
-					isSecretMsg: false,
-					visitorContent: "",
-					parentId: 0,
-					replyId: 0
-				},
+				form: vistorData,
 				rules: {
 					"nickName": [{
 						message: '怎么称呼?',
@@ -170,7 +245,7 @@
 					"eMail": [{
 						trigger: 'blur',
 						pattern: /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/,
-						message: '邮箱格式不正确'
+						message: '你这邮箱有问题??'
 					}, {
 						trigger: 'blur',
 						max: 50,
@@ -178,8 +253,8 @@
 					}],
 					"homePage": [{
 						trigger: 'blur',
-						pattern: /^((https|http)?:\/\/)[^\s]+/,
-						message: '仅支持 https | http'
+						pattern: /^((https|http)?:\/\/)+/,
+						message: '仅支持 https:// | http://'
 					}, {
 						trigger: 'blur',
 						max: 50,
@@ -194,10 +269,26 @@
 <style lang="less">
 	.replyMsgInfo {
 		display: flex;
+		flex-direction: column;
 		border-radius: 4px;
 		box-shadow: 0px 9px 10px 0 rgba(0, 0, 0, 0.24), 1px 3px 15px 0 rgba(0, 0, 0, 0.19);
 		padding: 20px 25px 20px;
 		margin-left: 15px;
 		margin-top: 10px;
 	}
+
+	.OwO {
+		padding: 0px 0px 20px 0px;
+	}
+
+	.OwO .OwO-logo {
+		height: 30px;
+	}
+
+	.OwO .quyin,
+	.OwO img {
+		margin-bottom: -0.125rem;
+		min-height: 3.5rem;
+		height: 1em;
+	}
 </style>

--
Gitblit v1.9.1