<template>
	<view class="site">
		<view class="site-bd">
			<view class="item">
				<view class="a">提现至</view>
				<view class="b">
					<image src="https://www.lijkj.cn/static/icon-card.png"></image>
					银行卡
				</view>
			</view>
		</view>
		<view class="site-bd">
			<view class="item">
				<view class="a">持卡人</view>
				<view class="b">
					<input v-model="cardname" type="text" placeholder="请输入持卡人姓名" />
				</view>
			</view>
			<view class="item">
				<view class="a">卡号</view>
				<view class="b">
					<input v-model="cardno" type="text" placeholder="请填写卡号" />
				</view>
			</view>
			<view class="item">
				<view class="a">支行信息</view>
				<view class="b">
					<input v-model="address" type="text" placeholder="请输入支行信息" />
				</view>
			</view>
			<view class="item">
				<view class="a">提现</view>
				<view class="b">
					<input v-model="money" type="text" placeholder="最低提现金额0" />
				</view>
			</view>
			<view class="items">
				当前可提现金额：<text>￥{{userInfo.money}}</text>
			</view>
		</view>
		<view class="site-bd">
			<view class="title">提现说明</view>
			<view class="desc">
				<text>1、单次最低提现100元，最高提现1000元；\n2、每日最多可提现次数：不限；每日最多提现金额(元)：不限\n3、每笔收取提现手续 3%；\n4、提现结果请查收对应渠道服务通知；\n5、如有疑问请及时联系客服。</text>
			</view>
		</view>
		<view class="btn" @click="toSubmit()">提现</view>
		<view class="history" @click="openPage()">提现记录</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userInfo: {},
				cardname: "",
				cardno: "",
				address: "",
				money: ""
			};
		},
		onShow() {
			this.getUserInfo();
		},
		methods: {
			//获取用户信息
			async getUserInfo() {
				const { code, data , msg } = await this.$api.getMemberInfo({token: uni.getStorageSync("token")});
				if(code == 1){
					this.userInfo = data.user;
				}else{
					uni.showToast({
						title: msg,
						icon: "none",
					})
				}
			},
			openPage() {
				uni.navigateTo({
					url: "/pages/user/verificationList"
				})
			},
			async toSubmit() {
				if (!this.cardname) {
					uni.showToast({
						title: '请输入持卡人姓名',
						icon: 'none',
					})
					return
				}
				if (!this.cardno) {
					uni.showToast({
						title: '请填写卡号',
						icon: 'none',
					})
					return
				}
				
				if (!this.address) {
					uni.showToast({
						title: '请输入支行信息',
						icon: 'none',
					})
					return
				}
				if (!this.money) {
					uni.showToast({
						title: '请输入提现金额',
						icon: 'none',
					})
					return
				}
				if (this.money<=0) {
					uni.showToast({
						title: '最低提现金额0',
						icon: 'none',
					})
					return
				}
				const { code, data, message } = await this.$api.settixianmomey({
					token: uni.getStorageSync("token"),
					type: 1,
					cardname: this.cardname,
					cardno: this.cardno,
					address: this.address,
					money: this.money
				});
				if(code == 1){
					uni.showToast({
						title: "提交成功"
					})
					setTimeout(()=>{
						this.openPage();
					},1000)
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
.site{
	padding: 0 25rpx 25rpx;
	overflow: hidden;
	.btn{
		width: 702rpx;
		line-height: 90rpx;
		background: #00C6A9;
		box-shadow: 0px 3rpx 10rpx 0px rgba(9,44,39,0.05);
		border-radius: 90rpx;
		text-align: center;
		font-weight: 500;
		font-size: 30rpx;
		color: #FFFFFF;
		margin: 0 auto;
		margin-top: 120rpx;
	}
	.history{
		text-align: center;
		font-weight: 500;
		font-size: 30rpx;
		margin-top: 40rpx;
		color: #00C6A9;
	}
	&-bd{
		width: 100%;
		background: #FFFFFF;
		box-shadow: 0px 3rpx 10rpx 0px rgba(9,44,39,0.05);
		border-radius: 20rpx;
		margin: 0 auto;
		padding: 0 30rpx;
		box-sizing: border-box;
		position: relative;
		margin-top: 20rpx;
		.title{
			padding: 35rpx 0;
			font-weight: 400;
			font-size: 30rpx;
			color: #09090B;
		}
		.desc{
			font-weight: 400;
			font-size: 24rpx;
			color: #999999;
			line-height: 42rpx;
			padding-bottom: 30rpx;
		}
		.items{
			display: flex;
			align-items: center;
			border-top: 1px solid #EAEAEA;
			padding: 35rpx 0;
			overflow: hidden;
			position: relative;
			font-weight: 500;
			font-size: 30rpx;
			color: #999999;
			text{
				color: #D80C0C;
			}
		}
		.item{
			display: flex;
			align-items: center;
			justify-content: space-between;
			border-top: 1px solid #EAEAEA;
			padding: 35rpx 0;
			overflow: hidden;
			position: relative;
			&:first-child{
				border-color: #FFFFFF;
			}
			.a{
				width: 160rpx;
				display: flex;
				align-items: center;
				font-weight: 500;
				font-size: 30rpx;
				color: #222222;
			}
			.b{
				flex: 1;
				display: flex;
				align-items: center;
				font-weight: 500;
				font-size: 30rpx;
				color: #333333;
				input{
					flex: 1;
					font-weight: 500;
					font-size: 30rpx;
					color: #999999;
				}
				image{
					width: 42rpx;
					height: 28rpx;
					margin-right: 20rpx;
				}
			}
		}
	}
}
</style>