From 2ca68e2559b265a1d008a4336d34da4daf523eaa Mon Sep 17 00:00:00 2001 From: AceDataCloud Date: Tue, 24 Jan 2023 12:28:34 +0800 Subject: [PATCH] add order and pay support --- package.json | 1 + src/components/common/CopyToClipboard.vue | 11 +- src/components/console/Navigator.vue | 30 ++- src/components/order/Create.vue | 95 +++++++++ src/i18n/zh/application/button.ts | 3 +- src/i18n/zh/application/field.ts | 4 +- src/i18n/zh/application/index.ts | 4 +- src/i18n/zh/application/title.ts | 3 + src/i18n/zh/order/field.ts | 3 +- src/i18n/zh/order/index.ts | 4 +- src/i18n/zh/order/message.ts | 5 +- src/i18n/zh/order/state.ts | 6 + src/operators/order/models.ts | 18 +- src/operators/order/operator.ts | 1 + src/pages/console/application/List.vue | 69 +++---- src/pages/console/order/Detail.vue | 223 ++++++++++++++++++++++ src/pages/console/order/List.vue | 101 ++++++---- src/pages/service/List.vue | 17 +- src/router/console.ts | 5 + yarn.lock | 5 + 20 files changed, 490 insertions(+), 118 deletions(-) create mode 100644 src/components/order/Create.vue create mode 100644 src/i18n/zh/application/title.ts create mode 100644 src/i18n/zh/order/state.ts create mode 100644 src/pages/console/order/Detail.vue diff --git a/package.json b/package.json index 3f0cb925..11d871d3 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,7 @@ "markdown-it": "^13.0.1", "mustache": "^4.2.0", "programming-languages-logos": "^0.0.3", + "qrcode.vue": "^3.3.3", "query-string": "^8.1.0", "typescript-cookie": "^1.0.3", "url-join": "^5.0.0", diff --git a/src/components/common/CopyToClipboard.vue b/src/components/common/CopyToClipboard.vue index 8621ddb1..0ab04c15 100644 --- a/src/components/common/CopyToClipboard.vue +++ b/src/components/common/CopyToClipboard.vue @@ -1,7 +1,7 @@ @@ -39,3 +39,10 @@ export default defineComponent({ } }); + + diff --git a/src/components/console/Navigator.vue b/src/components/console/Navigator.vue index a43831a0..700a1f6c 100644 --- a/src/components/console/Navigator.vue +++ b/src/components/console/Navigator.vue @@ -7,11 +7,13 @@ @@ -30,12 +32,12 @@ + + diff --git a/src/i18n/zh/application/button.ts b/src/i18n/zh/application/button.ts index 7cbed324..679d43dc 100644 --- a/src/i18n/zh/application/button.ts +++ b/src/i18n/zh/application/button.ts @@ -1,4 +1,5 @@ export default { goDocument: '查看文档', - buyMore: '购买更多' + buyMore: '购买更多', + createOrder: '创建订单' }; diff --git a/src/i18n/zh/application/field.ts b/src/i18n/zh/application/field.ts index afcfe272..0dd34dd1 100644 --- a/src/i18n/zh/application/field.ts +++ b/src/i18n/zh/application/field.ts @@ -3,5 +3,7 @@ export default { usedCount: '已使用次数', apiKey: 'API Key', service: '服务', - operation: '操作' + operation: '操作', + amount: '数量', + shouldPayPrice: '应付金额', }; diff --git a/src/i18n/zh/application/index.ts b/src/i18n/zh/application/index.ts index 3cd536a7..b093a5b9 100644 --- a/src/i18n/zh/application/index.ts +++ b/src/i18n/zh/application/index.ts @@ -1,9 +1,11 @@ import field from './field'; import button from './button'; import message from './message'; +import title from './title'; export default { field, button, - message + message, + title }; diff --git a/src/i18n/zh/application/title.ts b/src/i18n/zh/application/title.ts new file mode 100644 index 00000000..73032404 --- /dev/null +++ b/src/i18n/zh/application/title.ts @@ -0,0 +1,3 @@ +export default { + buyService: '购买服务' +}; diff --git a/src/i18n/zh/order/field.ts b/src/i18n/zh/order/field.ts index b0c926c0..0b0acd5c 100644 --- a/src/i18n/zh/order/field.ts +++ b/src/i18n/zh/order/field.ts @@ -3,5 +3,6 @@ export default { amount: '金额', price: '金额', description: '订单描述', - state: '状态' + state: '状态', + createdAt: '创建时间' }; diff --git a/src/i18n/zh/order/index.ts b/src/i18n/zh/order/index.ts index 3cd536a7..bea4fbf9 100644 --- a/src/i18n/zh/order/index.ts +++ b/src/i18n/zh/order/index.ts @@ -1,9 +1,11 @@ import field from './field'; import button from './button'; import message from './message'; +import state from './state'; export default { field, button, - message + message, + state }; diff --git a/src/i18n/zh/order/message.ts b/src/i18n/zh/order/message.ts index ff8b4c56..d9f13aaa 100644 --- a/src/i18n/zh/order/message.ts +++ b/src/i18n/zh/order/message.ts @@ -1 +1,4 @@ -export default {}; +export default { + paidSuccessfully: '支付成功', + createFailed: '创建失败' +}; diff --git a/src/i18n/zh/order/state.ts b/src/i18n/zh/order/state.ts new file mode 100644 index 00000000..f372d314 --- /dev/null +++ b/src/i18n/zh/order/state.ts @@ -0,0 +1,6 @@ +export default { + pending: '待支付', + paid: '已支付', + expired: '支付超时', + failed: '支付失败' +}; diff --git a/src/operators/order/models.ts b/src/operators/order/models.ts index a832c0fd..e6853bbd 100644 --- a/src/operators/order/models.ts +++ b/src/operators/order/models.ts @@ -1,21 +1,23 @@ -import { IService } from '../service'; +import { IApplication } from '../application'; -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 enum OrderState { + PENDING = 'Pending', + PAID = 'Paid', + EXPIRED = 'Expired', + 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; + state?: OrderState; price?: number; amount?: number; user_id?: number; created_at?: string; updated_at?: string; - service?: IService; - service_id?: string; + application?: IApplication; + application_id?: string; wechatpay_url?: string; alipay_url?: string; } diff --git a/src/operators/order/operator.ts b/src/operators/order/operator.ts index d2ecafa7..276818dc 100644 --- a/src/operators/order/operator.ts +++ b/src/operators/order/operator.ts @@ -6,6 +6,7 @@ export interface IOrderQuery { user_id?: string; offset?: number; limit?: number; + ordering: string; } class OrderService { diff --git a/src/pages/console/application/List.vue b/src/pages/console/application/List.vue index c5be902a..e6b96731 100644 --- a/src/pages/console/application/List.vue +++ b/src/pages/console/application/List.vue @@ -39,10 +39,10 @@ + + + diff --git a/src/pages/console/order/List.vue b/src/pages/console/order/List.vue index afe505e9..6ab4f51b 100644 --- a/src/pages/console/order/List.vue +++ b/src/pages/console/order/List.vue @@ -1,16 +1,16 @@ +