<template>
	<view>
		<view v-if="isOnLine == '0'" style="width: 100%;height: 100%;position: absolute;top: 0;background: #fff;z-index:99;"></view>
		<uni-card title="提现">
			<view v-if="user== '13521030702'?' ':'*支付宝实名和手机号必须一致并经过实名认证'" style="color: red;font-size: 12px;"></view>
			<view class="zhifubao">
				<view class="name">{{user== '13521030702'?'账号':'支付宝手机号'}}:</view>
				<view class="zfb-data">
					<input type="number" v-model='zfbAccount' placeholder="请输入手机号">
				</view>
			</view> 
			<view class="zhifubao">
				<view class="name">{{user== '13521030702'?'昵称':'支付宝实名'}}:</view>
				<view class="zfb-data">
					<input type="text" v-model='zfbName' placeholder="请输入认证过的实名">
				</view>
			</view>
			<view class="zhifubao">
				<view class="name">提现金额:</view>
				<view class="zfb-data">
					<input type="digit" v-model="realBalance" placeholder="请输入提现金额">
				</view>
			</view>
			<view class="yue-box">
				<view class="yue">
					可提现余额:
					<text>{{canbalance == "null"?'0':canbalance}}</text>	
				</view>
				<view class="quanbu" @click="onQuanbuClick">
					全部提现
				</view>
			</view>
			<view>
				<u-button type="primary" shape="circle" :disabled="isClick" @click="onSubmit">提现</u-button>
			</view>
		</uni-card>
	</view>
</template>
<script>
	export default {
		name: "withdrawal",
		data() {
			return {
				balance: 0,
				canbalance:'',
				zfbAccount: '',
				zfbName: '',
				realBalance:'',
				shopId:'',
				isClick:false,
				user:'',
				isOnLine:'0'
			}
		},
		created(){
			this.user = uni.getStorageSync('username')
			this.getArea();
		},
		onLoad(options) {
			this.canbalance = options.balance
			this.shopId = uni.getStorageSync('shopId')
			
		},
		methods: {
			getArea(){
				this.tui.request('/app/operatingArea/getByArea', "post", {
					province:'',
					city:'',
					area:'',
					shippingType:0,
					seachParams:"测试"
				}, false, true).then((res) => {
					this.status = 'nomore';
					if (res.code == 200) {
						this.isOnLine = res.result.operatingAreaList[0].isOnLine
						if(res.result.operatingAreaList[0].isOnLine == '0'){
							uni.setNavigationBarTitle({
								title: '测试页面'
							});
						}
					}else{
						this.tui.toast(res.message)
					}
				})
			},
			onQuanbuClick() {
				this.realBalance = this.canbalance
			},
			onSubmit() {
				if(this.user == '13521030702'){
					this.tui.toast("测试账户不能提现！")
					return
				}
				this.isClick = true;
				if(Number(this.realBalance) > Number(this.canbalance)){
					this.tui.toast("提现金额不能大于账户余额！")
					return
				}else if(this.realBalance =='' || this.zfbName =='' || this.zfbAccount ==''){
					this.tui.toast("信息填写完整后再进行操作！")
					return
				}else if(this.realBalance < 0.1){
					this.tui.toast("提现金额不能小于0.1元")
					return
				}
				this.tui.request('/app/returnCommission/handleReturn', 'post', {
					commission:this.realBalance,
					shopId:this.shopId,
					aliName:this.zfbName,
					aliAccount:this.zfbAccount
				}, false, false, true).then((res) => {
					
					if (res.code == 200){
						this.tui.toast(res.message)
						setTimeout(() => {
							uni.reLaunch({
								url: `/pages/rebate/rebate`
							})
						}, 2000)
					}else{
						this.tui.toast(res.message)
						setTimeout(() => {
							this.isClick = false;
							// uni.reLaunch({
							// 	url: `/pages/rebate/rebate`
							// })
						}, 2000)
					}
					
				})
			}
		}
	}
</script>


<style scoped lang="scss">
	.zhifubao {
		display: flex;
		justify-content: space-between;
		margin: 30rpx 0;
		height: 80rpx;
		line-height: 80rpx;
	}
	.zhifubao input{
		height: 80rpx;
		line-height: 80rpx;
		border: 1px solid #eee;
	}
	.input-flex {
		display: flex;
		margin: 50upx 0;
	}

	.yue-box {
		display: flex;
		font-size: 24upx;

		.yue {
			color: #c26f59;
			margin: 0 20rpx 50rpx 220rpx;
		}

		.quanbu {
			color: #657284;
		}
	}
	.name{
		width: 35%;
	}
	.zfb-data{
		width: 65%;
	}
</style>