fix:套餐界面修改参数
This commit is contained in:
@@ -128,11 +128,12 @@ export function fetchPackageList() {
|
|||||||
method: 'get'
|
method: 'get'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/** Submit package order */
|
/** Submit order with different types */
|
||||||
export function submitPackageOrder(packageId: string) {
|
export function submitOrder(data: Api.Order.SubmitOrderParams) {
|
||||||
return request({
|
return request({
|
||||||
url: '/u/order',
|
url: '/u/order',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: { packageId }
|
data
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
29
src/typings/api.d.ts
vendored
29
src/typings/api.d.ts
vendored
@@ -599,5 +599,34 @@ declare namespace Api {
|
|||||||
data: PackageItem[];
|
data: PackageItem[];
|
||||||
total?: number;
|
total?: number;
|
||||||
}
|
}
|
||||||
|
interface OrderSubmitParams {
|
||||||
|
packageId: string;
|
||||||
|
type: 0; // 限定为字面量类型 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Order {
|
||||||
|
/** Order type enum */
|
||||||
|
type OrderType = 0 | 1 | 2; // 根据实际需要添加其他类型
|
||||||
|
|
||||||
|
/** Base order params */
|
||||||
|
interface BaseOrderParams {
|
||||||
|
type: OrderType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Package order params */
|
||||||
|
interface PackageOrderParams extends BaseOrderParams {
|
||||||
|
type: 0;
|
||||||
|
packageId: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Recharge order params */
|
||||||
|
interface RechargeOrderParams extends BaseOrderParams {
|
||||||
|
type: 1;
|
||||||
|
orderAmount: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Combined order params type */
|
||||||
|
type SubmitOrderParams = PackageOrderParams | RechargeOrderParams;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
1
src/typings/auto-imports.d.ts
vendored
1
src/typings/auto-imports.d.ts
vendored
@@ -201,6 +201,7 @@ declare global {
|
|||||||
const shallowRef: typeof import('vue')['shallowRef']
|
const shallowRef: typeof import('vue')['shallowRef']
|
||||||
const sortRoutesByOrder: typeof import('../store/modules/route/shared')['sortRoutesByOrder']
|
const sortRoutesByOrder: typeof import('../store/modules/route/shared')['sortRoutesByOrder']
|
||||||
const storeToRefs: typeof import('pinia')['storeToRefs']
|
const storeToRefs: typeof import('pinia')['storeToRefs']
|
||||||
|
const submitOrder: typeof import('../service/api/auth')['submitOrder']
|
||||||
const submitPackageOrder: typeof import('../service/api/auth')['submitPackageOrder']
|
const submitPackageOrder: typeof import('../service/api/auth')['submitPackageOrder']
|
||||||
const suite: typeof import('vitest')['suite']
|
const suite: typeof import('vitest')['suite']
|
||||||
const syncRef: typeof import('@vueuse/core')['syncRef']
|
const syncRef: typeof import('@vueuse/core')['syncRef']
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { ref, onMounted } from 'vue';
|
import { ref, onMounted } from 'vue';
|
||||||
import { fetchPackageList, submitPackageOrder } from '@/service/api/auth';
|
import { fetchPackageList, submitOrder } from '@/service/api/auth';
|
||||||
import { message } from 'ant-design-vue';
|
import { message } from 'ant-design-vue';
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
@@ -113,7 +113,10 @@ const selectPackage = (option: PackageOption) => {
|
|||||||
// 添加办理套餐的方法
|
// 添加办理套餐的方法
|
||||||
const handleSubmitOrder = async () => {
|
const handleSubmitOrder = async () => {
|
||||||
try {
|
try {
|
||||||
await submitPackageOrder(selectedPackage.value.id);
|
await submitOrder({
|
||||||
|
type: 0,
|
||||||
|
packageId: selectedPackage.value.id
|
||||||
|
});
|
||||||
message.success('套餐办理成功!');
|
message.success('套餐办理成功!');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
message.error('套餐办理失败,请重试!');
|
message.error('套餐办理失败,请重试!');
|
||||||
|
|||||||
Reference in New Issue
Block a user