<script setup>
// Copyright 2024 FlexCDN root@flexcdn.cn. All rights reserved. Official site: https://flexcdn.cn .

import ctxRef from "@/utils/ctx_ref.js"
import Context from "./renewConfirm.js"
import PayMethodSelector from "@/components/pay/PayMethodSelector.vue";
import SubmitButton from "@/components/form/SubmitButton.vue";
import PostForm from "@/components/form/PostForm.vue";
import TStep from "@/components/ui/TStep.vue";
import TStepView from "@/components/ui/TStepView.vue";
import TSteps from "@/components/ui/TSteps.vue";
import DefinitionTable from "@/components/common/DefinitionTable.vue";

const ctx = ctxRef(new Context())

</script>

<template>
	<!-- 步骤 -->
	<TStepView step="pay">
		<TSteps>
			<TStep>
				<a href="/anti-ddos/instances">选择要续费的实例</a>
			</TStep>
			<TStep code="pay">
				支付
			</TStep>
		</TSteps>
	</TStepView>

	<PostForm action="$" @success="ctx.success" class="mt-2">
		<input type="hidden" name="userInstanceId" :value="ctx.userInstanceId"/>
		<input type="hidden" name="periodId" :value="ctx.periodId"/>

		<DefinitionTable>
			<tbody>
			<tr>
				<td class="title">高防实例</td>
				<td>[{{ctx.packageSummary}} / <span v-for="(ipAddr, index) in ctx.ipAddresses">{{ipAddr}}<span v-if="index != ctx.ipAddresses.length -1">,</span></span> / 当前有效期至{{ctx.dayTo}} / 新增{{ctx.periodName}}]</td>
			</tr>
			<tr>
				<td>价格</td>
				<td>￥{{ctx.amount}}元</td>
			</tr>
			<tr>
				<td>支付方式</td>
				<td>
					<PayMethodSelector></PayMethodSelector>
				</td>
			</tr>
			</tbody>
		</DefinitionTable>

		<SubmitButton v-show="ctx.amount > 0">确定续费</SubmitButton><span class="red" v-if="ctx.amount == 0">参数错误，请返回重新选择。</span> &nbsp; <a href="/anti-ddos/instances">上一步</a>
	</PostForm>
</template>

<style lang="postcss" scoped>
</style>