From c14e3278893b9dd1022aa488cee53a888c2a4c7e Mon Sep 17 00:00:00 2001
From: inleft <inleft@qq.com>
Date: Tue, 16 Aug 2022 19:34:48 +0800
Subject: [PATCH] 表情组件优化

---
 src/components/mini/box16-videoDetail.vue |  117 ++++++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 96 insertions(+), 21 deletions(-)

diff --git a/src/components/mini/box16-videoDetail.vue b/src/components/mini/box16-videoDetail.vue
index d093711..804dd89 100644
--- a/src/components/mini/box16-videoDetail.vue
+++ b/src/components/mini/box16-videoDetail.vue
@@ -1,13 +1,24 @@
 <template>
 	<div>
-		<div class="boxMain ">
-			<videoPlayBox ref="videoPlayBox" @swichPlay="swichPlay"></videoPlayBox>
+		<div v-if="showBackButton">
+			<a-button @click="()=>this.$router.back(-1)" style="position: sticky;">
+				<a-icon type="left" />
+			</a-button>
 		</div>
-		<div style="padding: 20px 20px 5px;margin-bottom: 20px;" class="myShadow fadeInLeft">
-			<pre>{{introduce}}</pre>
-		</div>
-		<div class="articleComment fadeInRight">
-			<comment ref="myComment" :articleId="articleId" :isAllowedComment="isAllowedComment" :foldReply="true" />
+		<div class="boxMain">
+			<div class="playBox" v-bind:class="{ fadeInLeft: this.$attrs.showFade,fade: !this.$attrs.showFade }">
+				<videoPlayBox ref="videoPlayBox" @swichPlay="swichPlay"></videoPlayBox>
+			</div>
+			<div 
+				v-bind:class="{ showButtonMargin:( showBackButton ) ,fadeInRight: this.$attrs.showFade,fade: !this.$attrs.showFade }">
+				<div class="introduce myShadow" v-if="introduce!=''">
+					<pre style="white-space: pre-line;">{{introduce}}</pre>
+				</div>
+				<div class="articleComment ">
+					<comment ref="myComment" :articleId="articleId" :isAllowedComment="isAllowedComment"
+						:foldReply="true" />
+				</div>
+			</div>
 		</div>
 	</div>
 
@@ -29,31 +40,60 @@
 			videoPlayBox,
 			comment,
 		},
+		created() {
+			if (this.$route.query.id != undefined && this.$route.query.id != null && this.$route.query.id != "") {
+				let item = {
+					id: this.$route.query.id,
+					isAllowedComment: this.isAllowedComment,
+					introduce: this.introduce,
+				}
+				this.showVideo(item);
+				this.showBackButton = true;
+			}
+		},
+		deactivated() {
+			if (this.showBackButton) {
+				this.$emit('detailBackAction', {
+					id: this.articleId,
+					isAllowedComment: this.isAllowedComment,
+					introduce: this.introduce,
+				})
+			}
+		},
 		watch: {
-			// '$route'(to, from) {
-			// 	if ("mdDetail" === to.name) {
-			// 		this.articleId = this.$route.query.id;
-			// 		this.articleFileType = this.$route.query.articleFileType;
-			// 	}
-			// },
+			'$route'(to, from) {
+				if ("videoDetail" === to.name) {
+					let item = {
+						id: this.$route.query.id,
+						isAllowedComment: this.isAllowedComment,
+						introduce: this.introduce,
+					}
+					this.showVideo(item);
+					this.showBackButton = true;
+				}
+			},
 			articleId: function(newValue, oldValue) {
 				if (newValue == undefined || newValue == null || newValue == "") {
 					this.errorMsg = "日志id参数缺失";
 				} else {
-					this.$nextTick(function() {
-						this.$refs.myComment.updateCommentList(this.articleId);
-					})
+					if (this.newValue != this.oldValue) {
+						this.$nextTick(function() {
+							this.$refs.myComment.updateCommentList(this.articleId);
+						})
+					}
 				}
 			},
 		},
 		data() {
 			return {
+				showBackButton: false,
 				articleId: "",
 				lastArticleId: "",
 				isAllowedComment: false,
 				introduce: "",
 				secret: "",
 				myLock: false,
+				showFade: true,
 				videoData: {
 					img: "http://t.inleft.com/share/media_photo/idea_beijing.jpg",
 					url: "",
@@ -67,9 +107,12 @@
 		methods: {
 			swichPlay(videoData) {
 				this.introduce = videoData.introduce;
+				this.articleId = videoData.id
 				this.$refs.myComment.updateCommentList(videoData.id);
 			},
 			showVideo(item) {
+				this.showBackButton = false;
+
 				//防止重复加载
 				this.lastArticleId = this.articleId;
 				this.articleId = item.id
@@ -81,11 +124,12 @@
 				this.isAllowedComment = item.isAllowedComment;
 				this.introduce = item.introduce;
 				this.loadData();
+
 			},
 			loadData() {
 
-				if (this.$refs.videoPlayBox.isPlaying) {
-					this.$message.info("上个视频正在播放中")
+				if (this.$refs.videoPlayBox != undefined && this.$refs.videoPlayBox.isPlaying) {
+					this.$message.info("视频源已切换..", 6)
 				}
 
 				if (this.myLock) {
@@ -95,8 +139,8 @@
 
 				let _this = this;
 				queryBlogArticleDetail({
-					id: this.articleId,
-					authWord: this.secret == "" ? null : md5(this.secret)
+					id: _this.articleId,
+					authWord: _this.secret == "" ? null : md5(_this.secret)
 				}).then((res) => {
 					this.myLock = !this.myLock;
 
@@ -115,10 +159,13 @@
 								placement: 'bottomRight'
 							});
 						}
+						this.myLock = !this.myLock;
 						return
 					}
 
 					this.isAllowedComment = res.data.isAllowedComment;
+					this.introduce = res.data.introduce;
+
 					this.videoData.url = res.data.articleFileURL;
 					this.videoData.img = res.data.coverFileURL;
 					this.videoData.title = res.data.title;
@@ -157,9 +204,21 @@
 
 	.boxMain {
 		user-select: none;
+		grid-template-columns: repeat(2, 1fr);
+		display: grid;
+		clear: both;
+		grid-row-gap: 2rem;
+		max-height: 100%;
+	}
+
+	.playBox {
 		display: flex;
 		justify-content: center;
-		padding: 5px 20px;
+		padding: 35px 0px;
+	}
+
+	.showButtonMargin {
+		margin: 75px 0px 0px 0px;
 	}
 
 	.myShadow {
@@ -167,4 +226,20 @@
 		box-shadow: 8px 8px 18px rgba(0, 0, 0, 0.1),
 			-8px -8px 18px #ffffff;
 	}
+
+	.introduce {
+		padding: 20px 20px 5px;
+		margin-bottom: 20px;
+	}
+
+	@media screen and (max-width: 1023px) {
+		.boxMain {
+			grid-template-columns: repeat(1, 1fr);
+			gap: 0rem;
+		}
+
+		.showButtonMargin {
+			margin: 0px;
+		}
+	}
 </style>

--
Gitblit v1.9.1