main #2
@ -166,27 +166,20 @@
|
||||
</div>
|
||||
|
||||
<label class="block text-sm font-medium text-gray-700 mb-2">购买时长</label>
|
||||
<select v-model="period" class="w-full border rounded px-3 py-2">
|
||||
<select v-model="period" @change="onPeriodChange" class="w-full border rounded px-3 py-2">
|
||||
<option v-for="p in periods" :key="p.value" :value="p.value">{{ p.label }}</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- 价格信息显示 -->
|
||||
<div v-if="domainCheckResult && domainCheckResult.available && domainPrice" class="border-t border-gray-200 pt-4">
|
||||
<div v-if="domainCheckResult && domainCheckResult.available && totalPrice" class="border-t border-gray-200 pt-4">
|
||||
<div class="flex justify-between items-center">
|
||||
<div class="text-sm text-gray-600">年度费用</div>
|
||||
<div class="font-medium">
|
||||
¥ {{ domainPrice }}
|
||||
<span class="text-gray-500 text-sm">(年付)</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center mt-2">
|
||||
<div class="text-sm text-gray-600">购买时长</div>
|
||||
<div class="font-medium">{{ period }} 年</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center mt-2 text-lg font-bold">
|
||||
<div>总计</div>
|
||||
<div>¥ {{ getTotalAmount() }}</div>
|
||||
<div>¥ {{ totalPrice.toFixed(2) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user