<template>
	<view class="tixian">
		<view class="tixian-header u-flex-col u-row-between" style="background: #fff;">
			<text>到账银行卡</text>
			<!-- <text @click="bangding">{{bankdata.bank_name ? `${bankdata.bank_name}(${bankdata.bank_no.substring(bankdata.bank_no.length - 4)})` : '请绑定银行卡'}}</text> -->
		</view>
		<view class="tixian-box" style="background: #fff;">
			<view class="box-title">
				提现金额
			</view>
			<view class="box-input u-flex u-row-between">
				<view class="u-flex">
					<text>¥</text>
					<input type="number" v-model="price" style="width: 400rpx;">
				</view>
				<view class="right">
					重新选择
				</view>
			</view>
		</view>
		<view class="tixian-btn" @click="tixian">
			确认提现
		</view>
	</view>
</template>

<script>
	import {
		withdraw,
		getBank,
		index
	} from "@/units/inquire.js"
	export default {
		data() {
			return {
				bankdata: {},
				money: '',
				price: '',

			}
		},
		onShow() {
			this.getdata()
		},
		methods: {
			tixian() {
				if (!this.price) {
					this.$u.toast("请输入提现金额")
					return
				}
				if (this.price > this.money) {
					this.$u.toast("提现金额不足")
					return
				}
				uni.showLoading({
					mask: true,
					title: "请稍后"
				})
				//发起提现
				// withdraw({

				// })
				this.$u.post('/api/hr.user/withdraw', {
					amount: this.price
				}).then(res => {
					if (res.code == 1) {
						this.$u.toast("发起提现成功")
						this.price = ''
						setTimeout(() => {
							this.getdata()
						}, 800)
					} else {
						this.$u.toast(res.msg)
					}
				})
			},
			all() {
				this.price = this.money || ''
			},
			getdata() {
				getBank().then(res => {
					this.bankdata = res.data || {}
				})
				index().then(res => {
					this.money = res.data.money || 0
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.tixian {
		height: 100vh;
		background: #F3F3F3;
		padding: 20rpx 24rpx 0 24rpx;
		box-sizing: border-box;

		.right {
			font-size: 32rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #0C66C2;
		}

		.tixian-btn {
			width: 702rpx;
			line-height: 92rpx;
			background: #0C66C2;
			border-radius: 12rpx;
			margin: 60rpx auto;
			text-align: center;
			font-size: 34rpx;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: 500;
			color: #FFFFFF;
		}

		.tixian-box {
			width: 702rpx;
			background: #FFFFFF;
			border-radius: 20rpx;
			margin: 20rpx auto;
			padding: 0 24rpx;
			box-sizing: border-box;

			.box-down {
				height: 90rpx;

				text:first-child {
					font-size: 26rpx;
					font-family: SFPro-Regular, SFPro;
					font-weight: 400;
					color: #222222;
				}

				text:last-child {
					font-size: 26rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #0C66C2;
				}
			}

			.box-input {
				height: 145rpx;
				border-bottom: 2rpx solid #F0F0F0;

				text {
					font-size: 72rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #222222;
					margin-right: 28rpx;
				}

				input {
					height: 145rpx;
					flex: 1;
					font-size: 72rpx;
				}
			}

			.box-title {
				font-size: 32rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #222222;
				padding-top: 32rpx;
			}

		}

		.tixian-header {
			width: 702rpx;
			height: 204rpx;
			background: #FFFFFF;
			border-radius: 20rpx;
			margin: 20rpx auto;
			padding: 32rpx 24rpx 42rpx 24rpx;
			box-sizing: border-box;

			text:first-child {
				font-size: 32rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #222222;
			}

			text:last-child {
				font-size: 32rpx;
				font-family: SFPro-Regular, SFPro;
				font-weight: 400;
				color: #222222;
			}
		}
	}

	page {
		background-color: #F3F3F3;
	}
</style>