<template>
	<view class="wrapper">
		<image :src="`${$imgUrl}common/reharge-success.png`" class="pic-status" mode="widthFix"></image>
		<view class="sub-text"><text>圈存前余额：</text><text>￥{{state.preBalance/100}}</text></view>
		<view class="sub-text"><text>圈存金额：</text><text>￥{{state.rechargeAmount/100}}</text></view>
		<view class="sub-text"><text>圈存后余额：</text><text>￥{{state.afterMoney/100}}</text></view>
		<view class="btn btn-primary" @click="view">返回查看</view>
	</view>
</template>

<script lang="ts" setup>
	import { reactive } from "vue";
	import {
		rechargeMoneyApi
	} from "@/utils/network/api.js";
	import {
		onLoad
	} from "@dcloudio/uni-app";
	import {
		request
	} from "@/utils/network/request.js";
	import {
		stringToJson
	} from "@/utils/network/encryption.js";
	const state = reactive({
		cardId: "",
		preBalance: 0,  //充值前余额
		rechargeAmount: 0,//充值金额
		afterMoney: 0  //充值后金额
	})
	onLoad((option) => {
		state.cardId = option.cardId
		money()
	})
	const money = () => {
		const options = {
			type: 2,
			data: {
				"cardId": state.cardId,
			},
			method: 'POST',
			showLoading: true,
		}
		request(rechargeMoneyApi, options).then((res) => {
			const data = stringToJson(res.bizContent);
			state.preBalance = data.preBalance
			state.rechargeAmount = data.rechargeAmount
			state.afterMoney = Number(data.rechargeAmount) + Number(data.preBalance)
			console.log("圈存金额查询2", data)
		})
	}
	const view = () => {
		uni.navigateBack()
	}
</script>

<style>
	.wrapper {
		display: flex;
		flex-direction: column;
		justify-content: center;
	}

	.text-result {
		font-size: 36rpx;
		color: #333;
		font-weight: 400;
	}

	.sub-text {
		font-size: 30rpx;
		font-weight: 400;
		color: black;
		padding-top: 40rpx;
		margin-left: 250rpx;
	}

	.sub-text>text:first-child {
		width: 36%;
		display: inline-block;
	}

	.pic-status {
		width: 690rpx;
		height: 300rpx;
		margin: 98rpx 30rpx 25rpx;
	}

	.btn-primary {
		width: 670rpx;
		height: 80rpx;
		line-height: 80rpx;
		background: linear-gradient(-90deg, #43A1E0 0%, #13E7C1 100%);
		border-radius: 40rpx;
		font-size: 32rpx;
		color: #ffffff;
		margin: 300rpx 40rpx 0;
		text-align: center;
	}
</style>