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
@@ -40,6 +40,7 @@
|
|||||||
"markdown-it": "^13.0.1",
|
"markdown-it": "^13.0.1",
|
||||||
"mustache": "^4.2.0",
|
"mustache": "^4.2.0",
|
||||||
"programming-languages-logos": "^0.0.3",
|
"programming-languages-logos": "^0.0.3",
|
||||||
|
"qrcode.vue": "^3.3.3",
|
||||||
"query-string": "^8.1.0",
|
"query-string": "^8.1.0",
|
||||||
"typescript-cookie": "^1.0.3",
|
"typescript-cookie": "^1.0.3",
|
||||||
"url-join": "^5.0.0",
|
"url-join": "^5.0.0",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<font-awesome-icon v-if="!copied" icon="fa-regular fa-copy" @click="onCopy" />
|
<font-awesome-icon v-if="!copied" icon="fa-regular fa-copy" class="icon-copy" @click="onCopy" />
|
||||||
<el-tooltip v-else :visible="copied" effect="dark" :content="$t('common.message.copied')" placement="top-start">
|
<el-tooltip v-else :visible="copied" effect="dark" :content="$t('common.message.copied')" placement="top-start">
|
||||||
<font-awesome-icon icon="fa-solid fa-check" />
|
<font-awesome-icon icon="fa-solid fa-check" class="icon-check" />
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -39,3 +39,10 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.icon-check,
|
||||||
|
.icon-copy {
|
||||||
|
margin-left: 5px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -7,11 +7,13 @@
|
|||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="24">
|
<el-col :span="24">
|
||||||
<div class="links">
|
<div class="links">
|
||||||
<a
|
<router-link
|
||||||
v-for="link in links"
|
v-for="(link, linkIndex) in links"
|
||||||
:key="link.key"
|
:key="linkIndex"
|
||||||
:class="{ link: true, active: $route.path == link.href }"
|
:to="{
|
||||||
@click="onClick(link.href)"
|
name: link.name
|
||||||
|
}"
|
||||||
|
:class="{ link: true, active: $route.name === link.name }"
|
||||||
>
|
>
|
||||||
<span class="icon">
|
<span class="icon">
|
||||||
<el-icon class="icon">
|
<el-icon class="icon">
|
||||||
@@ -22,7 +24,7 @@
|
|||||||
</span>
|
</span>
|
||||||
<span class="text">{{ link.text }}</span>
|
<span class="text">{{ link.text }}</span>
|
||||||
<span class="suffix"></span>
|
<span class="suffix"></span>
|
||||||
</a>
|
</router-link>
|
||||||
</div>
|
</div>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
@@ -30,12 +32,12 @@
|
|||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
import { Clock, MagicStick, Collection, VideoPlay, Goods, Loading, User, Postcard } from '@element-plus/icons-vue';
|
import { Clock, User, Postcard } from '@element-plus/icons-vue';
|
||||||
|
|
||||||
interface ILink {
|
interface ILink {
|
||||||
key: string;
|
key: string;
|
||||||
text: string;
|
text: string;
|
||||||
href: string;
|
name: string;
|
||||||
icon: string;
|
icon: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,11 +49,6 @@ export default defineComponent({
|
|||||||
name: 'Navigator',
|
name: 'Navigator',
|
||||||
components: {
|
components: {
|
||||||
Clock,
|
Clock,
|
||||||
Collection,
|
|
||||||
MagicStick,
|
|
||||||
VideoPlay,
|
|
||||||
Goods,
|
|
||||||
Loading,
|
|
||||||
Postcard,
|
Postcard,
|
||||||
User
|
User
|
||||||
},
|
},
|
||||||
@@ -61,13 +58,13 @@ export default defineComponent({
|
|||||||
{
|
{
|
||||||
key: 'profile',
|
key: 'profile',
|
||||||
text: this.$t('console.menu.orderList'),
|
text: this.$t('console.menu.orderList'),
|
||||||
href: '/console/orders',
|
name: 'console-order-list',
|
||||||
icon: 'user'
|
icon: 'user'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'verify',
|
key: 'verify',
|
||||||
text: this.$t('console.menu.applicationList'),
|
text: this.$t('console.menu.applicationList'),
|
||||||
href: '/console/applications',
|
name: 'console-application-list',
|
||||||
icon: 'postcard'
|
icon: 'postcard'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -80,9 +77,6 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
mounted() {},
|
mounted() {},
|
||||||
methods: {
|
methods: {
|
||||||
onClick(link: string) {
|
|
||||||
window.location.href = link;
|
|
||||||
},
|
|
||||||
onHome() {
|
onHome() {
|
||||||
this.$router.push({
|
this.$router.push({
|
||||||
name: 'home'
|
name: 'home'
|
||||||
|
|||||||
@@ -0,0 +1,95 @@
|
|||||||
|
<template>
|
||||||
|
<el-dialog :model-value="visible" :title="$t('application.title.buyService')" width="60%" center>
|
||||||
|
<el-form label-width="120px">
|
||||||
|
<el-form-item v-if="application?.service?.title" :label="$t('application.field.service')">
|
||||||
|
{{ application?.service?.title }}
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item :label="$t('application.field.amount')">
|
||||||
|
<el-input-number v-model="form.amount" :min="1" :max="10" controls-position="right" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-divider />
|
||||||
|
<el-form-item :label="$t('application.field.shouldPayPrice')">
|
||||||
|
<span class="price">¥{{ (getPrice() / 100).toFixed(2) }}</span>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<span class="dialog-footer">
|
||||||
|
<el-button @click="$emit('hide')">{{ $t('common.button.cancel') }}</el-button>
|
||||||
|
<el-button type="primary" :loading="creating" @click="onCreateOrder">
|
||||||
|
{{ $t('application.button.createOrder') }}
|
||||||
|
</el-button>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
import { IApplication, IOrderDetailResponse, orderOperator } from '@/operators';
|
||||||
|
import { defineComponent } from 'vue';
|
||||||
|
import { ElMessage } from 'element-plus';
|
||||||
|
|
||||||
|
export default defineComponent({
|
||||||
|
name: 'CreateOrderDialog',
|
||||||
|
props: {
|
||||||
|
application: {
|
||||||
|
type: Object as () => IApplication,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
visible: {
|
||||||
|
type: Boolean,
|
||||||
|
required: false,
|
||||||
|
default: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
emits: ['hide'],
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
form: {
|
||||||
|
amount: 1
|
||||||
|
},
|
||||||
|
creating: false
|
||||||
|
};
|
||||||
|
},
|
||||||
|
mounted() {},
|
||||||
|
methods: {
|
||||||
|
onCreateOrder() {
|
||||||
|
if (!this.application?.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.creating = true;
|
||||||
|
orderOperator
|
||||||
|
.create({
|
||||||
|
application_id: this.application?.id,
|
||||||
|
amount: 10
|
||||||
|
})
|
||||||
|
.then(({ data: data }: { data: IOrderDetailResponse }) => {
|
||||||
|
this.creating = false;
|
||||||
|
const order = data;
|
||||||
|
this.$router.push({
|
||||||
|
name: 'console-order-detail',
|
||||||
|
params: {
|
||||||
|
id: order.id
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
ElMessage.success(this.$t('order.message.createFailed'));
|
||||||
|
|
||||||
|
this.creating = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
getPrice() {
|
||||||
|
if (this.application.service?.price && this.form.amount)
|
||||||
|
return this.form.amount * this.application.service?.price;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.price {
|
||||||
|
font-size: 20px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
export default {
|
export default {
|
||||||
goDocument: '查看文档',
|
goDocument: '查看文档',
|
||||||
buyMore: '购买更多'
|
buyMore: '购买更多',
|
||||||
|
createOrder: '创建订单'
|
||||||
};
|
};
|
||||||
@@ -3,5 +3,7 @@ export default {
|
|||||||
usedCount: '已使用次数',
|
usedCount: '已使用次数',
|
||||||
apiKey: 'API Key',
|
apiKey: 'API Key',
|
||||||
service: '服务',
|
service: '服务',
|
||||||
operation: '操作'
|
operation: '操作',
|
||||||
|
amount: '数量',
|
||||||
|
shouldPayPrice: '应付金额',
|
||||||
};
|
};
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
import field from './field';
|
import field from './field';
|
||||||
import button from './button';
|
import button from './button';
|
||||||
import message from './message';
|
import message from './message';
|
||||||
|
import title from './title';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
field,
|
field,
|
||||||
button,
|
button,
|
||||||
message
|
message,
|
||||||
|
title
|
||||||
};
|
};
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
export default {
|
||||||
|
buyService: '购买服务'
|
||||||
|
};
|
||||||
@@ -3,5 +3,6 @@ export default {
|
|||||||
amount: '金额',
|
amount: '金额',
|
||||||
price: '金额',
|
price: '金额',
|
||||||
description: '订单描述',
|
description: '订单描述',
|
||||||
state: '状态'
|
state: '状态',
|
||||||
|
createdAt: '创建时间'
|
||||||
};
|
};
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
import field from './field';
|
import field from './field';
|
||||||
import button from './button';
|
import button from './button';
|
||||||
import message from './message';
|
import message from './message';
|
||||||
|
import state from './state';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
field,
|
field,
|
||||||
button,
|
button,
|
||||||
message
|
message,
|
||||||
|
state
|
||||||
};
|
};
|
||||||
@@ -1 +1,4 @@
|
|||||||
export default {};
|
export default {
|
||||||
|
paidSuccessfully: '支付成功',
|
||||||
|
createFailed: '创建失败'
|
||||||
|
};
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
export default {
|
||||||
|
pending: '待支付',
|
||||||
|
paid: '已支付',
|
||||||
|
expired: '支付超时',
|
||||||
|
failed: '支付失败'
|
||||||
|
};
|
||||||
@@ -1,21 +1,23 @@
|
|||||||
import { IService } from '../service';
|
import { IApplication } from '../application';
|
||||||
|
|
||||||
export const ORDER_STATE_PENDING = 'Pending';
|
export enum OrderState {
|
||||||
export const ORDER_STATE_PAID = 'Paid';
|
PENDING = 'Pending',
|
||||||
export const ORDER_STATE_EXPIRED = 'Expired';
|
PAID = 'Paid',
|
||||||
export const ORDER_STATE_FAILED = 'Failed';
|
EXPIRED = 'Expired',
|
||||||
|
FAILED = 'Failed'
|
||||||
|
}
|
||||||
|
|
||||||
export interface IOrder {
|
export interface IOrder {
|
||||||
id?: string;
|
id?: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
state?: typeof ORDER_STATE_PENDING | typeof ORDER_STATE_PAID | typeof ORDER_STATE_EXPIRED | typeof ORDER_STATE_FAILED;
|
state?: OrderState;
|
||||||
price?: number;
|
price?: number;
|
||||||
amount?: number;
|
amount?: number;
|
||||||
user_id?: number;
|
user_id?: number;
|
||||||
created_at?: string;
|
created_at?: string;
|
||||||
updated_at?: string;
|
updated_at?: string;
|
||||||
service?: IService;
|
application?: IApplication;
|
||||||
service_id?: string;
|
application_id?: string;
|
||||||
wechatpay_url?: string;
|
wechatpay_url?: string;
|
||||||
alipay_url?: string;
|
alipay_url?: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ export interface IOrderQuery {
|
|||||||
user_id?: string;
|
user_id?: string;
|
||||||
offset?: number;
|
offset?: number;
|
||||||
limit?: number;
|
limit?: number;
|
||||||
|
ordering: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
class OrderService {
|
class OrderService {
|
||||||
|
|||||||
@@ -39,10 +39,10 @@
|
|||||||
<el-table-column>
|
<el-table-column>
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<div class="float-right">
|
<div class="float-right">
|
||||||
<el-button @click="onGoDocument(scope.row.service)">
|
<el-button v-if="false" @click="onGoDocument(scope.row)">
|
||||||
{{ $t('application.button.goDocument') }}
|
{{ $t('application.button.goDocument') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button type="primary" @click="onBuyMore(scope.row.service)">
|
<el-button type="primary" @click="onBuyMore(scope.row)">
|
||||||
{{ $t('application.button.buyMore') }}
|
{{ $t('application.button.buyMore') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
@@ -61,37 +61,26 @@
|
|||||||
</el-row>
|
</el-row>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-dialog v-model="buying" title="Warning" width="30%" center>
|
<create-order v-if="active.application" :visible="buying" :application="active.application" @hide="buying = false" />
|
||||||
<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>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
import {
|
import { applicationOperator, IApplication, IApplicationListResponse, IService } from '@/operators';
|
||||||
applicationOperator,
|
|
||||||
IApplication,
|
|
||||||
IApplicationListResponse,
|
|
||||||
IOrderDetailResponse,
|
|
||||||
IService,
|
|
||||||
orderOperator
|
|
||||||
} from '@/operators';
|
|
||||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||||
import Pagination from '@/components/common/Pagination.vue';
|
import Pagination from '@/components/common/Pagination.vue';
|
||||||
import CopyToClipboard from '@/components/common/CopyToClipboard.vue';
|
import CopyToClipboard from '@/components/common/CopyToClipboard.vue';
|
||||||
|
import CreateOrder from '@/components/order/Create.vue';
|
||||||
|
|
||||||
interface IData {
|
interface IData {
|
||||||
applications: IApplication[];
|
applications: IApplication[];
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
total: number | undefined;
|
total: number | undefined;
|
||||||
limit: number;
|
limit: number;
|
||||||
page: number;
|
|
||||||
buying: boolean;
|
buying: boolean;
|
||||||
|
form: {
|
||||||
|
amount: number | undefined;
|
||||||
|
};
|
||||||
active: {
|
active: {
|
||||||
service: IService | undefined;
|
service: IService | undefined;
|
||||||
application: IApplication | undefined;
|
application: IApplication | undefined;
|
||||||
@@ -103,7 +92,8 @@ export default defineComponent({
|
|||||||
components: {
|
components: {
|
||||||
FontAwesomeIcon,
|
FontAwesomeIcon,
|
||||||
Pagination,
|
Pagination,
|
||||||
CopyToClipboard
|
CopyToClipboard,
|
||||||
|
CreateOrder
|
||||||
},
|
},
|
||||||
data(): IData {
|
data(): IData {
|
||||||
return {
|
return {
|
||||||
@@ -112,41 +102,39 @@ export default defineComponent({
|
|||||||
total: undefined,
|
total: undefined,
|
||||||
buying: false,
|
buying: false,
|
||||||
limit: 8,
|
limit: 8,
|
||||||
|
form: {
|
||||||
|
amount: 1
|
||||||
|
},
|
||||||
active: {
|
active: {
|
||||||
service: undefined,
|
service: undefined,
|
||||||
application: undefined
|
application: undefined
|
||||||
},
|
}
|
||||||
page: parseInt(this.$route.query.page?.toString() || '1')
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
redirect() {
|
redirect() {
|
||||||
return this.$route.query.redirect;
|
return this.$route.query.redirect;
|
||||||
|
},
|
||||||
|
page() {
|
||||||
|
return parseInt(this.$route.query.page?.toString() || '1');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
page: {
|
||||||
|
handler() {
|
||||||
|
this.onFetchData();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {},
|
|
||||||
mounted() {
|
mounted() {
|
||||||
this.onFetchData();
|
this.onFetchData();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onBuyMore(service: IService) {
|
onGoDocument(application: IApplication) {},
|
||||||
this.active.service = service;
|
onBuyMore(application: IApplication) {
|
||||||
|
this.active.application = application;
|
||||||
this.buying = true;
|
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) {
|
onPageChange(page: number) {
|
||||||
this.$router.push({
|
this.$router.push({
|
||||||
name: this.$route.name?.toString(),
|
name: this.$route.name?.toString(),
|
||||||
@@ -154,7 +142,6 @@ export default defineComponent({
|
|||||||
page: page
|
page: page
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.onFetchData();
|
|
||||||
},
|
},
|
||||||
onFetchData() {
|
onFetchData() {
|
||||||
this.loading = true;
|
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>
|
<template>
|
||||||
<el-row class="panel">
|
<el-row class="wrapper">
|
||||||
<el-col :span="24">
|
<el-col :span="24">
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="24">
|
<el-col :span="24">
|
||||||
<h2 class="title">{{ $t('common.title.allOrders') }}</h2>
|
<h2 class="title">{{ $t('common.title.allOrders') }}</h2>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-row>
|
<el-row class="panel">
|
||||||
<el-col :span="24">
|
<el-col :span="24">
|
||||||
<el-card shadow="hover">
|
<el-card shadow="hover">
|
||||||
<el-table v-loading="loading" :data="orders" stripe>
|
<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">
|
<template #default="scope">
|
||||||
<span class="key">{{ scope.row.id }}</span>
|
<span class="key">{{ scope.row.id }}</span>
|
||||||
<span class="copy">
|
<span class="copy">
|
||||||
@@ -18,17 +18,53 @@
|
|||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="price" :label="$t('order.field.price')">
|
<el-table-column :label="$t('order.field.price')">
|
||||||
<template #default="scope">
|
<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>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="state" :label="$t('order.field.state')" class-name="text-center" />
|
|
||||||
<el-table-column>
|
<el-table-column>
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<div class="float-right">
|
<div class="float-right">
|
||||||
<el-button type="primary" @click="onContinuePay(scope.row)">
|
<el-button
|
||||||
{{ $t('application.button.continuePay') }}
|
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>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -46,69 +82,56 @@
|
|||||||
</el-row>
|
</el-row>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</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>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
import { IOrder, IOrderListResponse, IOrderDetailResponse, orderOperator } from '@/operators/order';
|
import { IOrder, IOrderListResponse, IOrderDetailResponse, orderOperator, OrderState } from '@/operators/order';
|
||||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
|
||||||
import Pagination from '@/components/common/Pagination.vue';
|
import Pagination from '@/components/common/Pagination.vue';
|
||||||
import CopyToClipboard from '@/components/common/CopyToClipboard.vue';
|
import CopyToClipboard from '@/components/common/CopyToClipboard.vue';
|
||||||
import { IService } from '@/operators/service/models';
|
|
||||||
|
|
||||||
interface IData {
|
interface IData {
|
||||||
orders: IOrder[];
|
orders: IOrder[];
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
total: number | undefined;
|
total: number | undefined;
|
||||||
limit: number;
|
limit: number;
|
||||||
page: number;
|
OrderState: typeof OrderState;
|
||||||
paying: boolean;
|
|
||||||
active: {
|
|
||||||
service: IService | undefined;
|
|
||||||
order: IOrder | undefined;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'OrderList',
|
name: 'ConsoleOrderList',
|
||||||
components: {
|
components: {
|
||||||
FontAwesomeIcon,
|
|
||||||
Pagination,
|
Pagination,
|
||||||
CopyToClipboard
|
CopyToClipboard
|
||||||
},
|
},
|
||||||
data(): IData {
|
data(): IData {
|
||||||
return {
|
return {
|
||||||
|
OrderState: OrderState,
|
||||||
orders: [],
|
orders: [],
|
||||||
loading: false,
|
loading: false,
|
||||||
total: undefined,
|
total: undefined,
|
||||||
paying: false,
|
limit: 8
|
||||||
limit: 8,
|
|
||||||
active: {
|
|
||||||
service: undefined,
|
|
||||||
order: undefined
|
|
||||||
},
|
|
||||||
page: parseInt(this.$route.query.page?.toString() || '1')
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
redirect() {
|
redirect() {
|
||||||
return this.$route.query.redirect;
|
return this.$route.query.redirect;
|
||||||
|
},
|
||||||
|
page() {
|
||||||
|
return parseInt(this.$route.query.page?.toString() || '1');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
page: {
|
||||||
|
handler() {
|
||||||
|
this.onFetchData();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {},
|
|
||||||
mounted() {
|
mounted() {
|
||||||
this.onFetchData();
|
this.onFetchData();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onContinuePay(order: IOrder) {
|
|
||||||
this.active.order = order;
|
|
||||||
this.paying = true;
|
|
||||||
},
|
|
||||||
onPageChange(page: number) {
|
onPageChange(page: number) {
|
||||||
this.$router.push({
|
this.$router.push({
|
||||||
name: this.$route.name?.toString(),
|
name: this.$route.name?.toString(),
|
||||||
@@ -116,12 +139,12 @@ export default defineComponent({
|
|||||||
page: page
|
page: page
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.onFetchData();
|
|
||||||
},
|
},
|
||||||
onFetchData() {
|
onFetchData() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
orderOperator
|
orderOperator
|
||||||
.getAll({
|
.getAll({
|
||||||
|
ordering: '-created_at',
|
||||||
limit: this.limit,
|
limit: this.limit,
|
||||||
offset: (this.page - 1) * this.limit,
|
offset: (this.page - 1) * this.limit,
|
||||||
user_id: this.$store.getters.user.id
|
user_id: this.$store.getters.user.id
|
||||||
@@ -151,7 +174,7 @@ export default defineComponent({
|
|||||||
margin-bottom: 50px;
|
margin-bottom: 50px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.panel {
|
.wrapper {
|
||||||
padding: 30px;
|
padding: 30px;
|
||||||
.api-key {
|
.api-key {
|
||||||
.copy {
|
.copy {
|
||||||
|
|||||||
@@ -90,7 +90,6 @@ interface IData {
|
|||||||
loading: boolean;
|
loading: boolean;
|
||||||
total: number | undefined;
|
total: number | undefined;
|
||||||
limit: number;
|
limit: number;
|
||||||
page: number;
|
|
||||||
}
|
}
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'ServiceList',
|
name: 'ServiceList',
|
||||||
@@ -103,10 +102,21 @@ export default defineComponent({
|
|||||||
services: [],
|
services: [],
|
||||||
loading: true,
|
loading: true,
|
||||||
total: undefined,
|
total: undefined,
|
||||||
limit: 8,
|
limit: 8
|
||||||
page: parseInt(this.$route.query.page?.toString() || '1')
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
page() {
|
||||||
|
return parseInt(this.$route.query.page?.toString() || '1');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
page: {
|
||||||
|
handler() {
|
||||||
|
this.onFetchData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
this.onFetchData();
|
this.onFetchData();
|
||||||
},
|
},
|
||||||
@@ -118,7 +128,6 @@ export default defineComponent({
|
|||||||
page: page
|
page: page
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.onFetchData();
|
|
||||||
},
|
},
|
||||||
onFetchData() {
|
onFetchData() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
|
|||||||
@@ -11,6 +11,11 @@ export default {
|
|||||||
name: 'console-order-list',
|
name: 'console-order-list',
|
||||||
component: () => import('@/pages/console/order/List.vue')
|
component: () => import('@/pages/console/order/List.vue')
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'orders/:id',
|
||||||
|
name: 'console-order-detail',
|
||||||
|
component: () => import('@/pages/console/order/Detail.vue')
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: 'applications',
|
path: 'applications',
|
||||||
name: 'console-application-list',
|
name: 'console-application-list',
|
||||||
|
|||||||
@@ -2930,6 +2930,11 @@ purgecss@^4.0.3:
|
|||||||
postcss "^8.3.5"
|
postcss "^8.3.5"
|
||||||
postcss-selector-parser "^6.0.6"
|
postcss-selector-parser "^6.0.6"
|
||||||
|
|
||||||
|
qrcode.vue@^3.3.3:
|
||||||
|
version "3.3.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/qrcode.vue/-/qrcode.vue-3.3.3.tgz#00262244311a0ee1956fb7a0e238197ff7e14cfa"
|
||||||
|
integrity sha512-OsD4tQjIbxg/K6D5ZkWjBdYI9eg9K2i8qeYILdEAX5mdAydSAxV7xKmmZSP/hA12olLqEMZ9ryqDQrwa9jEMgw==
|
||||||
|
|
||||||
query-string@^8.1.0:
|
query-string@^8.1.0:
|
||||||
version "8.1.0"
|
version "8.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/query-string/-/query-string-8.1.0.tgz#e7f95367737219544cd360a11a4f4ca03836e115"
|
resolved "https://registry.yarnpkg.com/query-string/-/query-string-8.1.0.tgz#e7f95367737219544cd360a11a4f4ca03836e115"
|
||||||
|
|||||||
Reference in new issue
Block a user