<template>
	<view class="payment">
		<uni-nav-bar dark :fixed="true" background-color="#00aaff" :border="false" status-bar title="加油" />

		<view class="container">
			<uni-section title="输入金额" type="line" titleFontSize="34rpx"></uni-section>

			<view class="money-input">
				<image src="../../static/payment/money.png" mode="widthFix"></image>
				<input v-model="form.money" @focus="focus" placeholder="请输入加油金额" type="number" />
			</view>

			<view v-if="form.money" class="tip">
				折后共计{{ form.money * 0.99 }}元
			</view>

			<view class="select-money">
				<view v-for="item in 3" class="money-item">
					<view @click="selectMoney(item * 100,item)" :class="{ 'active-money' : index == item }"
						class="money">
						<view class="unit">￥</view>
						<view class="number">{{ item * 100 }}</view>
					</view>
				</view>
			</view>

			<view class="sumit">提交订单</view>
		</view>

		<!-- <test></test> -->
	</view>
</template>

<script setup>
	import {
		onShow
	} from "@dcloudio/uni-app"
	import {
		reactive,
		ref
	} from "vue";
	import test from '../../component/test.vue'

	const form = reactive({
		money: ''
	})
	const index = ref(0)

	//生命周期
	onShow(() => {
		if (wx.onNeedPrivacyAuthorization) {
			console.log('onNeedPrivacyAuthorization');
			wx.onNeedPrivacyAuthorization(resolve => {
				console.log('onNeedPrivacyAuthorization');
				// 需要用户同意隐私授权时
				// 弹出开发者自定义的隐私授权弹窗
				// this.resolvePrivacyAuthorization = resolve
				// showPrivacy.init(resolve)
			})
		}
	})

	//用户选择加油金额
	function selectMoney(money, item) {
		form.money = money
		index.value = item
	}

	//输入框获得焦点
	function focus() {

	}
</script>

<style scoped>
	.payment {
		height: 100vh;
		background: #F1F5F8;
		width: 750rpx;
		margin: 0 auto;
	}

	.container {
		width: 96%;
		margin: 0rpx auto;
		border-radius: 20rpx;
		box-sizing: border-box;
		padding: 20rpx;
		overflow: hidden;
		background: white;
		margin-top: 20rpx;
	}

	.money-input {
		display: flex;
		align-items: center;
		background: #F6F7FB;
		padding: 30rpx 10rpx;
		border-radius: 20rpx;
	}

	.tip {
		color: #00aaff;
		margin-top: 10rpx;
	}

	.money-input image {
		width: 45rpx;
	}

	.money-input input {
		font-size: 36rpx;
	}

	.select-money {
		display: flex;
		justify-content: space-between;
		flex-wrap: wrap;
		margin: 30rpx 0rpx;
	}

	.select-money .money-item {
		width: 32.33%;
		background: #F1F5F8;
		border-radius: 20rpx;
		margin-bottom: 20rpx;
		overflow: hidden;
	}

	.select-money .money {
		display: flex;
		align-items: center;
		justify-content: center;
		padding: 30rpx 0rpx;
		box-sizing: border-box;
		color: #5D5C61;
	}

	.select-money .active-money {
		background: #00aaff;
		color: white;
	}

	.select-money .unit {
		font-size: 26rpx;
	}

	.select-money .number {
		font-size: 34rpx;
	}


	.sumit {
		background: #33a5fc;
		color: white;
		font-size: 36rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		height: 80rpx;
		border-radius: 20rpx;
	}
</style>