add pdf preview
This commit is contained in:
1 parent
e67dfadac7
commit
c5ad94a129
6 files changed
+146
-26
No files matched your search
@@ -7,9 +7,12 @@
|
||||
@click="onClick(episode)"
|
||||
>
|
||||
<el-col :span="5" class="left">
|
||||
<span class="index">
|
||||
<span v-if="paid || episode.isFree" class="index">
|
||||
{{ episodeIndex + 1 }}
|
||||
</span>
|
||||
<span v-else class="lock">
|
||||
<el-icon class="icon"> <lock /> </el-icon>
|
||||
</span>
|
||||
</el-col>
|
||||
<el-col :span="19" class="right">
|
||||
<p class="title">
|
||||
@@ -32,12 +35,13 @@
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { IEpisode } from '@/services/episode/types';
|
||||
import { Clock } from '@element-plus/icons-vue';
|
||||
import { Clock, Lock } from '@element-plus/icons-vue';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'EpisodeSideList',
|
||||
components: {
|
||||
Clock
|
||||
Clock,
|
||||
Lock
|
||||
},
|
||||
props: {
|
||||
episodes: {
|
||||
@@ -49,6 +53,10 @@ export default defineComponent({
|
||||
active: {
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
paid: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
emits: ['choose'],
|
||||
@@ -94,6 +102,18 @@ export default defineComponent({
|
||||
line-height: 30px;
|
||||
background-image: linear-gradient(rgb(244, 72, 129), rgb(236, 69, 79));
|
||||
}
|
||||
.lock {
|
||||
display: block;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
text-align: center;
|
||||
margin: auto;
|
||||
border-radius: 50%;
|
||||
font-size: 0.6em;
|
||||
margin-top: 5px;
|
||||
line-height: 30px;
|
||||
background-image: linear-gradient(rgb(244, 72, 129), rgb(236, 69, 79));
|
||||
}
|
||||
}
|
||||
.right {
|
||||
width: calc(100% - 60px);
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
</div>
|
||||
<div class="operation">
|
||||
<p v-if="paid === false">
|
||||
<span v-if="course.price" class="price">¥{{ (course?.price / 100).toFixed(2) }}</span>
|
||||
<span v-if="course.price" class="price">¥ {{ (course?.price / 100).toFixed(2) }}</span>
|
||||
<el-button type="danger" :loading="buying" @click="onBuy">
|
||||
<el-icon v-if="!buying" class="icon">
|
||||
<goods />
|
||||
@@ -95,9 +95,12 @@
|
||||
>
|
||||
<el-row>
|
||||
<el-col :span="4" class="left">
|
||||
<span class="index">
|
||||
<span v-if="paid || episode?.isFree" class="index">
|
||||
{{ episodeIndex + 1 }}
|
||||
</span>
|
||||
<span v-else class="lock">
|
||||
<el-icon class="icon"> <lock /> </el-icon>
|
||||
</span>
|
||||
</el-col>
|
||||
<el-col :span="20" class="right">
|
||||
<div class="title">
|
||||
@@ -128,7 +131,7 @@ import { episodeService } from '@/services/episode/service';
|
||||
import { IEpisode, IEpisodeListResponse } from '@/services/episode/types';
|
||||
import { orderService } from '@/services/order/service';
|
||||
import { defineComponent } from 'vue';
|
||||
import { Clock, MagicStick, Collection, VideoPlay, Goods, Loading } from '@element-plus/icons-vue';
|
||||
import { Clock, MagicStick, Collection, VideoPlay, Goods, Lock } from '@element-plus/icons-vue';
|
||||
import VerificationAlert from '@/components/common/VerificationAlert.vue';
|
||||
import { IOrder, IOrderDetailResponse } from '@/services/order/types';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
@@ -151,7 +154,8 @@ export default defineComponent({
|
||||
MagicStick,
|
||||
VerificationAlert,
|
||||
VideoPlay,
|
||||
Goods
|
||||
Goods,
|
||||
Lock
|
||||
},
|
||||
data(): IData {
|
||||
return {
|
||||
@@ -346,6 +350,24 @@ export default defineComponent({
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
.lock {
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
background: #f8fafe;
|
||||
display: block;
|
||||
border-radius: 50%;
|
||||
line-height: 50px;
|
||||
text-align: center;
|
||||
font-size: 20px;
|
||||
border: 2px solid #e5e5e5;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
.icon {
|
||||
opacity: 0.6;
|
||||
}
|
||||
}
|
||||
}
|
||||
.title {
|
||||
p {
|
||||
|
||||
@@ -4,28 +4,41 @@
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<course-preview-card v-if="course" :course="course" />
|
||||
<episode-side-list :episodes="episodes" :active="id" @choose="onChoose($event)" />
|
||||
<episode-side-list :paid="paid" :episodes="episodes" :active="id" @choose="onChoose($event)" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-col>
|
||||
<el-col :span="19" class="main">
|
||||
<div v-if="paid === true || episode?.isFree">
|
||||
<episode-player
|
||||
v-if="prepared && resource?.fileId && resource.sign"
|
||||
:file-id="resource?.fileId"
|
||||
:preview="episode?.thumbnail"
|
||||
:sign="resource.sign"
|
||||
/>
|
||||
<div v-else class="transcode">
|
||||
<el-alert
|
||||
:title="$t('course.message.transcoding')"
|
||||
type="info"
|
||||
center
|
||||
show-icon
|
||||
:closable="false"
|
||||
class="info"
|
||||
<div v-if="episode?.type === 'Video'">
|
||||
<episode-player
|
||||
v-if="prepared && resource?.fileId && resource.sign"
|
||||
:file-id="resource?.fileId"
|
||||
:preview="episode?.thumbnail"
|
||||
:sign="resource.sign"
|
||||
/>
|
||||
<el-progress :percentage="50" status="exception" :indeterminate="true" :show-text="false" class="progress" />
|
||||
<div v-else class="transcode">
|
||||
<el-alert
|
||||
:title="$t('course.message.transcoding')"
|
||||
type="info"
|
||||
center
|
||||
show-icon
|
||||
:closable="false"
|
||||
class="info"
|
||||
/>
|
||||
<el-progress
|
||||
:percentage="50"
|
||||
status="exception"
|
||||
:indeterminate="true"
|
||||
:show-text="false"
|
||||
class="progress"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="episode?.type === 'Document'">
|
||||
<div class="pdf-wrapper">
|
||||
<pdf v-if="episode?.resourceUrl" :source="episode?.resourceUrl"></pdf>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="paid === false && !episode?.isFree">
|
||||
@@ -61,6 +74,8 @@ import { orderService } from '@/services/order/service';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { IOrder, IOrderDetailResponse } from '@/services/order/types';
|
||||
import { Goods } from '@element-plus/icons-vue';
|
||||
import episode from '@/router/episode';
|
||||
import Pdf from 'vue-pdf-embed';
|
||||
|
||||
interface IData {
|
||||
course: ICourse | undefined;
|
||||
@@ -81,7 +96,8 @@ export default defineComponent({
|
||||
EpisodeSideList,
|
||||
EpisodePlayer,
|
||||
CoursePreviewCard,
|
||||
Goods
|
||||
Goods,
|
||||
Pdf
|
||||
},
|
||||
data(): IData {
|
||||
return {
|
||||
@@ -110,6 +126,9 @@ export default defineComponent({
|
||||
episodeService.get(this.id).then(({ data: data }: { data: IEpisodeDetailResponse }) => {
|
||||
this.loading = false;
|
||||
this.episode = data;
|
||||
if (this.episode.type === 'Video') {
|
||||
this.onPrepareResouce();
|
||||
}
|
||||
});
|
||||
courseService.paid(this.courseId).then(({ data: { paid } }: { data: ICoursePaidStatusResponse }) => {
|
||||
this.paid = paid;
|
||||
@@ -120,7 +139,6 @@ export default defineComponent({
|
||||
courseService.get(this.courseId).then(({ data: data }: { data: ICourseDetailResponse }) => {
|
||||
this.course = data;
|
||||
});
|
||||
this.onPrepareResouce();
|
||||
},
|
||||
methods: {
|
||||
onPrepareResouce() {
|
||||
@@ -222,4 +240,9 @@ $width: 300px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.pdf-wrapper {
|
||||
overflow-y: scroll;
|
||||
height: 100vh;
|
||||
}
|
||||
</style>
|
||||
@@ -31,7 +31,7 @@ httpClient.interceptors.response.use(
|
||||
return response;
|
||||
},
|
||||
(error) => {
|
||||
if (error.response.status === 401) {
|
||||
if (error?.response?.status === 401) {
|
||||
store.dispatch('resetAuth');
|
||||
router.push('/');
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user