<template>
	<view class="content">
		<view class="tx-wrap">
			<view class="tx-tit">
				提现股权至提成
			</view>
			<input type="digit" v-model="txnum" placeholder="请输入提现股权" class="tx-inp" placeholder-class="tx-inp-p">
			<view class="gq-detail">
				<view class="">
					可提现： {{userInfo.use_stock }}（股权）
				</view>
				<view class="right" @click="txnum = userInfo.use_stock">
					全部提现
				</view>
			</view>
			<view class="tx-btn" @click="gqtx">
				提现
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				txnum: '',
				userInfo:{},
				txloading: 'loading',
			}
		},
		onLoad() {

		},
		onShow() {
			this.getCustomerInfo()
		},
		onReachBottom() {

		},
		onReady() {

		},
		methods: {
			gqtx() {
				let that = this
				if(this.txloading == 'loading') {
					return
				}
				if(this.txnum == '') {
					return this.$u.toast('请输入提现股权') 
				}
				if(this.txnum == 0) {
					return this.$u.toast('提现股权不能为零') 
				}
				if(this.txnum*1 > this.userInfo.use_stock*1) {
					return this.$u.toast('股权不足') 
				}
				this.txloading = 'loading'
				this.$u.api.txGq({
					number: this.txnum
				}).then(({data})=> {
					// uni.showToast({
					// 	title:'提现成功',
					// 	icon: 'success',
					// 	duration: 2000
					// }) 
					// this.getCustomerInfo()
					this.$u.toast('提现成功') 
					setTimeout(()=> {
						that.getCustomerInfo()
					},1500)
				}).catch(err => {
					this.txloading = 'no'
				})
			},
			getCustomerInfo() {
				this.$u.api.getYgdetail({
					request_id: this.$store.state.userInfo.staffId
				}).then(({
					data
				}) => {
					this.userInfo = data
					if(!this.userInfo.use_stock) {
						this.userInfo.use_stock = 0
					}
					this.txloading = 'no'
				})
			},
		}
	}
</script>

<style lang="scss">
	.content {
		padding-top: 1rpx;
	}

	.tx-wrap {
		width: 700rpx;
		// height: 420rpx;
		padding: 20rpx 0 50rpx 0;
		margin: 19rpx auto;
		background-color: #fff;
		border-radius: 20rpx;

		// display: flex;
		// flex-direction: color;
		.tx-tit {
			margin: auto;
			width: 660rpx;
			font-size: 32rpx;
			color: #333;
			font-weight: bold;
			border-bottom: 1px solid #eee;
			line-height: 87rpx;
		}

		.tx-inp {
			display: block;
			width: 660rpx;
			height: 114rpx;
			font-size: 56rpx;
			font-weight: bold;
			color: #000;
			// padding-left: 20rpx;
			border-bottom: 1rpx solid #eee;
			margin: auto;
		}

		.tx-inp-p {
			font-size: 36rpx;
		}

		.gq-detail {
			display: flex;
			justify-content: space-between;
			padding: 20rpx;
			font-size: 28rpx;

			.left {}

			.right {
				color: #d74f3a;
			}
		}

		.tx-btn {
			width: 660rpx;
			height: 70rpx;
			line-height: 70rpx;
			background-color: #ec643e;
			color: #fff;
			font-size: 32rpx;
			text-align: center;
			margin: 30rpx auto 0;
			border-radius: 35rpx;
		}
	}
</style>
