add order and pay support
This commit is contained in:
1 parent
cfea244d28
commit
2ca68e2559
20 files changed
+490
-118
No files matched your search
@@ -39,10 +39,10 @@
|
||||
<el-table-column>
|
||||
<template #default="scope">
|
||||
<div class="float-right">
|
||||
<el-button @click="onGoDocument(scope.row.service)">
|
||||
<el-button v-if="false" @click="onGoDocument(scope.row)">
|
||||
{{ $t('application.button.goDocument') }}
|
||||
</el-button>
|
||||
<el-button type="primary" @click="onBuyMore(scope.row.service)">
|
||||
<el-button type="primary" @click="onBuyMore(scope.row)">
|
||||
{{ $t('application.button.buyMore') }}
|
||||
</el-button>
|
||||
</div>
|
||||
@@ -61,37 +61,26 @@
|
||||
</el-row>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-dialog v-model="buying" title="Warning" width="30%" center>
|
||||
<span> It should be noted that the content will not be aligned in center by default </span>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="buying = false">Cancel</el-button>
|
||||
<el-button type="primary" @click="onCreateOrder()"> Confirm </el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<create-order v-if="active.application" :visible="buying" :application="active.application" @hide="buying = false" />
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import {
|
||||
applicationOperator,
|
||||
IApplication,
|
||||
IApplicationListResponse,
|
||||
IOrderDetailResponse,
|
||||
IService,
|
||||
orderOperator
|
||||
} from '@/operators';
|
||||
import { applicationOperator, IApplication, IApplicationListResponse, IService } from '@/operators';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import Pagination from '@/components/common/Pagination.vue';
|
||||
import CopyToClipboard from '@/components/common/CopyToClipboard.vue';
|
||||
import CreateOrder from '@/components/order/Create.vue';
|
||||
|
||||
interface IData {
|
||||
applications: IApplication[];
|
||||
loading: boolean;
|
||||
total: number | undefined;
|
||||
limit: number;
|
||||
page: number;
|
||||
buying: boolean;
|
||||
form: {
|
||||
amount: number | undefined;
|
||||
};
|
||||
active: {
|
||||
service: IService | undefined;
|
||||
application: IApplication | undefined;
|
||||
@@ -103,7 +92,8 @@ export default defineComponent({
|
||||
components: {
|
||||
FontAwesomeIcon,
|
||||
Pagination,
|
||||
CopyToClipboard
|
||||
CopyToClipboard,
|
||||
CreateOrder
|
||||
},
|
||||
data(): IData {
|
||||
return {
|
||||
@@ -112,41 +102,39 @@ export default defineComponent({
|
||||
total: undefined,
|
||||
buying: false,
|
||||
limit: 8,
|
||||
form: {
|
||||
amount: 1
|
||||
},
|
||||
active: {
|
||||
service: undefined,
|
||||
application: undefined
|
||||
},
|
||||
page: parseInt(this.$route.query.page?.toString() || '1')
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
redirect() {
|
||||
return this.$route.query.redirect;
|
||||
},
|
||||
page() {
|
||||
return parseInt(this.$route.query.page?.toString() || '1');
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
page: {
|
||||
handler() {
|
||||
this.onFetchData();
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {},
|
||||
mounted() {
|
||||
this.onFetchData();
|
||||
},
|
||||
methods: {
|
||||
onBuyMore(service: IService) {
|
||||
this.active.service = service;
|
||||
onGoDocument(application: IApplication) {},
|
||||
onBuyMore(application: IApplication) {
|
||||
this.active.application = application;
|
||||
this.buying = true;
|
||||
},
|
||||
onGoDocument(service: IService) {},
|
||||
onCreateOrder() {
|
||||
if (!this.active?.service?.id) {
|
||||
return;
|
||||
}
|
||||
orderOperator
|
||||
.create({
|
||||
service_id: this.active?.service?.id,
|
||||
amount: 10
|
||||
})
|
||||
.then(({ data: data }: { data: IOrderDetailResponse }) => {
|
||||
console.log('data', data);
|
||||
});
|
||||
},
|
||||
onPageChange(page: number) {
|
||||
this.$router.push({
|
||||
name: this.$route.name?.toString(),
|
||||
@@ -154,7 +142,6 @@ export default defineComponent({
|
||||
page: page
|
||||
}
|
||||
});
|
||||
this.onFetchData();
|
||||
},
|
||||
onFetchData() {
|
||||
this.loading = true;
|
||||
|
||||
@@ -0,0 +1,223 @@
|
||||
<template>
|
||||
<el-row class="wrapper">
|
||||
<el-col :span="24">
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<h2 class="title">{{ $t('common.title.allOrders') }}</h2>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row class="panel">
|
||||
<el-col :span="24">
|
||||
<el-card shadow="hover">
|
||||
<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>
|
||||
</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 === PayWay.WechatPay
|
||||
}"
|
||||
>
|
||||
<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?.wechatpay_url" :value="order?.wechatpay_url" :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>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { IOrder, IOrderDetailResponse, orderOperator, OrderState } from '@/operators/order';
|
||||
import QrCode from 'qrcode.vue';
|
||||
import { ElMessage } from 'element-plus';
|
||||
|
||||
enum PayWay {
|
||||
WechatPay = 'WechatPay',
|
||||
AliPay = 'AliPay'
|
||||
}
|
||||
|
||||
interface IData {
|
||||
PayWay: typeof PayWay;
|
||||
payWay: PayWay | undefined;
|
||||
order: IOrder | undefined;
|
||||
loading: boolean;
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ConsoleOrderDetail',
|
||||
components: {
|
||||
QrCode
|
||||
},
|
||||
data(): IData {
|
||||
return {
|
||||
PayWay: PayWay,
|
||||
payWay: PayWay.WechatPay,
|
||||
order: undefined,
|
||||
loading: false
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
id() {
|
||||
return this.$route.params.id.toString();
|
||||
},
|
||||
redirect() {
|
||||
return this.$route.query.redirect;
|
||||
}
|
||||
},
|
||||
watch: {},
|
||||
mounted() {
|
||||
this.onFetchData();
|
||||
this.onCheck();
|
||||
},
|
||||
methods: {
|
||||
onFetchData() {
|
||||
this.loading = true;
|
||||
orderOperator
|
||||
.get(this.id)
|
||||
.then(({ data: data }: { data: IOrderDetailResponse }) => {
|
||||
this.order = data;
|
||||
this.loading = false;
|
||||
})
|
||||
.catch(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
onCheck() {
|
||||
orderOperator
|
||||
.get(this.id)
|
||||
.then(({ data: data }: { data: IOrderDetailResponse }) => {
|
||||
this.order = data;
|
||||
if (this.order.state === OrderState.PAID) {
|
||||
ElMessage.success(this.$t('order.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>
|
||||
.title {
|
||||
font-size: 26px;
|
||||
font-weight: bold;
|
||||
margin-bottom: 20px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.wrapper {
|
||||
padding: 30px;
|
||||
|
||||
.panel {
|
||||
.order {
|
||||
.price {
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,16 +1,16 @@
|
||||
<template>
|
||||
<el-row class="panel">
|
||||
<el-row class="wrapper">
|
||||
<el-col :span="24">
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<h2 class="title">{{ $t('common.title.allOrders') }}</h2>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-row class="panel">
|
||||
<el-col :span="24">
|
||||
<el-card shadow="hover">
|
||||
<el-table v-loading="loading" :data="orders" stripe>
|
||||
<el-table-column prop="id" :label="$t('order.field.id')" class-name="text-center">
|
||||
<el-table-column prop="id" :label="$t('order.field.id')" class-name="text-center" width="350px">
|
||||
<template #default="scope">
|
||||
<span class="key">{{ scope.row.id }}</span>
|
||||
<span class="copy">
|
||||
@@ -18,17 +18,53 @@
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="price" :label="$t('order.field.price')">
|
||||
<el-table-column :label="$t('order.field.price')">
|
||||
<template #default="scope">
|
||||
<span class="key">{{ scope.row.price }}</span>
|
||||
<span class="price">¥{{ (scope.row?.price / 100).toFixed(2) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('order.field.createdAt')">
|
||||
<template #default="scope">
|
||||
<span class="created-at">{{ scope.row.created_at }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('order.field.description')">
|
||||
<template #default="scope">
|
||||
<span class="description">{{ scope.row.description }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="state" :label="$t('order.field.state')" class-name="text-center">
|
||||
<template #default="scope">
|
||||
<span v-if="scope.row.state === OrderState?.PENDING">
|
||||
<el-tag type="info" class="mx-1" effect="dark">{{ $t('order.state.pending') }}</el-tag>
|
||||
</span>
|
||||
<span v-else-if="scope.row.state === OrderState?.PAID" class="state state-paid">
|
||||
<el-tag type="success" class="mx-1" effect="dark">{{ $t('order.state.paid') }}</el-tag>
|
||||
</span>
|
||||
<span v-else-if="scope.row.state === OrderState?.EXPIRED" class="state state-expired">
|
||||
<el-tag type="warning" class="mx-1" effect="dark">{{ $t('order.state.expired') }}</el-tag>
|
||||
</span>
|
||||
<span v-else-if="scope.row.state === OrderState?.FAILED" class="state state-failed">
|
||||
<el-tag type="danger" class="mx-1" effect="dark"> {{ $t('order.state.failed') }}</el-tag>
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="state" :label="$t('order.field.state')" class-name="text-center" />
|
||||
<el-table-column>
|
||||
<template #default="scope">
|
||||
<div class="float-right">
|
||||
<el-button type="primary" @click="onContinuePay(scope.row)">
|
||||
{{ $t('application.button.continuePay') }}
|
||||
<el-button
|
||||
v-if="scope.row.state !== OrderState.PAID"
|
||||
type="primary"
|
||||
@click="
|
||||
$router.push({
|
||||
name: 'console-order-detail',
|
||||
params: {
|
||||
id: scope.row.id
|
||||
}
|
||||
})
|
||||
"
|
||||
>
|
||||
{{ $t('order.button.continuePay') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
@@ -46,69 +82,56 @@
|
||||
</el-row>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-dialog v-model="paying" title="Warning" width="30%" center>
|
||||
<span> It should be noted that the content will not be aligned in center by default </span>
|
||||
<template #footer>
|
||||
{{ active.order?.wechatpay_url }}
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { IOrder, IOrderListResponse, IOrderDetailResponse, orderOperator } from '@/operators/order';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import { IOrder, IOrderListResponse, IOrderDetailResponse, orderOperator, OrderState } from '@/operators/order';
|
||||
import Pagination from '@/components/common/Pagination.vue';
|
||||
import CopyToClipboard from '@/components/common/CopyToClipboard.vue';
|
||||
import { IService } from '@/operators/service/models';
|
||||
|
||||
interface IData {
|
||||
orders: IOrder[];
|
||||
loading: boolean;
|
||||
total: number | undefined;
|
||||
limit: number;
|
||||
page: number;
|
||||
paying: boolean;
|
||||
active: {
|
||||
service: IService | undefined;
|
||||
order: IOrder | undefined;
|
||||
};
|
||||
OrderState: typeof OrderState;
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
name: 'OrderList',
|
||||
name: 'ConsoleOrderList',
|
||||
components: {
|
||||
FontAwesomeIcon,
|
||||
Pagination,
|
||||
CopyToClipboard
|
||||
},
|
||||
data(): IData {
|
||||
return {
|
||||
OrderState: OrderState,
|
||||
orders: [],
|
||||
loading: false,
|
||||
total: undefined,
|
||||
paying: false,
|
||||
limit: 8,
|
||||
active: {
|
||||
service: undefined,
|
||||
order: undefined
|
||||
},
|
||||
page: parseInt(this.$route.query.page?.toString() || '1')
|
||||
limit: 8
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
redirect() {
|
||||
return this.$route.query.redirect;
|
||||
},
|
||||
page() {
|
||||
return parseInt(this.$route.query.page?.toString() || '1');
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
page: {
|
||||
handler() {
|
||||
this.onFetchData();
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {},
|
||||
mounted() {
|
||||
this.onFetchData();
|
||||
},
|
||||
methods: {
|
||||
onContinuePay(order: IOrder) {
|
||||
this.active.order = order;
|
||||
this.paying = true;
|
||||
},
|
||||
onPageChange(page: number) {
|
||||
this.$router.push({
|
||||
name: this.$route.name?.toString(),
|
||||
@@ -116,12 +139,12 @@ export default defineComponent({
|
||||
page: page
|
||||
}
|
||||
});
|
||||
this.onFetchData();
|
||||
},
|
||||
onFetchData() {
|
||||
this.loading = true;
|
||||
orderOperator
|
||||
.getAll({
|
||||
ordering: '-created_at',
|
||||
limit: this.limit,
|
||||
offset: (this.page - 1) * this.limit,
|
||||
user_id: this.$store.getters.user.id
|
||||
@@ -151,7 +174,7 @@ export default defineComponent({
|
||||
margin-bottom: 50px;
|
||||
}
|
||||
|
||||
.panel {
|
||||
.wrapper {
|
||||
padding: 30px;
|
||||
.api-key {
|
||||
.copy {
|
||||
|
||||
Reference in new issue
Block a user