ingrate pay func
This commit is contained in:
1 parent
67f8e78bad
commit
7526ffa2b9
6 files changed
+58
-15
No files matched your search
@@ -1,5 +1,7 @@
|
||||
import button from './button';
|
||||
import message from './message';
|
||||
|
||||
export default {
|
||||
button
|
||||
button,
|
||||
message
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
export default {
|
||||
paidSuccessfully: '支付成功'
|
||||
};
|
||||
@@ -133,8 +133,9 @@ export default defineComponent({
|
||||
onBuy() {
|
||||
orderService
|
||||
.create({
|
||||
id: uuidv4(),
|
||||
courses: [this.id]
|
||||
id: uuidv4().replaceAll(/-/g, ''),
|
||||
courses: [this.id],
|
||||
description: `知数云课程${this.id}`
|
||||
})
|
||||
.then(({ data: data }: { data: IOrderDetailResponse }) => {
|
||||
this.loading = false;
|
||||
|
||||
+41
-11
@@ -5,16 +5,21 @@
|
||||
<div class="container">
|
||||
<el-row v-if="order">
|
||||
<el-col :span="24">
|
||||
<div class="courses">
|
||||
<div v-for="(course, courseIndex) in courses" :key="courseIndex">
|
||||
<div class="title">
|
||||
{{ course.title }}
|
||||
</div>
|
||||
<div class="price">
|
||||
{{ course.price }}
|
||||
<el-card>
|
||||
<div class="courses">
|
||||
<div v-for="(course, courseIndex) in courses" :key="courseIndex">
|
||||
<div class="title">
|
||||
{{ course.title }}
|
||||
</div>
|
||||
<div class="price">
|
||||
{{ course.price }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="paycode">
|
||||
<qr-code v-if="order.wechatpayUrl" :value="order.wechatpayUrl" :size="200" class="m-auto" />
|
||||
</div>
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
@@ -27,8 +32,10 @@
|
||||
import { ICourse, ICourseDetailResponse } from '@/services/course/types';
|
||||
import { orderService } from '@/services/order/service';
|
||||
import { courseService } from '@/services/course/service';
|
||||
import { IOrder, IOrderDetailResponse } from '@/services/order/types';
|
||||
import { IOrder, IOrderDetailResponse, ORDER_STATE_PAID } from '@/services/order/types';
|
||||
import { defineComponent } from 'vue';
|
||||
import QrCode from 'qrcode.vue';
|
||||
import { ElMessage } from 'element-plus';
|
||||
|
||||
interface IData {
|
||||
order: IOrder | undefined;
|
||||
@@ -38,7 +45,9 @@ interface IData {
|
||||
|
||||
export default defineComponent({
|
||||
name: 'OrderDetail',
|
||||
components: {},
|
||||
components: {
|
||||
QrCode
|
||||
},
|
||||
data(): IData {
|
||||
return {
|
||||
order: undefined,
|
||||
@@ -66,8 +75,29 @@ export default defineComponent({
|
||||
});
|
||||
});
|
||||
});
|
||||
this.onCheck();
|
||||
},
|
||||
methods: {}
|
||||
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'));
|
||||
return;
|
||||
}
|
||||
setTimeout(() => {
|
||||
this.onCheck();
|
||||
}, 2000);
|
||||
})
|
||||
.catch(() => {
|
||||
setTimeout(() => {
|
||||
this.onCheck();
|
||||
}, 2000);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<template></template>
|
||||
@@ -1,12 +1,18 @@
|
||||
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?: 'Pending' | 'Expired' | 'Paied' | 'Failed';
|
||||
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 {
|
||||
|
||||
Reference in new issue
Block a user