<template>
	<view class="wrap">
		<view class="lf-p-l-30 lf-p-r-30 lf-m-t-30" style="height: auto;">
			<view class="bg-white lf-h-100 lf-p-30 flex align-center" style="border-radius: 10rpx; box-sizing: border-box;">
				<view>
					<img :src="info.avatar" mode="aspectFill" style="height: 120rpx;width: 120rpx;border-radius: 50%;"></img>
				</view>
				<view class="lf-m-l-20 text-black1 lf-font-32">
					{{info.nickname}}
				</view>
				
			</view>
		</view>
		<view class="lf-p-l-30 lf-p-r-30 lf-m-t-30" style="height: auto;">
			<view class="bg-white lf-h-100 lf-p-l-30 lf-p-r-30 flex flex-direction" style="border-radius: 10rpx; box-sizing: border-box;padding-bottom: 50rpx;padding-top: 34rpx;">
				<view class="flex align-start flex-direction solid-bottom">
					<view class="text-black lf-font-28 lf-m-b-30">支付宝姓名</view>
					<input type="text" v-model="name" placeholder="请输入您的姓名" class="lf-font-28 lf-color-999">
				</view>
				<view style="margin-top: 60rpx;" class="flex align-start flex-direction solid-bottom">
					<view class="text-black lf-font-28 lf-m-b-30">支付宝账号</view>
					<input type="text" v-model="account" placeholder="请输入支付宝账号" class="lf-font-28 lf-color-999">
				</view>
			</view>	
		</view>
		
		<view class="lf-p-30" style="height: 408rpx;">
			<view class="bg-white lf-h-100" style="border-radius: 10rpx;">
				<view class="text-black lf-font-28 lf-p-l-30 lf-p-t-30">提取金额</view>
				<view class="lf-p-l-20 flex solid-bottom align-center" style="padding-top: 90rpx;">
					<text class="text-black lf-font-48 unit">￥</text>
					<!-- <u-input v-model="num" :type="type" :border="border" :height="height" :auto-height="autoHeight"/> -->
					<input type="number" v-model="num" class="lf-p-l-10 text-black1" style="width: 80%;padding-right: 30rpx;font-size: 72rpx;height: 100rpx;" />
					<view v-if="num != ''">
						<u-icon @click="clearAble()" name="close-circle" color="#999999" size="40"></u-icon>
					</view>
				</view>
				<view class="lf-font-28 lf-color-999 lf-p-t-26 lf-p-l-30" v-if="!ifshow">
					可用余额
					<text>￥{{info.income || 0}}</text>
				</view>
				<view v-else class="lf-color-price lf-font-28 lf-p-t-26 lf-p-l-30">输入金额超过可用余额</view>
			</view>
		</view>
		
		
		<view class="lf-p-l-30 lf-p-r-30 lf-p-b-30" style="height: auto;">
			<view class="bg-white lf-h-100 lf-p-30" style="border-radius: 10rpx; box-sizing: border-box;">
				<view class="text-black lf-font-28">提现说明</view>
				<view class="flex flex-direction justify-around lf-p-t-20">
					<view class="lf-font-28" style="color: #555;">
						1、提现到账时间为T+1；
					</view>
					<view class="lf-font-28" style="color: #555;">
						2、提现最高单笔金额为1000元；
					</view>
					<view class="lf-font-28" style="color: #555;">
						3、提现手续费单笔收费10%；
					</view>
				</view>
			</view>
		</view>
		
		
		<view class="lf-m-b-30">
			<view class="padding-lr-lg">
				<button class="cu-btn block bg-orange lg" style="border-radius: 42rpx;" @tap="submitWidthdraw()">
					<text class="lf-font-32 text-white">提现</text>
				</button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userInfo: '',
				info: '',
				name: '',
				account: '',
				num: ''
			}
		},
		computed: {
			ifshow() {
				if(Number(this.num) > Number(this.info.income)) {
					return true
				}else {
					return false
				}
			}
		},
		methods: {
			getData(){
				this.$http(this.API.API_USER_CENTER).then(res => {
					this.info = res.data;
					console.log(this.info)
				})
			},
			clearAble() {
				this.num = ''
				this.showClean = false
			},
			submitWidthdraw() {
				if(!this.name) {
					this.$msg('请输入支付宝姓名!')
					return
				}
				if(!this.account) {
					this.$msg('请输入支付宝账号!')
					return
				}
				if(!this.num) {
					this.$msg('请输入提现金额!')
					return
				}
				this.$http(this.API.API_WIDTHDRAW, {
					account: this.account,
					username: this.name,
					extract_price:this.num,
					channel:this.alipay,
					token: this.userInfo.token
				}).then(res => {
					console.log(res)
				})
			}
		},
		onLoad(e) {
			this.userInfo = uni.getStorageSync('userinfo') || {};
			this.getData()
		}
	}
</script>

<style>
	page{
		background-color: #F5F5F5;
	}
</style>
<style scoped>
	.wrap {
		height: 100%;
		width: 100%;
		background-color: #F5F5F5;
	}
	.unit{
		display: flex;
		height: 100rpx;
		align-items: flex-end;
		box-sizing: border-box;
		padding-bottom: 10rpx;
	}
</style>
