<template>
	<view class="wrap">
		<u--form :model="applyInfo" ref="uForm" error-type="message">
			<u-form-item prop="mercType" label-position="left" label="商户类型" label-width="190">
				<view class="" @click="uinp">
					<u--input placeholder="点击选择" type="text" disabled :placeholder-style="placeholderStyle"
						v-model="applyInfo.custInfo.mercType"></u--input>
				</view>
				<u-action-sheet @close="close" @select="select" :closeOnClickOverlay="false" cancelText="取消"
					:actions="ysDict.mercType()" :show="show" round='20' :title="title"></u-action-sheet>
			</u-form-item>
			<u-form-item label="所属行业类型" label-width="190" right-icon="arrow-right" prop="mccStr">
				<u--input placeholder="点击查询" :placeholder-style="placeholderStyle" v-model="applyInfo.custInfo.mccStr"
					type="text" @click="toQueryMcc"></u--input>
			</u-form-item>

			<u-form-item label="商户名称" label-width="190" prop="mercName">
				<u--input v-model="applyInfo.custInfo.mercName" :placeholder="mercNameFormat" type="text"
					:placeholder-style="placeholderStyle" />
			</u-form-item>
			<u-form-item label="门头照片" label-width="190" prop='applyInfo.imgPaths.A006'>
				<u-upload width="160" height="160" :action="post_url+'upload_file'" max-count=1
					@on-change="mercImgCopy($event,'A006')"></u-upload>
			</u-form-item>
			<u-form-item label="内部照片" label-width="190" prop='applyInfo.imgPaths.A007'>
				<u-upload width="160" height="160" :action="post_url+'upload_file'" max-count=1
					@on-change="mercImgCopy($event,'A007')"></u-upload>
			</u-form-item>
			<u-form-item label="营业执照" prop="license_copy" label-width="190">
				<u-upload width="160" height="160" :action="busAction" :form-data="license_copy" max-count=1
					@on-change="flicense_copy"></u-upload>
			</u-form-item>
			<u-form-item label="营业执照号" label-width="190" prop="busNo">
				<u--input v-model="applyInfo.busInfo.busNo"  placeholder='请输入营业执照号' type="text" :placeholder-style="placeholderStyle" />
			</u-form-item>
			<u-form-item label="营业执照名称" label-width="190" prop="busNm">
				<u--input v-model="applyInfo.busInfo.busNm" type="text" :placeholder="mercNameFormat"  placeholder='请输入营业执照名称'
					:placeholder-style="placeholderStyle" />
			</u-form-item>

			<u-form-item label="营业执照有效日期" label-width="250" prop="busCertDateStr">
				<u--input v-model="applyInfo.busInfo.busCertDateStr" type="text" placeholder='请输入营业执照有效日期'
					:placeholder-style="placeholderStyle" />
			</u-form-item>
			<!-- 省市区 -->
			<u-form-item label="营业归属地" label-width="190" right-icon="arrow-right" prop="busAdrStr">
				<u--input placeholder="点击选择" v-model="applyInfo.busInfo.busAdrStr" type="text" disabled
					@click="toSelAdr" :placeholder-style="placeholderStyle" />
			</u-form-item>
			<!-- 营业执照上的地址 -->
			<u-form-item label="营业详细地址" label-width="190" prop="busAddr">
				<u-input v-model="applyInfo.busInfo.busAddr" type="text" placeholder='请输入营业详细地址' :placeholder-style="placeholderStyle" />
			</u-form-item>
			<!-- 店铺地址 -->
			<u-form-item label="店铺地址" label-width="190" prop="trueAddr">
				<u-input v-model="applyInfo.busInfo.trueAddr" placeholder='请输入店铺地址' type="text" :placeholder-style="placeholderStyle" />
			</u-form-item>
			<u-form-item label="法人身份证正面" prop="idcard_front" label-width="190">
				<u-upload width="160" ref="crpFront" height="160" :action="crpAction" :form-data="idcard_front"
					max-count=1 @on-change="crp_front"></u-upload>
			</u-form-item>
			<u-form-item label="法人身份证反面" prop="idcard_back" label-width="190">
				<u-upload width="160" ref="crpBack" height="160" :action="crpAction" :form-data="idcard_back"
					max-count=1 @on-change="crp_back"></u-upload>
			</u-form-item>
			<u-form-item label="法人姓名" label-width="190" prop="crpNm">
				<u--input v-model="applyInfo.crpInfo.crpNm" type="text"  placeholder='请输入法人姓名'
					:placeholder-style="placeholderStyle"></u--input>
			</u-form-item>
			<u-form-item label="法人证件号" label-width="190" prop="crpCertNo">
				<u--input v-model="applyInfo.crpInfo.crpCertNo" type="text"  placeholder='请输入法人证件号'
					:placeholder-style="placeholderStyle"></u--input>
			</u-form-item>
			<u-form-item label="法人手机号" label-width="190" prop="crpPhone">
				<u--input v-model="applyInfo.crpInfo.crpPhone" type="text"   placeholder='请输入手机号'
					:placeholder-style="placeholderStyle"></u--input>
			</u-form-item>
			<u-form-item label="法人邮箱" label-width="190" prop="contactMail">
				<u--input v-model="applyInfo.custInfo.contactMail" type="text"  placeholder='请输入邮箱号'
					:placeholder-style="placeholderStyle"></u--input>
			</u-form-item>
			<u-form-item label="是否法人结算" label-width="190" prop="isCrpSett">
				<u-switch v-model="isCrpSett" size='40'></u-switch>
			</u-form-item>
			<!-- v-if="isShowCrpSett"  非法人专属-->
			<u-form-item label="结算户名" label-width="190" prop="stlAccNm" v-if="!isCrpSett">
				<u--input v-model="applyInfo.stlAccInfo.stlAccNm" placeholder='请输入结算户名' :placeholder-style="placeholderStyle" />
			</u-form-item>
			<!-- // v-if="isShowCrpSett" -->
			<u-form-item label="银行预留手机号" label-width="250" prop="bankMobile" v-if="!isCrpSett">
				<u--input v-model="applyInfo.stlAccInfo.bankMobile" placeholder='请输入银行预留手机号' type="text" :placeholder-style="placeholderStyle" />
			</u-form-item>
			<!-- v-if="isShowCrpSett" 非法人专属-->
			<u-form-item v-if="!isCrpSett" label="开户人证件号" label-width="190" prop="openCertNo">
				<u--input v-model="applyInfo.stlAccInfo.openCertNo" placeholder='请输入开户人证件号' type="text" :placeholder-style="placeholderStyle" />
			</u-form-item>
			<!-- 非法人专属 -->
			<u-form-item label="结算账户正面(卡号面)" label-width="250" prop="fbank_copy">
				<u-upload width="160" height="160" :action="post_url+'orc'" :form-data="{'type':'bankcard'}" max-count=1
					@on-change="fbank_copy"></u-upload>
			</u-form-item>
			<u-form-item label="结算账户反面" label-width="250" prop="bbank_copy">
				<u-upload width="160" height="160" :action="post_url+'upload_file'" :form-data="{'type':'bankcard'}"
					max-count=1 @on-change="bbank_copy"></u-upload>
			</u-form-item>
			<u-form-item label="结算账号" label-width="190" prop="stlAccNo">
				<u--input v-model="applyInfo.stlAccInfo.stlAccNo" placeholder='请输入结算账号址' :placeholder-style="placeholderStyle" />
			</u-form-item>
			
			<u-form-item label="开户支行" label-width="190" right-icon="arrow-right" prop="bankSubStr">
				<u--input placeholder="请输入开户支行" v-model="applyInfo.stlAccInfo.bankSubStr" type="text"
					@click="toSelBank(0)" :placeholder-style="placeholderStyle" />
			</u-form-item>
			<u-form-item label="实时账费率" label-position="top" v-if="isIncludeBOT('01')">
				<view class="clollC">
					<u-form-item label="费率（%）" label-width="210">
						<u--input type="text" v-model="applyInfo.signInfo.codeScanD0Fee.rateFee" placeholder='费率（%）'
							:placeholder-style="placeholderStyle"></u--input>
					</u-form-item>
					<!-- <u-form-item  label="最低收费（分）" label-width="210">
						<u--input  type="text" v-model="applyInfo.signInfo.codeScanD0Fee.rateBottom" :placeholder-style="placeholderStyle"></u--input>
					</u-form-item> -->
				</view>
			</u-form-item>
			<u-form-item label="设备编号" label-width="190" prop="payDeviceNo">
				<u-row gutter="16">
					<u-col span="11">
						<u-input style="width: 200px;" placeholder="请输入音箱设备上的条码" v-model="applyInfo.payDeviceNo"
							type="text" :placeholder-style="placeholderStyle" />
					</u-col>
					<u-col span="1">
						<u-icon name="scan" color="#2979ff" size="60" @click="scancodeDevice"></u-icon>
					</u-col>
				</u-row>
			</u-form-item>
			<u-form-item label="客户经理" label-width="190">
				<u--input v-model="applyInfo.custInfo.cusMgrNm" placeholder='请输入客户经理' :placeholder-style="placeholderStyle" />
			</u-form-item>
			<!-- <u-form-item  label="结算账户类型" label-width="190" right-icon="arrow-right" prop="stlAccType">
				<u--input  placeholder="点击选择"  v-model="applyInfo.stlAccInfo.stlAccTypeStr" type="text"
				 @click="stlAccTypeShow=true" :placeholder-style="placeholderStyle"></u--input> -->
			<!-- <u--select v-model="stlAccTypeShow" value-name="value" label-name="name" mode="single-column"
				 :list="ysDict.stlAccType()" @confirm="stlAccTypeConfirm"></u--select>
			</u-form-item>

			<!--  v-if="isShowCrpSett" -->
			<!-- <u-form-item label-position="top" >
				<u-collapse :arrow="false">
					<u-collapse-item  title="备用结算账号" open>
						<view class="feeItme">
							<u-form-item  label="账户类型" label-width="190" >
								<u--input  placeholder="点击选择"  v-model="applyInfo.stlAccInfo.standByStlAccTypeStr" 
								type="text" @click="standByStlAccTypeShow=true" :placeholder-style="placeholderStyle"></u--input>
								<u-select v-model="standByStlAccTypeShow" value-name="value" label-name="name" mode="single-column" :list="ysDict.stlAccType()" @confirm="stabdByStlAccTypeConfirm"></u-select>
							</u-form-item>
							<u-form-item  label="结算账户卡号面"  label-width="250">
								<u-upload width="160" height="160" :action="post_url+'orc'" :form-data="{'type':'bankcard'}" max-count=1 @on-change="fbank_copy_stand"></u-upload>
							</u-form-item>
							<u-form-item  label="结算账号" label-width="190">
								<u--input type="text"  v-model="applyInfo.stlAccInfo.standByStlAccNo" :placeholder-style="placeholderStyle"></u--input>
							</u-form-item>
							<u-form-item  label="结算户名" label-width="190">
								<u--input type="text"  v-model="applyInfo.stlAccInfo.standByStlAccNm" :placeholder-style="placeholderStyle"></u--input>
							</u-form-item>
							<u-form-item  label="开户支行" label-width="190" right-icon="arrow-right" prop="bankSubStr">
								<u--input  placeholder="点击选择" 
								v-model="applyInfo.stlAccInfo.standByBankSubStr" type="text" disabled @click="toSelBank(1)" :placeholder-style="placeholderStyle"/>
							</u-form-item>
						</view>
					</u-collapse-item>
				</u-collapse>
			</u-form-item> -->

			<!-- 	<u-form-item label="到账时间" label-width="190" >
				<u-checkbox-group @change="busOpenTypeChange">
					<u-checkbox 
						v-model="item.checked" 
						v-for="(item, index) in busOpenTypes" :key="index" 
						:name="item.value"
						:disabled="item.value==='00'"
						:label-disabled="item.value==='00'"
					>{{item.name}}</u-checkbox>
				</u-checkbox-group>
			</u-form-item>
			<u-form-item label="T+1到账费率" label-position="top" v-if="isIncludeBOT('00')">
				<view class="clollC">
					<u-collapse :accordion="false" :head-style="{backgroundColor:'#E8E8E8',paddingLeft:'20rpx'}">
						<u-collapse-item  title="微信扫码费率" >
							<view class="feeItme">
								<u-form-item  label="费率（%）" label-width="190" >
									<u-input type="text" v-model="applyInfo.signInfo.codeScanT1Fee.wxPayFee.rateFee" :placeholder-style="placeholderStyle"></u-input>
								</u-form-item>
								<u-form-item  label="最低收费（分）" label-width="210">
									<u-input type="text"  v-model="applyInfo.signInfo.codeScanT1Fee.wxPayFee.rateBottom" :placeholder-style="placeholderStyle"></u-input>
								</u-form-item>
							</view>
						</u-collapse-item>
						<u-collapse-item  title="支付宝扫码费率">
							<view class="feeItme">
								<u-form-item  label="费率（%）" label-width="210">
									<u-input  type="text" v-model="applyInfo.signInfo.codeScanT1Fee.aliPayFee.rateFee" :placeholder-style="placeholderStyle"></u-input>
								</u-form-item>
								<u-form-item  label="最低收费（分）" label-width="210">
									<u-input  type="text" v-model="applyInfo.signInfo.codeScanT1Fee.aliPayFee.rateBottom" :placeholder-style="placeholderStyle"></u-input>
								</u-form-item>
							</view>
						</u-collapse-item>
						
						<u-collapse-item  title="银联一档借记卡扫码费率">
							<view class="feeItme">
								<u-form-item  label="费率（%）" label-width="210">
									<u-input  type="text" v-model="applyInfo.signInfo.codeScanT1Fee.bank1debitPayFee.rateFee" :placeholder-style="placeholderStyle"></u-input>
								</u-form-item>
								<u-form-item  label="最低收费（分）" label-width="210">
									<u-input  type="text" v-model="applyInfo.signInfo.codeScanT1Fee.bank1debitPayFee.rateBottom" :placeholder-style="placeholderStyle"></u-input>
								</u-form-item>
								<u-form-item  label="最高收费（分）" label-width="210">
									<u-input  type="text" v-model="applyInfo.signInfo.codeScanT1Fee.bank1debitPayFee.rateTop" :placeholder-style="placeholderStyle"></u-input>
								</u-form-item>
							</view>
						</u-collapse-item>
						
						<u-collapse-item  title="银联一档贷记卡扫码费率">
							<view class="feeItme">
								<u-form-item  label="费率（%）" label-width="210">
									<u-input  type="text" v-model="applyInfo.signInfo.codeScanT1Fee.bank1creditPayFee.rateFee" :placeholder-style="placeholderStyle"></u-input>
								</u-form-item>
								<u-form-item  label="最低收费（分）" label-width="210">
									<u-input  type="text" v-model="applyInfo.signInfo.codeScanT1Fee.bank1creditPayFee.rateBottom" :placeholder-style="placeholderStyle"></u-input>
								</u-form-item>
							</view>
						</u-collapse-item>
						
						<u-collapse-item  title="银联二档借记卡扫码费率">
							<view class="feeItme">
								<u-form-item  label="费率（%）" label-width="210">
									<u-input  type="text" v-model="applyInfo.signInfo.codeScanT1Fee.bank2debitPayFee.rateFee" :placeholder-style="placeholderStyle"></u-input>
								</u-form-item>
								<u-form-item  label="最低收费（分）" label-width="210">
									<u-input  type="text" v-model="applyInfo.signInfo.codeScanT1Fee.bank2debitPayFee.rateBottom" :placeholder-style="placeholderStyle"></u-input>
								</u-form-item>
								<u-form-item  label="最高收费（分）" label-width="210">
									<u-input  type="text" v-model="applyInfo.signInfo.codeScanT1Fee.bank2debitPayFee.rateTop" :placeholder-style="placeholderStyle"></u-input>
								</u-form-item>
							</view>
						</u-collapse-item>
						
						<u-collapse-item  title="银联二档贷记卡扫码费率">
							<view class="feeItme">
								<u-form-item  label="费率（%）" label-width="210">
									<u-input  type="text" v-model="applyInfo.signInfo.codeScanT1Fee.bank2creditPayFee.rateFee" :placeholder-style="placeholderStyle"></u-input>
								</u-form-item>
								<u-form-item  label="最低收费（分）" label-width="210">
									<u-input  type="text" v-model="applyInfo.signInfo.codeScanT1Fee.bank2creditPayFee.rateBottom" :placeholder-style="placeholderStyle"></u-input>
								</u-form-item>
							</view>
						</u-collapse-item>
					</u-collapse>
				</view>
			</u-form-item> -->
			<!-- 		<u-form-item label="D+1到账费率" label-position="top" v-if="isIncludeBOT('20')">
				<view class="clollC">
					<u-form-item  label="收费方式" label-width="210">
						<u-radio-group v-model="applyInfo.signInfo.d1Fee.rateType" shape="square">
							<u-radio name="0">百分比</u-radio>
							<u-radio name="1">固定金额</u-radio>
						</u-radio-group>
					</u-form-item>
					<u-form-item :label="d1FeeLabel" label-width="210">
						<u-input  type="text" v-model="applyInfo.signInfo.d1Fee.rateFee" :placeholder-style="placeholderStyle"></u-input>
					</u-form-item>
					<u-form-item  v-if="siBF" label="最低收费（分）" label-width="210">
						<u-input  type="text" v-model="applyInfo.signInfo.d1Fee.rateBottom" :placeholder-style="placeholderStyle"></u-input>
					</u-form-item>

				</view>
			</u-form-item > -->
		
			<!-- <u-form-item  label="发送签约短信" label-width="190" >
				<u-switch v-model="isSendMsg" active-value="1" inactive-value="3"></u-switch>
			</u-form-item> -->
			
			<!-- 	<u-form-item  label="渠道抽成利率(%)" label-width="250" prop="merchRate">
				<u--input   v-model="applyInfo.merch_rate" type="text" :placeholder-style="placeholderStyle"></u--input>
			</u-form-item> -->
		</u--form>
		<!-- 协议 -->
		<view class="agreement">
			<view class="agreement-text">
				<u-checkbox-group size='35' iconSize='25'  v-model="check_agreement" placement="column" @change="check_agreement_Change">
					<u-checkbox :customStyle="{marginBottom: '8px'}" v-for="(item, index) in checkboxList1" :key="index"
						:label="item.name" :name="item.name" labelSize='30'>
					</u-checkbox>
				</u-checkbox-group>
				<u-tag v-for="(value,index) in agreement_list" :text="value.title+'、'" :index=index
					border-color="#ffffff" mode="plain" :show="!agreement_show" @click="agreement_Click" />
			</view>
		</view>
		<!-- 签名 -->
		<view v-show="show_sign">
			<view>商户签名</view>
			<signInput ref="sign" canvasId="oneDrowCanvas" canvasIds="oneRotateCanvas" :header="{}"
				:action="post_url+ 'upload_file'" @signToUrl="merchSign"></signInput>
			<view>经理签名</view>
			<signInput ref="sign" canvasId="twoDrowCanvas" canvasIds="twoRotateCanvas" :header="{}"
				:action="post_url+ 'upload_file'" @signToUrl="managerSign"></signInput>
		</view>
		<!-- 协议内容 -->
		<u-popup v-model="agreement_show" mode="center" width="100%" height="100%" :closeable="true"
			close-icon-color="#FF0000">
			<u-parse :html="agreement_content" class="u-padding-20"></u-parse>
		</u-popup>
		<!-- 提交 -->
		<u-button class="subBtn" type="primary" v-if="isSig" @click="toSign">去签约</u-button>
		<u-button class="subBtn" v-else @click="applySubmit">提交</u-button>


	</view>
</template>

<script>
	import ysDict from '@/pages/index/dictDatas.js'
	import signInput from "@/pages/index/am-sign-input.vue"
	import {
		get_agreement,
		uploadInfoToYs,
		modifyInfoToYs,
		uploadImgsToYs,
		auditInfoToYs,
		signToYs
	} from '@/utils/api.js'
	export default {
		components: {
			signInput
		},
		data() {
			return {
				checkboxList1: [{
					name: '代表同意',
					disabled: false
				}],
				title: '商户类型',
				show: false, //商户类型
				isSig: false,
				isSaveInfo: false,
				ysDict: [],
				busOpenTypes: [],
				seledBusOpenTypes: ["00"],
				crpTypeshow: false,
				busCertTypeShow: false,
				busDisabled: true,
				stlAccTypeShow: false,
				standByStlAccTypeShow: false,
				check_agreement: [],
				show_sign: false, //显示签名
				agreement_list: [],
				d1FeeLabel: '费率（%）',
				applyInfo: {
					channelName: '', //进件渠道名
					channelType: '', //进件渠道值
					merch_rate: '0.25',
					//基本信息
					custInfo: {
						mercName: '', //商户名称
						mercShortName: '', //商户简称,默认为商户名称
						mercType: '', //商户类型
						mccStr: '', //所属行业类型
						mccCd: '', //mcc码
						contactMail: '', //联系人邮箱
						cusMgrNm: '', //客户经理，推广人姓名？
						cusMgrID: '',
						notifyUrl: '', //异步地址
						agtMercId: "8014520000032X1", //代理商编号
					},
					//法人信息
					crpInfo: {
						crpCertNo: '', //法人证件号
						crpCertType: '00', //法人证件类型,00：身份证   06：国外护照 07：港澳通行证 08：台胞通行证
						crpCertTypeStr: '身份证',
						certBgn: '', //证件开始日期,证件开始日期yyyyMMdd
						certExpire: '', //证件有效期,日期格式yyyyMMdd ，如果为长期或者永久，请填值“29991231”
						crpNm: '', //法人姓名
						crpPhone: '' //法人手机号
					},
					//结算信息
					stlAccInfo: {
						isUncrpSett: '', //是否非法人结算,Y是 N否，默认否
						stlAccNm: '', //结算户名
						stlAccNo: '', //结算账号
						bankSubCode: '', //开户支行联行号
						bankSubStr: '', //开户支行
						stlAccType: '', //结算账户类型,11 对私 21 对公 23 对公存折 24 单位结算卡
						stlAccTypeStr: '',
						bankMobile: '', //银行预留手机号,非法人结算必填
						openCertNo: '', //开开户证件号,非法人结算必填
						standByStlAccNo: '', //备用结算账号
						standByStlAccNm: '', //备用结算户名
						standByBankSubStr: '', //备用结算账户开户支行

					},
					//营业信息
					busInfo: {
						busNo: '', //营业执照号
						busNm: '', //营业执照名称
						busCertBgn: '', //营业执照有效开始日期,非小微必填
						busCertExpire: '', //营业执照有效期,非小微必填 
						busCertDateStr: '', //busCertBgn + busCertDateStr
						busProviceCode: '', //营业归属省代码
						busCityCode: '', //营业归属市代码
						busAreaCode: '', //营业归属区(县)代码
						busAdrStr: '', //busProviceCode+busCityCode+busAreaCode
						busCertType: '', //营业执照证件类型,非小微商户必填 
						busAddr: '', //营业详细地址
						trueAddr: '', //真是店铺地址
					},
					imgPaths: { //图片地址
						A002: ''
					},
					signInfo: {
						busOpenType: '00', //到账方式 00扫码工作日到账（T+1），01扫码实时到账，20 D+1到账,多选用“|”分隔
						contractType: '2', //电子合同
						isSendConMsg: '3', //是否发送签约短信 1发，3不发
						notifyUrl: '', //异步通知接口，后天添加
						codeScanT1Fee: { //扫码工作日到账费率 00
							wxPayFee: {
								rateType: '0'
							},
							aliPayFee: {
								rateType: '0'
							},
							bank1debitPayFee: {
								rateType: '0'
							},
							bank1creditPayFee: {
								rateType: '0'
							},
							bank2debitPayFee: {
								rateType: '0'
							},
							bank2creditPayFee: {
								rateType: '0'
							}

						},
						codeScanD0Fee: { //扫码实时到账垫资费 01
							rateType: '0',
						},
						d1Fee: { //天天到账垫资费 20
							rateType: '0',
						},
					},
					payDeviceNo: '', //机器条码
					appChannelType: '1'
				},

				isCrpSett: true, //是否法人结算
				isShowCrpSett: false,
				mccQueryMercType: '',
				busCertTypes: [],
				post_url: "",
				idcard_front: {
					'type': 'idcard',
					'id_card_side': 'front'
				}, //身份证正面
				idcard_back: {
					'type': 'idcard',
					'id_card_side': 'back'
				}, //身份证反面
				license_copy: {
					'type': 'business_license'
				}, //营业执照
				merch_sign: '', //商家签名图片
				manager_sign: '', //经理签名图片
				agreement_content: '', //协议内容
				agreement_show: false, //显示协议内容
				isSendMsg: false, //是否发送签约短信
				sigUrl: '',
				// rules:{
				// 	mccStr:[
				// 		{
				// 			required:true,
				// 			message:'请选择所属行业类型',
				// 			trigger: 'blur'
				// 		}
				// 	],
				// 	payDeviceNo:[
				// 		{
				// 			required:true,
				// 			message:'请填写机器条码',
				// 			trigger: ['blur', 'change']
				// 		}
				// 	],
				// 	mercName:[
				// 		{
				// 			required:true,
				// 			message:'请填写商户名称',
				// 			trigger: ['blur', 'change']
				// 		}
				// 	],
				// 	mercShortName:[
				// 		{
				// 			required:true,
				// 			message:'请填写商户简称',
				// 			trigger: ['blur', 'change']
				// 		}
				// 	]
				// },
				errorType: ['toast', 'border-bottom'],
				mercNameFormat: '',
				placeholderStyle: 'font-size:22rpx;color:#c0c4cc;'
			}
		},

		onLoad(options) {
			console.log("21321323423423", options);
			this.applyInfo.channelType = options.ctype
			this.applyInfo.channelName = options.cname
			this.post_url = getApp().globalData.baidu_sdk_url
			this.ysDict = ysDict
			this.busOpenTypes = ysDict.busOpenTypes()
			//获取协议
			// this.get_agreement()
			//
			var curUser = uni.getStorageSync('user_info')
			this.applyInfo.custInfo.cusMgrID = curUser.id
			this.applyInfo.custInfo.cusMgrNm = curUser.realname
			if (typeof options.applyInfo != 'undefined' && options.applyInfo != null) {
				this.applyInfo = JSON.parse(options.applyInfo)
				console.log(this.applyInfo)
			}
		},

		onReady() {
			// this.$refs.uForm.setRules(this.rules);
		},

		onBackPress(options) {
			// console.log(options)
			// if(this.isSaveInfo){
			// 	uni.showModal({
			// 		title:"提示",
			// 		content:"是否保存填写的信息",
			// 		success:function(res){
			// 			if(res.confirm){
			// 				console.log("调用保存接口")
			// 				return false
			// 			}else if(res.cancel){
			// 				return false
			// 			}
			// 		}
			// 	})
			// }else{
			// 	return false
			// }
			// return true

		},

		computed: {

			//法人证件上传地址
			crpAction() {
				//证件类型
				let crpCertType = this.applyInfo.crpInfo.crpCertType
				return crpCertType === '00' ? this.post_url + 'orc' : this.post_url + 'upload_file'
			},

			//营业证件上传地址
			busAction() {
				let mercType = this.applyInfo.custInfo.mercType
				let busCerType = this.applyInfo.busInfo.busCertType
				return mercType === '2' ? this.post_url + "iocr" : (busCerType === "z4" ? this.post_url + "upload_file" :
					this.post_url + 'orc')
			},

			//D+1收费方式按照%时显示最低收费
			siBF() {
				return this.applyInfo.signInfo.d1Fee.rateType === "0"
			},

			//是否包含某个到账时间
			isIncludeBOT() {
				return v => {
					return this.seledBusOpenTypes.includes(v)
				}
			},

		},

		watch: {
			//监听证件类型
			'applyInfo.crpInfo.crpCertType': function() {
				//更改证件类型后清空图片
				this.$refs.crpFront.clear()
				this.$refs.crpBack.clear()
			},

			//监听商户类型
			'applyInfo.custInfo.mercType': {
				handler: function(n, o) {
					//小微个体企业
					if (["2", "3", "4"].includes(n)) {
						this.applyInfo.busInfo.busCertTypeStr = "社会统一信用代码"
						this.applyInfo.busInfo.busCertType = "19"
						this.busDisabled = true
					}
					//事业单位
					if (n === "6") {
						this.applyInfo.busInfo.busCertTypeStr = "事业单位法人证书"
						this.applyInfo.busInfo.busCertType = "z2"
						this.busDisabled = true
					}

					//政府机关
					if (n === "7") {
						this.busCertTypes = [{
								name: '事业单位法人证书',
								value: 'z2'
							},
							{
								name: '其他证明文件',
								value: 'z4'
							}
						]
						this.busDisabled = false
					}

					//社会组织
					if (n === "5") {
						this.busCertTypes = [{
								name: '民办非企业单位登记证书',
								value: 'z5'
							},
							{
								name: '基金会法人登记证书',
								value: 'z6'
							},
							{
								name: '其他证明文件',
								value: 'z4'
							}
						]
						this.busDisabled = false
					}

					n === "2" ? this.mercNameFormat = '格式：城市+门头名称 或 城市+法人姓名+主营' : this.mercNameFormat = '请输入内容'
					//处理查询mcc时的参数,商户类型,2 小微 3个体 4企业 5 社会组织 6 事业单位 7 政府机关
					//商户类型,1-个体工商户 2-企业 3-小微 5-社会组织  6-事业单位 7-政府机关，mcc码和商户类型不能全部为空。

					switch (n) {
						case "2":
							this.mccQueryMercType = "3"
							break;
						case "3":
							this.mccQueryMercType = "1"
							break;
						case "4":
							this.mccQueryMercType = "2"
							break;
						default:
							this.mccQueryMercType = n
							break;
					}



				},
				immediate: true

			},


			//监听法人结算值
			isCrpSett: {
				handler: function(n, o) {
					console.log(n)
					this.applyInfo.stlAccInfo.isUncrpSett = n ? 'N' : 'Y'
					this.isShowCrpSett = !n
				},
				immediate: true
			},

			'applyInfo.signInfo.d1Fee.rateType': {
				handler: function(n, o) {
					this.d1FeeLabel = n === '0' ? '费率（%）' : '费率（分）'
				},
				immediate: true
			},

			isSendMsg: {
				handler: function(n, o) {
					this.applyInfo.signInfo.isSendConMsg = n ? '1' : '3'
				}
			}

		},

		methods: {
			uinp() {
				this.show = true
			},
			close() {
				this.show = false
			},
			select(e) {
				console.log('select', e);
				this.applyInfo.custInfo.mercType = e.name
				this.close()
			},
			//查询mcc
			toQueryMcc() {
				var that = this
				this.$u.route('pages/applyment/sel-mccd/sel-mccd', {
					merchType: this.mccQueryMercType
				});
				uni.$once("queryMcc", function(data) {
					that.applyInfo.custInfo.mccCd = data.mccCd
					that.applyInfo.custInfo.mccStr = data.mercClsNm
				})
			},

			//上传商户照片
			mercImgCopy(e, key) {
				var result = JSON.parse(e.data)
				if (result.code != 200) {
					this.$u.toast(result.msg)
					return
				}
				this.applyInfo.imgPaths[key] = result.data.img_path
			},

			//选择证件类型
			crpTypeConfirm(e) {
				this.applyInfo.crpInfo.crpCertType = e[0].value
				this.applyInfo.crpInfo.crpCertTypeStr = e[0].label
			},

			//选择营业额执照类型
			busCertTypeConfirm(e) {
				this.applyInfo.busInfo.busCertType = e[0].value
				this.applyInfo.busInfo.busCertTypeStr = e[0].label
			},

			//识别证件正面
			crp_front(e) {
				var result = JSON.parse(e.data)
				console.log(result)
				if (result.code === "200") {
					if (this.applyInfo.crpInfo.crpCertType === "00") {
						this.applyInfo.crpInfo.crpNm = result.data.name
						this.applyInfo.crpInfo.crpCertNo = result.data.id_card
						this.applyInfo.crpInfo.crpSex = result.data.sex
						//证件类型为身份证时，上传身份证正面图片地址
						this.applyInfo.imgPaths.A002 = result.data.img_path
						return
					}
					//非身份证正面图片地址
					this.applyInfo.imgPaths.A013 = result.data.img_path
				} else {
					this.$u.toast(result.msg)
				}
			},

			//识别证件反面
			crp_back(e) {
				var result = JSON.parse(e.data)
				console.log(result)
				if (result.code === "200") {
					if (this.applyInfo.crpInfo.crpCertType === "00") {
						this.applyInfo.crpInfo.certBgn = result.data.start_date.replace(/-/g, '')
						this.applyInfo.crpInfo.certExpire = result.data.end_date.replace(/-/g, '')
						this.applyInfo.imgPaths.A003 = result.data.img_path
						return
					}
					this.applyInfo.imgPaths.A014 = result.data.img_path
				} else {
					this.$u.toast(result.msg)
				}
			},

			//识别营业执照
			flicense_copy(e) {
				var result = JSON.parse(e.data)
				console.log(result)
				if (result.code != 200) {
					this.$u.toast(result.msg)
					return
				}
				//可以提交的时候判断
				// if(this.applyInfo.crpInfo.crpNm!=result.data.contact_name){
				// 	this.$u.toast("法人身份证和营业执照法人名称不一致")
				// 	return
				// }
				let {
					merch_name,
					license_address,
					license_number,
					period_begin,
					period_end,
					img_path,
					business_scope
				} = result.data
				this.applyInfo.busInfo.busNo = license_number
				this.applyInfo.busInfo.busNm = merch_name
				this.applyInfo.busInfo.busAddr = license_address
				this.applyInfo.busInfo.busCertBgn = period_begin.replace(/-/g, '')
				this.applyInfo.busInfo.busCertExpire = this.$util.isDate(period_end) ? period_end.replace(/-/g, '') :
					'29991231'
				this.applyInfo.busInfo.busCertDateStr = period_begin + "-" + period_end
				//个营业营业执照类型对一个的图片key
				let addr = {
					'19': 'A001',
					'z2': 'A015',
					'z4': 'A016',
					'z5': 'A017',
					'z6': 'A018',
				}
				//处理图片地址
				let busCerType = this.applyInfo.busInfo.busCertType
				this.applyInfo.imgPaths[addr[busCerType]] = img_path

			},

			//识别结算账户正面
			fbank_copy(e) {

				var result = JSON.parse(e.data)
				console.log(result)
				if (result.code !== "200") {
					this.$u.toast(result.msg)
					return
				}
				const {
					bank_card_number,
					img_path
				} = result.data
				this.applyInfo.stlAccInfo.stlAccNo = this.$u.trim(bank_card_number, 'all')
				this.applyInfo.imgPaths.A004 = img_path
			},

			//识别结算账户反面
			bbank_copy(e) {

				var result = JSON.parse(e.data)
				console.log(result)
				if (result.code !== "200") {
					this.$u.toast(result.msg)
					return
				}
				const {
					img_path
				} = result.data
				this.applyInfo.imgPaths.A005 = img_path
				console.log("------=")
			},

			//识别备用结算账户正面
			fbank_copy_stand(e) {

				var result = JSON.parse(e.data)
				console.log(result)
				if (result.code !== "200") {
					this.$u.toast(result.msg)
					return
				}
				const {
					bank_card_number,
					img_path
				} = result.data
				this.applyInfo.stlAccInfo.standByStlAccNo = this.$u.trim(bank_card_number, 'all')
				this.applyInfo.imgPaths.A0041 = img_path
			},

			//打开选择营业执照类型面板
			busCertTypeClick() {
				if (this.busDisabled) {
					return
				}
				this.busCertTypeShow = true
			},

			//打开地址选择页面
			toSelAdr() {
				var that = this
				this.$u.route('pages/applyment/sel-city/sel-city')
				uni.$once("queryAreas", function(data) {
					console.log(data)
					if (JSON.stringify(data) !== "{}") {
						that.applyInfo.busInfo.busProviceCode = data.provice.cityCd
						that.applyInfo.busInfo.busCityCode = data.city.cityCd
						that.applyInfo.busInfo.busAreaCode = data.area.cityCd
						that.applyInfo.busInfo.busAdrStr = (data.provice.cityNm) + (data.city.cityNm) + (data.area
							.cityNm)
					}

				})
			},

			//打开开户行选择页面
			toSelBank(type) {
				var that = this
				this.$u.route('pages/applyment/sel-bank/sel-bank');
				uni.$once("querBank", function(data) {
					if (type === 0) {
						that.applyInfo.stlAccInfo.bankSubStr = data.bankName
						that.applyInfo.stlAccInfo.bankSubCode = data.bankCode
					} else if (type === 1) {
						that.applyInfo.stlAccInfo.standByBankSubStr = data.bankName
						that.applyInfo.stlAccInfo.standByBankSubCode = data.bankCode
						that.applyInfo.stlAccInfo.standByBankProvince = data.provinceCode
						that.applyInfo.stlAccInfo.standByBankCity = data.cityCode
						console.log(that.applyInfo.stlAccInfo)
					}
				})
			},

			//结算账户类型选择
			stlAccTypeConfirm(e) {
				this.applyInfo.stlAccInfo.stlAccType = e[0].value
				this.applyInfo.stlAccInfo.stlAccTypeStr = e[0].label
			},

			//备用结算账户类型选择
			stabdByStlAccTypeConfirm(e) {
				this.applyInfo.stlAccInfo.standByStlAccType = e[0].value
				this.applyInfo.stlAccInfo.standByStlAccTypeStr = e[0].label
			},

			//到账时间选择
			busOpenTypeChange(e) {
				this.seledBusOpenTypes = e
				this.applyInfo.signInfo.busOpenType = e.join('|')
			},

			//扫设备码
			scancodeDevice(e) {
				let that = this;
				// 只允许通过相机扫码
				uni.scanCode({
					onlyFromCamera: true,
					success: function(res) {
						console.log('条码类型：' + res.scanType);
						console.log('条码内容：' + res.result);
						that.applyInfo.payDeviceNo = res.result
					}
				});
			},

			//获取协议
			get_agreement() {
				get_agreement().then(res => {
					if (res.code === "200") {
						var res_list = res.data

						for (var i = 0; i < res_list.length; i++) {

							res_list[i].content = res_list[i].content.replace(/seal/g,
								"<img src='static/gongzhang.png' width='100px' />");
							res_list[i].content = res_list[i].content.replace(/legal/g,
								"<img src='static/legal.png' width='100px' />");
						}
						this.agreement_list = res_list
					}
				})
			},

			// 勾选版权协议
			check_agreement_Change(e) {
				if (e.length > 0) {
					this.applyInfo.agreement = true;
					this.show_sign = true
				} else {
					this.show_sign = false
				}
			},

			//查看协议
			agreement_Click(index) {
				this.agreement_content = this.agreement_list[index].content
				this.agreement_show = true
			},

			//商户签名
			merchSign(e) {
				if (e.statusCode === 200) {
					var result = JSON.parse(e.data);
					this.merch_sign = "data:image/png;base64," + result.data.img_base64
				} else {
					this.$u.toast("签名异常 请联系管理处理")
				}
			},

			//经理签名
			managerSign(e) {
				if (e.statusCode === 200) {
					var result = JSON.parse(e.data);
					this.manager_sign = "data:image/png;base64," + result.data.img_base64
				} else {
					this.$u.toast("签名异常 请联系管理处理")
				}
			},

			//提交进件资料
			applySubmit() {
				//校验表单
				this.$refs.uForm.validate(valid => {
					if (valid) {
						let _this = this
						//上传资料到银盛
						var apiName = _this.isSaveInfo ? modifyInfoToYs : uploadInfoToYs
						uni.showLoading({
							title: '正在处理数据',
							mask: true
						})

						//测试参数
						this.applyInfo = this.ysDict.params()
						console.log(this.applyInfo)
						//return
						apiName(this.applyInfo).then(res => {
							if (res.code !== 200) {
								uni.hideLoading()
								_this.$u.toast(res.msg)
								return
							}
							var sysFlowId = res.data.sysFlowId
							//赋值入网流水号，共修改时使用
							_this.applyInfo.sysFlowId = sysFlowId
							//上传成功，进行图片上传
							uploadImgsToYs({
								imgPaths: _this.applyInfo.imgPaths,
								sysFlowId: sysFlowId
							}).then(re => {
								if (re.code == 200) {
									setTimeout(function() {
										//资料确认
										auditInfoToYs({
											auditFlag: "Y",
											sysFlowId: sysFlowId
										}).then(r => {
											if (r.code !== 200) {
												uni.hideLoading()
												_this.$u.toast(r.msg)
												return
											}
											//审核通过后保存到数据库，后续修改修改信息则是条用修改接口
											//_this.isSaveInfo = true		
											let custId = r.data.custId
											//进行签约
											let params = _this.applyInfo.signInfo
											params.custId = custId
											signToYs(params).then(result => {
												if (result.code !== 200) {
													_this.$u.toast(r.msg)
													return
												}
												console.log(result)
												_this.sigUrl = result.data
													.signUrl
												uni.showToast({
													title: "签约申请成功"
												})
												_this.isSig = true

											})
										})

									}, 3000)

								} else {
									uni.hideLoading()
								}
							})

						})
					}
				});
			},

			//签约页面跳转
			toSign() {
				this.$u.route({
					url: '/pages/applyment/ys/sign?sigUrl=' + this.sigUrl,
				})
			},

			toJSON() {}

		}
	}
</script>

<style lang="scss" scoped>
	.wrap {
		padding: 0 30rpx 30rpx;

		.u-size-default {
			padding: 0rpx
		}

		.signature .inputs .explain {
			width: 200rpx;
		}

		.button-line {
			transform: rotate(90deg);
			position: fixed;
			bottom: 170rpx;
			left: -100rpx;
			width: 340rpx;
			height: 50rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			z-index: 999;
		}
	}

	.agreement {
		display: flex;
		align-items: center;
		margin: 40rpx 0;

		.agreement-text {
			padding-left: 8rpx;
			color: $u-tips-color;
		}
	}

	.subBtn {
		margin-top: 30rpx;
	}

	.clollC {
		padding-left: 20rpx;
		width: 630rpx;
	}

	.feeItme {
		padding-left: 30rpx;
	}
</style>