<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 Menu from "@/views/servers/packages/@menu.vue";
import PostForm from "@/components/form/PostForm.vue";
import SubmitButton from "@/components/form/SubmitButton.vue";
import PayMethodSelector from "@/components/pay/PayMethodSelector.vue";
import DefinitionTable from "@/components/common/DefinitionTable.vue";

const ctx = ctxRef(new Context())

</script>

<template>
	<Menu active-tab="buy"></Menu>

	<PostForm action="$" @success="ctx.success">
		<input type="hidden" name="packageId" :value="ctx.packageId"/>
		<input type="hidden" name="regionId" :value="ctx.regionId"/>
		<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.packageName}} / {{ctx.regionName}} / {{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>确定购买</SubmitButton> &nbsp; <a href="/servers/packages/buy" @click.prevent="ctx.goBack()">上一步</a>
	</PostForm>
</template>

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