success integration of service
This commit is contained in:
1 parent
5679818def
commit
0ae8c4a003
40 files changed
+190
-1337
No files matched your search
@@ -1,11 +1,11 @@
|
||||
# Adademy
|
||||
# Data
|
||||
|
||||
## Setup domain
|
||||
|
||||
Modify the host file, like `/etc/hosts`, add this line:
|
||||
|
||||
```
|
||||
127.0.0.1 academy.local.zhishuyun.com
|
||||
127.0.0.1 data.local.zhishuyun.com
|
||||
```
|
||||
|
||||
Then save it.
|
||||
@@ -28,4 +28,4 @@ Run below command to start local server:
|
||||
sudo yarn start
|
||||
```
|
||||
|
||||
Then open `https://academy.local.zhishuyun.com` to view the content.
|
||||
Then open `https://data.local.zhishuyun.com` to view the content.
|
||||
@@ -1,7 +1,7 @@
|
||||
apiVersion: networking.k8s.io/v1beta1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: ingress-zhishuyun-academy-frontend
|
||||
name: ingress-zhishuyun-data-frontend
|
||||
namespace: zhishuyun-test
|
||||
annotations:
|
||||
kubernetes.io/ingress.class: 'nginx'
|
||||
@@ -10,13 +10,13 @@ metadata:
|
||||
spec:
|
||||
tls:
|
||||
- hosts:
|
||||
- academy.test.zhishuyun.com
|
||||
- data.test.zhishuyun.com
|
||||
secretName: tls-wildcard-test-zhishuyun-com
|
||||
rules:
|
||||
- host: academy.test.zhishuyun.com
|
||||
- host: data.test.zhishuyun.com
|
||||
http:
|
||||
paths:
|
||||
- backend:
|
||||
serviceName: zhishuyun-academy-frontend
|
||||
serviceName: zhishuyun-data-frontend
|
||||
servicePort: 8083
|
||||
path: /
|
||||
@@ -2,8 +2,8 @@ apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
labels:
|
||||
app: zhishuyun-academy-frontend
|
||||
name: zhishuyun-academy-frontend
|
||||
app: zhishuyun-data-frontend
|
||||
name: zhishuyun-data-frontend
|
||||
namespace: zhishuyun-test
|
||||
spec:
|
||||
ports:
|
||||
@@ -11,4 +11,4 @@ spec:
|
||||
port: 8083
|
||||
targetPort: 80
|
||||
selector:
|
||||
app: zhishuyun-academy-frontend
|
||||
app: zhishuyun-data-frontend
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
version: '3'
|
||||
services:
|
||||
zhishuyun-academy-frontend:
|
||||
container_name: 'zhishuyun-academy-frontend'
|
||||
zhishuyun-data-frontend:
|
||||
container_name: 'zhishuyun-data-frontend'
|
||||
build: ./
|
||||
image: 'ghcr.io/zhishuyun/zhishuyun-academy-frontend:${BUILD_NUMBER}'
|
||||
image: 'ghcr.io/zhishuyun/zhishuyun-data-frontend:${BUILD_NUMBER}'
|
||||
ports:
|
||||
- '8086:80'
|
||||
+2
-2
@@ -13,12 +13,12 @@ server {
|
||||
}
|
||||
|
||||
location /api/ {
|
||||
proxy_pass http://zhishuyun-academy-backend:8000/api/;
|
||||
proxy_pass http://zhishuyun-data-backend:8000/api/;
|
||||
proxy_http_version 1.1;
|
||||
}
|
||||
|
||||
location /static/ {
|
||||
proxy_pass http://zhishuyun-academy-backend:8000/static/;
|
||||
proxy_pass http://zhishuyun-data-backend:8000/static/;
|
||||
proxy_http_version 1.1;
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "zhishuyun-academy",
|
||||
"name": "zhishuyun-data",
|
||||
"version": "0.1.0",
|
||||
"scripts": {
|
||||
"start": "cross-env NODE_ENV=$npm_config_env vite --host",
|
||||
@@ -14,8 +14,8 @@
|
||||
"lint": "npx eslint src --fix --ext .ts,.tsx,.vue,.js,.jsx",
|
||||
"prettier": "npx prettier --write .",
|
||||
"init:https": "npm run init:ca && npm run init:cert",
|
||||
"init:ca": "npx mkcert create-ca --validity 36500 --key certs/academy.local.zhishuyun.com.ca.key --cert certs/academy.local.zhishuyun.com.ca.crt",
|
||||
"init:cert": "npx mkcert create-cert --ca-key certs/academy.local.zhishuyun.com.ca.key --ca-cert certs/academy.local.zhishuyun.com.ca.crt --validity 36500 --key certs/academy.local.zhishuyun.com.cert.key --cert certs/academy.local.zhishuyun.com.cert.crt --domains academy.local.zhishuyun.com"
|
||||
"init:ca": "npx mkcert create-ca --validity 36500 --key certs/data.local.zhishuyun.com.ca.key --cert certs/data.local.zhishuyun.com.ca.crt",
|
||||
"init:cert": "npx mkcert create-cert --ca-key certs/data.local.zhishuyun.com.ca.key --ca-cert certs/data.local.zhishuyun.com.ca.crt --validity 36500 --key certs/data.local.zhishuyun.com.cert.key --cert certs/data.local.zhishuyun.com.cert.crt --domains data.local.zhishuyun.com"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/uuid": "^8.3.4",
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
<template>
|
||||
<el-container>
|
||||
<el-header>
|
||||
<top-header />
|
||||
</el-header>
|
||||
<el-main> <router-view /> </el-main>
|
||||
<el-footer>
|
||||
<bottom-footer />
|
||||
</el-footer>
|
||||
</el-container>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { TopHeader } from '@/components/common/index';
|
||||
import BottomFooter from '@/components/common/BottomFooter.vue';
|
||||
export default {
|
||||
name: 'LayoutCategory',
|
||||
components: {
|
||||
TopHeader,
|
||||
BottomFooter
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.el-header,
|
||||
.el-footer {
|
||||
padding: 0;
|
||||
}
|
||||
</style>
|
||||
@@ -1,14 +0,0 @@
|
||||
<template>
|
||||
<el-container>
|
||||
<el-container>
|
||||
<el-main> <router-view /> </el-main>
|
||||
</el-container>
|
||||
</el-container>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'LayoutEpisode',
|
||||
components: {}
|
||||
};
|
||||
</script>
|
||||
@@ -1,30 +0,0 @@
|
||||
<template>
|
||||
<el-container>
|
||||
<el-header>
|
||||
<top-header />
|
||||
</el-header>
|
||||
<el-main> <router-view /> </el-main>
|
||||
<el-footer>
|
||||
<bottom-footer />
|
||||
</el-footer>
|
||||
</el-container>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { TopHeader } from '@/components/common/index';
|
||||
import BottomFooter from '@/components/common/BottomFooter.vue';
|
||||
export default {
|
||||
name: 'LayoutOrder',
|
||||
components: {
|
||||
TopHeader,
|
||||
BottomFooter
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.el-header,
|
||||
.el-footer {
|
||||
padding: 0;
|
||||
}
|
||||
</style>
|
||||
File renamed without changes.
@@ -1,52 +0,0 @@
|
||||
<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>
|
||||
@@ -1,38 +0,0 @@
|
||||
<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,106 +0,0 @@
|
||||
<template>
|
||||
<el-row class="categories">
|
||||
<el-col :span="24">
|
||||
<el-row>
|
||||
<el-col :span="18" :offset="3">
|
||||
<el-row :gutter="20">
|
||||
<el-col v-for="(category, categoryIndex) in categories" :key="categoryIndex" :span="6">
|
||||
<div class="category" @click="onDetail(category.alias)">
|
||||
<div class="left">
|
||||
<img :src="category.logo" />
|
||||
</div>
|
||||
<div class="right">
|
||||
<h2 class="name">{{ category.name }}</h2>
|
||||
<p class="info">{{ category.courses?.length }} {{ $t('common.entity.course') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { categoryService } from '@/services/category/service';
|
||||
import { ICategory, ICategoryListResponse } from '@/services/category/types';
|
||||
import { defineComponent } from 'vue';
|
||||
|
||||
interface IData {
|
||||
categories: ICategory[];
|
||||
loading: boolean;
|
||||
}
|
||||
export default defineComponent({
|
||||
name: 'CategoryList',
|
||||
data(): IData {
|
||||
return {
|
||||
categories: [],
|
||||
loading: false
|
||||
};
|
||||
},
|
||||
async mounted() {
|
||||
this.loading = true;
|
||||
console.debug('start to load all categories');
|
||||
categoryService.getAll().then(({ data: data }: { data: ICategoryListResponse }) => {
|
||||
this.categories = data.items;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
onDetail(alias?: string) {
|
||||
this.$router.push({
|
||||
name: 'course-list',
|
||||
query: {
|
||||
category: alias
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.categories {
|
||||
// background-color: #0f1725;
|
||||
background-image: radial-gradient(circle at 0 0, #223c6a, rgba(15, 23, 37, 0) 56%),
|
||||
linear-gradient(180deg, #0f1725, #0f1725);
|
||||
padding: 40px 0;
|
||||
.category {
|
||||
width: 100%;
|
||||
background-color: #13233c;
|
||||
height: 90px;
|
||||
color: white;
|
||||
border-radius: 10px;
|
||||
margin: 15px 0;
|
||||
border-width: 2px;
|
||||
border-style: solid;
|
||||
border-color: #13233c;
|
||||
cursor: pointer;
|
||||
.left,
|
||||
.right {
|
||||
float: left;
|
||||
}
|
||||
&:hover {
|
||||
border-color: rgba(50, 138, 241, 0.2);
|
||||
}
|
||||
|
||||
.left {
|
||||
width: 80px;
|
||||
img {
|
||||
width: 60px;
|
||||
margin: 10px;
|
||||
}
|
||||
margin-right: 10px;
|
||||
}
|
||||
.right {
|
||||
width: calc(100% - 90px);
|
||||
margin-top: 15px;
|
||||
.name {
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,252 +0,0 @@
|
||||
<template>
|
||||
<el-row>
|
||||
<el-col :span="5" class="side">
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<course-preview-card v-if="course" :course="course" />
|
||||
<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">
|
||||
<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"
|
||||
/>
|
||||
<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'">
|
||||
<episode-document v-if="episode.resourceUrl" :resource-url="episode.resourceUrl" />
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="paid === false && !episode?.isFree">
|
||||
<el-card class="unpaid">
|
||||
<el-result icon="info" :title="undefined" :sub-title="$t('course.message.needPay')">
|
||||
<template #extra>
|
||||
<el-button type="danger" :loading="buying" class="buy" @click="onBuy">
|
||||
<el-icon v-if="!buying" class="icon">
|
||||
<goods />
|
||||
</el-icon>
|
||||
{{ $t('course.button.buy') }}
|
||||
</el-button>
|
||||
</template>
|
||||
</el-result>
|
||||
</el-card>
|
||||
</div>
|
||||
<div>
|
||||
<create-comment v-if="episode?.id" :episode-id="episode?.id" />
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { episodeService } from '@/services/episode/service';
|
||||
import { IEpisode, IEpisodeDetailResponse, IEpisodeListResponse, IEpisodeSignResponse } from '@/services/episode/types';
|
||||
import { defineComponent } from 'vue';
|
||||
import EpisodeSideList from '@/components/episode/SideList.vue';
|
||||
import EpisodePlayer from '@/components/episode/Player.vue';
|
||||
import EpisodeDocument from '@/components/episode/Document.vue';
|
||||
import CoursePreviewCard from '@/components/course/PreviewCard.vue';
|
||||
import CreateComment from '@/components/comment/Create.vue';
|
||||
import { courseService } from '@/services/course/service';
|
||||
import { ICourse, ICourseDetailResponse, ICoursePaidStatusResponse } from '@/services/course/types';
|
||||
import { IResource, IResourceDetailResponse } from '@/services/resource/types';
|
||||
import { ElMessage } from 'element-plus';
|
||||
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';
|
||||
|
||||
interface IData {
|
||||
course: ICourse | undefined;
|
||||
episode: IEpisode | undefined;
|
||||
resource: IResource | undefined;
|
||||
episodes: IEpisode[];
|
||||
order: IOrder | undefined;
|
||||
buying: boolean;
|
||||
loading: boolean;
|
||||
prepared: boolean;
|
||||
paid: boolean | undefined;
|
||||
sign: string | undefined;
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
name: 'EpisodeDetail',
|
||||
components: {
|
||||
EpisodeSideList,
|
||||
EpisodePlayer,
|
||||
CoursePreviewCard,
|
||||
Goods,
|
||||
EpisodeDocument,
|
||||
CreateComment
|
||||
},
|
||||
data(): IData {
|
||||
return {
|
||||
course: undefined,
|
||||
episode: undefined,
|
||||
buying: false,
|
||||
loading: false,
|
||||
order: undefined,
|
||||
episodes: [],
|
||||
resource: undefined,
|
||||
paid: undefined,
|
||||
sign: undefined,
|
||||
prepared: false
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
id() {
|
||||
return parseInt(this.$route.params.id.toString());
|
||||
},
|
||||
courseId() {
|
||||
return parseInt(this.$route.params.courseId.toString());
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
this.loading = true;
|
||||
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;
|
||||
});
|
||||
episodeService.getAllForCourse(this.courseId).then(({ data: data }: { data: IEpisodeListResponse }) => {
|
||||
this.episodes = data.items;
|
||||
});
|
||||
courseService.get(this.courseId).then(({ data: data }: { data: ICourseDetailResponse }) => {
|
||||
this.course = data;
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
onPrepareResouce() {
|
||||
episodeService.resource(this.id).then(({ data: data }: { data: IResourceDetailResponse }) => {
|
||||
this.resource = data;
|
||||
if (data.sign) {
|
||||
this.prepared = true;
|
||||
}
|
||||
});
|
||||
if (!this.prepared) {
|
||||
setTimeout(() => {
|
||||
this.onPrepareResouce();
|
||||
}, 3000);
|
||||
}
|
||||
},
|
||||
onChoose(episode: IEpisode) {
|
||||
this.$router.push({
|
||||
...this.$route,
|
||||
params: {
|
||||
id: episode.id,
|
||||
courseId: this.courseId
|
||||
}
|
||||
});
|
||||
setTimeout(() => {
|
||||
window.location.reload();
|
||||
}, 0);
|
||||
},
|
||||
onBuy() {
|
||||
this.buying = true;
|
||||
ElMessage.info(this.$t('course.message.creatingOrder'));
|
||||
orderService
|
||||
.create({
|
||||
id: uuidv4().replaceAll(/-/g, ''),
|
||||
courses: [this.courseId],
|
||||
description: `${this.$t('common.title.orderDescription')} - ${this.courseId}`
|
||||
})
|
||||
.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('course.message.createOrderFailed'));
|
||||
this.buying = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
$width: 300px;
|
||||
.side {
|
||||
background-color: #0d131d;
|
||||
min-height: 100vh;
|
||||
overflow-y: scroll;
|
||||
width: $width;
|
||||
}
|
||||
.main {
|
||||
position: relative;
|
||||
width: calc(100% - $width);
|
||||
background-image: radial-gradient(circle at 0 2%, #283e63, #172337 99%);
|
||||
}
|
||||
|
||||
.transcode {
|
||||
width: 300px;
|
||||
height: 200px;
|
||||
margin: auto;
|
||||
top: 50%;
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
transform: translate(0, -50%);
|
||||
.progress {
|
||||
margin: auto;
|
||||
}
|
||||
.info {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.unpaid {
|
||||
width: 400px;
|
||||
// height: 200px;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
.buy {
|
||||
.icon {
|
||||
margin-right: 2px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.document-wrapper {
|
||||
overflow-y: scroll;
|
||||
height: 80vh;
|
||||
padding: 15px;
|
||||
}
|
||||
</style>
|
||||
@@ -1,325 +0,0 @@
|
||||
<template>
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<div class="wrapper">
|
||||
<div class="container">
|
||||
<el-row v-if="order">
|
||||
<el-col :span="24">
|
||||
<el-card>
|
||||
<el-row>
|
||||
<el-col :span="12" :offset="6">
|
||||
<div class="order">
|
||||
<el-descriptions :title="$t('course.title.orderInfo')" :column="1">
|
||||
<el-descriptions-item :label="$t('course.title.orderId')">{{ order?.id }}</el-descriptions-item>
|
||||
<el-descriptions-item :label="$t('course.title.orderDescription')">
|
||||
{{ order?.description }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item v-if="order?.price" :label="$t('course.title.orderPrice')">
|
||||
<span class="price">¥{{ (order?.price / 100).toFixed(2) }}</span>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item
|
||||
v-for="(course, courseIndex) in courses"
|
||||
:key="courseIndex"
|
||||
:label="$t('course.title.orderGood')"
|
||||
>
|
||||
<span>{{ course.title }}</span>
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12" :offset="6">
|
||||
<el-divider border-style="dashed" />
|
||||
<div class="payways">
|
||||
<div
|
||||
:class="{
|
||||
payway: true,
|
||||
wechat: true,
|
||||
active: payway === 'wechat'
|
||||
}"
|
||||
>
|
||||
<span class="payicon wechat"></span>
|
||||
{{ $t('course.title.payWayWechat') }}
|
||||
</div>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12" :offset="6">
|
||||
<el-row class="paycodes">
|
||||
<el-col :span="12">
|
||||
<div class="paycode wechat">
|
||||
<qr-code v-if="order.wechatpayUrl" :value="order.wechatpayUrl" :size="200" class="m-auto" />
|
||||
<p class="help-text">{{ $t('course.message.wechatPayHelp') }}</p>
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<div class="help-img">
|
||||
<img src="https://midas.gtimg.cn/enterprise/images/ep_sys_wx_tip.jpg" />
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { ICourse, ICourseDetailResponse } from '@/services/course/types';
|
||||
import { orderService } from '@/services/order/service';
|
||||
import { courseService } from '@/services/course/service';
|
||||
import { IOrder, IOrderDetailResponse, ORDER_STATE_PAID } from '@/services/order/types';
|
||||
import { defineComponent } from 'vue';
|
||||
import QrCode from 'qrcode.vue';
|
||||
import { ElMessage } from 'element-plus';
|
||||
|
||||
const PAYWAY_WECHAT = 'wechat';
|
||||
|
||||
interface IData {
|
||||
payway: typeof PAYWAY_WECHAT;
|
||||
order: IOrder | undefined;
|
||||
courses: ICourse[] | undefined;
|
||||
loading: boolean;
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
name: 'OrderDetail',
|
||||
components: {
|
||||
QrCode
|
||||
},
|
||||
data(): IData {
|
||||
return {
|
||||
payway: PAYWAY_WECHAT,
|
||||
order: undefined,
|
||||
courses: [],
|
||||
loading: false
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
verified() {
|
||||
return this.$store.getters.user.isVerified;
|
||||
},
|
||||
id() {
|
||||
return this.$route.params.id.toString();
|
||||
},
|
||||
redirect() {
|
||||
return this.$route.query.redirect;
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
this.loading = true;
|
||||
orderService.get(this.id).then(({ data: data }: { data: IOrderDetailResponse }) => {
|
||||
this.loading = false;
|
||||
this.order = data;
|
||||
this.order.courses?.forEach((courseId: number) => {
|
||||
console.log('course', courseId);
|
||||
courseService.get(courseId).then(({ data: data2 }: { data: ICourseDetailResponse }) => {
|
||||
this.courses?.push(data2);
|
||||
});
|
||||
});
|
||||
});
|
||||
this.onCheck();
|
||||
},
|
||||
methods: {
|
||||
onCheck() {
|
||||
orderService
|
||||
.get(this.id)
|
||||
.then(({ data: data }: { data: IOrderDetailResponse }) => {
|
||||
this.order = data;
|
||||
if (this.order.state === ORDER_STATE_PAID) {
|
||||
ElMessage.success(this.$t('course.message.paidSuccessfully'));
|
||||
setTimeout(() => {
|
||||
if (this.redirect) {
|
||||
window.location.replace(this.redirect?.toString());
|
||||
}
|
||||
}, 2000);
|
||||
return;
|
||||
}
|
||||
setTimeout(() => {
|
||||
this.onCheck();
|
||||
}, 2000);
|
||||
})
|
||||
.catch(() => {
|
||||
setTimeout(() => {
|
||||
this.onCheck();
|
||||
}, 2000);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.wrapper {
|
||||
width: 100%;
|
||||
height: 800px;
|
||||
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;
|
||||
}
|
||||
}
|
||||
.thumbnail {
|
||||
text-align: center;
|
||||
img {
|
||||
pointer-events: none;
|
||||
width: 200px;
|
||||
height: 200px;
|
||||
margin-top: 50px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
||||
|
||||
.verification-alert {
|
||||
padding-top: 50px;
|
||||
.go {
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
|
||||
.order {
|
||||
.price {
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
|
||||
.el-card {
|
||||
padding: 50px 0;
|
||||
}
|
||||
|
||||
.payways {
|
||||
overflow: hidden;
|
||||
.payway {
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
float: left;
|
||||
width: 120px;
|
||||
line-height: 40px;
|
||||
text-align: center;
|
||||
height: 40px;
|
||||
border: 1px solid #eee;
|
||||
&.active {
|
||||
border: 1px solid #3879d1;
|
||||
}
|
||||
}
|
||||
|
||||
.payicon {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
margin-top: 2px;
|
||||
display: inline-block;
|
||||
&.wechat {
|
||||
position: relative;
|
||||
top: 3px;
|
||||
width: 22px;
|
||||
height: 19px;
|
||||
background-image: url(//midas.gtimg.cn/enterprise/images/ep_new_sprites@2x.png);
|
||||
background-repeat: no-repeat;
|
||||
background-size: 60px 250px;
|
||||
background-position: 0 -50px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.paycodes {
|
||||
padding: 30px 0;
|
||||
.wechat {
|
||||
.help-text {
|
||||
display: block;
|
||||
background-color: #00c800;
|
||||
color: white;
|
||||
font-size: 14px;
|
||||
height: 35px;
|
||||
width: 240px;
|
||||
text-align: center;
|
||||
line-height: 35px;
|
||||
margin: 10px auto 0 auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.episodes {
|
||||
padding: 50px 0;
|
||||
&.disabled {
|
||||
opacity: 0.2;
|
||||
pointer-events: none;
|
||||
}
|
||||
.episode {
|
||||
cursor: pointer;
|
||||
margin-bottom: 2rem;
|
||||
height: 100px;
|
||||
border-radius: 0.934rem !important;
|
||||
.left {
|
||||
.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: 5px;
|
||||
left: 35px;
|
||||
}
|
||||
}
|
||||
.title {
|
||||
p {
|
||||
font-size: 1.2rem;
|
||||
font-weight: bold;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
.introduction {
|
||||
p {
|
||||
font-size: 0.8rem;
|
||||
color: rgb(161, 161, 161);
|
||||
}
|
||||
}
|
||||
.info {
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
.icon {
|
||||
position: relative;
|
||||
top: 1px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -16,36 +16,36 @@
|
||||
<el-skeleton :rows="5" animated />
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row v-if="course">
|
||||
<el-row v-if="service">
|
||||
<el-col :span="6">
|
||||
<div class="thumbnail">
|
||||
<img :src="course.thumbnail" />
|
||||
<img :src="service.thumbnail" />
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col :span="18">
|
||||
<div class="title mb-5">
|
||||
<p>{{ course.title }}</p>
|
||||
<p>{{ service.title }}</p>
|
||||
</div>
|
||||
<div class="category">
|
||||
<!-- <el-button>{{ course.category }}</el-button> -->
|
||||
<!-- <el-button>{{ service.category }}</el-button> -->
|
||||
</div>
|
||||
<div class="introduction mb-5">
|
||||
<p>{{ course.introduction }}</p>
|
||||
<p>{{ service.introduction }}</p>
|
||||
</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="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('course.button.buy') }}
|
||||
{{ $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('course.button.startStudy') }}
|
||||
{{ $t('service.button.startStudy') }}
|
||||
</el-button>
|
||||
</p>
|
||||
</div>
|
||||
@@ -55,16 +55,16 @@
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row v-if="course">
|
||||
<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">{{ course?.duration }}{{ $t('common.entity.minute') }}</span>
|
||||
<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">{{ course?.level }}</span>
|
||||
<span class="value">{{ service?.level }}</span>
|
||||
</div>
|
||||
<div v-if="episodes && episodes.length > 0" class="number">
|
||||
<el-icon class="icon"> <collection /> </el-icon>
|
||||
@@ -87,7 +87,7 @@
|
||||
$router.push({
|
||||
name: 'episode-detail',
|
||||
params: {
|
||||
courseId: course?.id,
|
||||
serviceId: service?.id,
|
||||
id: episode.id
|
||||
}
|
||||
})
|
||||
@@ -125,8 +125,8 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { courseService } from '@/services/course/service';
|
||||
import { ICourse, ICourseDetailResponse, ICoursePaidStatusResponse } from '@/services/course/types';
|
||||
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';
|
||||
@@ -138,7 +138,7 @@ import { v4 as uuidv4 } from 'uuid';
|
||||
import { ElMessage } from 'element-plus';
|
||||
|
||||
interface IData {
|
||||
course: ICourse | undefined;
|
||||
service: IService | undefined;
|
||||
order: IOrder | undefined;
|
||||
episodes: IEpisode[] | undefined;
|
||||
loading: boolean;
|
||||
@@ -147,7 +147,7 @@ interface IData {
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
name: 'CourseDetail',
|
||||
name: 'ServiceDetail',
|
||||
components: {
|
||||
Clock,
|
||||
Collection,
|
||||
@@ -159,7 +159,7 @@ export default defineComponent({
|
||||
},
|
||||
data(): IData {
|
||||
return {
|
||||
course: undefined,
|
||||
service: undefined,
|
||||
order: undefined,
|
||||
episodes: [],
|
||||
loading: false,
|
||||
@@ -177,14 +177,14 @@ export default defineComponent({
|
||||
},
|
||||
async mounted() {
|
||||
this.loading = true;
|
||||
courseService.get(this.id).then(({ data: data }: { data: ICourseDetailResponse }) => {
|
||||
serviceService.get(this.id).then(({ data: data }: { data: IServiceDetailResponse }) => {
|
||||
this.loading = false;
|
||||
this.course = data;
|
||||
this.service = data;
|
||||
});
|
||||
courseService.paid(this.id).then(({ data: { paid } }: { data: ICoursePaidStatusResponse }) => {
|
||||
serviceService.paid(this.id).then(({ data: { paid } }: { data: IServicePaidStatusResponse }) => {
|
||||
this.paid = paid;
|
||||
});
|
||||
episodeService.getAllForCourse(this.id).then(({ data: data }: { data: IEpisodeListResponse }) => {
|
||||
episodeService.getAllForService(this.id).then(({ data: data }: { data: IEpisodeListResponse }) => {
|
||||
this.episodes = data.items;
|
||||
});
|
||||
},
|
||||
@@ -195,7 +195,7 @@ export default defineComponent({
|
||||
this.$router.push({
|
||||
name: 'episode-detail',
|
||||
params: {
|
||||
courseId: this.course?.id,
|
||||
serviceId: this.service?.id,
|
||||
id: episode.id
|
||||
}
|
||||
});
|
||||
@@ -203,11 +203,11 @@ export default defineComponent({
|
||||
},
|
||||
onBuy() {
|
||||
this.buying = true;
|
||||
ElMessage.info(this.$t('course.message.creatingOrder'));
|
||||
ElMessage.info(this.$t('service.message.creatingOrder'));
|
||||
orderService
|
||||
.create({
|
||||
id: uuidv4().replaceAll(/-/g, ''),
|
||||
courses: [this.id],
|
||||
services: [this.id],
|
||||
description: `${this.$t('common.title.orderDescription')} - ${this.id}`
|
||||
})
|
||||
.then(({ data: data }: { data: IOrderDetailResponse }) => {
|
||||
@@ -224,7 +224,7 @@ export default defineComponent({
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
ElMessage.error(this.$t('course.message.createOrderFailed'));
|
||||
ElMessage.error(this.$t('service.message.createOrderFailed'));
|
||||
this.buying = false;
|
||||
});
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
<template>
|
||||
<el-row>
|
||||
<el-col :span="20" :offset="2">
|
||||
<div class="courses">
|
||||
<el-card v-if="loading" class="course">
|
||||
<div class="services">
|
||||
<el-card v-if="loading" class="service">
|
||||
<el-skeleton :rows="5" animated />
|
||||
</el-card>
|
||||
<el-card v-for="(course, courseIndex) in courses" :key="courseIndex" shadow="hover" class="course">
|
||||
<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 course.tags"
|
||||
v-for="(tag, tagIndex) in service.tags"
|
||||
:key="tagIndex"
|
||||
size="small"
|
||||
type="success"
|
||||
@@ -21,36 +21,36 @@
|
||||
class="title mb-5"
|
||||
@click="
|
||||
$router.push({
|
||||
name: 'course-detail',
|
||||
name: 'service-detail',
|
||||
params: {
|
||||
id: course.id
|
||||
id: service.id
|
||||
}
|
||||
})
|
||||
"
|
||||
>
|
||||
<p>{{ course.title }}</p>
|
||||
<p>{{ service.title }}</p>
|
||||
</div>
|
||||
<div class="introduction mb-5">
|
||||
<p>{{ course.introduction }}</p>
|
||||
<p>{{ service.introduction }}</p>
|
||||
</div>
|
||||
<div class="study">
|
||||
<router-link
|
||||
:to="{
|
||||
name: 'course-detail',
|
||||
name: 'service-detail',
|
||||
params: {
|
||||
id: course.id
|
||||
id: service.id
|
||||
}
|
||||
}"
|
||||
>
|
||||
<el-button type="danger">
|
||||
<el-icon class="icon"> <video-play /> </el-icon>
|
||||
{{ $t('course.button.startStudy') }}
|
||||
{{ $t('service.button.startStudy') }}
|
||||
</el-button>
|
||||
</router-link>
|
||||
</div>
|
||||
</div>
|
||||
<div class="thumbnail">
|
||||
<img :src="course.thumbnail" />
|
||||
<img :src="service.thumbnail" />
|
||||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
@@ -59,31 +59,31 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { courseService } from '@/services/course/service';
|
||||
import { ICourse, ICourseListResponse } from '@/services/course/types';
|
||||
import { serviceService } from '@/services/service/service';
|
||||
import { IService, IServiceListResponse } from '@/services/service/types';
|
||||
import { defineComponent } from 'vue';
|
||||
import { VideoPlay } from '@element-plus/icons-vue';
|
||||
|
||||
interface IData {
|
||||
courses: ICourse[];
|
||||
services: IService[];
|
||||
loading: boolean;
|
||||
}
|
||||
export default defineComponent({
|
||||
name: 'CourseList',
|
||||
name: 'ServiceList',
|
||||
components: {
|
||||
VideoPlay
|
||||
},
|
||||
data(): IData {
|
||||
return {
|
||||
courses: [],
|
||||
services: [],
|
||||
loading: false
|
||||
};
|
||||
},
|
||||
async mounted() {
|
||||
this.loading = true;
|
||||
console.debug('start to load all courses');
|
||||
courseService.getAll().then(({ data: data }: { data: ICourseListResponse }) => {
|
||||
this.courses = data.items;
|
||||
console.debug('start to load all services');
|
||||
serviceService.getAll().then(({ data: data }: { data: IServiceListResponse }) => {
|
||||
this.services = data.items;
|
||||
this.loading = false;
|
||||
});
|
||||
}
|
||||
@@ -91,9 +91,9 @@ export default defineComponent({
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.courses {
|
||||
.services {
|
||||
padding: 50px;
|
||||
.course {
|
||||
.service {
|
||||
width: 1200px;
|
||||
height: 360px;
|
||||
border-radius: 0.9rem !important;
|
||||
@@ -1,28 +0,0 @@
|
||||
import { t } from '../i18n';
|
||||
|
||||
export default {
|
||||
path: '/auth',
|
||||
name: 'auth',
|
||||
meta: {
|
||||
title: t('common.nav.content')
|
||||
},
|
||||
component: () => import('@/layouts/Auth.vue'),
|
||||
children: [
|
||||
{
|
||||
path: 'login',
|
||||
name: 'auth-login',
|
||||
meta: {
|
||||
title: t('common.nav.article')
|
||||
},
|
||||
component: () => import('@/pages/auth/Login.vue')
|
||||
},
|
||||
{
|
||||
path: 'callback',
|
||||
name: 'auth-callback',
|
||||
meta: {
|
||||
title: t('common.nav.article')
|
||||
},
|
||||
component: () => import('@/pages/auth/Callback.vue')
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -1,15 +0,0 @@
|
||||
export default {
|
||||
path: '/categories',
|
||||
name: 'categories',
|
||||
meta: {
|
||||
auth: true
|
||||
},
|
||||
component: () => import('@/layouts/Category.vue'),
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
name: 'category-list',
|
||||
component: () => import('@/pages/category/List.vue')
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -1,20 +0,0 @@
|
||||
export default {
|
||||
path: '/courses',
|
||||
name: 'courses',
|
||||
meta: {
|
||||
auth: true
|
||||
},
|
||||
component: () => import('@/layouts/Course.vue'),
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
name: 'course-list',
|
||||
component: () => import('@/pages/course/List.vue')
|
||||
},
|
||||
{
|
||||
path: ':id',
|
||||
name: 'course-detail',
|
||||
component: () => import('@/pages/course/Detail.vue')
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -1,15 +0,0 @@
|
||||
export default {
|
||||
path: '/courses/:courseId/episodes/',
|
||||
name: 'episodes',
|
||||
meta: {
|
||||
auth: true
|
||||
},
|
||||
component: () => import('@/layouts/Episode.vue'),
|
||||
children: [
|
||||
{
|
||||
path: ':id',
|
||||
name: 'episode-detail',
|
||||
component: () => import('@/pages/episode/Detail.vue')
|
||||
}
|
||||
]
|
||||
};
|
||||
+3
-11
@@ -1,22 +1,14 @@
|
||||
import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router';
|
||||
import auth from './auth';
|
||||
import course from './course';
|
||||
import category from './category';
|
||||
import episode from './episode';
|
||||
import order from './order';
|
||||
import service from './service';
|
||||
import store from '@/store';
|
||||
|
||||
const routes = [
|
||||
{
|
||||
path: '/',
|
||||
name: 'home',
|
||||
redirect: '/courses'
|
||||
redirect: '/services'
|
||||
},
|
||||
auth,
|
||||
course,
|
||||
episode,
|
||||
category,
|
||||
order
|
||||
service
|
||||
];
|
||||
|
||||
const router = createRouter({
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
export default {
|
||||
path: '/orders',
|
||||
name: 'orders',
|
||||
meta: {
|
||||
auth: true
|
||||
},
|
||||
component: () => import('@/layouts/Order.vue'),
|
||||
children: [
|
||||
{
|
||||
path: ':id',
|
||||
name: 'order-detail',
|
||||
component: () => import('@/pages/order/Detail.vue')
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
export default {
|
||||
path: '/services',
|
||||
name: 'services',
|
||||
meta: {
|
||||
auth: true
|
||||
},
|
||||
component: () => import('@/layouts/Service.vue'),
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
name: 'service-list',
|
||||
component: () => import('@/pages/service/List.vue')
|
||||
},
|
||||
{
|
||||
path: ':id',
|
||||
name: 'service-detail',
|
||||
component: () => import('@/pages/service/Detail.vue')
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
import { AxiosResponse } from 'axios';
|
||||
import httpClient from '../instance';
|
||||
import { IApi, IApiDetailResponse, IApiListResponse } from './types';
|
||||
|
||||
class ApiService {
|
||||
key = 'apis';
|
||||
|
||||
async getAll(): Promise<AxiosResponse<IApiListResponse>> {
|
||||
return await httpClient.get(`/${this.key}/`);
|
||||
}
|
||||
|
||||
async get(id: number): Promise<AxiosResponse<IApiDetailResponse>> {
|
||||
return await httpClient.get(`/${this.key}/${id}`);
|
||||
}
|
||||
|
||||
async create(data: IApi): Promise<AxiosResponse<IApiDetailResponse>> {
|
||||
return await httpClient.post(`/${this.key}/`, data);
|
||||
}
|
||||
|
||||
async update(id: number, data: IApi): Promise<AxiosResponse<IApiDetailResponse>> {
|
||||
return await httpClient.put(`/${this.key}/${id}`, data);
|
||||
}
|
||||
|
||||
async delete(id: number): Promise<AxiosResponse<null>> {
|
||||
return await httpClient.delete(`/${this.key}/${id}`);
|
||||
}
|
||||
}
|
||||
|
||||
export const serviceService = new ApiService();
|
||||
@@ -0,0 +1,15 @@
|
||||
export interface IApi {
|
||||
id: number;
|
||||
name: string;
|
||||
endpoint: string;
|
||||
requestMethod: string;
|
||||
createdAt?: string;
|
||||
updatedAt?: string;
|
||||
}
|
||||
|
||||
export interface IApiListResponse {
|
||||
count: number;
|
||||
items: IApi[];
|
||||
}
|
||||
|
||||
export type IApiDetailResponse = IApi;
|
||||
@@ -1,29 +0,0 @@
|
||||
import { AxiosResponse } from 'axios';
|
||||
import httpClient from '../instance';
|
||||
import { ICategory, ICategoryDetailResponse, ICategoryListResponse } from './types';
|
||||
|
||||
class CategoryService {
|
||||
key = 'categories';
|
||||
|
||||
async getAll(): Promise<AxiosResponse<ICategoryListResponse>> {
|
||||
return await httpClient.get(`/${this.key}/`);
|
||||
}
|
||||
|
||||
async get(id: number): Promise<AxiosResponse<ICategoryDetailResponse>> {
|
||||
return await httpClient.get(`/${this.key}/${id}`);
|
||||
}
|
||||
|
||||
async create(data: ICategory): Promise<AxiosResponse<ICategoryDetailResponse>> {
|
||||
return await httpClient.post(`/${this.key}/`, data);
|
||||
}
|
||||
|
||||
async update(id: number, data: ICategory): Promise<AxiosResponse<ICategoryDetailResponse>> {
|
||||
return await httpClient.put(`/${this.key}/${id}`, data);
|
||||
}
|
||||
|
||||
async delete(id: number): Promise<AxiosResponse<null>> {
|
||||
return await httpClient.delete(`/${this.key}/${id}`);
|
||||
}
|
||||
}
|
||||
|
||||
export const categoryService = new CategoryService();
|
||||
@@ -1,18 +0,0 @@
|
||||
import { ICourse } from '../course/types';
|
||||
|
||||
export interface ICategory {
|
||||
id: number;
|
||||
name?: string;
|
||||
alias?: string;
|
||||
logo?: string;
|
||||
courses?: ICourse[];
|
||||
createdAt?: string;
|
||||
updatedAt?: string;
|
||||
}
|
||||
|
||||
export interface ICategoryListResponse {
|
||||
count: number;
|
||||
items: ICategory[];
|
||||
}
|
||||
|
||||
export type ICategoryDetailResponse = ICategory;
|
||||
@@ -1,37 +0,0 @@
|
||||
import { AxiosResponse } from 'axios';
|
||||
import httpClient from '../instance';
|
||||
import { IComment, ICommentDetailResponse, ICommentListResponse } from './types';
|
||||
|
||||
class CommentService {
|
||||
key = 'comments';
|
||||
|
||||
async getAll(): Promise<AxiosResponse<ICommentListResponse>> {
|
||||
return await httpClient.get(`/${this.key}/`);
|
||||
}
|
||||
|
||||
async get(id: number): Promise<AxiosResponse<ICommentDetailResponse>> {
|
||||
return await httpClient.get(`/${this.key}/${id}`);
|
||||
}
|
||||
|
||||
async create(data: IComment): Promise<AxiosResponse<ICommentDetailResponse>> {
|
||||
return await httpClient.post(`/${this.key}/`, data);
|
||||
}
|
||||
|
||||
async update(id: number, data: IComment): Promise<AxiosResponse<ICommentDetailResponse>> {
|
||||
return await httpClient.put(`/${this.key}/${id}`, data);
|
||||
}
|
||||
|
||||
async delete(id: number): Promise<AxiosResponse<null>> {
|
||||
return await httpClient.delete(`/${this.key}/${id}`);
|
||||
}
|
||||
|
||||
async createForEpisode(episodeId: number, data: IComment): Promise<AxiosResponse<ICommentDetailResponse>> {
|
||||
return await httpClient.post(`/episodes/${episodeId}/${this.key}/`, data);
|
||||
}
|
||||
|
||||
async getAllForEpisode(episodeId: number): Promise<AxiosResponse<ICommentListResponse>> {
|
||||
return await httpClient.get(`/episodes/${episodeId}/${this.key}/`);
|
||||
}
|
||||
}
|
||||
|
||||
export const commentService = new CommentService();
|
||||
@@ -1,14 +0,0 @@
|
||||
export interface IComment {
|
||||
id?: number;
|
||||
content?: string;
|
||||
createdAt?: string;
|
||||
updatedAt?: string;
|
||||
publisherId?: number;
|
||||
}
|
||||
|
||||
export interface ICommentListResponse {
|
||||
count: number;
|
||||
items: IComment[];
|
||||
}
|
||||
|
||||
export type ICommentDetailResponse = IComment;
|
||||
@@ -1,41 +0,0 @@
|
||||
import { AxiosResponse } from 'axios';
|
||||
import httpClient from '../instance';
|
||||
import { ICourse, ICourseDetailResponse, ICourseListResponse, ICoursePaidStatusResponse } from './types';
|
||||
|
||||
class CourseService {
|
||||
key = 'courses';
|
||||
|
||||
async getAll(): Promise<AxiosResponse<ICourseListResponse>> {
|
||||
return await httpClient.get(`/${this.key}/`);
|
||||
}
|
||||
|
||||
async get(id: number): Promise<AxiosResponse<ICourseDetailResponse>> {
|
||||
return await httpClient.get(`/${this.key}/${id}`);
|
||||
}
|
||||
|
||||
async create(data: ICourse): Promise<AxiosResponse<ICourseDetailResponse>> {
|
||||
return await httpClient.post(`/${this.key}/`, data);
|
||||
}
|
||||
|
||||
async update(id: number, data: ICourse): Promise<AxiosResponse<ICourseDetailResponse>> {
|
||||
return await httpClient.put(`/${this.key}/${id}`, data);
|
||||
}
|
||||
|
||||
async delete(id: number): Promise<AxiosResponse<null>> {
|
||||
return await httpClient.delete(`/${this.key}/${id}`);
|
||||
}
|
||||
|
||||
async createForTeacher(teacherId: number, data: ICourse): Promise<AxiosResponse<ICourseDetailResponse>> {
|
||||
return await httpClient.post(`/teachers/${teacherId}/${this.key}/`, data);
|
||||
}
|
||||
|
||||
async getAllForTeacher(teacherId: number): Promise<AxiosResponse<ICourseListResponse>> {
|
||||
return await httpClient.get(`/teachers/${teacherId}/${this.key}/`);
|
||||
}
|
||||
|
||||
async paid(id: number): Promise<AxiosResponse<ICoursePaidStatusResponse>> {
|
||||
return await httpClient.get(`/courses/${id}/paid/`);
|
||||
}
|
||||
}
|
||||
|
||||
export const courseService = new CourseService();
|
||||
@@ -1,30 +0,0 @@
|
||||
export const COURSE_LEVEL_BEGINNER = 'Beginner';
|
||||
export const COURSE_LEVEL_INTERMEDIATE = 'Intermediate';
|
||||
export const COURSE_LEVEL_ADVANCED = 'Advanced';
|
||||
|
||||
export interface ICourse {
|
||||
id: number;
|
||||
tags?: string[];
|
||||
title?: string;
|
||||
cover?: string;
|
||||
thumbnail?: string;
|
||||
level?: typeof COURSE_LEVEL_BEGINNER | typeof COURSE_LEVEL_INTERMEDIATE | typeof COURSE_LEVEL_ADVANCED;
|
||||
discount?: number;
|
||||
price?: number;
|
||||
duration?: number;
|
||||
introduction?: string;
|
||||
createdAt?: string;
|
||||
updatedAt?: string;
|
||||
publisherId?: number;
|
||||
}
|
||||
|
||||
export interface ICourseListResponse {
|
||||
count: number;
|
||||
items: ICourse[];
|
||||
}
|
||||
|
||||
export type ICourseDetailResponse = ICourse;
|
||||
|
||||
export interface ICoursePaidStatusResponse {
|
||||
paid: boolean;
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
import { AxiosResponse } from 'axios';
|
||||
import httpClient from '../instance';
|
||||
import { IResourceDetailResponse } from '../resource/types';
|
||||
import { IEpisode, IEpisodeDetailResponse, IEpisodeListResponse, IEpisodeSignResponse } from './types';
|
||||
|
||||
class EpisodeService {
|
||||
key = 'episodes';
|
||||
|
||||
async getAll(): Promise<AxiosResponse<IEpisodeListResponse>> {
|
||||
return await httpClient.get(`/${this.key}/`);
|
||||
}
|
||||
|
||||
async get(id: number): Promise<AxiosResponse<IEpisodeDetailResponse>> {
|
||||
return await httpClient.get(`/${this.key}/${id}`);
|
||||
}
|
||||
|
||||
async resource(id: number): Promise<AxiosResponse<IResourceDetailResponse>> {
|
||||
return await httpClient.post(`/${this.key}/${id}/resource/`);
|
||||
}
|
||||
|
||||
async sign(id: number): Promise<AxiosResponse<IEpisodeSignResponse>> {
|
||||
return await httpClient.get(`/${this.key}/${id}/sign/`);
|
||||
}
|
||||
|
||||
async create(data: IEpisode): Promise<AxiosResponse<IEpisodeDetailResponse>> {
|
||||
return await httpClient.post(`/${this.key}/`, data);
|
||||
}
|
||||
|
||||
async update(id: number, data: IEpisode): Promise<AxiosResponse<IEpisodeDetailResponse>> {
|
||||
return await httpClient.put(`/${this.key}/${id}`, data);
|
||||
}
|
||||
|
||||
async delete(id: number): Promise<AxiosResponse<null>> {
|
||||
return await httpClient.delete(`/${this.key}/${id}`);
|
||||
}
|
||||
|
||||
async createForCourse(courseId: number, data: IEpisode): Promise<AxiosResponse<IEpisodeDetailResponse>> {
|
||||
return await httpClient.post(`/courses/${courseId}/${this.key}/`, data);
|
||||
}
|
||||
|
||||
async getAllForCourse(courseId: number): Promise<AxiosResponse<IEpisodeListResponse>> {
|
||||
return await httpClient.get(`/courses/${courseId}/${this.key}/`);
|
||||
}
|
||||
}
|
||||
|
||||
export const episodeService = new EpisodeService();
|
||||
@@ -1,29 +0,0 @@
|
||||
export interface IEpisode {
|
||||
id: number;
|
||||
tags?: string[];
|
||||
title?: string;
|
||||
cover?: string;
|
||||
thumbnail?: string;
|
||||
duration?: number;
|
||||
introduction?: string;
|
||||
state?: 'Pending' | 'Running' | 'Ready';
|
||||
type?: 'Video' | 'Document';
|
||||
isFree?: boolean;
|
||||
index?: number;
|
||||
viewCount?: number;
|
||||
resourceUrl?: string;
|
||||
createdAt?: string;
|
||||
updatedAt?: string;
|
||||
publisherId?: number;
|
||||
}
|
||||
|
||||
export interface IEpisodeListResponse {
|
||||
count: number;
|
||||
items: IEpisode[];
|
||||
}
|
||||
|
||||
export interface IEpisodeSignResponse {
|
||||
sign: string;
|
||||
}
|
||||
|
||||
export type IEpisodeDetailResponse = IEpisode;
|
||||
@@ -1,29 +0,0 @@
|
||||
import { AxiosResponse } from 'axios';
|
||||
import httpClient from '../instance';
|
||||
import { IOrder, IOrderDetailResponse, IOrderListResponse } from './types';
|
||||
|
||||
class OrderService {
|
||||
key = 'orders';
|
||||
|
||||
async getAll(): Promise<AxiosResponse<IOrderListResponse>> {
|
||||
return await httpClient.get(`/${this.key}/`);
|
||||
}
|
||||
|
||||
async get(id: string): Promise<AxiosResponse<IOrderDetailResponse>> {
|
||||
return await httpClient.get(`/${this.key}/${id}`);
|
||||
}
|
||||
|
||||
async create(data: IOrder): Promise<AxiosResponse<IOrderDetailResponse>> {
|
||||
return await httpClient.post(`/${this.key}/`, data);
|
||||
}
|
||||
|
||||
async update(id: string, data: IOrder): Promise<AxiosResponse<IOrderDetailResponse>> {
|
||||
return await httpClient.put(`/${this.key}/${id}`, data);
|
||||
}
|
||||
|
||||
async delete(id: string): Promise<AxiosResponse<null>> {
|
||||
return await httpClient.delete(`/${this.key}/${id}`);
|
||||
}
|
||||
}
|
||||
|
||||
export const orderService = new OrderService();
|
||||
@@ -1,23 +0,0 @@
|
||||
export const ORDER_STATE_PENDING = 'Pending';
|
||||
export const ORDER_STATE_PAID = 'Paid';
|
||||
export const ORDER_STATE_EXPIRED = 'Expired';
|
||||
export const ORDER_STATE_FAILED = 'Failed';
|
||||
|
||||
export interface IOrder {
|
||||
id?: string;
|
||||
description?: string;
|
||||
state?: typeof ORDER_STATE_PENDING | typeof ORDER_STATE_PAID | typeof ORDER_STATE_EXPIRED | typeof ORDER_STATE_FAILED;
|
||||
price?: number;
|
||||
creatorId?: number;
|
||||
createdAt?: string;
|
||||
updatedAt?: string;
|
||||
courses?: number[];
|
||||
wechatpayUrl?: string;
|
||||
}
|
||||
|
||||
export interface IOrderListResponse {
|
||||
count: number;
|
||||
items: IOrder[];
|
||||
}
|
||||
|
||||
export type IOrderDetailResponse = IOrder;
|
||||
@@ -1,15 +0,0 @@
|
||||
export interface IResource {
|
||||
id: string;
|
||||
fileId?: string;
|
||||
transcodeTaskState?: string;
|
||||
uploadTaskState?: string;
|
||||
transcodeTaskId?: string;
|
||||
uploadTaskId?: string;
|
||||
watermarks?: string[];
|
||||
episode?: number;
|
||||
sign?: string;
|
||||
createdAt?: string;
|
||||
updatedAt?: string;
|
||||
}
|
||||
|
||||
export type IResourceDetailResponse = IResource;
|
||||
@@ -0,0 +1,29 @@
|
||||
import { AxiosResponse } from 'axios';
|
||||
import httpClient from '../instance';
|
||||
import { IService, IServiceDetailResponse, IServiceListResponse } from './types';
|
||||
|
||||
class ServiceService {
|
||||
key = 'services';
|
||||
|
||||
async getAll(): Promise<AxiosResponse<IServiceListResponse>> {
|
||||
return await httpClient.get(`/${this.key}/`);
|
||||
}
|
||||
|
||||
async get(id: number): Promise<AxiosResponse<IServiceDetailResponse>> {
|
||||
return await httpClient.get(`/${this.key}/${id}`);
|
||||
}
|
||||
|
||||
async create(data: IService): Promise<AxiosResponse<IServiceDetailResponse>> {
|
||||
return await httpClient.post(`/${this.key}/`, data);
|
||||
}
|
||||
|
||||
async update(id: number, data: IService): Promise<AxiosResponse<IServiceDetailResponse>> {
|
||||
return await httpClient.put(`/${this.key}/${id}`, data);
|
||||
}
|
||||
|
||||
async delete(id: number): Promise<AxiosResponse<null>> {
|
||||
return await httpClient.delete(`/${this.key}/${id}`);
|
||||
}
|
||||
}
|
||||
|
||||
export const serviceService = new ServiceService();
|
||||
@@ -0,0 +1,19 @@
|
||||
export interface IService {
|
||||
id: number;
|
||||
title: string;
|
||||
description?: string;
|
||||
tags?: string[];
|
||||
thumbnail?: string;
|
||||
price?: number;
|
||||
applied_count: number;
|
||||
introduction: string;
|
||||
createdAt?: string;
|
||||
updatedAt?: string;
|
||||
}
|
||||
|
||||
export interface IServiceListResponse {
|
||||
count: number;
|
||||
items: IService[];
|
||||
}
|
||||
|
||||
export type IServiceDetailResponse = IService;
|
||||
+10
-10
@@ -9,7 +9,7 @@ const getAuthEndpoint = () => {
|
||||
console.log('process.env.NODE_ENV', process.env.NODE_ENV);
|
||||
switch (process.env.NODE_ENV) {
|
||||
case 'local':
|
||||
return 'http://localhost:8001';
|
||||
return 'http://127.0.0.1:8001';
|
||||
case 'test':
|
||||
return 'https://auth.test.zhishuyun.com';
|
||||
case 'production':
|
||||
@@ -18,26 +18,26 @@ const getAuthEndpoint = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const getAcademyEndpoint = () => {
|
||||
const getDataEndpoint = () => {
|
||||
switch (process.env.NODE_ENV) {
|
||||
case 'local':
|
||||
return 'http://localhost:8002';
|
||||
return 'http://127.0.0.1:8007';
|
||||
case 'test':
|
||||
return 'https://academy.test.zhishuyun.com';
|
||||
return 'https://data.test.zhishuyun.com';
|
||||
case 'production':
|
||||
default:
|
||||
return 'https://academy.zhishuyun.com';
|
||||
return 'https://data.zhishuyun.com';
|
||||
}
|
||||
};
|
||||
|
||||
export default defineConfig({
|
||||
server: {
|
||||
// open: true,
|
||||
host: 'academy.local.zhishuyun.com',
|
||||
host: 'data.local.zhishuyun.com',
|
||||
port: 443,
|
||||
https: {
|
||||
key: fs.readFileSync('certs/academy.local.zhishuyun.com.cert.key'),
|
||||
cert: fs.readFileSync('certs/academy.local.zhishuyun.com.cert.crt')
|
||||
key: fs.readFileSync('certs/data.local.zhishuyun.com.cert.key'),
|
||||
cert: fs.readFileSync('certs/data.local.zhishuyun.com.cert.crt')
|
||||
},
|
||||
proxy: {
|
||||
'/api/v1/me': {
|
||||
@@ -49,11 +49,11 @@ export default defineConfig({
|
||||
changeOrigin: true
|
||||
},
|
||||
'/api': {
|
||||
target: getAcademyEndpoint(),
|
||||
target: getDataEndpoint(),
|
||||
changeOrigin: true
|
||||
},
|
||||
'/static': {
|
||||
target: getAcademyEndpoint(),
|
||||
target: getDataEndpoint(),
|
||||
changeOrigin: true
|
||||
}
|
||||
// '/ws': {
|
||||
|
||||
Reference in new issue
Block a user