update service list
This commit is contained in:
1 parent
0ae8c4a003
commit
7e38c8944a
29 files changed
+270
-470
No files matched your search
@@ -0,0 +1,52 @@
|
||||
<template>
|
||||
<div></div>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { getCookie } from 'typescript-cookie';
|
||||
|
||||
interface IData {
|
||||
accessToken: string | undefined;
|
||||
refreshToken: string | undefined;
|
||||
redirect: string | undefined;
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
name: 'Login',
|
||||
data(): IData {
|
||||
return {
|
||||
accessToken: undefined,
|
||||
refreshToken: undefined,
|
||||
redirect: this.$route.query.redirect?.toString()
|
||||
};
|
||||
},
|
||||
async mounted() {
|
||||
this.accessToken = getCookie('ACCESS_TOKEN');
|
||||
this.refreshToken = getCookie('REFRESH_TOKEN');
|
||||
if (this.accessToken && this.refreshToken) {
|
||||
await this.$store.dispatch('setAccessToken', this.accessToken);
|
||||
await this.$store.dispatch('setRefreshToken', this.refreshToken);
|
||||
if (this.redirect) {
|
||||
this.$router.push(this.redirect);
|
||||
}
|
||||
} else {
|
||||
const host = window.location.host;
|
||||
const subDomain = import.meta.env.DEV ? 'test.zhishuyun.com' : host.substring(host.indexOf('.') + 1);
|
||||
// callback url used to init access token and then redirect back of `redirect`
|
||||
const callbackUrl = `https://${host}/auth/callback?redirect=${this.redirect}`;
|
||||
const targetUrl = `https://auth.${subDomain}?redirect=${callbackUrl}`;
|
||||
window.location.href = targetUrl;
|
||||
}
|
||||
},
|
||||
methods: {}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.panel {
|
||||
.title {
|
||||
text-align: center;
|
||||
font-size: 22px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,38 @@
|
||||
<template>
|
||||
<div></div>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
|
||||
interface IData {
|
||||
redirect: string | undefined;
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
name: 'Login',
|
||||
data(): IData {
|
||||
return {
|
||||
redirect: this.$route.query.redirect?.toString()
|
||||
};
|
||||
},
|
||||
async mounted() {
|
||||
const host = window.location.host;
|
||||
const subDomain = import.meta.env.DEV ? 'test.zhishuyun.com' : host.substring(host.indexOf('.') + 1);
|
||||
// callback url used to init access token and then redirect back of `redirect`
|
||||
const callbackUrl = `https://${host}/auth/callback?redirect=${this.redirect}`;
|
||||
// redirect to auth service to get access token then redirect back
|
||||
const targetUrl = `https://auth.${subDomain}?redirect=${callbackUrl}`;
|
||||
window.location.href = targetUrl;
|
||||
},
|
||||
methods: {}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.panel {
|
||||
.title {
|
||||
text-align: center;
|
||||
font-size: 22px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,146 +1,16 @@
|
||||
<template>
|
||||
<verification-alert />
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<div class="wrapper">
|
||||
<div class="container">
|
||||
<el-row v-if="loading">
|
||||
<el-col :span="6">
|
||||
<el-skeleton style="width: 150px; margin: auto; margin-top: 50px" animated>
|
||||
<template #template>
|
||||
<el-skeleton-item variant="image" style="width: 150px; height: 150px" />
|
||||
</template>
|
||||
</el-skeleton>
|
||||
</el-col>
|
||||
<el-col :span="18">
|
||||
<el-skeleton :rows="5" animated />
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row v-if="service">
|
||||
<el-col :span="6">
|
||||
<div class="thumbnail">
|
||||
<img :src="service.thumbnail" />
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col :span="18">
|
||||
<div class="title mb-5">
|
||||
<p>{{ service.title }}</p>
|
||||
</div>
|
||||
<div class="category">
|
||||
<!-- <el-button>{{ service.category }}</el-button> -->
|
||||
</div>
|
||||
<div class="introduction mb-5">
|
||||
<p>{{ service.introduction }}</p>
|
||||
</div>
|
||||
<div class="operation">
|
||||
<p v-if="paid === false">
|
||||
<span v-if="service.price" class="price">¥ {{ (service?.price / 100).toFixed(2) }}</span>
|
||||
<el-button type="danger" :loading="buying" @click="onBuy">
|
||||
<el-icon v-if="!buying" class="icon">
|
||||
<goods />
|
||||
</el-icon>
|
||||
{{ $t('service.button.buy') }}
|
||||
</el-button>
|
||||
</p>
|
||||
<p v-if="paid === true">
|
||||
<el-button type="danger" @click="onStudy">
|
||||
<el-icon class="icon"> <video-play /> </el-icon>
|
||||
{{ $t('service.button.startStudy') }}
|
||||
</el-button>
|
||||
</p>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row v-if="service">
|
||||
<el-col :span="24">
|
||||
<div class="banner">
|
||||
<div class="duration">
|
||||
<el-icon class="icon"> <clock /> </el-icon>
|
||||
<span class="value">{{ service?.duration }}{{ $t('common.entity.minute') }}</span>
|
||||
</div>
|
||||
<div class="level">
|
||||
<el-icon class="icon"> <magic-stick /> </el-icon>
|
||||
<span class="value">{{ service?.level }}</span>
|
||||
</div>
|
||||
<div v-if="episodes && episodes.length > 0" class="number">
|
||||
<el-icon class="icon"> <collection /> </el-icon>
|
||||
<span class="value">{{ episodes?.length }}{{ $t('common.entity.episodes') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :class="{ episodes: true, disabled: !verified }">
|
||||
<el-col :span="14" :offset="5">
|
||||
<el-card v-if="loading" shadow="hover" class="episode">
|
||||
<el-skeleton :rows="5" animated />
|
||||
</el-card>
|
||||
<el-card
|
||||
v-for="(episode, episodeIndex) in episodes"
|
||||
:key="episodeIndex"
|
||||
shadow="hover"
|
||||
class="episode"
|
||||
@click="
|
||||
$router.push({
|
||||
name: 'episode-detail',
|
||||
params: {
|
||||
serviceId: service?.id,
|
||||
id: episode.id
|
||||
}
|
||||
})
|
||||
"
|
||||
>
|
||||
<el-row>
|
||||
<el-col :span="4" class="left">
|
||||
<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">
|
||||
<p>
|
||||
{{ episode.title }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="introduction">
|
||||
<p>{{ episode.introduction }}</p>
|
||||
</div>
|
||||
<div class="info">
|
||||
<span class="duration">
|
||||
<el-icon class="icon"> <clock /> </el-icon>
|
||||
{{ episode.duration }} {{ $t('common.entity.minute') }}
|
||||
</span>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { serviceService } from '@/services/service/service';
|
||||
import { IService, IServiceDetailResponse, IServicePaidStatusResponse } from '@/services/service/types';
|
||||
import { episodeService } from '@/services/episode/service';
|
||||
import { IEpisode, IEpisodeListResponse } from '@/services/episode/types';
|
||||
import { orderService } from '@/services/order/service';
|
||||
import { serviceOperator } from '@/operators';
|
||||
import { defineComponent } from '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';
|
||||
import { ElMessage } from 'element-plus';
|
||||
|
||||
interface IData {
|
||||
service: IService | undefined;
|
||||
order: IOrder | undefined;
|
||||
episodes: IEpisode[] | undefined;
|
||||
loading: boolean;
|
||||
buying: boolean;
|
||||
paid: boolean | undefined;
|
||||
@@ -177,224 +47,9 @@ export default defineComponent({
|
||||
},
|
||||
async mounted() {
|
||||
this.loading = true;
|
||||
serviceService.get(this.id).then(({ data: data }: { data: IServiceDetailResponse }) => {
|
||||
this.loading = false;
|
||||
this.service = data;
|
||||
});
|
||||
serviceService.paid(this.id).then(({ data: { paid } }: { data: IServicePaidStatusResponse }) => {
|
||||
this.paid = paid;
|
||||
});
|
||||
episodeService.getAllForService(this.id).then(({ data: data }: { data: IEpisodeListResponse }) => {
|
||||
this.episodes = data.items;
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
onStudy() {
|
||||
if (this.episodes && this.episodes.length > 0) {
|
||||
const episode = this.episodes[0];
|
||||
this.$router.push({
|
||||
name: 'episode-detail',
|
||||
params: {
|
||||
serviceId: this.service?.id,
|
||||
id: episode.id
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
onBuy() {
|
||||
this.buying = true;
|
||||
ElMessage.info(this.$t('service.message.creatingOrder'));
|
||||
orderService
|
||||
.create({
|
||||
id: uuidv4().replaceAll(/-/g, ''),
|
||||
services: [this.id],
|
||||
description: `${this.$t('common.title.orderDescription')} - ${this.id}`
|
||||
})
|
||||
.then(({ data: data }: { data: IOrderDetailResponse }) => {
|
||||
this.buying = false;
|
||||
this.order = data;
|
||||
this.$router.push({
|
||||
name: 'order-detail',
|
||||
params: {
|
||||
id: this.order.id
|
||||
},
|
||||
query: {
|
||||
redirect: window.location.href
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
ElMessage.error(this.$t('service.message.createOrderFailed'));
|
||||
this.buying = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
methods: {}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.wrapper {
|
||||
width: 100%;
|
||||
height: 400px;
|
||||
background-image: radial-gradient(circle at 0 2%, #283e63, #172337 99%);
|
||||
.container {
|
||||
width: 1200px;
|
||||
margin: auto;
|
||||
padding-top: 50px;
|
||||
|
||||
.title {
|
||||
p {
|
||||
font-weight: bold;
|
||||
color: white;
|
||||
font-size: 2.4rem;
|
||||
}
|
||||
}
|
||||
.introduction {
|
||||
p {
|
||||
color: white;
|
||||
font-size: 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
.price {
|
||||
display: block;
|
||||
font-size: 30px;
|
||||
font-weight: bold;
|
||||
margin-bottom: 10px;
|
||||
color: var(--el-color-danger);
|
||||
}
|
||||
.thumbnail {
|
||||
text-align: center;
|
||||
img {
|
||||
pointer-events: none;
|
||||
width: 200px;
|
||||
height: 200px;
|
||||
margin-top: 50px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.operation {
|
||||
.el-button {
|
||||
.icon {
|
||||
margin-right: 2px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.banner {
|
||||
border-bottom-left-radius: 28px;
|
||||
border-bottom-right-radius: 28px;
|
||||
background: linear-gradient(270deg, #f44881, #ec454f);
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
width: 100%;
|
||||
height: 55px;
|
||||
padding: 12px 50px;
|
||||
.duration,
|
||||
.level,
|
||||
.number {
|
||||
font-size: 13px;
|
||||
color: white;
|
||||
display: inline-block;
|
||||
margin-right: 10px;
|
||||
color: 10px;
|
||||
.icon {
|
||||
position: relative;
|
||||
top: 1px;
|
||||
// margin-right: 5px;
|
||||
}
|
||||
.value {
|
||||
margin-left: 5px;
|
||||
// font-weight: bold;
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.verification-alert {
|
||||
padding-top: 50px;
|
||||
.go {
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
|
||||
.episodes {
|
||||
padding: 50px 0;
|
||||
&.disabled {
|
||||
opacity: 0.2;
|
||||
pointer-events: none;
|
||||
}
|
||||
.episode {
|
||||
cursor: pointer;
|
||||
margin-bottom: 2rem;
|
||||
height: 140px;
|
||||
border-radius: 0.934rem !important;
|
||||
.left {
|
||||
position: relative;
|
||||
.index {
|
||||
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%);
|
||||
}
|
||||
.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 {
|
||||
font-size: 1.2rem;
|
||||
font-weight: bold;
|
||||
margin-bottom: 10px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
}
|
||||
.introduction {
|
||||
p {
|
||||
height: 28px;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
font-size: 0.8rem;
|
||||
color: rgb(161, 161, 161);
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
}
|
||||
.info {
|
||||
font-size: 12px;
|
||||
color: rgb(161, 161, 161);
|
||||
.icon {
|
||||
position: relative;
|
||||
top: 1px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<style lang="scss" scoped></style>
|
||||
+91
-83
@@ -1,39 +1,27 @@
|
||||
<template>
|
||||
<el-row>
|
||||
<el-col :span="20" :offset="2">
|
||||
<div class="services">
|
||||
<el-card v-if="loading" class="service">
|
||||
<el-skeleton :rows="5" animated />
|
||||
</el-card>
|
||||
<el-card v-for="(service, serviceIndex) in services" :key="serviceIndex" shadow="hover" class="service">
|
||||
<div class="content">
|
||||
<!-- <div class="tags mb-5">
|
||||
<el-button
|
||||
v-for="(tag, tagIndex) in service.tags"
|
||||
:key="tagIndex"
|
||||
size="small"
|
||||
type="success"
|
||||
class="tag"
|
||||
>{{ tag }}</el-button
|
||||
>
|
||||
</div> -->
|
||||
<div
|
||||
class="title mb-5"
|
||||
@click="
|
||||
$router.push({
|
||||
name: 'service-detail',
|
||||
params: {
|
||||
id: service.id
|
||||
}
|
||||
})
|
||||
"
|
||||
>
|
||||
<p>{{ service.title }}</p>
|
||||
<el-row :gutter="15" class="services">
|
||||
<el-col v-for="(service, serviceIndex) in services" :key="serviceIndex" :md="6" :xs="24">
|
||||
<el-card shadow="hover" class="service">
|
||||
<div class="icon">
|
||||
<el-icon> <user /> </el-icon>
|
||||
</div>
|
||||
<div class="introduction mb-5">
|
||||
<p>{{ service.introduction }}</p>
|
||||
<div class="title">{{ service.title }}</div>
|
||||
<div class="price">
|
||||
<p v-if="service && service.price && service.price > 0" class="nonfree">
|
||||
¥{{ service.price }} / {{ $t('service.unit.usage') }}
|
||||
</p>
|
||||
<p v-else class="free">
|
||||
{{ $t('service.message.free') }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="study">
|
||||
<div class="introduction">
|
||||
<p>
|
||||
{{ service.introduction }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="operations">
|
||||
<router-link
|
||||
:to="{
|
||||
name: 'service-detail',
|
||||
@@ -43,26 +31,22 @@
|
||||
}"
|
||||
>
|
||||
<el-button type="danger">
|
||||
<el-icon class="icon"> <video-play /> </el-icon>
|
||||
{{ $t('service.button.startStudy') }}
|
||||
{{ $t('service.button.learnMore') }}
|
||||
</el-button>
|
||||
</router-link>
|
||||
</div>
|
||||
</div>
|
||||
<div class="thumbnail">
|
||||
<img :src="service.thumbnail" />
|
||||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<div class="services"></div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { serviceService } from '@/services/service/service';
|
||||
import { IService, IServiceListResponse } from '@/services/service/types';
|
||||
import { serviceOperator, IService, IServiceListResponse } from '@/operators';
|
||||
import { defineComponent } from 'vue';
|
||||
import { VideoPlay } from '@element-plus/icons-vue';
|
||||
import { User, Picture } from '@element-plus/icons-vue';
|
||||
|
||||
interface IData {
|
||||
services: IService[];
|
||||
@@ -71,7 +55,8 @@ interface IData {
|
||||
export default defineComponent({
|
||||
name: 'ServiceList',
|
||||
components: {
|
||||
VideoPlay
|
||||
User,
|
||||
Picture
|
||||
},
|
||||
data(): IData {
|
||||
return {
|
||||
@@ -82,7 +67,7 @@ export default defineComponent({
|
||||
async mounted() {
|
||||
this.loading = true;
|
||||
console.debug('start to load all services');
|
||||
serviceService.getAll().then(({ data: data }: { data: IServiceListResponse }) => {
|
||||
serviceOperator.getAll().then(({ data: data }: { data: IServiceListResponse }) => {
|
||||
this.services = data.items;
|
||||
this.loading = false;
|
||||
});
|
||||
@@ -91,58 +76,81 @@ export default defineComponent({
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
$transition-duration: 0.5s;
|
||||
.services {
|
||||
padding: 50px;
|
||||
.service {
|
||||
width: 1200px;
|
||||
height: 360px;
|
||||
border-radius: 0.9rem !important;
|
||||
margin: 2rem auto;
|
||||
padding: 2rem 3rem;
|
||||
width: 100%;
|
||||
height: 280px;
|
||||
border-radius: 10px !important;
|
||||
margin: 10px auto;
|
||||
padding: 30px 0;
|
||||
position: relative;
|
||||
.content {
|
||||
max-width: 650px;
|
||||
}
|
||||
transition: all $transition-duration;
|
||||
|
||||
.tags {
|
||||
.tag {
|
||||
padding-left: 20px;
|
||||
padding-right: 20px;
|
||||
}
|
||||
.icon {
|
||||
font-size: 60px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.title {
|
||||
cursor: pointer;
|
||||
p {
|
||||
font-size: 1.7rem;
|
||||
color: #666;
|
||||
font-size: 14px;
|
||||
text-align: center;
|
||||
margin: 0;
|
||||
margin-bottom: 8px;
|
||||
padding: 0 20px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.price {
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
margin: 0;
|
||||
.nonfree {
|
||||
color: #ff5441;
|
||||
}
|
||||
.free {
|
||||
color: #29c287;
|
||||
}
|
||||
}
|
||||
|
||||
.introduction {
|
||||
p {
|
||||
font-size: 1rem;
|
||||
color: rgb(96 111 123);
|
||||
}
|
||||
padding: 5px 0;
|
||||
text-align: center;
|
||||
margin: 0 auto;
|
||||
overflow: hidden;
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
text-overflow: ellipsis;
|
||||
color: #9f9f9f;
|
||||
font-size: 12px;
|
||||
opacity: 0;
|
||||
word-break: break-all;
|
||||
transition: all $transition-duration;
|
||||
text-overflow: ellipsis;
|
||||
height: 42px;
|
||||
}
|
||||
.thumbnail {
|
||||
img {
|
||||
position: absolute;
|
||||
right: -165px;
|
||||
margin-top: -50px;
|
||||
max-width: 80%;
|
||||
pointer-events: none;
|
||||
top: 0;
|
||||
width: 500px;
|
||||
height: 500px;
|
||||
}
|
||||
|
||||
.operations {
|
||||
opacity: 0;
|
||||
position: absolute;
|
||||
bottom: 30px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
text-align: center;
|
||||
transition: all $transition-duration;
|
||||
}
|
||||
.study {
|
||||
.el-button {
|
||||
padding-left: 30px;
|
||||
padding-right: 30px;
|
||||
.icon {
|
||||
margin-right: 4px;
|
||||
transform: scale(1.2);
|
||||
}
|
||||
|
||||
&:hover {
|
||||
padding-top: 0;
|
||||
.introduction {
|
||||
opacity: 1;
|
||||
}
|
||||
.operations {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user