<!-- 提现 -->
<template>


	<view class="">
		<!-- #ifdef H5 -->
		<view style="color: #000000;">
			<tn-nav-bar backgroundColor="#ffffff" :bottomShadow="false">提现</tn-nav-bar>
			<view :style="{height: tobheight+'px'}"></view>
		</view>
		<!-- #endif -->


		<view class="draw-money-wrap" style="background: #f6f6f6;height: 100%;">

			<view class="head-box">
				<!-- <shopro-navbar :background="{ background: 'none' }" :backTextStyle="{ color: '#fff' }" backText="提现" backIconColor="#fff"></shopro-navbar> -->
				<!-- 可提现 -->
				<view class="wallet-num-box u-flex u-col-center u-row-between">
					<view class="">
						<view class="num-title">可提现金额（元）</view>
						<view class="wallet-num">{{enableMoney.toFixed(2)}}</view>
					</view>
					<button class="u-reset-button log-btn"
						@tap="$Router.push({ path: '/pages/user/commission/withdraw-log' })">提现记录</button>
					<!-- <button class="u-reset-button log-btn">提现记录</button> -->
				</view>
			</view>
			<!-- 提现输入卡片-->
			<view class="draw-card">
				<view class="card-title">提现金额</view>
				<view class="input-box u-flex u-col-center">
					<view calss="unit">￥</view>
					<input class="u-flex-1 u-p-l-10" type="number" @input="onWithdrawInput" v-model="money"
						:placeholder-style="placeholderStyle" placeholder="请输入提现金额" />
				</view>
				<view class="bank-box u-flex u-col-center u-row-between u-m-b-30">
					<view class="name">提现至</view>
					<view class="bank-list u-flex" v-if="selectedWithdrawType==1" @click="showWithdrawList=true">
						<view class="sel-box u-flex u-col-center">
							<image class="item-img" src="https://file.shopro.top/imgs/wallet/bank_type.png" mode="">
							</image>
							<view class="item-title u-m-l-20">银行卡</view>
						</view>
					</view>
					<view class="bank-list u-flex" v-if="selectedWithdrawType==2" @click="showWithdrawList=true">
						<view class="sel-box u-flex u-col-center">
							<image class="item-img" src="https://file.shopro.top/imgs/wallet/wx_type.png" mode="">
							</image>
							<view class="item-title u-m-l-20">微信</view>
						</view>
					</view>
					<view class="bank-list u-flex" v-if="selectedWithdrawType==3" @click="showWithdrawList=true">
						<view class="sel-box u-flex u-col-center">
							<image class="item-img" src="https://file.shopro.top/imgs/wallet/ali_type.png" mode="">
							</image>
							<view class="item-title u-m-l-20">支付宝</view>
						</view>
					</view>
				</view>
				<view class="" v-if="selectedWithdrawType==1">
					<view class="bank-box u-flex u-col-center u-row-between u-m-b-30">
						<view class="name">银行卡号：</view>
						<view class="bank-list u-flex">
							{{cardNum?cardNum:'暂无'}}
						</view>
					</view>
					<view class="bank-box u-flex u-col-center u-row-between u-m-b-30">
						<view class="name">开户行：</view>
						<view class="bank-list u-flex">
							{{bankName?bankName:'暂无'}}
						</view>
					</view>
					<view class="bank-box u-flex u-col-center u-row-between u-m-b-30">
						<view class="name">姓名：</view>
						<view class="bank-list u-flex">
							{{realname?realname:'暂无'}}
						</view>
					</view>
				</view>
				<view class="" v-if="selectedWithdrawType==2">
					<view class="bank-box u-flex u-col-center u-row-between u-m-b-30">
						<view class="name">微信二维码：</view>
						<view class="bank-list u-flex">
							<image @click="preImg(wx_qrcode_url)" v-if="wx_qrcode_url" :src="wx_qrcode_url" mode=""
								style="width:80rpx;height: 80rpx;">
							</image>
							<text v-else>暂无</text>
						</view>
					</view>
					<view class="bank-box u-flex u-col-center u-row-between u-m-b-30">
						<view class="name">姓名：</view>
						<view class="bank-list u-flex">
							{{realname?realname:'暂无'}}
						</view>
					</view>
				</view>
				<view class="" v-if="selectedWithdrawType==3">
					<view class="bank-box u-flex u-col-center u-row-between u-m-b-30">
						<view class="name">支付宝二维码：</view>
						<view class="bank-list u-flex">
							<image @click="preImg(ali_qrcode_url)" v-if="ali_qrcode_url" :src="ali_qrcode_url" mode=""
								style="width:80rpx;height: 80rpx;">
							</image>
							<text v-else>暂无</text>
						</view>
					</view>
					<view class="bank-box u-flex u-col-center u-row-between u-m-b-30">
						<view class="name">姓名：</view>
						<view class="bank-list u-flex">
							{{realname?realname:'暂无'}}
						</view>
					</view>
				</view>


				<!-- 提现信息 -->
				<view class="bank-info u-m-b-80">
					<view class="u-flex u-row-between u-col-center" v-if="withdrawType">
						<block v-if="withdrawType === 'wechat'">
							<view class="bank-info-title">
								{{ !withdrawInfo ? '暂无微信授权信息' : `${withdrawInfo.bank_name || ''}  [${withdrawInfo.card_no || ''}] ${withdrawInfo.real_name || ''}` }}
							</view>
							<button v-if="!withdrawInfo" class="u-reset-button bind-btn u-m-l-20"
								@tap="bindThirdOauth()">绑定</button>
						</block>
						<block v-else>
							<view class="bank-info-title">
								{{
								!withdrawInfo
									? `暂无${withdrawList[withdrawType].title}信息`
									: `${withdrawInfo.bank_name || ''}  [${withdrawInfo.card_no || ''}] ${withdrawInfo.real_name || ''}`
							}}
							</view>
							<button class="u-reset-button bind-btn u-m-l-20"
								@tap="toBind">{{ withdrawInfo ? '修改' : '添加' }}</button>
						</block>
					</view>
				</view>
				<button class="u-reset-button save-btn" @tap="confirmWithdraw">确认提现</button>
			</view>
			<!-- 提现说明 -->
			<view class="draw-notice">
				<view class="title">{{ruleInfo.instructions}}</view>
				<view class="draw-list">1.单次最低提现 {{minCash}} 元。</view>
				<view class="draw-list">2.单日可提现 {{dayCash}} 元。</view>
				<textarea class="draw-list" :value="withdrawTxt" name="" id="" cols="999999" rows="999999" auto-height
					disabled></textarea>


				<!-- <view class="draw-list">{{withdrawTxt}}</view> -->

				<!-- <view class="draw-list">
				2.每日最多可提现次数: {{ ruleInfo.perday_num ? ruleInfo.perday_num : '不限' }}；每日最多提现金额(元):
				{{ ruleInfo.perday_amount ? ruleInfo.perday_amount : '不限' }}；
			</view>
				<!-- <view class="draw-list">3.每笔收取提现手续费 {{ ruleInfo.extract_rate }}%；</view> -->
				<!-- <view class="draw-list">2.提现结果请查收对应渠道服务通知。</view>
				<view class="draw-list">3.如有疑问请及时联系客服。</view> -->
				<!-- <view class="draw-list">4.一级分佣比例为{{ruleInfo.first}}%。</view>
				<view class="draw-list">4.一级分佣比例为{{ruleInfo.first}}%。</view>
				<view class="draw-list">5.二级分佣比例为{{ruleInfo.second}}%。</view> -->
				<!-- <view class="draw-list">6.三级分佣比例为{{ruleInfo.third}}%。</view> -->
			</view>
			<!-- 提现方式 -->
			<u-popup :show="showWithdrawList" @close="showWithdrawList=false" mode="bottom" safe-area-inset-bottom
				:closeable="true" border-radius="30">
				<view class="page_box withdraw-modal">
					<view class="modal-head u-flex u-row-center u-col-center">选择提现方式</view>
					<view class="content_box modal-content">
						<u-radio-group v-model="selectedWithdrawType" activeColor="#A36FFF" wrap
							v-for="(item, index) in withdrawList" :key="index">
							<view class="type-item"
								style="display: flex;align-items: center;justify-content: space-between;">
								<view class="" style="display: flex;align-items: center; ">
									<u-radio shape="circle" iconSize="30" :name="item.type" labelWidth="100%">
									</u-radio>
									<view class="item-left u-flex u-col-center u-m-l-30">
										<image class="item-img" :src="item.icon" mode=""></image>
										<view class="item-title u-m-l-20">{{item.title}}</view>
									</view>
								</view>

								<view class="" style="color: rgb(163, 111, 255);width: 100rpx;"
									@click="updateWithDrawInfo(index+1)">
									修改
								</view>
							</view>
						</u-radio-group>
					</view>
					<view class="modal-bottom"><button class="u-reset-button modal-save-btn"
							@tap="onSaveWithdrawType">确定</button></view>
				</view>
			</u-popup>
			<u-popup :show="showBindForm" @close="showBindForm = false" :round="10">
				<view class="carmimodal">
					<view class="carmiclose" @click="showBindForm = false"><u-icon name="close-circle-fill" color="#fff"
							size="22"></u-icon></view>

					<view class="carmititle">添加提现信息</view>
					<view class="" v-if="selectedWithdrawType==1">
						<view class="carmiinput"><u--input placeholder="请输入您的银行卡号" border="surround" clearable
								v-model="cardNum"></u--input></view>
						<view class="carmiinput"><u--input placeholder="请输入银行卡开户行" border="surround" clearable
								v-model="bankName"></u--input></view>
					</view>

					<view class="">
						<view class="kf_qrcode tn-flex justify-center" v-if="selectedWithdrawType==2">
							<u--image :showLoading="true" :src="wx_qrcode_url" width="100px" height="100px"
								@click="clickuimage()"></u--image>
						</view>
						<view class="kf_qrcode tn-flex justify-center" v-if="selectedWithdrawType==3">
							<u--image :showLoading="true" :src="ali_qrcode_url" width="100px" height="100px"
								@click="clickuimage()"></u--image>
						</view>
						<view class="u-text-center" v-if="selectedWithdrawType!=1">
							点击上传{{selectedWithdrawType==2?"微信":'支付宝'}}收款码
						</view>
					</view>
					<view class="carmiinput"><u--input placeholder="请输入您的真实姓名" border="surround" clearable
							v-model="realname"></u--input></view>
					<view @click="exchange" class="carmiexchange">立即保存</view>

				</view>
			</u-popup>
			<!-- 绑定修改银行信息 -->


			<!-- modal -->
			<u-modal ref="uModal" v-model="showModal" :show-cancel-button="true" confirm-color="#7063D2"
				cancel-color="#666666" @confirm="$Router.push('/pages/user/wallet/withdraw-log')" confirm-text="查看记录"
				cancel-text="继续提现" content="您的申请提现已提交" title="申请成功"></u-modal>
		</view>
		<wike-loading-page :isLoading="isLoading"></wike-loading-page>
	</view>
</template>

<script>
	import {
		mapState,
		mapActions,
		mapGetters
	} from 'vuex';
	import {
		apiurl
	} from '@/common/request/request';

	import {
		sysParms,
		applyWithdraw,
		withDrawInfo,
		saveWithDrawInfo
	} from '@/api/my/index.js'
	// import FormValidate from '@/shopro/validate/form';
	// import wechat from '@/shopro/wechat/wechat';

	import {
		taskCount,
		recommendCount,
		userInfo

	} from '@/api/my/index.js'
	export default {

		data() {
			return {
				// isLoading:true,
				isLoading: false,
				tobheight: 45,
				platform: this.$platform.get(),
				showModal: false,
				money: '', //提现金额
				ruleInfo: {}, //提现规则
				formTitle: '',
				withdrawType: '',


				showBindForm: false,
				selectedWithdrawType: 2,
				withdrawInfo: {}, //提现信息
				showWithdrawList: false,

				withdrawList: [],
				// 表单样式
				errorType: ['message'],
				labelStyle: {
					'font-size': '30rpx',
					'font-weight': '500',
					color: '#333'
				},
				placeholderStyle: 'font-size: 30rpx; font-weight: 500;color:#C2C7CF;',
				form: {
					data: {
						real_name: '',
						bank_name: '',
						card_no: ''
					},
					// bankRules: {
					// 	real_name: FormValidate.realName,
					// 	bank_name: FormValidate.bankName,
					// 	card_no: FormValidate.bankCode
					// },
					// alipayRules: {
					// 	real_name: FormValidate.realName,
					// 	card_no: FormValidate.alipayAccount
					// }
				},
				okmoney: 0.00,
				extract_min_price: 0,
				extract_rate: 0,
				paymentcode: '',
				paymentcodeid: '',
				realname: '',
				qrcode_wechat: '',


				withdrawTxt: "",
				withDrawWay: -1,

				enableMoney: 0,
				withDrawType: 1,

				minCash: 0,
				dayCash: 0,
				methods: [],
				cardNum: '',
				bankName: '',

				withDrawInfo: {},
				userInfo: {},
				wx_qrcode_url: '',
				ali_qrcode_url: ''
			};
		},
		computed: {
			// ...mapGetters(['appInfo', 'userInfo'])
		},
		async onShow() {
			if (this.withDrawType == 1) {
				let ress1 = await taskCount()
				if (ress1.code == 0) {
					console.log('提现-任务佣金汇总返回值', ress1);
					this.enableMoney = Number(ress1.data.cashing)
					console.log('任务-可提现金额', this.enableMoney);
				}
			} else {
				let ress2 = await recommendCount()
				if (ress2.code == 0) {
					console.log('提现-推广佣金汇总返回值', ress2);
					this.enableMoney = Number(ress2.data.cashing)
					console.log('推广-可提现金额', this.enableMoney);
				}
			}

			let res66 = await userInfo()
			if (res66.code == 0) {
				this.userInfo = res66.data

				this.bankName = this.userInfo.bank_name
				this.cardNum = this.userInfo.card_num
				this.realname = this.userInfo.real_name

				this.wx_qrcode_url = this.userInfo.wx_qrcode_url
				this.ali_qrcode_url = this.userInfo.ali_qrcode_url

				console.log('提现-用户个人信息', this.userInfo);
			}
		},
		async onLoad(o) {
			// let ress6 = await withDrawInfo()

			// if (ress6.code == 0) {
			// 	console.log('用户保存的提现信息', ress6);
			// 	this.withDrawInfo = ress6.data
			// }



			this.withDrawType = o.type

			let ress = await sysParms()
			console.log('提现页系统参数返回值', ress, ress.msg, this.$IMG_URL + '/imgs/wallet/bank_type.png');
			if (ress.code == 0) {
				this.withdrawTxt = ress.data[4].value.description

				this.minCash = ress.data[4].value.rule.min
				this.dayCash = ress.data[4].value.rule.day
				this.methods = ress.data[4].value.method

				this.selectedWithdrawType = Number(this.methods[0])


				this.methods.forEach((item, index) => {
					if (item == 2) {
						this.withdrawList.push({
							icon: 'https://file.shopro.top/imgs/wallet/wx_type.png',
							title: '微信零钱',
							value: 'wechat',
							type: 2
						})
					} else if (item == 3) {
						this.withdrawList.push({
							icon: 'https://file.shopro.top/imgs/wallet/ali_type.png',
							title: '支付宝账户',
							value: 'alipay',
							type: 3
						})
					} else if (item == 1) {

						this.withdrawList.push({
							icon: 'https://file.shopro.top/imgs/wallet/bank_type.png',
							title: '银行卡转账',
							value: 'bank',
							type: 1
						})
					}
				})
				console.log('支持的提现方式列表', this.withdrawList);
			}
		},
		methods: {
			//点击预览图片
			preImg(item) {
				uni.previewImage({
					current: item,
					urls: [item], //存放图片的数组
					loop: true,
					indicator: 'default'
				})
			},
			updateWithDrawInfo(i) {
				this.showWithdrawList = false;
				this.showBindForm = true
				this.selectedWithdrawType = i
				// if (i == 1) {
				// 	this.bankName = this.userInfo.bank_name
				// 	this.cardNum = this.userInfo.card_num
				// 	this.realname = this.userInfo.real_name
				// } else if (i == 2) {
				// 	this.realname = this.userInfo.real_name
				// 	this.paymentcode = this.userInfo.wx_qrcode_url
				// } else {
				// 	this.realname = this.userInfo.real_name
				// 	this.paymentcode = this.userInfo.ali_qrcode_url
				// }
			},



			async confirmWithdraw() {
				const that = this;
				// 类型（1.余额 2.分销）
				// 提现方式(1.银行卡 2.微信 3.支付宝)
				if (this.money.trim() == '') {
					return uni.showToast({
						title: '请输入提现金额',
						icon: 'none'
					})
				}
				if (Number(this.money.trim()) < this.minCash) {
					return uni.showToast({
						title: '最低提现金额为' + this.minCash,
						icon: 'none'
					})
				}
				if (Number(this.money.trim()) > this.enableMoney) {
					return uni.showToast({
						title: '提现金额不能大于可提现金额',
						icon: 'none'
					})
				}
				// if (this.selectedWithdrawType == 1) {
				// 	this.$u.toast('银行卡提现暂未开通');
				// 	return;
				// }
				if (this.selectedWithdrawType == 1) {
					if (!this.cardNum || !this.realname || !this.bankName) {
						this.$u.toast('请上传提现信息');
						this.showBindForm = true
						return;
					}
				} else if (this.selectedWithdrawType == 2) {
					if (!this.wx_qrcode_url || !this.realname) {
						this.$u.toast('请上传提现信息');
						this.showBindForm = true
						return;
					}
				} else {
					if (!this.ali_qrcode_url || !this.realname) {
						this.$u.toast('请上传提现信息');
						this.showBindForm = true
						return;
					}
				}
				console.log('申请提现参数', {
					type: this.withDrawType,
					method: this.selectedWithdrawType,
					amount: this.money,
					wx_qrcode_url: this.wx_qrcode_url,
					ali_qrcode_url: this.ali_qrcode_url,

					real_name: this.realname,


					card_num: this.cardNum,
					bank_name: this.bankName
				});
				let parms = {}
				if (this.selectedWithdrawType == 1) {
					parms = {
						type: this.withDrawType,
						method: this.selectedWithdrawType,
						amount: this.money,

						real_name: this.realname,
						card_num: this.cardNum,
						bank_name: this.bankName
					}
				} else if (this.selectedWithdrawType == 2) {
					parms = {
						type: this.withDrawType,
						method: this.selectedWithdrawType,
						amount: this.money,

						real_name: this.realname,
						wx_qrcode_url: this.wx_qrcode_url
					}
				} else {
					parms = {
						type: this.withDrawType,
						method: this.selectedWithdrawType,
						amount: this.money,

						real_name: this.realname,
						ali_qrcode_url: this.ali_qrcode_url
					}
				}
				let ress = await applyWithdraw(parms)
				console.log('申请提现返回值', ress, ress.msg);
				// if (ress.code == 0) {
				if (ress.code == 0) {
					uni.showToast({
						title: '提现申请成功'
					})

					this.selectedWithdrawType = Number(this.methods[0])
					this.money = ''
					this.realname = ''
					this.cardNum = ''
					this.bankName = ''
					this.paymentcode = ''
					console.log('提现参数重置后', {
						type: this.withDrawType,
						method: this.selectedWithdrawType,
						amount: this.money,

						real_name: this.realname,
						card_num: this.cardNum,
						bank_name: this.bankName,
						qrcode_url: this.paymentcode
					});
					setTimeout(() => {
						uni.navigateTo({
							url: '/pages/user/commission/withdraw-log'
						})
					}, 1500)
				} else {
					uni.showToast({
						title: ress.msg,
						icon: 'none'
					})
				}
			},



			getCheck() {
				var that = this;
				that.$http('commission.auth').then(res => {
					if (res.code == 0) {
						uni.setNavigationBarTitle({
							title: this.appInfo.site_name
						});
						that.okmoney = res.data.money
						that.qrcode_wechat = res.data.qrcode_wechat
						that.isLoading = false
					}
				})
			},
			getGroupConf() {
				var that = this;
				// that.$http('conf.getGroupConf',{group: 'system.commission_cashout'}).then(res => {
				// 	if(res.code == 0){

				// 		that.extract_min_price = res.data.extract_min_price
				// 		that.extract_rate = res.data.extract_rate
				// 	}
				// })
			},
			// 确认提现方式
			onSaveWithdrawType() {
				this.showWithdrawList = false;
			},
			async bindThirdOauth() {
				let that = this;
				wechat.bind();
				that.getWithdrawInfo();
			},
			async exchange() {
				let that = this;
				if (this.selectedWithdrawType == 1) {
					if (!that.cardNum) {
						uni.showToast({
							title: '请填写提现银行卡号',
							icon: 'none'
						})
						return;
					}

					if (!that.bankName) {
						uni.showToast({
							title: '请填写开户行',
							icon: 'none'
						})
						return;
					}
				} else if (this.selectedWithdrawType == 2) {
					if (!that.wx_qrcode_url) {
						uni.showToast({
							title: '请上传微信收款码',
							icon: 'none'
						})
						return;
					}
				} else {
					if (!that.ali_qrcode_url) {
						uni.showToast({
							title: '请上传支付宝收款码',
							icon: 'none'
						})
						return;
					}
				}

				if (!that.realname) {
					uni.showToast({
						title: '请填写您的真实姓名',
						icon: 'none'
					})
					return;
				}

				if (this.selectedWithdrawType == 1) {
					if (that.realname && that.cardNum && that.bankName) {
						that.showBindForm = false
					}
				} else if (this.selectedWithdrawType == 2) {
					if (that.realname && that.wx_qrcode_url) {
						that.showBindForm = false
					}
				} else {
					if (that.realname && that.ali_qrcode_url) {
						that.showBindForm = false
					}
				}
				this.confirmWithdraw()
				return
			},
			//上传收款码
			clickuimage() {
				var that = this;
				uni.chooseImage({
					count: 1, //默认9
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album', 'camera'], //从相册选择
					success: function(res) {
						uni.showLoading({
							title: '上传中...'
						})
						const tempFilePaths = res.tempFilePaths;
						//上传服务器将服务器;
						uni.uploadFile({
							url: 'http://t20.9026.com/api/common/upload',
							filePath: tempFilePaths[0],
							name: 'file',
							formData: {
								accept: 'image'
							},
							success: res2 => {
								uni.hideLoading();
								let a = JSON.parse(res2.data);
								if (a.code == 0) {
									if (that.selectedWithdrawType == 2) {
										that.wx_qrcode_url = a.data.url
									} else {
										that.ali_qrcode_url = a.data.url
									}
									// that.paymentcodeid = a.data.id
								} else {
									uni.showToast({
										title: '上传收款码失败',
										icon: 'none'
									})

								}
							}
						});
					}
				});
			},
			// 提现检验
			onWithdrawInput(e) {
				let sVal = String(e.detail.value);
				sVal = sVal.replace(/\b(0+)/gi, '');
				sVal = sVal.replace(/[^\d]/g, '');
				this.money = sVal;
			},
			// 提现
			withdraw() {
				const that = this;
				if (!this.qrcode_wechat) {
					this.$u.toast('请上传提现信息');
					this.showBindForm = true
					return;
				}

				// console.log(that.money,that.ruleInfo.extract_min_price,that.okmoney);

				// if (that.okmoney == 0 && that.money > that.okmoney) {
				// 	that.$u.toast('金额不足');
				// 	return;
				// }
				console.log(Number(that.money), Number(that.ruleInfo.extract_min_price), Number(that.okmoney));
				if (Number(that.money) <= 0) {
					that.$u.toast('请输入提现金额');
					return;
				}
				if (Number(that.okmoney) == 0) {
					that.$u.toast('金额不足');
					return;
				}
				if (Number(that.okmoney) > 0 && Number(that.money) > Number(that.okmoney)) {
					that.$u.toast('金额不足');
					return;
				}


				if (Number(that.money) < Number(that.ruleInfo.extract_min_price)) {
					that.$u.toast('最低提现金额' + that.ruleInfo.extract_min_price + '元');
					return;
				}
				that.$http(
					'commission.extract', {
						// type: that.withdrawType,
						extract_price: that.money
					},
					'申请中...',
					false
				).then(res => {
					if (res.code === 0) {
						// that.$u.toast(res.msg);
						that.money = '';
						// uni.showToast({
						// 	title:'提现成功'
						// })
						uni.showModal({
							confirmText: '继续提现',
							confirmColor: '#5e49c3',
							content: '提现成功',
							title: '提示',
							success(res) {

							}
						})
						that.getCheck()


					} else {
						that.money = '';
						// that.showModal = true;
						//  #ifdef MP-WEIXIN
						// this.$store.commit('subscribeMessage', 'wallet');
						//  #endif
						uni.showToast({
							title: '提现失败',
							icon: 'none'
						})

					}
				});
			},
			initForm() {
				this.form.data = {
					real_name: '',
					bank_name: '',
					card_no: ''
				};
			},

			// 绑定,修改
			toBind() {
				this.showBindForm = true;
				this.form.data = {
					...this.form.data,
					...this.withdrawInfo
				};
				switch (this.withdrawType) {
					case 'bank':
						this.formTitle = this.withdrawInfo ? '修改银行卡' : '添加银行卡';
						this.$nextTick(() => {
							this.$refs.bank.setRules(this.form.bankRules);
						});
						break;
					case 'alipay':
						this.formTitle = this.withdrawInfo ? '修改支付宝' : '添加支付宝';
						this.$nextTick(() => {
							this.$refs.alipay.setRules(this.form.alipayRules);
						});
						break;
					default:
						break;
				}
			},
			// 确认提交表单
			saveForm() {
				let that = this;
				this.$refs[this.withdrawType].validate().then(res => {
					if (res) {
						that.$http(
							'money.bankEdit', {
								type: that.withdrawType,
								...that.form.data
							},
							'提交中...'
						).then(res => {
							if (res.code === 1) {
								that.showBindForm = false;
								that.$u.toast(res.msg);
								that.initForm();
								that.getWithdrawInfo();
							}
						});
					}
				});
			},
			// 提现规则
			getWithdrawRules() {
				let that = this;
				that.$http('conf.getGroupConf', {
					group: 'system.commission'
				}).then(res => {
					if (res.code === 0) {
						that.ruleInfo = res.data;
						// that.selectedWithdrawType = that.ruleInfo.methods[0];
					}
				});
			},
			// 获取提现信息
			getWithdrawInfo() {
				let that = this;
				that.$http(
					'money.bankInfo', {
						type: that.withdrawType
					},
					'',
					false
				).then(res => {
					that.withdrawInfo = res.code === 1 ? res.data : null;
				});
			}
		}
	};
</script>

<style lang="scss">
	textarea {
		width: 100%;
	}

	.head-box {
		background: url('http://file.shopro.top/imgs/user/draw_money_head_bg.png') no-repeat;
		background-size: 100% auto;
		min-height: 400rpx;
		padding-bottom: var(--status-bar-height);

		// 可提现
		.wallet-num-box {
			padding: 20rpx 40rpx 0;

			.num-title {
				font-size: 26rpx;
				font-weight: 500;
				color: #ffffff;
				margin-bottom: 20rpx;
			}

			.wallet-num {
				font-size: 60rpx;
				font-weight: 500;
				color: #ffffff;
			}

			.log-btn {
				width: 170rpx;
				height: 60rpx;
				line-height: 60rpx;
				background: rgba(255, 255, 255, 0.1);
				border: 1rpx solid #eeeeee;
				border-radius: 30rpx;
				padding: 0;
				font-size: 26rpx;
				font-weight: 500;
				color: #ffffff;
				margin-right: 0;
			}
		}
	}

	// 提现输入卡片
	.draw-card {
		background-color: #fff;
		border-radius: 20rpx;
		width: 690rpx;
		min-height: 530rpx;
		margin: -70rpx auto 0;
		padding: 30rpx;

		.card-title {
			font-size: 30rpx;
			font-weight: 500;
			color: #333333;
			margin-bottom: 30rpx;
		}

		.input-box {
			width: 624rpx;
			border-bottom: 1rpx solid #eee;
			height: 100rpx;
			margin-bottom: 40rpx;

			.unit {
				font-size: 48rpx;
				color: #333;
			}
		}

		.bank-box {
			.name {
				font-size: 28rpx;
				font-weight: 500;
				color: #333333;
			}

			.bank-list {
				.empty-text {
					font-size: 28rpx;
					font-weight: 400;
					color: #999999;
				}

				.sel-box {
					.item-img {
						width: 36rpx;
						height: 36rpx;
					}

					.item-title {
						font-size: 28rpx;
						color: #333333;
					}
				}
			}
		}

		.bank-info {
			height: 50rpx;
			font-size: 28rpx;
			font-weight: 400;
			color: #999999;

			.bank-info-title {
				width: 500rpx;
			}

			.bind-btn {
				padding: 0 20rpx;
				line-height: 50rpx;
				background: #f5f6f8;
				border-radius: 20rpx;
				color: #999;
			}
		}

		.save-btn {
			width: 616rpx;
			height: 86rpx;
			line-height: 86rpx;
			background: linear-gradient(-90deg, #a36fff, #5336ff);
			box-shadow: 0px 7rpx 11rpx 2rpx rgba(124, 103, 214, 0.34);
			border-radius: 43rpx;
			font-size: 30rpx;
			font-weight: 500;
			color: #ffffff;
		}
	}

	// 提现说明
	.draw-notice {
		width: 684rpx;
		min-height: 327rpx;
		background: #ffffff;
		border-radius: 20rpx;
		padding: 30rpx 35rpx;
		margin: 20rpx auto;

		.title {
			font-size: 30rpx;
			font-weight: 500;
			color: #333333;
			margin-bottom: 30rpx;
		}

		.draw-list {
			font-size: 24rpx;
			font-weight: 400;
			color: #999999;
			margin-bottom: 10rpx;
		}
	}

	// 提现费方式
	.withdraw-modal {
		min-height: 600rpx;
		background-color: #fff;

		.modal-head {
			height: 80rpx;
			font-size: 30rpx;
			font-weight: 600;
			color: #333333;
			border-bottom: 1rpx solid rgba(#dfdfdf, 0.5);
		}

		.modal-content {
			// display: flex;
			// flex-direction: column;
			// padding-left: 50rpx;

			.type-item {
				height: 100rpx;
				border-bottom: 1rpx solid rgba(#dfdfdf, 0.5);
				width: 750rpx;
				display: flex;
				align-items: center;
				padding-left: 50rpx;

				.item-img {
					width: 36rpx;
					height: 36rpx;
				}

				.item-title {
					font-size: 28rpx;
					color: #333333;
				}
			}
		}

		.modal-bottom {
			padding: 30rpx;

			.modal-save-btn {
				width: 690rpx;
				height: 80rpx;
				line-height: 80rpx;
				background: linear-gradient(90deg, #a36fff, #5336ff);
				box-shadow: 0 7rpx 11rpx 2rpx rgba(124, 103, 214, 0.34);
				border-radius: 40rpx;
				font-weight: 500;
				color: #ffffff;
			}
		}
	}

	// 绑定
	.form-box {
		.head-title {
			height: 100rpx;
			font-size: 34rpx;
			font-weight: 600;
		}

		.form-save-btn {
			width: 340rpx;
			height: 80rpx;
			line-height: 80rpx;
			background: linear-gradient(90deg, #a36fff, #5336ff);
			box-shadow: 0 7rpx 11rpx 2rpx rgba(124, 103, 214, 0.34);
			border-radius: 40rpx;
			font-weight: 500;
			color: #ffffff;
		}

		.form-cancel-btn {
			width: 340rpx;
			height: 80rpx;
			line-height: 80rpx;
			border: 1rpx solid #999;
			border-radius: 40rpx;
			font-weight: 500;
			color: #999;
		}
	}

	.carmimodal {
		// width: 600rpx;
		border-radius: 20rpx;
		position: relative;

		.carmiclose {
			position: absolute;
			right: 15rpx;
			top: 15rpx;
		}

		.carmititle {
			background: linear-gradient(-90deg, #a36fff, #5336ff);
			color: #fff;
			height: 120rpx;
			line-height: 120rpx;
			font-size: 32rpx;
			font-weight: bold;
			text-align: center;
			border-radius: 20rpx 20rpx 0 0;
			margin-bottom: 60rpx;
		}

		.carmiinput {
			margin: 30rpx;
		}

		.carmiexchange {
			margin: 80rpx 30rpx 90rpx 30rpx;
			background: linear-gradient(-90deg, #a36fff, #5336ff);
			color: #fff;
			border-radius: 80rpx;
			height: 80rpx;
			line-height: 80rpx;
			text-align: center;
		}

		.kf_qrcode {
			// margin-left: 200rpx;
			margin-bottom: 30rpx;
		}
	}
</style>