add create order
This commit is contained in:
1 parent
0b6bb8d173
commit
e67dfadac7
9 files changed
+94
-18
No files matched your search
@@ -18,7 +18,7 @@ body {
|
|||||||
|
|
||||||
.el-card {
|
.el-card {
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
border-radius: 0.375rem;
|
border-radius: 1rem;
|
||||||
border: none;
|
border: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div v-else class="mt-3 pr-10 float-right">
|
<div v-else class="mt-3 pr-10 float-right">
|
||||||
<el-dropdown trigger="click">
|
<el-dropdown trigger="click">
|
||||||
<img :src="user.avatar || defaultAvatar" class="avatar" />
|
<img :src="user?.avatar || defaultAvatar" class="avatar" />
|
||||||
<template #dropdown>
|
<template #dropdown>
|
||||||
<el-dropdown-menu>
|
<el-dropdown-menu>
|
||||||
<el-dropdown-item @click="onProfile">{{ $t('common.button.profile') }}</el-dropdown-item>
|
<el-dropdown-item @click="onProfile">{{ $t('common.button.profile') }}</el-dropdown-item>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
export default {
|
export default {
|
||||||
paidSuccessfully: '支付成功',
|
paidSuccessfully: '支付成功',
|
||||||
paid: '已经购买成功',
|
paid: '已经购买成功',
|
||||||
needPay: '需要购买',
|
needPay: '您需要购买完整课程才能观看',
|
||||||
wechatPayHelp: '请打开手机微信,扫一扫完成支付',
|
wechatPayHelp: '请打开手机微信,扫一扫完成支付',
|
||||||
createOrderFailed: '创建订单失败',
|
createOrderFailed: '创建订单失败',
|
||||||
creatingOrder: '正在生成订单',
|
creatingOrder: '正在生成订单',
|
||||||
|
|||||||
@@ -34,15 +34,16 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="operation">
|
<div class="operation">
|
||||||
<p v-if="paid === false">
|
<p v-if="paid === false">
|
||||||
<el-button @click="onBuy" type="danger" :loading="buying">
|
<span v-if="course.price" class="price">¥{{ (course?.price / 100).toFixed(2) }}</span>
|
||||||
<el-icon class="icon" v-if="!buying">
|
<el-button type="danger" :loading="buying" @click="onBuy">
|
||||||
|
<el-icon v-if="!buying" class="icon">
|
||||||
<goods />
|
<goods />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
{{ $t('course.button.buy') }}
|
{{ $t('course.button.buy') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</p>
|
</p>
|
||||||
<p v-if="paid === true">
|
<p v-if="paid === true">
|
||||||
<el-button @click="onStudy" type="danger">
|
<el-button type="danger" @click="onStudy">
|
||||||
<el-icon class="icon"> <video-play /> </el-icon>
|
<el-icon class="icon"> <video-play /> </el-icon>
|
||||||
{{ $t('course.button.startStudy') }}
|
{{ $t('course.button.startStudy') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
@@ -150,8 +151,7 @@ export default defineComponent({
|
|||||||
MagicStick,
|
MagicStick,
|
||||||
VerificationAlert,
|
VerificationAlert,
|
||||||
VideoPlay,
|
VideoPlay,
|
||||||
Goods,
|
Goods
|
||||||
Loading
|
|
||||||
},
|
},
|
||||||
data(): IData {
|
data(): IData {
|
||||||
return {
|
return {
|
||||||
@@ -213,6 +213,9 @@ export default defineComponent({
|
|||||||
name: 'order-detail',
|
name: 'order-detail',
|
||||||
params: {
|
params: {
|
||||||
id: this.order.id
|
id: this.order.id
|
||||||
|
},
|
||||||
|
query: {
|
||||||
|
redirect: window.location.href
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
@@ -248,6 +251,14 @@ export default defineComponent({
|
|||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.price {
|
||||||
|
display: block;
|
||||||
|
font-size: 30px;
|
||||||
|
font-weight: bold;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
color: var(--el-color-danger);
|
||||||
|
}
|
||||||
.thumbnail {
|
.thumbnail {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
img {
|
img {
|
||||||
|
|||||||
@@ -29,7 +29,18 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="paid === false && !episode?.isFree">
|
<div v-if="paid === false && !episode?.isFree">
|
||||||
{{ $t('course.message.needPay') }}
|
<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>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
@@ -45,12 +56,19 @@ import CoursePreviewCard from '@/components/course/PreviewCard.vue';
|
|||||||
import { courseService } from '@/services/course/service';
|
import { courseService } from '@/services/course/service';
|
||||||
import { ICourse, ICourseDetailResponse, ICoursePaidStatusResponse } from '@/services/course/types';
|
import { ICourse, ICourseDetailResponse, ICoursePaidStatusResponse } from '@/services/course/types';
|
||||||
import { IResource, IResourceDetailResponse } from '@/services/resource/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';
|
||||||
|
|
||||||
interface IData {
|
interface IData {
|
||||||
course: ICourse | undefined;
|
course: ICourse | undefined;
|
||||||
episode: IEpisode | undefined;
|
episode: IEpisode | undefined;
|
||||||
resource: IResource | undefined;
|
resource: IResource | undefined;
|
||||||
episodes: IEpisode[];
|
episodes: IEpisode[];
|
||||||
|
order: IOrder | undefined;
|
||||||
|
buying: boolean;
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
prepared: boolean;
|
prepared: boolean;
|
||||||
paid: boolean | undefined;
|
paid: boolean | undefined;
|
||||||
@@ -62,13 +80,16 @@ export default defineComponent({
|
|||||||
components: {
|
components: {
|
||||||
EpisodeSideList,
|
EpisodeSideList,
|
||||||
EpisodePlayer,
|
EpisodePlayer,
|
||||||
CoursePreviewCard
|
CoursePreviewCard,
|
||||||
|
Goods
|
||||||
},
|
},
|
||||||
data(): IData {
|
data(): IData {
|
||||||
return {
|
return {
|
||||||
course: undefined,
|
course: undefined,
|
||||||
episode: undefined,
|
episode: undefined,
|
||||||
|
buying: false,
|
||||||
loading: false,
|
loading: false,
|
||||||
|
order: undefined,
|
||||||
episodes: [],
|
episodes: [],
|
||||||
resource: undefined,
|
resource: undefined,
|
||||||
paid: undefined,
|
paid: undefined,
|
||||||
@@ -126,6 +147,33 @@ export default defineComponent({
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
}, 0);
|
}, 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;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -140,6 +188,7 @@ $width: 300px;
|
|||||||
width: $width;
|
width: $width;
|
||||||
}
|
}
|
||||||
.main {
|
.main {
|
||||||
|
position: relative;
|
||||||
width: calc(100% - $width);
|
width: calc(100% - $width);
|
||||||
background-image: radial-gradient(circle at 0 2%, #283e63, #172337 99%);
|
background-image: radial-gradient(circle at 0 2%, #283e63, #172337 99%);
|
||||||
}
|
}
|
||||||
@@ -159,4 +208,18 @@ $width: 300px;
|
|||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.unpaid {
|
||||||
|
width: 400px;
|
||||||
|
// height: 200px;
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
.buy {
|
||||||
|
.icon {
|
||||||
|
margin-right: 2px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -108,6 +108,9 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
id() {
|
id() {
|
||||||
return this.$route.params.id.toString();
|
return this.$route.params.id.toString();
|
||||||
|
},
|
||||||
|
redirect() {
|
||||||
|
return this.$route.query.redirect;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
@@ -132,6 +135,11 @@ export default defineComponent({
|
|||||||
this.order = data;
|
this.order = data;
|
||||||
if (this.order.state === ORDER_STATE_PAID) {
|
if (this.order.state === ORDER_STATE_PAID) {
|
||||||
ElMessage.success(this.$t('course.message.paidSuccessfully'));
|
ElMessage.success(this.$t('course.message.paidSuccessfully'));
|
||||||
|
setTimeout(() => {
|
||||||
|
if (this.redirect) {
|
||||||
|
window.location.replace(this.redirect?.toString());
|
||||||
|
}
|
||||||
|
}, 2000);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
<template></template>
|
|
||||||
@@ -6,11 +6,6 @@ export default {
|
|||||||
},
|
},
|
||||||
component: () => import('@/layouts/Order.vue'),
|
component: () => import('@/layouts/Order.vue'),
|
||||||
children: [
|
children: [
|
||||||
{
|
|
||||||
path: '',
|
|
||||||
name: 'order-list',
|
|
||||||
component: () => import('@/pages/order/List.vue')
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
path: ':id',
|
path: ':id',
|
||||||
name: 'order-detail',
|
name: 'order-detail',
|
||||||
|
|||||||
+2
-2
@@ -23,10 +23,10 @@ const getAcademyEndpoint = () => {
|
|||||||
case 'local':
|
case 'local':
|
||||||
return 'http://localhost:8002';
|
return 'http://localhost:8002';
|
||||||
case 'test':
|
case 'test':
|
||||||
return 'https://auth.test.zhishuyun.com';
|
return 'https://academy.test.zhishuyun.com';
|
||||||
case 'production':
|
case 'production':
|
||||||
default:
|
default:
|
||||||
return 'https://auth.zhishuyun.com';
|
return 'https://academy.zhishuyun.com';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user