inleft
2022-08-14 a3ab3afe580daa80e9689f6e513e75a385f75bac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
<template>
    <div>
        <div v-if="showBackButton">
            <a-button @click="()=>this.$router.back(-1)" style="position: sticky;">
                <a-icon type="left" />
            </a-button>
        </div>
        <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>
 
</template>
 
<script>
    import {
        history
    } from '../../api/blogArticleComment.js'
    import videoPlayBox from "../mini/box15-videoPlayBox.vue"
    import comment from "../mini/box12-comment.vue"
 
    import {
        queryBlogArticleDetail
    } from '../../api/blogArticle.js'
 
    export default {
        components: {
            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 ("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 {
                    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: "",
                    type: "normal",
                    title: "",
                    introduce: "",
                    id: ""
                }
            }
        },
        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
 
                if (this.articleId == this.lastArticleId) {
                    return
                }
 
                this.isAllowedComment = item.isAllowedComment;
                this.introduce = item.introduce;
                this.loadData();
 
            },
            loadData() {
 
                if (this.$refs.videoPlayBox != undefined && this.$refs.videoPlayBox.isPlaying) {
                    this.$message.info("视频源已切换..", 6)
                }
 
                if (this.myLock) {
                    this.$message.info("正在努力加载中..", 3)
                    return
                }
 
                let _this = this;
                queryBlogArticleDetail({
                    id: _this.articleId,
                    authWord: _this.secret == "" ? null : md5(_this.secret)
                }).then((res) => {
                    this.myLock = !this.myLock;
 
                    if (res.code != 200) {
 
                        if (res.code == 1019001) {
                            //日志需要授权
                            this.$message.error(res.message)
                        } else if (res.code == 1019002) {
 
                            this.$message.error(res.message)
                        } else {
                            this.$notification.error({
                                message: '好像哪里不对劲..',
                                description: res.message,
                                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;
                    this.videoData.introduce = res.data.introduce;
                    this.videoData.id = res.data.id;
 
 
                    if (res.data.articleFileURL != null &&
                        res.data.articleFileURL != "" &&
                        res.data.articleFileURL.endsWith("m3u8")) {
                        this.videoData.type = "customHls";
                    } else {
                        this.videoData.type = "normal";
                    }
 
                    this.myLock = !this.myLock;
                    if (this.lastArticleId != this.articleId) {
                        let tempParam = JSON.parse(JSON.stringify(this.videoData))
                        _this.$refs.videoPlayBox.startPlay(tempParam)
                    }
                })
 
            }
        },
    }
</script>
<style scoped>
    a {
        color: black;
    }
 
    pre {
        font-family: 'HYTangMeiRen';
        src: url("http://t.inleft.com/share/z%E5%AD%97%E4%BD%93%E5%BA%93/hytmr55%E6%B1%89%E4%BB%AA%E5%94%90%E7%BE%8E%E4%BA%BA%E5%AD%97%E4%BD%93.woff") format("truetype");
    }
 
    .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: 35px 0px;
    }
 
    .showButtonMargin {
        margin: 75px 0px 0px 0px;
    }
 
    .myShadow {
 
        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>