<template>
	<view class="">
		<view class="cash-card mlr-36 mt-20">
			<view class="size-32 pl-30 pt-22 pb-22 bb">
				提现额度
			</view>
			<view class="size-40 pl-30 pt-32 pb-32 bb">
				<input type="number" v-model="money" value="" placeholder="请输入金额" @blur="getnum"/>
			</view>
			<!-- <view v-if="userInfo.property" class="u-font-24 pl-30 pt-22 pb-22">
				可用余额{{userInfo.property.bonus}}蜜币，最小提现金额1000蜜币
			</view> -->
			<view class="size-24 pl-30 pt-22 pb-22">
				可提现余额{{price}}元
			</view>
		</view>
		<view class="plr-36 mt-50">
			提现
		</view>
		<view class="cash-ul plr-36 flex">
			<view class="cash-li mt-34 center pt-32 pb-32 border-pink">
				<image src="../../static/zfb.png" mode=""></image>
				<text class="u-m-l-20">支付宝提现</text>
			</view>
		</view>
		<view class="cash-card1 mlr-36 mt-50">
			<view class="size-32 pl-30 pt-22 pb-22 bb">
				提现账号
			</view>
			<view class="pl-30 pr-30 pt-22 pb-22 bb flex">
				<view class="u-font-26">
					支付宝账号
				</view>
				<view class="">
					<input type="text" v-model="account" value="" placeholder="请输入支付宝账号" class="u-font-26 text-right" />
				</view>
			</view>
			<view class="pl-30 pr-30 pt-22 pb-22 flex">
				<view class="u-font-26">
					真实姓名
				</view>
				<view class="">
					<input type="text" value="" v-model="name" placeholder="请输入真实姓名" class="u-font-26 text-right" />
				</view>
			</view>
		</view>
		<view class="plr-36 mt-30 size-26 gray-2">
			*单笔限额{{cash.withdraw_min}}-{{cash.withdraw_max}}元
		</view>
		<u-button @click="submit" type="primary" :disabled="!money || !account || !name" class="mlr-36 mt-80">确认提现</u-button>
		<u-modal v-model="show" :content="content" :show-title="false" @confirm="confirm"></u-modal>
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex'
	export default {
		data() {
			return {
				price:'',
				balance:'',
				money: '',
				account: '',
				name: '',
				show: false,
				content: '提现成功',
				cash:''
			}
		},
		computed: {
			...mapState(["userInfo"])
		},
		onLoad() {
			this.getmoney()
			this.init()
		},
		methods: {
			init(){//提现手续费
				this.$http('/addons/ddrive/user/cash_set',"POST").then(data=>{
					console.log(data);
					this.cash = data.cash_set
				})
			},
			// 我的收入
			getmoney() {
				this.$http('/addons/ddrive/user/userIncome', "POST").then(data => {
					console.log(data);
					this.price = data.withdraw_money
				})
			},
			getnum(e){
				if(parseFloat(e.detail.value) < this.cash.withdraw_min){
					uni.showToast({
						title:'单笔限额最小' + this.cash.withdraw_min + '元',
						icon:'none'
					})
					this.money = ''
				}else if(parseFloat(e.detail.value) > this.cash.withdraw_max){
					uni.showToast({
						title:'单笔限额最大' + this.cash.withdraw_max + '元',
						icon:'none'
					})
					this.money = ''
				}
			},
			confirm(){
				uni.navigateBack({
					
				})
			},
			submit() {
				this.$http('/addons/ddrive/money/sbCash', {
					money: this.money,
					account_number: this.account,
					payee: this.name
				}, "POST").then(data => {
					this.show = true
					this.getmoney()
				}).catch(data=>{
					
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	/deep/.u-btn {
		height: 96rpx !important;
	}

	/deep/.u-btn--primary--disabled {
		background-color: $bg-1 !important;
	}

	/deep/.u-primary-hover {
		background-color: $blue !important;
	}

	page {
		background: #F8F8F8;
	}

	.cash-card {
		background: #fff;
		border-radius: 10rpx;
		box-shadow: 0px 0px 24px 0px rgba(187, 187, 187, 0.36);
	}

	.cash-li {
		width: 48%;
		background: #fff;
		border-radius: 10rpx;
		box-shadow: 0px 0px 24px 0px rgba(187, 187, 187, 0.36);
		
		image {
			width: 55rpx;
			height: 55rpx;
			border-radius: 50%;
		}
	}

	.cash-card1 {
		background: #fff;
		border-radius: 10rpx;
		box-shadow: 0px 0px 24px 0px rgba(187, 187, 187, 0.36);
	}
</style>
