@@ -47,43 +21,13 @@
-
-
-
-
-
- {{ plan.core }}核 {{ plan.memory }}GB {{ plan.disk_size }}GB
-
-
-
CPU: {{ plan.core }}核
-
内存: {{ plan.memory }}GB
-
系统盘: {{ plan.disk_size }}GB
-
带宽: {{ plan.bandwidth }}Mbps
-
-
-
-
- ¥{{ plan.origin_price }}/月
-
-
- +¥{{ getPriceDiff(plan) }}/月
-
-
- -¥{{ Math.abs(getPriceDiff(plan)) }}/月
-
-
-
-
+
+
@@ -255,7 +199,7 @@
type="button"
class="w-full px-4 py-2 bg-[#1fc76f] border border-transparent rounded-md text-sm font-medium text-white hover:bg-[#19b862] focus:outline-none"
@click="createUpgradeOrder"
- :disabled="isLoading || !selectedPlan || !selectedPaymentMethod"
+ :disabled="isLoading || !selectedPlanId || !selectedPaymentMethod"
>
{{ isLoading ? '处理中...' : '确认升级' }}
@@ -303,7 +247,7 @@ export default {
data() {
return {
show: true,
- selectedPlan: null,
+ selectedPlanId: '',
selectedPaymentMethod: null,
order: null,
showPaymentProcessing: false,
@@ -333,6 +277,10 @@ export default {
region: this.serverDoc.region
};
},
+ selectedPlan() {
+ if (!this.selectedPlanId || !this.upgradePlans.length) return null;
+ return this.upgradePlans.find(plan => plan.plan_id === this.selectedPlanId);
+ },
upgradePriceInfo() {
if (!this.selectedPlan || !this.serverInfo) return null;
@@ -386,7 +334,7 @@ export default {
if (!this.server) {
throw new DashboardError('缺少服务器信息');
}
- if (!this.selectedPlan) {
+ if (!this.selectedPlanId) {
throw new DashboardError('请选择升级套餐');
}
},
@@ -533,12 +481,7 @@ export default {
this.upgradePlansLoading = false;
}
},
- getPriceDiff(plan) {
- if (!this.serverInfo) return 0;
- const currentPrice = this.serverInfo.plan_price;
- const newPrice = parseFloat(plan.origin_price);
- return newPrice - currentPrice;
- },
+
cancel() {
this.stopPaymentCheck();
this.show = false;
@@ -552,7 +495,7 @@ export default {
this.error = null;
this.$resources.createUpgradeOrder.submit({
server: this.server,
- new_plan_id: this.selectedPlan.plan_id
+ new_plan_id: this.selectedPlanId
});
},
processPayment() {
@@ -598,7 +541,52 @@ export default {
clearInterval(this.checkInterval);
this.checkInterval = null;
}
- }
+ },
+ getPlanDisplayName(plan) {
+ // 根据阿里云API返回的数据结构显示套餐信息
+ const cpu = plan.core || plan.cpu || '未知';
+ const memory = plan.memory || '未知';
+ const disk = plan.disk_size || plan.system_disk_size || '未知';
+ const bandwidth = plan.bandwidth || '未知';
+ const price = plan.origin_price || '未知';
+ const planType = plan.plan_type || '';
+ const publicIpNum = plan.public_ip_num || 0;
+
+ // 处理内存显示(如果是小数,转换为MB)
+ let memoryDisplay = memory;
+ if (typeof memory === 'number' && memory < 1) {
+ memoryDisplay = Math.round(memory * 1024) + 'MB';
+ } else if (typeof memory === 'number') {
+ memoryDisplay = memory + 'GB';
+ }
+
+ // 处理带宽显示
+ let bandwidthDisplay = bandwidth;
+ if (typeof bandwidth === 'number') {
+ bandwidthDisplay = bandwidth + 'Mbps';
+ }
+
+ // 根据plan_type添加类型前缀
+ let typePrefix = '';
+ switch (planType) {
+ case 'NORMAL':
+ typePrefix = '通用型 - ';
+ break;
+ case 'MULTI_IP':
+ typePrefix = '多公网IP型 - ';
+ break;
+ case 'INTERNATIONAL':
+ typePrefix = '国际型 - ';
+ break;
+ case 'CAPACITY':
+ typePrefix = '容量型 - ';
+ break;
+ default:
+ typePrefix = '';
+ }
+
+ return `${typePrefix}${cpu}核/${memoryDisplay}/${disk}GB/${bandwidthDisplay}/${publicIpNum}个公网IP - ¥${price}/月`;
+ }
},
beforeUnmount() {
this.stopPaymentCheck();