<template>
	<view class="page">
		<navbar title="充值" 
		bgColor="#A3D250"
		color="#fff"
		leftClick 
		@leftClick="$utils.navigateBack" />
		
		<view class="bg"/>
		
		<view class="price">
			<view class="title">
				请输入充值金额（元）
			</view>
			<view class="input-box">
				<view class="input">
					<input type="text" v-model="form.money"/>
				</view>
			</view>
			<view class="num">
				余额：{{ riceInfo.balance || 0 }}
			</view>
		</view>
		
		<view class="cell">
			<view class="cell-top">充值说明</view>
			<view style="padding: 0 20rpx 20rpx 20rpx;">
				<uv-parse :content="configList.recharge_instructions"></uv-parse>
			</view>
		</view>
		
		<view class="uni-color-btn"
		@click="submit">
			充值
		</view>
		
		<!-- <view class="cell">
			<view class="cell-top">提现记录</view>
			<view class="cell-box" 
			:key="index"
			v-for="(item,index) in list">
				<uv-cell-group>
					<uv-cell 
					:title="item.title" 
					:label="item.createTime" 
					:center="true">
						<template #value>
							<view class="cell-text">
								<view class="price-text">-19.9</view>
								<view class="tips">已到账</view>
							</view>
						</template>
					</uv-cell>
				</uv-cell-group>
			</view>
		</view> -->
		
	</view>
</template>

<script>
	import mixinsList from '@/mixins/list.js'
	import { mapState } from 'vuex'
	export default {
		mixins : [mixinsList],
		data() {
			return {
				// mixinsListApi : 'getWaterPageList',
				list : [],
				type : ['-', '+'],
				form : {
					money : 0,
				},
			}
		},
		computed: {
			...mapState(['userInfo', 'riceInfo']),
		},
		onShow() {
			this.$store.commit('getUserInfo')
			this.$store.commit('getRiceInfo')
		},
		methods: {
			submit(){
				
				if(this.$utils.verificationAll(this.form, {
					money : '请输入金额'
				})){
					return
				}
				
				if(this.form.money <= 0){
					uni.showToast({
						title: '输入金额必须大于0',
						icon: 'none'
					})
					return
				}
				
				this.$api('recharge', res => {
					if(res.code == 200){
						uni.showToast({
							title: '充值成功',
							icon : 'none'
						})
						this.form.money = 0
						setTimeout(uni.navigateBack, 800, -1)
					}
				})
			},
		}
	}
</script>

<style scoped lang="scss">
.page{
	.bg{
		background-color: $uni-color;
		height: 380rpx;
		position: absolute;
		left: 0;
		width: 100%;
		z-index: -1;
		border-bottom-left-radius: 30rpx;
		border-bottom-right-radius: 30rpx;
	}
	
	.price{
		color: #FFFFFF;
		padding: 40rpx;
		.title{
			color: #eee;
			font-size: 28rpx;
		}
		.input-box{
			background-color: #FFFFFF;
			color: $uni-color;
			display: flex;
			justify-content: center;
			border-radius: 30rpx;
			align-items: center;
			padding: 10rpx;
			margin: 20rpx 0;
			.input{
				color: #000;
				font-size: 40rpx;
				font-weight: 900;
				display: flex;
				flex: 1;
				input{
					flex: 1;
					padding: 14rpx 20rpx;
				}
			}
		}
		.num{
			font-size: 30rpx;
			font-weight: 900;
			margin-top: 10rpx;
		}
	}
	
	.cell {
		margin: 20rpx;
		background-color: #FFFFFF;
		border-radius: 16rpx;
	
	
		.cell-top {
			padding: 40rpx 34rpx;
			color: #474747;
			font-size: 34rpx;
			font-weight: 600;
			position: relative;
			&::after{
				content: '';
				display: block;
				position: absolute;
				left: 55rpx;
				bottom: 38rpx;
				height: 10rpx;
				width: 120rpx;
				background: linear-gradient(to right, #fff, $uni-color);
			}
		}
		.cell-text{
			text-align: right;
			.price-text{
				color: #f40;
				font-size: 32rpx;
				font-weight: 900;
			}
			.tips{
				font-size: 22rpx;
				color: #aaa;
				margin-top: 10rpx;
			}
		}
	}
}
</style>
