main #2
@ -32,31 +32,24 @@
|
||||
{{ getRegionName(region) }}
|
||||
</option>
|
||||
</select>
|
||||
<!-- 调试信息 -->
|
||||
<div v-if="regions.length === 0" class="mt-2 text-sm text-gray-500">
|
||||
正在加载区域列表...
|
||||
</div>
|
||||
<div v-if="regions.length > 0" class="mt-2 text-sm text-gray-500">
|
||||
已加载 {{ regions.length }} 个区域
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-2">套餐选择</label>
|
||||
<select v-model="selectedPlanId" class="w-full border rounded px-3 py-2" required>
|
||||
<option value="">请选择套餐</option>
|
||||
<option v-for="plan in plans" :key="plan.plan_id" :value="plan.plan_id">
|
||||
{{ getPlanDisplayName(plan) }}
|
||||
<label class="block text-sm font-medium text-gray-700 mb-2">镜像选择(Jsite服务器推荐选择Ubuntu-22.04)</label>
|
||||
<select v-model="selectedImageId" class="w-full border rounded px-3 py-2" required @change="onImageChange">
|
||||
<option value="">请选择镜像</option>
|
||||
<option v-for="image in images" :key="getImageId(image)" :value="getImageId(image)">
|
||||
{{ getImageDisplayName(image) }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-2">镜像选择</label>
|
||||
<select v-model="selectedImageId" class="w-full border rounded px-3 py-2" required>
|
||||
<option value="">请选择镜像</option>
|
||||
<option v-for="image in images" :key="getImageId(image)" :value="getImageId(image)">
|
||||
{{ getImageDisplayName(image) }}
|
||||
<label class="block text-sm font-medium text-gray-700 mb-2">套餐选择</label>
|
||||
<select v-model="selectedPlanId" class="w-full border rounded px-3 py-2" required :disabled="!selectedImageId">
|
||||
<option value="">请选择套餐</option>
|
||||
<option v-for="plan in filteredPlans" :key="plan.plan_id" :value="plan.plan_id">
|
||||
{{ getPlanDisplayName(plan) }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
@ -533,6 +526,40 @@ export default {
|
||||
},
|
||||
|
||||
},
|
||||
computed: {
|
||||
filteredPlans() {
|
||||
// 如果没有选择镜像,返回空数组
|
||||
if (!this.selectedImageId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// 获取选择的镜像信息
|
||||
const selectedImage = this.images.find(img => this.getImageId(img) === this.selectedImageId);
|
||||
if (!selectedImage) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// 获取镜像平台信息
|
||||
const imagePlatform = selectedImage.platform || '';
|
||||
|
||||
// 根据镜像平台过滤套餐
|
||||
return this.plans.filter(plan => {
|
||||
const supportPlatform = plan.support_platform;
|
||||
if (!supportPlatform) {
|
||||
return true; // 如果没有support_platform信息,默认显示
|
||||
}
|
||||
|
||||
try {
|
||||
// 解析support_platform字段(JSON字符串格式)
|
||||
const platforms = JSON.parse(supportPlatform);
|
||||
return platforms.includes(imagePlatform);
|
||||
} catch (e) {
|
||||
// 如果解析失败,尝试字符串匹配
|
||||
return supportPlatform.includes(imagePlatform);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
beforeUnmount() {
|
||||
this.stopPaymentCheck();
|
||||
},
|
||||
@ -547,13 +574,22 @@ export default {
|
||||
this.images = [];
|
||||
|
||||
if (this.selectedRegionId) {
|
||||
await this.$resources.aliyunPlans.submit({ region_id: this.selectedRegionId });
|
||||
// 只加载镜像,套餐将在选择镜像后加载
|
||||
await this.$resources.aliyunImages.submit({
|
||||
region_id: this.selectedRegionId,
|
||||
image_type: 'system' // 明确指定镜像类型
|
||||
});
|
||||
}
|
||||
},
|
||||
async onImageChange() {
|
||||
this.selectedPlanId = '';
|
||||
this.plans = [];
|
||||
if (this.selectedImageId) {
|
||||
await this.$resources.aliyunPlans.submit({
|
||||
region_id: this.selectedRegionId
|
||||
});
|
||||
}
|
||||
},
|
||||
async createInstance() {
|
||||
if (!this.selectedRegionId || !this.selectedPlanId || !this.selectedImageId) {
|
||||
this.error = '请选择完整配置';
|
||||
@ -675,7 +711,7 @@ export default {
|
||||
return `${typePrefix}${cpu}核/${memoryDisplay}/${disk}GB/${bandwidthDisplay}/${publicIpNum}个公网IP - ¥${price}/月`;
|
||||
},
|
||||
getSelectedPlanPrice() {
|
||||
const selectedPlan = this.plans.find(plan => plan.plan_id === this.selectedPlanId);
|
||||
const selectedPlan = this.filteredPlans.find(plan => plan.plan_id === this.selectedPlanId);
|
||||
return selectedPlan ? (selectedPlan.origin_price || 0) : 0;
|
||||
},
|
||||
getTotalAmount() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user