diff --git a/dashboard/src2/pages/NewJsiteDomain.vue b/dashboard/src2/pages/NewJsiteDomain.vue index 57db66f..a0aba01 100644 --- a/dashboard/src2/pages/NewJsiteDomain.vue +++ b/dashboard/src2/pages/NewJsiteDomain.vue @@ -166,27 +166,20 @@ - -
+
-
年度费用
-
- ¥ {{ domainPrice }} - (年付) -
-
-
购买时长
{{ period }} 年
总计
-
¥ {{ getTotalAmount() }}
+
¥ {{ totalPrice.toFixed(2) }}
@@ -391,6 +384,7 @@ export default { error: null, domainCheckResult: null, domainPrice: null, + totalPrice: null, // 当前选择年限的总价 // 支付相关状态 order: null, domain: null, @@ -780,7 +774,10 @@ export default { // 如果域名可用,获取价格 if (response.available) { - this.getDomainPrice(); + this.$resources.getDomainPrice.submit({ + domain: this.fullDomain, + year: this.period + }); } }, onError(error) { @@ -795,19 +792,19 @@ export default { url: 'jcloud.api.domain_west.get_west_domain_price', onSuccess(response) { if (response.status === "Error") { - this.domainPrice = null; + this.totalPrice = null; return; } - // 解析价格信息 + // 解析价格信息 - 直接使用总价 if (response.data && response.data.price) { - this.domainPrice = response.data.price; + this.totalPrice = response.data.price; } else { - this.domainPrice = 50; // 默认价格 + this.totalPrice = 50; // 默认价格 } }, onError(error) { - this.domainPrice = 50; // 默认价格 + this.totalPrice = 50; // 默认价格 } }; }, @@ -1095,9 +1092,14 @@ export default { // 直接提交数据,验证由对话框组件负责 this.$resources.createDomainOwner.submit(formData); }, - getTotalAmount() { - const yearlyPrice = this.domainPrice || 0; - return (yearlyPrice * this.period).toFixed(2); + onPeriodChange() { + // 购买时长变化时,立即获取对应年限的价格 + if (this.domainCheckResult && this.domainCheckResult.available) { + this.$resources.getDomainPrice.submit({ + domain: this.fullDomain, + year: this.period + }); + } }, selectSuffix(suffix) { this.selectedSuffix = suffix; diff --git a/jcloud/api/domain_west.py b/jcloud/api/domain_west.py index 88477ff..f159363 100644 --- a/jcloud/api/domain_west.py +++ b/jcloud/api/domain_west.py @@ -1454,14 +1454,13 @@ def create_domain_order(domain, period=1, payment_method='balance', domain_owner if not client: return {"success": False, "message": "API客户端初始化失败"} - # 获取域名价格 - 使用统一的 get_west_domain_price 函数 - price_result = get_west_domain_price(domain, 1) + # 获取域名价格 - 根据实际购买的年限 + price_result = get_west_domain_price(domain, period) if price_result.get("status") == "error": return {"success": False, "message": "获取域名价格失败"} - # 计算总价格 - 使用与前端一致的价格字段 - yearly_price = price_result.get("data", {}).get("price", 0) # 使用前端一致的价格字段 - total_amount = yearly_price * period + # 使用对应年限的总价 + total_amount = price_result.get("data", {}).get("price", 0) # 生成订单号 order_id = f"{datetime.now().strftime('%Y%m%d%H%M%S%f')[:-3] + ''.join(random.choices('0123456789', k=6))}" @@ -1480,7 +1479,7 @@ def create_domain_order(domain, period=1, payment_method='balance', domain_owner "domain": domain, "period": period, "domain_owner": domain_owner, - "yearly_price": yearly_price, + "total_price": total_amount, "auto_renew": False, # 注册域名所需参数 "regyear": period,