From 2d0d6eb59b63faa81669e4028218f4bd6b1cc36e Mon Sep 17 00:00:00 2001 From: Leo_Ding <2405260743@qq.com> Date: Fri, 16 Jan 2026 18:25:56 +0800 Subject: [PATCH] 1 --- src/apis/home.ts | 3 +++ .../admin/account/cost/exchange/index.vue | 13 +++++++----- .../admin/account/cost/myOrder/index.vue | 4 +--- src/views/instanceCreate/index.vue | 21 ++++++++++++++++--- 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/apis/home.ts b/src/apis/home.ts index c3e436f..476e642 100644 --- a/src/apis/home.ts +++ b/src/apis/home.ts @@ -49,3 +49,6 @@ export const getHostInfo=(params:any)=>request.get('/v1/host/info',{params}) //兑换算力点 export const exchangePoint=(params:any)=>request.put('/v1/balance/exchange_point',params) +//创建实例 +export const createHost=(params:any)=>request.post('/v1/host/host_case',params) + diff --git a/src/views/admin/account/cost/exchange/index.vue b/src/views/admin/account/cost/exchange/index.vue index 66b01b5..74db06a 100644 --- a/src/views/admin/account/cost/exchange/index.vue +++ b/src/views/admin/account/cost/exchange/index.vue @@ -9,7 +9,7 @@ - +
@@ -17,7 +17,7 @@
¥ - {{ userInfo.balance }} + {{ formatCurrency(balance) }}
@@ -262,7 +262,7 @@ const handleCustomAmountChange = () => { if (!isNaN(amount)) { if (amount > 10000) { customAmountError.value = '单次最大兑换金额为10000元' - } else if (amount > userInfo.value.balance) { + } else if (amount > balance.value) { customAmountError.value = '兑换金额不能超过余额' } else { customAmountError.value = '' @@ -289,15 +289,18 @@ const handleAgreementConfirm = () => { // 处理兑换 const handleExchange = async () => { showAgreementError.value = false + if (!agreementChecked.value) { showAgreementError.value = true message.error('请先阅读并确认用户协议') return } - if (selectedExchangeAmount.value > userInfo.value.balance) { + + if (selectedExchangeAmount.value > balance.value) { message.error('兑换金额不能超过余额') return } + Modal.confirm({ title: '确认兑换', content: `您确定要兑换 ¥${selectedExchangeAmount.value} 获得 ${selectedExchangeAmount.value} 算力点吗?此操作不可撤销。`, @@ -423,6 +426,7 @@ onMounted(() => { /* 样式保持不变,同上 */ .points-exchange-page { padding: 20px; + background-color: #ffffff; /* min-height: 100vh; */ } @@ -493,7 +497,6 @@ onMounted(() => { font-weight: 600; color: rgba(0, 0, 0, 0.85); margin-bottom: 8px; - width: 120px; } .amount-options { diff --git a/src/views/admin/account/cost/myOrder/index.vue b/src/views/admin/account/cost/myOrder/index.vue index 3e01720..6ed7067 100644 --- a/src/views/admin/account/cost/myOrder/index.vue +++ b/src/views/admin/account/cost/myOrder/index.vue @@ -90,9 +90,7 @@
+
+ 实例名称: +
+ +
+
计费方式*:
@@ -128,7 +134,7 @@ import { message } from 'ant-design-vue' import type { TableColumnsType } from 'ant-design-vue' import { useRoute,useRouter } from 'vue-router' import { getImages } from "@/apis/home" -import { getMyCouponTotal, getTotalCost, getHostInfo } from "@/apis/home" +import { getMyCouponTotal, getTotalCost, getHostInfo,createHost } from "@/apis/home" const router=useRouter() interface GpuModelOption { value: string @@ -138,7 +144,7 @@ interface GpuModelOption { regions: string[] } - +const instanceName=ref('') const checked = ref(false) const totalMoney = ref(0) // 响应式数据 @@ -222,8 +228,17 @@ const isShow=computed(()=>{ const handleCreate = async () => { creating.value = true try { - await new Promise(resolve => setTimeout(resolve, 2000)) + const params={ + host_id:HostId.value, + billingMethod:billingType.value, + gpuNum:gpuCount.value, + case_name:instanceName.value, + image_id:selectedImage.value, + is_use_voucher:checked.value + } + const res=await createHost(params) message.success('实例创建成功!') + creating.value=false } catch (error) { message.error('创建失败,请重试') } finally {