<template>
	<view class="container">
		<div id="AssginBox">
			<!-- <p class="TitleHeader"></p>-->
			<p id="ReturnBox" @click="BackToMini('personalCenter')">
				<img src="../../static/img/return.png" class="returnImgBox" alt="">
				<span style="vertical-align: middle;">返回</span>
			</p>
			<!-- 充值 -->
			<div id="DepositBox">
				<div class="ImgContent">
					<img mode='widthFix'
						src="https://xiaopay2020.oss-cn-shenzhen.aliyuncs.com/static/weapp/images/xiaopaycard (31).png"
						alt="">
					<div class="contentDiv">
						<p>
							<span class="schoolNameTx"
								style="font-size:17px;font-weight:700;width: 50vw;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;"></span>
							<span class="IconCls">电子校园卡</span>
						</p>
						<p class="HidenText" style="margin-top:17vw;">
							<span style="font-size:13px;">姓名：<span class="userNameTx"></span></span>
							<span class="StudentCls" style="font-size:13px;text-align:right;display: none;">班级：<span
									class="ClsNameTx"></span></span>
							<span class='TeacherCls' style="font-size:13px;text-align:right;display: none;">教职工</span>
						</p>
						<p style="font-size:15px;color:#fff;font-weight:700;margin-top: 10px;">
							<span>余额：￥<span class="cardBalanceTx"></span></span>
							<span @click="ToWalletTx">余额提现<img class='ImgIcon1' mode='widthFix'
									src="https://xiaopay2020.oss-cn-shenzhen.aliyuncs.com/static/weapp/images/xiaopaycard (17).png"
									alt=""></span>
						</p>
					</div>
				</div>
				<div style="font-size:14px;color:#268EF8;text-decoration:underline;text-align:center;margin:10px 0;">
					<span @click="BackToMini('purchaseDetail')">账户明细</span>
				</div>
				<div class="depositBox">
					<p class="inputTitle">充值金额</p>
					<div id="MoneyBox">
						<div class="depotMoney" @click="depotMoney(500)">500</div>
						<div class="depotMoney" @click="depotMoney(1000)">1000</div>
						<div class="depotMoney" @click="depotMoney(1500)">1500</div>
					</div>
					<div>
						<span
							style="font-size:17px;font-weight:bold;position: absolute;left: 5px;bottom: -1px;">￥</span>
						<input class="depositTx" v-model="Money" type="number" @input="inputControl" @blur="ReturnToTop"
							maxlength="4" style="width:90%;" placeholder="请输入其他金额，最低3元" />
					</div>
					<p>
						<img mode='widthFix' class="depositImg" src="../../static/img/depositIcon.png" alt="">
						<span style="vertical-align:middle;font-size:14px;">最大可充值金额：<span style="color:red;">￥<span
									class="canDepositTx">{{RechargeMax}}</span></span></span>
					</p>
				</div>
				<div class="accountBox1">
					<div class="AcountTitle">付款账户</div>
					<div class="bankNameClass" @click="queryBindCardList"></div>
					<img @click="queryBindCardList" src="../../static/img/8.png" alt="">
				</div>
				<button class="bottomDetail bottom1 DisaBledBtn DepositID" style="margin-top: 400rpx;"
					@click="toDeposit(0)">充值生活费</button>
				<div class="changeCardBox">
					<span @click="BackToMini('AssignAddCard')">我要换银行卡支付</span>
				</div>
			</div>
			<!-- 提现 -->
			<div id='TxWalletBox'>
				<div class="TopBox">
					<p>提现金额</p>
					<div class="changeCardBox dayTips">每日可提现一次</div>
				</div>

				<div class="TxDiv">
					<span style="font-size:17px;font-weight:bold;position: absolute;left: 5px;bottom: -1px;">￥</span>
					<input style="width:50%;padding-right:40%;" type="number" v-model="ReflectMoney" class="TxClsTx"
						@blur="ReturnToTop" maxlength="4" placeholder="输入提现金额" @input="inputControl">
					<span style="position:absolute;right:20px;font-weight:700;font-size:14px;color:#129A5E;"
						@click="TxAllFun">全部</span>
				</div>
				<div class="accountBox1">
					<div class="AcountTitle">提现至</div>
					<div class="bankNameClass1"></div>
				</div>
				<div class="payCardEndNo"
					style="width:90vw;text-align:right;font-weight:700;font-size:15px;margin-top: 5px;"></div>
				<button class="bottomDetail bottom2" @click="toDeposit(1)">提现</button>
				<div class="changeCardBox">
					<span @click="BackToMini('TxHistory')">提现记录</span>
				</div>
			</div>

			<!-- 切换绑定的一类卡列表 -->
			<div class="BgCoverBox showBindCardList PhoneConfirmBox" style="display: none;"></div>
			<div class="BankClass showBindCardList" style="display: none;">
				<div class="choiceBox">选择付款账户</div>
				<div class="hideListCover">

				</div>
				<div class="bottomDiv" @click="HideHTML('showBindCardList',0)">取消</div>
			</div>

			<!-- 手机号验证 -->
			<div class="PhoneConfirmBox MyPhoneCls" style="display: none;">
				<img src="../../static/img/close.png" class="closePhoneBox" alt="" @click="hidePhoneBox">
				<p style='text-align:center;font-size:18px;font-weight:bold;margin-bottom:30px;'>验证开卡手机号</p>
				<p class="myPhoneP">
					<span class="title1">手机号：</span>
					<span style="flex: 1;" class="myPhoneTx"></span>
					<span class="changPhone" @click="BackToMini('AssignChangPhone')">变更手机号</span>
				</p>
				<div class="myPhoneDiv">
					<span class="title1">验证码：</span>
					<div style="flex: 1;">
						<input class="VerifyCode" v-model="VerifyCode" @blur="ReturnToTop" type="text" maxlength="6"
							placeholder="验证码" />
					</div>
					<span class="CodeMsg" @click="SendMsg">{{CodeMsg}}</span>
				</div>
				<button class="doBtnTx" @click="DoNextStep">充值</button>
			</div>
			<!-- 20210421 -->
			<div class="RechargeException" style="display: none;">
				<div class="tiptext">您在银行预留的身份信息已过期，请更新身份信息后再继续交易</div>
				<div class="weui-form">
					<div class="weui-form__control-area">
						<div class="weui-cells__group weui-cells__group_form">
							<div
								class="weui-cell weui-cell_active weui-cell_access weui-cell_select weui-cell_select-after">
								<div class="weui-cell__hd"><label class="weui-label">所属职业</label></div>
								<div class="weui-cell__bd" id="showPicker"
									style="color: #A1A4A8;text-align: center;overflow: hidden;text-overflow: ellipsis; white-space: nowrap;">
									请选择职业类型</div>
							</div>
							<div class="weui-cell weui-cell_active weui-cell_access weui-cell_select weui-cell_select-after"
								id="showCityPicker3">
								<div class="weui-cell__hd"><label class="weui-label" id="city3-label">家庭地址</label></div>
								<div class="weui-cell__bd" id="homeAddress"
									style="color: #A1A4A8;text-align: center;overflow: hidden;text-overflow: ellipsis; white-space: nowrap;">
									请选择家庭地址</div>
							</div>
							<div class="weui-cell weui-cell_active weui-cell_access ">
								<div class="weui-cell__hd"><label class="weui-label">所在街道</label></div>
								<div class="weui-cell__bd weui-flex">
									<input class="weui-input" style="text-align: right;padding-right: 17px;" type="text"
										@input="StreetInformation" placeholder="请输入具体街道和门牌号">
								</div>
							</div>
							<div class="">
								<div class="weui-cell__hd"><label class="weui-label">身份证照片</label></div>
								<div class="weui-cell__bd">
									<div class="liDiv">
										<div class="imgBox">
											<img src="../../static/img/idCardBg1.png" alt="" class="idCardPhoto1">
											<div class="positionCam">
												<input class="weui-uploader__input" type="file" accept="image/*"
													multiple="" onchange="uploaderInput(this,1)">
												【点击可上传】
											</div>
											<!-- <img class="idCardPhoto1" src="ss" alt="" style=""> -->
										</div>
										<div class="imgBox">
											<img src="../../static/img/idCardBg0.png" alt="" class="idCardPhoto2">
											<div class="positionCam">
												<input class="weui-uploader__input" type="file" accept="image/*"
													multiple="" d onchange="uploaderInput(this,2)">
												【点击可上传】
											</div>
											<!-- <img class="idCardPhoto2" src="1" alt=""> -->
										</div>
									</div>
								</div>
							</div>
							<button class="bottomDetail" @click="UpdateRechargeException">立即更新</button>
						</div>
					</div>
				</div>

			</div>
		</div>
	</view>
</template>

<script>
	import cityData from "@/common/js/city.js"
	console.log(cityData);

	var gHost = "https://" + window.location.host;
	if (window.location.protocol != "https:") {
		gHost = "https://fpdev.xiaopay.net";
	}
	let times = 0;
	var limitClick = false; //禁止重复点击
	var sessionID = '',
		userID = '';
	var payCardNumber = ''; //一类卡号
	var orderSerialNo = ''; //提现结果查询 指令号
	var businessNo = '',
		otpOrderNo = '',
		mobileNo = '';
	var msCount = 60; //定时器
	var MyTimer = null;
	var fromType = 0; //0转账  1提现
	var opeType = 0; //0充值  1提现   手机号验证
	var bankInfo = {
		acctNoArray: '',
		idNo: '',
		schoolId: '',
		trueName: '',
		userId: '',
		sessionid: '',
		wechattype: 1
	}
	// 20210422 充值账户异常资料补充参数
	var acctErrorUpdateParms = {
		backSideImgId: '', //反面身份证图片Id
		frontSideImgId: '', //正面身份证图片Id
		homeAddress: '', //家庭住址
		occupation: '', //职业代码
		StreetInformation: '', //街道
		businessNo: ''
	}
	// /wefile/wefileId
	// 获取上传影像的Token接口
	let wefileId = {}
	// bizCode: "000000"
	// bizMsg: "获取上传影像token成功"
	// businessNo: "OB89d5ed802cRA202104226389071452"
	// expiredTime: 1619072725503
	// project: "BOBS-OBP"
	// uuid: "8238f256d8f54209a0e9a2a3b25e7393"
	// wefileToken: "QplB0tfvjtzOU+tWgKI2+L+4B9HE8kbpJVREUTwXZCsVqXcUwyDxHAbTU3bW8ziGb4hKAaWiLQXAyZUbYRB9hBKhSt1VVvoFl5qOCR4GT+X1KpcQgBlhKYi/NYPkmsjeZO/qn9YXGDp/1sGmxazv6T05y8EbU9HXreRhF/jh8G1HtUCwprFoaulGFShvV819EUBdHifDF5IjpPekLtgzIm8C/kYYX8xproKvxV4maRji5p1Krkyv/U1K3C18/TyjHwPpC4KlOEqA6QpFujR8yZ42qvLZqfqgUkRFZ4WC27/nN3+do9VNpNbK4MAMSLTRaxdGmKe2wStKbZ5OQ+1WFA=="
	// wefileUrl: "https://bfiles-stg.pingan.com.cn/brcp/secfile/sec_wefiles_udmp_upload.do"
	export default {
		name: "assignDeposit",
		data() {
			return {
				Money: '', //选择金额
				RechargeMax: '2000', //最大充值限制
				ReflectMoney: '', //提现金额
				VerifyCode: '', //验证码
				cardBalanceTx: '0', //余额
				CodeMsg: "获取验证码"
			}
		},
		created: function() {

		},
		mounted: function() {
			let this_ = this
			this.$nextTick(function() {
				// $(".RechargeException").siblings().hide()
				// $(".RechargeException").show()
				//快捷充值按钮
				$('.depotMoney').click(function() {
					console.log(this);
					$(this).addClass('choiceClass');
					$(this).siblings().removeClass('choiceClass');
					$('.depositTx')[0].value = $(this)[0].innerHTML;
					$('.DepositID').removeClass('DisaBledBtn');
				})
				// 家庭住址
				$('#homeAddress').on('click', function() {
					weui.picker(cityData, {
						defaultValue: [110000, 110000, 110101],
						depth: 3,
						onChange: function(result) {
							console.log(result);
						},
						onConfirm: function(result) {
							console.log(result);
							console.log(result);
							acctErrorUpdateParms.homeAddress = result[0].label + '/' +
								result[1].label + '/' +
								result[2].label
							$("#homeAddress")[0].innerText = result[0].label + '/' +
								result[1].label + '/' +
								result[2].label
							$("#homeAddress").css("color", "#000");
						},
						title: '家庭地址'
					});
				});
				// 选择职业
				$('#showPicker').on('click', function() {
					// 获取职业信息
					this_.getOccupationList().then(OccupationList => {
						let data = OccupationList.map(v => {
							return {
								label: v.comment,
								value: v.code
							}
						})
						weui.picker(data, {
							onChange: function(result) {
								console.log(result);
							},
							onConfirm: function(result) {
								console.log(result[0].value);
								acctErrorUpdateParms.occupation = result[0].value
								$("#showPicker")[0].innerText = result[0].label
								$("#showPicker").css("color", "#000");
							},
							title: '职业信息选择'
						});
					}).catch(err => {
						weui.topTips("获取职业信息列表失败");
					})
				});

				// 初始化

				userID = this_.getQueryParams('userID');
				sessionID = this_.getQueryParams('seesionID');
				fromType = this_.getQueryParams('fromType');
				let windowHeight = window.innerHeight;
				if (this_.getQueryParams('tabbar')) { //usermain打开加返回按钮
					$('#ReturnBox').css('display', 'block');
					$('.bottom2').css('margin-top', (windowHeight - 370 < 0 ? 30 : windowHeight -
						370) + 'px');
					$('.bottom1').css('margin-top', (windowHeight - 570 < 0 ? 30 : windowHeight -
						570) + 'px');
				} else {
					$('.bottom2').css('margin-top', (windowHeight - 320 < 0 ? 30 : windowHeight -
						320) + 'px');
					$('.bottom1').css('margin-top', (windowHeight - 590 < 0 ? 30 : windowHeight -
						590) + 'px');
				}
				bankInfo.sessionid = sessionID;
				this_.QueryUserInfo();
				$('#AssginBox').css('display', 'block');
				if (fromType == 0) {
					// $('.TitleHeader').html('电子账户充值');
				} else {
					this_.ToWalletTx();
				}
				setTimeout(function() {
					this_.getWefileId()
				}, 500)
			})
		},
		methods: {
			async depotMoney(value) {
				this.Money = parseInt(value)
			},
			//定时器
			IntervalFun() {
				if (msCount == 1) {
					window.clearInterval(MyTimer); //停止计时器
					$('.CodeMsg').css('color', '#01BC73');
					this.CodeMsg = "获取验证码"
					msCount = 60;
				} else {
					msCount--;
					$('.CodeMsg').css('color', 'gray');
					this.CodeMsg = (msCount + "s后获取")
				}
			},
			//按钮操作
			HideHTML(dom, type) {
				if (type == 0) {
					$('.' + dom).css('display', 'none');
				} else {
					$('.' + dom).css('display', 'block');
				}
			},
			//切换到提现
			ToWalletTx() {
				$('#DepositBox').css('display', 'none');
				$('#TxWalletBox').css('display', 'block');
				// $('.TitleHeader').html('电子账户提现');
				$('.doBtnTx').html('提现');
				opeType = 1;
			},
			//全部提现
			TxAllFun() {
				this.ReflectMoney = this.cardBalanceTx * 1
				// $('.TxClsTx').val($('.cardBalanceTx')[0].textContent * 1);
			},
			//隐藏验证码弹框
			hidePhoneBox() {
				$('.PhoneConfirmBox').css('display', 'none');
				// $('.VerifyCode').val('');
				this.VerifyCode = ''
				orderSerialNo = '';
				businessNo = '';
				otpOrderNo = '';
			},
			//返回小程序 跳转指定页面
			BackToMini(page) {
				if (page == 'UserMain' || page == 'personalCenter') {
					wx.miniProgram.switchTab({
						url: `/pages/${page}/main`,
					});
				} else {
					wx.miniProgram.redirectTo({
						url: `/pages/${page}/main`,
					});
				}
			},
			// 输入限制
			inputControl(obj, val) {
				console.log(obj, val);
				obj.value = obj.target.value
				obj.value = obj.value.replace(/[^\d.]/g, ""); //清除"数字"和"."以外的字符
				obj.value = obj.value.replace(/^\./g, ""); //验证第一个字符是数字而不是.
				obj.value = obj.value.replace(/\.{2,}/g, "."); //只保留第一个. 清除多余的.
				obj.value = obj.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", "."); //只允许输入一个小数点
				obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3'); //只能输入两个小数
				obj.value = obj.value * 1 > 2000 ? 2000 : obj.value;
				this.Money = obj.value + '';
				this.ReflectMoney = obj.value + '';
				if (obj.value == '' || obj.value * 1 < 3) {
					$('.DepositID').addClass('DisaBledBtn');
				} else {
					$('.DepositID').removeClass('DisaBledBtn');
				}
			},
			//input键盘弹起不会弹
			ReturnToTop() {
				document.scrollingElement.scrollTo(0, this.scrollTop);
			},
			//提现结果查询
			transferResults() {
				let this_ = this;
				times++;
				let loading = weui.loading('请稍后');
				let params = {
					accountNo: bankInfo.acctNoArray,
					businessNo: businessNo,
					orderSerialNo: orderSerialNo, //提现指令号
					schoolId: bankInfo.schoolId,
					userId: userID,
					sessionid: sessionID,
					wechattype: 1,
				}
				$.ajax({
					url: gHost + '/bank-wechat/transfer/query',
					type: "POST",
					contentType: "application/x-www-form-urlencoded",
					data: params,
					success: function(res7) {
						if (res7.code == "10000") {
							if (res7.results.status == 0 || res7.results.status ==
								1) { //status 状态 0：失败;1：成功;2：处理中 返回处理中，需要调用“提现(提现)结果查询”接口查结果
								loading.hide();
								if (res7.results.status == 0) {
									weui.topTips(res7.results.bizMsg)
								} else {
									weui.toast('提现成功！', 1500);
								}
								setTimeout(() => {
									location.reload();
								}, 2000)
							} else {
								if (times == 3) {
									loading.hide();
									weui.topTips('当前提现人数过多，请至我的账户中查看余额');
									setTimeout(() => {
										this_.BackToMini('UserMain');
									}, 1500)
								} else {
									setTimeout(res => {
										this_.transferResults();
									}, 2000)
								}
							}
						} else {
							loading.hide();
							weui.topTips(res7.message)
						}
					},
					error: function(err) {
						loading.hide();
					},
				});
			},
			//充值结果查询
			depositResults() {
				let this_ = this;
				times++;
				let loading = weui.loading('请稍后');
				let params = {
					businessNo: businessNo,
					schoolId: bankInfo.schoolId,
					userId: userID,
					sessionid: sessionID,
					wechattype: 1,
				}
				$.ajax({
					url: gHost + '/bank-wechat/recharge/query',
					type: "POST",
					contentType: "application/x-www-form-urlencoded",
					data: params,
					success: function(res8) {
						if (res8.code == "10000") {
							if (res8.results.orderStatus == 3 || res8.results.orderStatus ==
								4) { //orderStatus 0:初始值,1:已提交,2:未知,3:失败,4:成功,5:成功未打款
								loading.hide();
								if (res8.results.orderStatus == 3) {
									weui.topTips(res8.results.errMsg)
								} else {
									weui.toast('充值成功！', 1500);
								}
								setTimeout(() => {
									location.reload();
								}, 2000)
							} else {
								if (times == 3) {
									loading.hide();
									weui.topTips('当前充值人数过多，请至我的账户中查看余额');
									setTimeout(() => {
										this_.BackToMini('UserMain');
									}, 1500)
								} else {
									setTimeout(res => {
										this_.depositResults();
									}, 2000)
								}
							}
						} else {
							loading.hide();
							weui.topTips(res8.message);
						}
					},
					error: function(err) {
						loading.hide();
					},
				});
			},
			//充值/提现方法
			DoNextStep() {
				let this_ = this;
				console.log('请填写验证码');
				if (this_.VerifyCode == '') {
					weui.topTips('请填写验证码')
					return
				};
				if (limitClick) {
					return
				} else {
					limitClick = true;
					setTimeout(() => {
						limitClick = false;
					}, 3000);
				}
				let loading = weui.loading('请稍后');
				times = 0;
				if (opeType == 0) { //充值
					let params = {
						businessNo: businessNo,
						otpOrderNo: otpOrderNo,
						fromAccNo: payCardNumber, //付款账户
						otpValue: $('.VerifyCode')[0].value, //验证码
						transAmt: $('.depositTx')[0].value * 1, //交易金额
						schoolId: bankInfo.schoolId,
						userId: userID,
						sessionid: sessionID,
						wechattype: 1,
					}
					$.ajax({
						url: gHost + '/bank-wechat/recharge',
						type: "POST",
						contentType: "application/x-www-form-urlencoded",
						data: params,
						success: function(res5) {
							if (res5.code == "10000") {
								if (res5.errCode && res5.errCode == 'TI009') {
									loading.hide();
									weui.topTips(res5.results.errMsg);
									setTimeout(function() {
										$(".RechargeException").siblings().hide()
										$(".RechargeException").show()
									})
									return
								};
								if (res5.results.orderStatus == 3 || res5.results.orderStatus ==
									4) { //orderStatus 0:初始值,1:已提交,2:未知,3:失败,4:成功,5:成功未打款
									if (res5.results.orderStatus == 3) {
										loading.hide();
										weui.topTips(res5.results.errMsg);
									} else {
										loading.hide();
										weui.toast('充值成功！', 1500);
									}
									setTimeout(() => {
										location.reload();
									}, 2000)
								} else {
									setTimeout(() => {
										// loading.hide();
										this_.depositResults();
									}, 2000)
								}
							} else {
								loading.hide();
								weui.topTips(res5.message)
							}
						},
						error: function(err) {
							loading.hide();
						},
					});
				} else if (opeType == 1) { //提现
					let params = {
						accountName: bankInfo.trueName,
						amount: $('.TxClsTx')[0].value * 1,
						businessNo: businessNo,
						fromAccountName: bankInfo.trueName,
						fromAccountNo: bankInfo.acctNoArray,
						otpOrderNo: otpOrderNo,
						otpValue: $('.VerifyCode')[0].value, //验证码
						toAccountNo: payCardNumber,
						schoolId: bankInfo.schoolId,
						userId: userID,
						sessionid: sessionID,
						wechattype: 1,
					}
					$.ajax({
						url: gHost + '/bank-wechat/transfer/withdrawal',
						type: "POST",
						contentType: "application/x-www-form-urlencoded",
						data: params,
						success: function(res6) {
							if (res6.code == "10000") {
								orderSerialNo = res6.results.orderSerialNo;
								if (res6.results.status == 1 || res6.results.status ==
									0) { //状态 0：失败;1：成功;2：处理中 返回处理中，需要调用“提现(转账)结果查询”接口查结果
									if (res6.results.status == 0) {
										loading.hide();
										weui.topTips(res6.results.bizMsg)
									} else {
										loading.hide();
										weui.toast('提现成功！', 1500);
									}
									setTimeout(() => {
										location.reload();
									}, 2000)
								} else {
									setTimeout(() => {
										// loading.hide();
										transferResults();
									}, 2000)
								}
							} else {
								loading.hide();
								weui.topTips(res6.message)
							}
						},
						error: function(err) {
							loading.hide();
						},
					});
				}
			},
			//充值/提现判断
			toDeposit(type) { //type 0充值  1提现
				let this_ = this;
				businessNo = '';
				otpOrderNo = '';
				opeType = type;
				if (type == 0) {
					if ($('.DepositID').hasClass('DisaBledBtn'));
					if (this.Money * 1 < 3) {
						weui.topTips('充值金额必须大于3元');
						return
					}
					if (this.Money * 1 > this.RechargeMax * 1) {
						weui.topTips(`充值金额不能大于${this.RechargeMax*1}元`);
						return
					}

				} else {
					if ($('.TxClsTx')[0].value * 1 < 0.01) {
						weui.topTips('提现金额须大于等于0.01元');
						return
					}
					if ($('.TxClsTx')[0].value * 1 > this.RechargeMax * 1) {
						weui.topTips(
							`提现金额不可大于账户余额`);
						return
					}
				}
				$('.PhoneConfirmBox').css('display', 'block');
			},
			//发送验证码
			SendMsg() {
				let this_ = this;
				if (this_.CodeMsg != '获取验证码') return false;
				let loading = weui.loading('发送中');
				if (opeType == 0) { //充值
					let params = {
						fromAccNo: payCardNumber, //付款账户,
						transAmt: $('.depositTx')[0].value * 1, //交易金额
						schoolId: bankInfo.schoolId,
						userId: userID,
						sessionid: sessionID,
						wechattype: 1,
					}
					$.ajax({
						url: gHost + '/bank-wechat/otp/send/recharge',
						type: "POST",
						contentType: "application/x-www-form-urlencoded",
						data: params,
						success: function(res5) {
							loading.hide();
							if (res5.code == "10000") {
								otpOrderNo = res5.results.otpOrderNo;
								businessNo = res5.results.businessNo;
								weui.toast('验证码已发送，请注意查收！', 1000);
								this_.IntervalFun();
								MyTimer = window.setInterval(IntervalFun, 1000);
							} else {
								weui.topTips(res5.message)
							}
						},
						error: function(err) {
							loading.hide();
						},
					});
				} else if (opeType == 1) { //提现
					let params = {
						accountNo: bankInfo.acctNoArray, //银行卡号
						mobileNo: mobileNo, //手机号
						'transferAccountBizKeyVO.accountName': bankInfo.trueName, //收款方户名
						'transferAccountBizKeyVO.amount': $('.TxClsTx')[0].value * 1, //提现金额
						'transferAccountBizKeyVO.fromAccountName': bankInfo.trueName, //转出户名
						'transferAccountBizKeyVO.fromAccountNo': bankInfo.acctNoArray, //转出卡号（互联网账户卡号）
						'transferAccountBizKeyVO.toAccountNo': payCardNumber, //收款方卡号（绑定卡卡号）
						schoolId: bankInfo.schoolId,
						userId: userID,
						sessionid: sessionID,
						wechattype: 1,
					}
					$.ajax({
						url: gHost + '/bank-wechat/otp/send/transfer/account',
						type: "POST",
						contentType: "application/x-www-form-urlencoded",
						data: params,
						success: function(res5) {
							loading.hide();
							if (res5.code == "10000") {
								otpOrderNo = res5.results.otpOrderNo;
								businessNo = res5.results.businessNo;
								weui.toast('验证码已发送，请注意查收！', 1000);
								this_.IntervalFun();
								MyTimer = window.setInterval(this_.IntervalFun, 1000);
							} else {
								weui.topTips(res5.message)
							}
						},
						error: function(err) {
							loading.hide(res5.message);
						},
					});
				}
			},
			//换绑卡
			ChangeCardPay(bankName, bindCard) {
				let this_ = this;
				if (bindCard == payCardNumber) {
					return
				}
				var loading = weui.loading('请稍后');
				$.ajax({
					url: gHost + '/bank-wechat/user/bank/change/bind',
					type: "POST",
					contentType: "application/x-www-form-urlencoded",
					data: {
						schoolId: bankInfo.schoolId,
						userId: userID,
						sessionid: sessionID,
						wechattype: 1,
						accountName: bankName,
						accountNo: bindCard,
					},
					success: function(res5) {
						loading.hide();
						if (res5.code == "10000") {
							this_.HideHTML('showBindCardList', 0);
							this_.queryUserBankInfo();
						} else {
							weui.topTips(res5.message)
						}
					},
					error: function(err) {
						loading.hide();
					},
				});
			},
			//查询一类卡绑定列表
			queryBindCardList() {
				let this_ = this;
				let loading = weui.loading('请稍后');
				$.ajax({
					url: gHost + '/bank-wechat/query/account',
					type: "POST",
					contentType: "application/x-www-form-urlencoded",
					data: {
						schoolId: bankInfo.schoolId,
						userId: userID,
						sessionid: sessionID,
						wechattype: 1
					},
					success: function(res4) {
						loading.hide();
						if (res4.code == "10000") {
							var divList = '';
							var choiceIndex = 0;
							for (let i = 0; i < res4.results.accountList[0].bindcardList.length; i++) {
								divList += `<div onclick=ChangeCardPay('${res4.results.accountList[0].bindcardList[i].bankName}','${res4.results.accountList[0].bindcardList[i].bindCardNo}')>
			                    <p>${res4.results.accountList[0].bindcardList[i].bankName}</p>
			                    <p>${res4.results.accountList[0].bindcardList[i].bindCardNo.substr(0,4)+" **** **** "+res4.results.accountList[0].bindcardList[i].bindCardNo.substr(-4)}</p>
			                    <img class='myImg${i} BankListImg' src='img/choiceBank.png'>
			                    </div>`
								if (res4.results.accountList[0].bindcardList[i].bindCardNo == payCardNumber) {
									choiceIndex = i;
								}
							}
							$('.hideListCover').html(divList);
							$(`.myImg${choiceIndex}`).css('display', 'block');
							$('.showBindCardList').css('display', 'block');
						} else {
							weui.topTips(res4.message)
						}
					},
					error: function(err) {
						loading.hide();
					},
				});
			},
			//获取银行余额
			queryBankInfo() {
				let this_ = this;
				let loading = weui.loading('请稍后');
				$.ajax({
					url: gHost + '/bank-wechat/query/balance',
					type: "POST",
					timeout: 8000,
					contentType: "application/x-www-form-urlencoded",
					data: bankInfo,
					success: function(res3) {
						loading.hide();
						if (res3.code == "10000") {
							if (res3.results.acctInfoList == null) {
								weui.topTips("账户信息为空，余额查询失败");
							} else {
								this_.cardBalanceTx = ((res3.results.acctInfoList[0].hqBalanceDTOList[0]
									.balance *
									1).toFixed(2));
								$('.TxClsTx').attr('placeholder',
									`可提现金额${(res3.results.acctInfoList[0].hqBalanceDTOList[0].balance*1).toFixed(2)}元`
								)
								this_.RechargeMax = ((2000 - ((res3.results.acctInfoList[0]
									.hqBalanceDTOList[0]
									.balance * 1).toFixed(2) * 1)).toFixed(2));
							}
						} else {
							weui.topTips(res3.message)
						}
					},
					error: function(err) {
						loading.hide();
					},
					complete: function(XMLHttpRequest, status) {
						loading.hide();
						if (status == 'timeout') {
							weui.topTips("请求超时，余额查询失败");
						}
					}
				})
			},
			//获取用户已填写银行信息
			queryUserBankInfo() {
				let this_ = this;
				let loading = weui.loading('请稍后');
				$.ajax({
					url: gHost + '/bank-wechat/user/bank/get',
					type: "POST",
					contentType: "application/x-www-form-urlencoded",
					data: {
						schoolId: bankInfo.schoolId,
						userId: userID,
						sessionid: sessionID,
						wechattype: 1
					},
					success: function(res2) {
						if (res2.code == "10000") {
							bankInfo.acctNoArray = res2.results.accountNo;
							bankInfo.idNo = res2.results.idNo;
							bankInfo.trueName = res2.results.trueName;
							payCardNumber = res2.results.bindCardNo;
							$('.bankNameClass').html(
								`${res2.results.bindCardName}(${res2.results.bindCardNo.substr(-4)})`);
							$('.bankNameClass1').html(res2.results.bindCardName + '(储蓄卡)');
							$('.payCardEndNo').html('尾号' + res2.results.bindCardNo.substr(-4));
							$('.myPhoneTx').html(res2.results.mobileNo);
							mobileNo = res2.results.mobileNo;
							this_.queryBankInfo();
						} else {
							weui.topTips(res2.message)
						}
					},
					error: function(err) {
						loading.hide();
					},
				});
			},
			//查询用户信息
			QueryUserInfo() {
				let this_ = this;
				let loading = weui.loading('请稍后');
				$.ajax({
					url: gHost + '/wechat/svweapp/QueryPersonalInfo',
					type: "POST",
					contentType: "application/x-www-form-urlencoded",
					data: {
						userid: userID,
						sessionid: sessionID,
						wechattype: 1
					},
					success: function(res1) {
						loading.hide();
						if (res1.code == "10000") {
							bankInfo.schoolId = res1.results.schoolid;
							bankInfo.userId = res1.results.id;
							$('.userNameTx').html(res1.results.name);
							$('.schoolNameTx').html(res1.results.schoolname);
							$('.ClsNameTx').html(res1.results.gradename + res1.results.classname);
							if (res1.results.usertype == 1) {
								$('.StudentCls').css('display', 'block');
								$('.TeacherCls').css('display', 'none');
							} else {
								$('.StudentCls').css('display', 'none');
								$('.TeacherCls').css('display', 'block');
							}
							this_.queryUserBankInfo();
						} else {
							weui.topTips(res1.message);
							setTimeout(() => {
								this_.BackToMini('UserMain');
							}, 1500)
						}
					},
					error: function(err) {
						loading.hide();
					},
				});
			},
			// 充值账户异常资料补充
			// recharge/acctErrorUpdateResource
			acctErrorUpdateResource() {
				acctErrorUpdateParms.businessNo = wefileId.businessNo; //业务流水号
				acctErrorUpdateParms.schoolId = bankInfo.schoolId;
				acctErrorUpdateParms.userId = userID;
				acctErrorUpdateParms.homeAddress = acctErrorUpdateParms.homeAddress + acctErrorUpdateParms
					.StreetInformation
				let {
					backSideImgId,
					frontSideImgId,
					homeAddress,
					occupation
				} = acctErrorUpdateParms
				acctErrorUpdateParms.sessionid = sessionID
				acctErrorUpdateParms.wechattype = 1
				if (!occupation) {
					weui.topTips("请选择职业信息");
					return
				}
				if (!homeAddress) {
					weui.topTips("请选择家庭住址");
					return
				}

				if (!backSideImgId) {
					weui.topTips("请上传反面身份证图片");
					return
				}
				if (!frontSideImgId) {
					weui.topTips("请上传正面身份证图片");
					return
				}
				let loading = weui.loading('信息更新中,请稍后');
				return new Promise((resolve, reject) => {
					$.ajax({
						url: gHost + '/bank-wechat/recharge/acctErrorUpdateResource',
						type: "POST",
						contentType: "application/x-www-form-urlencoded",
						data: acctErrorUpdateParms,
						timeout: 8000, //超时时间设置，单位毫秒
						success: function(res) {
							loading.hide();
							if (res.code == '000000') {
								weui.topTips("信息更新成功", {
									duration: 3000, //3秒后消失
									className: 'weui-toptips_success', //自定义类名
									callback: function() {
										//回调函数
										console.log('close')
										window.location.reload()
									}
								});
								resolve(res)
							} else {
								weui.topTips("信息更新失败," + res.message);
								loading.hide();
								reject(res.message)
							}
						},
						error: function(err) {
							loading.hide();
							reject(err)
						},
					})
				})
			},
			//点击上传文件
			uploaderInput(e, CredType) {
				let fileInfo = e.files[0];
				let fileTypeList = fileInfo.name.split(".");
				let fileType = fileTypeList[fileTypeList.length - 1];
				if (!(fileType == "jpg" || fileType == "png")) {
					weui.topTips("不符合的文件格式,请重新选择");
					return;
				}
				let reads = new FileReader();
				reads.readAsDataURL(fileInfo);
				reads.onload = function(e) {
					$(`.idCardPhoto${CredType}`).attr('src', this.result)
				};
				// console.log(fileInfo, fileType)
				// console.log(wefileId);
				let formData = new FormData();
				formData.append("project", wefileId.project)
				formData.append("file", fileInfo)
				formData.append("fileName", fileInfo.name)
				formData.append("expiredTime", wefileId.expiredTime)
				formData.append("uuid", wefileId.uuid)
				formData.append("wefileToken", wefileId.wefileToken)
				formData.append("wefileUrl", wefileId.wefileUrl)
				formData.append("sessionid", sessionID)
				formData.append("wechattype", 1)
				this.UploadIDCardInfo(wefileId.wefileUrl, formData, CredType)
			},
			// 【获取上传影像token接口】中已经返回了请求地址
			UploadIDCardInfo(url, formData, type) {
				let loading = weui.loading('请稍后,正在上传');
				return new Promise((resolve, reject) => {
					$.ajax({
						url: gHost +
							`/bank-wechat-server/wefile/upload?wechattype=1&sessionid=${sessionID}`,
						type: "post",
						data: formData,
						processData: false,
						contentType: false,
						success: function(res) {
							console.log(res);
							if (res.code == '10000') {
								if (type == 1) {
									acctErrorUpdateParms.frontSideImgId = res.results;
								} else {
									acctErrorUpdateParms.backSideImgId = res.results;
								}
								weui.topTips("上传成功", {
									duration: 3000, //3秒后消失
									className: 'weui-toptips_success', //自定义类名
									callback: function() {}
								});
								loading.hide();
								resolve(res)
							} else {
								weui.topTips(res.message);
								loading.hide();
								reject(res.message)
							}
							// setTimeout(function() {
							// 	loading.hide();
							// 	resolve(res)
							// }, 3000)
						},
						error: function(err) {
							loading.hide();
							weui.topTips("上传失败！请检查");
							reject(err)
						},
					})
				})
			},
			getWefileId(fileType = 'jpg/png/jpeg') {
				let loading = weui.loading('请稍后');
				return new Promise((resolve, reject) => {
					$.ajax({
						url: gHost + '/bank-wechat/wefile/wefileId',
						type: "post",
						data: {
							Authorization: this.getQueryParams('seesionID'),
							businessNo: businessNo,
							fileType: fileType, //jpg/png/doc/docx/txt/pdf/ppt/xls/xlsx/pptx/jpeg
							schoolId: bankInfo.schoolId,
							userId: userID,
							sessionid: sessionID,
							wechattype: 1
						},
						success: function(res) {
							loading.hide();
							if (res.code == "10000") {
								wefileId = res.results
								resolve(res.results)
							} else {
								reject(res.message)
							}
						},
						error: function(err) {
							loading.hide();
							reject(err)
						},
					})
				})
			},
			//街道信息
			StreetInformation(e) {
				let value = $(e)[0].value;
				console.log(value);
				acctErrorUpdateParms.StreetInformation = value
			},
			//立即更新
			UpdateRechargeException() {
				this.acctErrorUpdateResource()
			},
			// query/getOccupationList职业信息接口
			getOccupationList() {
				let loading = weui.loading('请稍后');
				return new Promise((resolve, reject) => {
					$.ajax({
						url: gHost + '/bank-wechat/query/getOccupationList',
						type: "post",
						data: {
							sessionid: sessionID,
							wechattype: 1
						},
						headers: {
							'Authorization': getQueryParams('seesionID'),
						},
						success: function(res) {
							loading.hide();
							if (res.code == "10000") {
								resolve(res.results)
							} else {
								reject(res.message)
							}
						},
						error: function(err) {
							loading.hide();
							reject(err)
						},
					})
				})
			},
			//获取参数
			getQueryParams(params) {
				var query = window.location.search.substring(1);
				var vars = query.split("&");
				for (var i = 0; i < vars.length; i++) {
					var pair = vars[i].split("=");
					if (pair[0] == params) {
						return pair[1];
					}
				}
				return (false);
			}
		}
	}
</script>

<style scoped lang="scss">
	.RechargeException {
		padding-top: 0.63rem;
	}

	.weui-label {
		width: 118px;
		height: 42px;
		font-size: 40rpx;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 500;
		color: #3D3D3D;
		line-height: 42px;
		font-weight: bold;
	}

	.tiptext {
		/* width: 24.5rem; */
		height: 1.06rem;
		font-size: 0.75rem;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #03BC73;
		line-height: 1.06rem;
		margin-bottom: 0.625rem;
		text-align: center;
	}

	.RechargeException input::placeholder {
		color: #A1A4A8;
	}

	.RechargeException .weui-cell {
		height: 4rem;
		/* line-height: 4rem; */
		padding: 0 !important;
	}

	.RechargeException .liDiv .imgBox {
		width: 15.13rem;
		/* height: 10rem; */
		margin: 0 auto;
		/* margin-top: 0.88rem; */
		text-align: center;
	}

	.imgBox img {
		width: 100%;
	}

	.imgBox .positionCam {
		height: 1rem;
		font-size: 0.69rem;
		font-family: PingFang-SC-Medium, PingFang-SC;
		font-weight: 500;
		color: #6D7278;
		line-height: 1rem;
		text-align: center;
		position: relative;
		top: -2.0625rem;
	}

	.idCardPhoto1,
	.idCardPhoto2 {
		width: auto !important;
		height: auto;
		max-width: 100%;
		max-height: 100%;
	}

	.weui-toptips_success {
		background-color: #03BC73 !important
	}

	html,
	body {
		/* -webkit-overflow-scrolling:none; */
	}

	#MoneyBox {
		display: flex;
		border: none !important;
		justify-content: space-between;
		margin-bottom: 25px !important;
	}

	.DisaBledBtn {
		background: #e6e6e6 !important;
		color: gray;
	}

	.choiceClass {
		background: #01BC73 !important;
		;
		color: #fff !important;
	}

	#MoneyBox>div {
		width: 28% !important;
		height: 40px !important;
		line-height: 40px !important;
		border-radius: 5px;
		font-size: 15px;
		text-align: center;
	}

	.TopBox>.dayTips {
		color: #888888;
		text-decoration: none;
		display: inline-block;
		width: 48vw;
		font-size: 13px;
		text-align: right;
	}

	.changPhone {
		font-size: 14px;
		color: #39F;
		text-align: right;
	}

	.TopBox>p {
		font-size: 17px;
		font-weight: bold;
		width: 40vw;
		display: inline-block;
	}

	.myPhoneDiv {
		height: 50px;
		display: flex;
		align-items: center;
		border-bottom: 1px solid #eeeeee;
	}

	body,
	p {
		margin: 0;
	}

	input {
		outline: none;
	}

	button {
		border: none;
	}

	#TxWalletBox {
		display: none;
		margin-top: 30px;
	}

	.title1 {
		display: inline-block;
		width: 30%;
	}

	.closePhoneBox {
		position: absolute;
		top: 10px;
		right: 10px;
		width: 20px;
		height: 20px;
	}

	#ReturnBox {
		font-size: 15px;
		display: none;
		margin: 10px 0;
	}

	.returnImgBox {
		width: 15px;
		height: 15px;
		vertical-align: middle;
	}

	.TxDiv {
		width: 90vw;
		height: 48px;
		line-height: 48px;
		position: relative;
		margin: 10px 0;
		border-radius: 5px;
		border: 1px solid #EEEEEE;
	}

	.accountBox1 {
		margin-top: 20px;
		font-weight: bold;
		position: relative;
	}

	.accountBox1 .AcountTitle {
		font-size: 14px;
		display: inline-block;
		color: #888;
	}

	.accountBox1 .bankNameClass1 {
		font-size: 15px;
		float: right;
		position: absolute;
		right: 0;
		bottom: 3px;
		top: 2px;
	}

	.accountBox1 img {
		width: 8px;
		height: 13px;
		position: absolute;
		right: 0;
		bottom: 5px;
	}

	.TxClsTx {
		width: 50%;
		padding-right: 40%;
		display: inline-block;
		vertical-align: bottom;
		/* border: 1px solid #EEEEEE; */
		border: none;
		padding-left: 25px;
		outline: none;
		height: 48px;
		font-size: 15px;
	}

	#AssginBox {
		width: 90vw;
		padding: 0 5vw;
		/* height:100vh; */
		overflow-y: auto;
		display: none;
		padding-top: 20rpx;
	}

	.MyPhoneCls {
		position: fixed;
		width: 70vw;
		font-size: 15px;
		left: 10vw;
		padding: 20px 5vw;
		top: 20vh;
		background: #fff;
		border-radius: 5px;
		z-index: 20;
		display: flex;
		justify-content: space-between;
	}

	.doBtnTx {
		border: none;
		width: 60vw;
		margin-left: 5vw;
		height: 41px;
		margin-top: 60px;
		line-height: 40px;
		font-size: 16px;
		background: #01BC73;
		color: #fff;
		border-radius: 5px;
		outline: none;
	}

	.MyPhoneCls input {
		width: 21vw;
		border: none;
		outline: none;
	}

	.CodeMsg {
		color: #01BC73;
		border-radius: 5px;
		background: #EBEBEB;
		font-size: 13px;
		padding: 2%;
	}

	.myPhoneP {
		border-bottom: 1px solid #eeeeee;
		font-size: 14px;
		display: flex;
	}

	.VerifyCode {
		font-size: 14px;
		/* color: #888888; */
	}

	.MyPhoneCls p {
		height: 50px;
		line-height: 50px;
	}

	.TitleHeader {
		font-size: 15px;
		text-align: center;
		height: 60px;
		line-height: 60px;
	}

	.centerBox {
		position: absolute;
		font-weight: bold;
		color: #fff;
		width: 80vw;
		left: 13vw;
		top: 5vw;
	}

	.BankClass {
		width: 100vw;
		position: fixed;
		bottom: 0;
		left: 0;
		z-index: 15;
		max-height: 60vh;
		background: #F2F2F2;
		overflow-y: auto;
		text-align: center;
		border-top-left-radius: 20px;
		border-top-right-radius: 20px;
	}

	.hideListCover>div {
		border-bottom: 1px solid #e6e6e6;
		padding: 10px 0;
		background: #fff;
		font-size: 14px;
		position: relative;
	}

	.BankListImg {
		position: absolute;
		display: none;
		right: 50px;
		width: 15px;
		top: 25px;
	}

	.BankClass>p {
		height: 25px;
		line-height: 25px;
	}

	.choiceBox {
		font-weight: bold;
		height: 50px;
		line-height: 50px;
		border-bottom: 1px solid #e6e6e6;
	}

	.HidenText span {
		width: 40vw;
		text-overflow: ellipsis;
		overflow: hidden;
		white-space: nowrap;
	}

	.IconCls {
		font-size: 12px;
		background: #20946D;
		border-radius: 15px;
		text-align: center;
		padding: 1vw 2vw;
	}

	.ImgIcon1 {
		display: inline-block;
		width: 8px !important;
		margin-left: 5px;
		margin-top: -2px;
		vertical-align: middle;
	}

	.ImgContent {
		position: relative;
		/* margin-left: 5vw; */
	}

	.ImgContent>img {
		width: 90vw;
	}

	.contentDiv {
		position: absolute;
		top: 0;
		color: #fff;
		padding: 5vw;
	}

	.contentDiv>p {
		width: 80vw;
		display: flex;
		justify-content: space-between;
	}

	.contentDiv>span {
		color: #fff;
	}

	.depositBox {
		width: 90vw;
		margin-top: 20px;
	}

	.AllCharge {
		padding: 0 5px;
		border-radius: 20px;
		font-size: 15px;
		width: 25%;
		text-align: center;
		height: 40px;
		position: absolute;
		line-height: 40px;
		color: #fff;
		background: #A5876B;
		top: 5px;
		right: 0;
	}

	.depositImg {
		width: 14px;
		vertical-align: middle;
		margin-right: 8px;
	}

	.inputTitle {
		font-size: 17px;
		font-weight: bold;
	}

	.depositBox div {
		width: 90vw;
		height: 46px;
		line-height: 46px;
		margin: 10px 0;
		border-radius: 5px;
		position: relative;
		border: 1px solid #EEEEEE;
	}

	.depositBox>div>input {
		display: inline-block;
		// vertical-align: bottom;
		border: none;
		padding-left: 25px;
		height: 46px;
		outline: none;
		font-size: 15px;
	}

	.BgCoverBox {
		width: 100vw;
		height: 100vh;
		position: fixed;
		left: 0;
		top: 0;
		z-index: 10;
		background: #000000;
		opacity: 0.5;
	}

	.hideListCover {
		max-height: 50vh;
		overflow-y: auto;
		padding: 0;
	}

	.bottomDiv {
		font-weight: bold;
		height: 50px;
		line-height: 50px;
		border-bottom: 1px solid #e6e6e6;
	}

	.accountBox {
		margin: 40px 0 12px 0;
		font-weight: bold;
		position: relative;
	}

	.accountBox>img {
		width: 8px;
		height: 13px;
		position: absolute;
		right: 0;
		bottom: 4px;
	}

	.AcountTitle {
		font-size: 14px;
		display: inline-block;
		color: #888;
	}

	.bankNameClass {
		font-size: 15px;
		float: right;
		margin-right: 18px;
		position: absolute;
		right: 0;
		bottom: 0;
	}

	.changeCardBox {
		font-size: 15px;
		color: #268EF8;
		text-align: center;
		text-decoration: underline;
		width: 90vw;
		bottom: 40px;
	}

	.bottomDetail {
		background: #01BC73;
		color: #fff;
		width: 86vw;
		height: 45px;
		outline: none;
		line-height: 45px;
		font-size: 17px;
		text-align: center;
		bottom: 70px;
		margin: 20vh 0 10px 2vw;
		border: none;
		border-radius: 5px;
	}

	.depositTx div {
		position: absolute;
		border: none;
	}
</style>
