<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 "./confirm.js"
import TStep from "@/components/ui/TStep.vue";
import TStepView from "@/components/ui/TStepView.vue";
import TSteps from "@/components/ui/TSteps.vue";
import PostForm from "@/components/form/PostForm.vue";
import PayMethodSelector from "@/components/pay/PayMethodSelector.vue";
import SubmitButton from "@/components/form/SubmitButton.vue";
import DefinitionTable from "@/components/common/DefinitionTable.vue";

const ctx = ctxRef(new Context())

</script>

<template>
	<!-- 步骤 -->
	<TStepView step="pay">
		<TSteps>
			<TStep code="selectInstance">
				<a href="/anti-ddos/packages">选择实例规格</a>
			</TStep>
			<TStep code="pay">支付</TStep>
		</TSteps>
	</TStepView>

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

		<DefinitionTable>
			<tbody>
			<tr>
				<td class="title">高防实例</td>
				<td>[{{ctx.packageSummary}} / {{ctx.periodName}}] x {{ctx.count}}</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/packages">上一步</a>
	</PostForm>
</template>

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