<template>
	<view>
		<view class="width100 mart10 backcorfff">
			<view class="username">
				<view class="namecont">负责人名称</view>
				<input placeholder="请输入负责人名称" v-model="dutyPeopleName" style="width: 70%;"
					placeholder-style="color: #bfbfbf;font-size:14px;padding-top:2px;" />
			</view>
			<view class="username">
				<view class="namecont">负责人电话</view>
				<input placeholder="请输入负责人电话" v-model="dutyPeoplePhone" style="width: 70%;"
					placeholder-style="color: #bfbfbf;font-size:14px;padding-top:2px;" />
			</view>
			<view class="username">
				<view class="namecont">负责人邮箱</view>
				<input placeholder="请输入负责人邮箱" v-model="dutyPeopleEmail" style="width: 70%;"
					placeholder-style="color: #bfbfbf;font-size:14px;padding-top:2px;" />
			</view>

			<view class="username">
				<view class="namecont">门店账号</view>
				<input placeholder="请输入门店账号" v-model="storeaccount" style="width: 70%;"
					placeholder-style="color: #bfbfbf;font-size:14px;padding-top:2px;" />
			</view>
			<view class="username">
				<view class="namecont">门店名称</view>
				<input placeholder="请输入门店名称" v-model="storename" style="width: 70%;"
					placeholder-style="color: #bfbfbf;font-size:14px;padding-top:2px;" />
			</view>
			<view class="username">
				<view class="namecont">门店电话</view>
				<input placeholder="请输入门店电话" v-model="storephone" style="width: 70%;"
					placeholder-style="color: #bfbfbf;font-size:14px;padding-top:2px;" />
			</view>
			<view class="username" @click="showjob()">
				<view class="namecont">行业类目</view>
				<input placeholder="请选择类目" v-model="industrycategory" style="width: 70%;" :disabled="true"
					 placeholder-style="color: #bfbfbf;font-size:14px;padding-top:2px;" />
				<image src="../../../static/img/jtg.png" mode="widthFix" class="iconw"></image>
			</view>
			<view class="username">
				<view class="namecont">经营地区</view>
				<pickRegions :defaultRegion="defaultRegionCode" class="width70" @getRegion="handleGetRegion">
					<view style="color: #333333;font-size:14px;padding-top:2px;" v-if="regionName">
						{{regionName}}
					</view>
					<view style="color: #bfbfbf;font-size:14px;padding-top:2px;" v-else>请选择经营地区</view>
				</pickRegions>
				<image src="../../../static/img/jtg.png" mode="widthFix" class="iconw"></image>
			</view>
			<view class="username">
				<view class="namecont">详情地址</view>
				<input placeholder="请精确到XX路XX号" v-model="detailsaddress" style="width: 70%;"
					placeholder-style="color: #bfbfbf;font-size:14px;padding-top:2px;" />
			</view>

			<view class="notes font16" style="border-bottom: 0px;">
				<view class="width70 aliitem fcor666">
					门店照片
				</view>
			</view>
			<view class="width94 displ mart5">
				<image :src="storeimg1" v-if="storeimg1" mode="widthFix" class="width45" style="margin-left: 3%;"
					@click="upload(6)"></image>
				<image src="../../../static/img/store/store1.png" v-else mode="widthFix" class="width45"
					style="margin-left: 3%;" @click="upload(6)"></image>
				<image src="../../../static/img/store/store2.png" mode="widthFix" class="width45"
					@click="perImage('../../../static/img/store/store2.png')" style="margin-left: 3%;"></image>
			</view>

			<view class="width94 displ mart5">
				<image :src="storeimg2" v-if="storeimg2" mode="widthFix" class="width45" style="margin-left: 3%;"
					@click="upload(7)"></image>
				<image src="../../../static/img/store/store3.png" v-else mode="widthFix" class="width45"
					style="margin-left: 3%;" @click="upload(7)"></image>
				<image src="../../../static/img/store/store4.png" mode="widthFix" class="width45"
					@click="perImage('../../../static/img/store/store4.png')" style="margin-left: 3%;"></image>
			</view>

			<view class="width94 displ mart5 marb15">
				<image :src="storeimg3" v-if="storeimg3" mode="widthFix" class="width45" style="margin-left: 3%;"
					@click="upload(8)"></image>
				<image src="../../../static/img/store/store5.png" v-else mode="widthFix" class="width45"
					style="margin-left: 3%;" @click="upload(8)"></image>
				<image src="../../../static/img/store/store6.png" mode="widthFix" class="width45"
					@click="perImage('../../../static/img/store/store6.png')" style="margin-left: 3%;"></image>
			</view>
		</view>

		<view class="username" style="border-bottom: 0px;">
			<view class="namecont" style="width: 40%;">是否单独结算</view>
			<view class="width30 aliitem" @tap="aloneSettle='0'">
				<radio class="checbox" :checked="aloneSettle=='0'" color="#0083f5" /> 否
			</view>
			<view class="width30 aliitem" @tap="aloneSettle='1'">
				<radio class="checbox" :checked="aloneSettle=='1'" color="#0083f5" /> 是
			</view>
		</view>
		<view class="width100 mart10 backcorfff" v-if="aloneSettle == 1">
			<view class="titlename font18 fontwig6 fcor333">营业执照</view>
			<view class="width94 displ">
				<image :src="businimg" v-if="businimg" mode="widthFix" class="width45" style="margin-left: 3%;"
					@click="upload(1)"></image>
				<image src="../../../static/img/businesslic.png" v-else mode="widthFix" class="width45"
					style="margin-left: 3%;" @click="upload(1)"></image>
				<image src="../../../static/img/businesslic1.png" mode="widthFix" class="width45"
					style="margin-left: 3%;" @click="perImage('../../../static/img/businesslic1.png')"></image>
			</view>
			<view class="username" style="border-bottom: 0px;">
				<view class="namecont">公司名称</view>
				<input placeholder="请输入营业执照上的名称" v-model="companyname" style="width: 70%;"
					placeholder-style="color: #bfbfbf;font-size:14px;padding-top:2px;" />
			</view>
			<view class="notes font13" style="color: #eb5823;border-bottom: 1px solid #f6f6f6;">
				<image mode="widthFix" class="iconw" src="../../../static/img/gth.png"></image> 公司名称应与营业执照一致
			</view>
			<view class="username">
				<view class="namecont">营业执照号</view>
				<input placeholder="请输入营业执照号" v-model="businnum" style="width: 70%;"
					placeholder-style="color: #bfbfbf;font-size:14px;padding-top:2px;" />
			</view>
			<view class="username">
				<view class="namecont">注册地址</view>
				<input placeholder="请输入注册地址" v-model="regaddress" style="width: 70%;"
					placeholder-style="color: #bfbfbf;font-size:14px;padding-top:2px;" />
			</view>
			<view class="username" style="border-bottom: 0px;">
				<view class="namecont">营业期限</view>
				<view class="width30 aliitem" @tap="timetype='1'">
					<radio class="checbox" :checked="timetype == '1'" color="#0083f5" /> 选择时间
				</view>
				<view class="width30 aliitem" @tap="timetype='2'">
					<radio class="checbox" :checked="timetype == '2'" color="#0083f5" /> 长期有效
				</view>
			</view>
			
			<view class="username width80">
				<picker mode="date" class="width40 fotct" :value="start_date" :start="startDate" :end="endDate"
					@change="bindDateChange">
					<view class="date">{{start_date}}</view>
				</picker>
				<view class="width10 fotct">至</view>
				<picker v-if="timetype == '1'" mode="date" class="width40 fotct" :value="end_date" :start="startDate"
					:end="endDate" @change="bindDateChange2">
					<view class="date">{{end_date}}</view>
				</picker>
				<view class="width40 fotct fcor999" v-if="timetype == '2' ">长期有效</view>
			</view>
			<view class="titlename font18 fontwig6 fcor333">法人信息</view>
			<view class="notes font16" style="border-bottom: 0px;">
				<view class="width70 aliitem fcor666">
					证件照片
				</view>
				<view class="fcor666 alijusend width30 font14"
					@click="perImage('../../../static/img/businesslic3.png')">查看示例
					<image mode="widthFix" style="width: 12px;" src="../../../static/img/jtg.png"></image>
				</view>
			</view>
			<view class="width94 displ mart5">
				<image :src="idcardposimg" v-if="idcardposimg" mode="widthFix" class="width45" style="margin-left: 3%;"
					@click="upload(2)"></image>
				<image src='../../../static/img/frontidcard.png' v-else mode="widthFix" class="width45"
					style="margin-left: 3%;" @click="upload(2)"></image>
				<image :src="idcardsideimg" v-if="idcardsideimg" mode="widthFix" class="width45"
					style="margin-left: 3%;" @click="upload(3)"></image>
				<image src="../../../static/img/reverseidcard.png" v-else mode="widthFix" class="width45"
					style="margin-left: 3%;" @click="upload(3)"></image>
			</view>
			<view class="username">
				<view class="namecont">法人姓名</view>
				<input placeholder="请输入法人姓名" v-model="idcardname" style="width: 70%;"
					placeholder-style="color: #bfbfbf;font-size:14px;padding-top:2px;" />
			</view>
			<view class="username">
				<view class="namecont">身份证号</view>
				<input placeholder="请输入身份证号" v-model="idcard" style="width: 70%;"
					placeholder-style="color: #bfbfbf;font-size:14px;padding-top:2px;" />
			</view>
			<view class="username">
				<view class="namecont">身份证地址</view>
				<input placeholder="请输入身份证地址" v-model="larIdCardAddress" style="width: 70%;"
					placeholder-style="color: #bfbfbf;font-size:14px;padding-top:2px;" />
			</view>
			<view class="username" style="border-bottom: 0px;">
				<view class="namecont">有效期</view>
				<view class="width30 aliitem" @tap="idcardtime='1'">
					<radio class="checbox" :checked="idcardtime=='1'" color="#0083f5" /> 选择时间
				</view>
				<view class="width30 aliitem" @tap="idcardtime='2'">
					<radio class="checbox" :checked="idcardtime=='2'" color="#0083f5" /> 长期有效
				</view>
			</view>
			<view class="username width80">
				<picker mode="date" class="width40 fotct" :value="cardstart_date" :start="startDate" :end="endDate"
					@change="bindCardDateChange">
					<view class="date">{{cardstart_date}}</view>
				</picker>
				<view class="width10 fotct">至</view>
				<picker v-if="idcardtime == '1'" mode="date" class="width40 fotct" :value="cardend_date"
					:start="startDate" :end="endDate" @change="bindCardDateChange2">
					<view class="date">{{cardend_date}}</view>
				</picker>
				<view class="width40 fotct fcor999" v-if="idcardtime == '2' ">长期有效</view>
			</view>

			
		

			<view class="titlename font18 fontwig6 fcor333">结算信息</view>
			<view class="username" @click="showPopup()">
				<view class="namecont">结算类型</view>
				<input placeholder="请选择结算类型" v-model="lementType" style="width: 70%;" :disabled="true"
					placeholder-style="color: #bfbfbf;font-size:14px;padding-top:2px;"  />
				<image src="../../../static/img/jtg.png" mode="widthFix" class="iconw"></image>
			</view>
			<view class="notes font16" style="border-bottom: 0px;" v-if="lementId == 3">
				<view class="width70 aliitem fcor666">
					非法人身份证照片
				</view>
				<view class="fcor666 alijusend width30 font14"
					@click="perImage('../../../static/img/businesslic3.png')">查看示例
					<image mode="widthFix" style="width: 12px;" src="../../../static/img/jtg.png"></image>
				</view>
			</view>
			<view class="width94 displ mart5" v-if="lementId == 3">
				<image :src="settleIdCardPortraitImg" v-if="settleIdCardPortraitImg" mode="widthFix" class="width45"
					style="margin-left: 3%;" @click="upload(4)"></image>
				<image src="../../../static/img/frontidcard.png" v-else mode="widthFix" class="width45"
					style="margin-left: 3%;" @click="upload(4)"></image>
				<image :src="settleIdCardNationalEmblemImg" v-if="settleIdCardNationalEmblemImg" mode="widthFix"
					class="width45" style="margin-left: 3%;" @click="upload(5)"></image>
				<image src="../../../static/img/reverseidcard.png" v-else mode="widthFix" class="width45"
					style="margin-left: 3%;" @click="upload(5)"></image>
			</view>
			<view class="username" v-if="lementId == 3">
				<view class="namecont">姓名</view>
				<input placeholder="请输入姓名" v-model="idcardname" style="width: 70%;"
					placeholder-style="color: #bfbfbf;font-size:14px;padding-top:2px;" />
			</view>
			<view class="username" v-if="lementId == 3">
				<view class="namecont">身份证号</view>
				<input placeholder="请输入身份证号" v-model="idcard" style="width: 70%;"
					placeholder-style="color: #bfbfbf;font-size:14px;padding-top:2px;" />
			</view>
			<view class="username" v-if="lementId == 3">
				<view class="namecont">身份证地址</view>
				<input placeholder="请输入身份证地址" v-model="nonlarIdCardAddress" style="width: 70%;"
					placeholder-style="color: #bfbfbf;font-size:14px;padding-top:2px;" />
			</view>
			<view class="username" style="border-bottom: 0px;" v-if="lementId == 3">
				<view class="namecont">有效期</view>
				<view class="width30 aliitem" @tap="settleIdPeriodType='1'">
					<radio class="checbox" :checked="settleIdPeriodType=='1'" color="#0083f5" /> 选择时间
				</view>
				<view class="width30 aliitem" @tap="settleIdPeriodType='2'">
					<radio class="checbox" :checked="settleIdPeriodType=='2'" color="#0083f5" /> 长期有效
				</view>
			</view>
			<view class="username width80" v-if="lementId == 3">
				<picker mode="date" class="width40 fotct" :value="settleIdCardPeriodStart" :start="startDate"
					:end="endDate" @change="bindCardDateChange3">
					<view class="date">{{settleIdCardPeriodStart}}</view>
				</picker>
				<view class="width10 fotct">至</view>
				<picker v-if="settleIdPeriodType == '1'" mode="date" class="width40 fotct"
					:value="settleIdCardPeriodEnd" :start="startDate" :end="endDate" @change="bindCardDateChange4">
					<view class="date">{{settleIdCardPeriodEnd}}</view>
				</picker>
				<view class="width40 fotct fcor999" v-if="settleIdPeriodType == '2' ">长期有效</view>
			</view>
			<view class="username">
				<view class="namecont">银行卡号</view>
				<input placeholder="请输入银行卡号" v-model="bankNo" style="width: 70%;"
					placeholder-style="color: #bfbfbf;font-size:14px;padding-top:2px;" />
			</view>
			<view class="username">
				<view class="namecont">银行卡持有人</view>
				<input placeholder="请输入银行卡持有人" v-model="bankName" style="width: 70%;"
					placeholder-style="color: #bfbfbf;font-size:14px;padding-top:2px;" />
			</view>
			<view class="username">
				<view class="namecont">所属银行</view>
				<input placeholder="请输入所属银行" v-model="belongbank" style="width: 70%;"
					placeholder-style="color: #bfbfbf;font-size:14px;padding-top:2px;" />
			</view>
			<view class="username">
				<view class="namecont">开户行地址</view>
				<pickRegions :defaultRegion="defaultRegionCode" class="width70" @getRegion="handleBankCityCode">
					<view style="color: #333333;font-size:14px;padding-top:2px;" v-if="bankregionName">
						{{bankregionName}}
					</view>
					<view style="color: #bfbfbf;font-size:14px;padding-top:2px;" v-else>请选择开户行地址</view>
				</pickRegions>
				<image src="../../../static/img/jtg.png" mode="widthFix" class="iconw"></image>
			</view>
		</view>
		<view class="btn" @tap="configStore">提交</view>
		<view class="height60"></view>

		<wybPopup ref="popup" type="bottom" width="500" bgColor="#f6f6f6" radius="6" :showCloseIcon="true">
			<!-- 结算类型 -->
			<view class="width100">
				<view class="fotct font18 fontwig6 fcor333 mart10 height30">选择商户类型</view>
				<view class="width92 mart20" @click="changelementtype(1)">
					<view class="wybtc" style="height: 40px;">
						<image src="../../../static/img/wyb4.png" mode="widthFix" class="iconw40"></image>
						<view class="width70 margle10">
							<view class="fcor333 font16">对公结算</view>
						</view>
						<image src="../../../static/img/jtg.png" mode="widthFix" class="iconw margle20"></image>
					</view>
				</view>
				<view class="width92 mart20" @click="changelementtype(2)">
					<view class="wybtc" style="height: 40px;">
						<image src="../../../static/img/wyb4.png" mode="widthFix" class="iconw40"></image>
						<view class="width70 margle10">
							<view class="fcor333 font16">对私法人结算</view>
						</view>
						<image src="../../../static/img/jtg.png" mode="widthFix" class="iconw margle20"></image>
					</view>
				</view>
				<view class="width92 mart20" @click="changelementtype(3)">
					<view class="wybtc" style="height: 40px;">
						<image src="../../../static/img/wyb4.png" mode="widthFix" class="iconw40"></image>
						<view class="width70 margle10">
							<view class="fcor333 font16">对私非法人结算</view>
						</view>
						<image src="../../../static/img/jtg.png" mode="widthFix" class="iconw margle20"></image>
					</view>
				</view>
			</view>
		</wybPopup>
	</view>
</template>

<script>
	import {
		recognizeBusinessLicense,
		configStore,
		getImgSignedUrl,
		recognizeIdCard
	} from '../../../Utils/Api.js';
	import pickRegions from '../../../components/pick-regions/pick-regions.vue';
	import wybPopup from '../../../components/wyb-popup/wyb-popup.vue';
	let app = getApp();
	export default {
		components: {
			pickRegions,
			wybPopup
		},
		data() {
			return {
				reqUrl: app.globalData.url, //请求地址
				dutyPeopleName: '', //"负责人名称",
				dutyPeoplePhone: '', //"负责人电话",
				dutyPeopleEmail: '', //"负责人邮箱"
				imgsUrl: app.globalData.imgUrl, //图片访问地址
				businessLicenselist: [], // 营业执照识别数据
				businimg: '', //营业执照图片
				uploadbusinimg: '', // 上传营业执照
				companyname: '', //公司名称
				businnum: '', // 营业执照号
				regaddress: '', //注册地址
				industrycategory: '', //行业类目
				inducateid: '', //行业id
				detailsaddress: '', // 详情地址 
				timetype: '1', // times:选择时间  longterm: 长期
				start_date: '开始时间', //开始时间
				end_date: '结束时间', //到期时间
				region: [], //选择区域
				areaCode: '', //区级
				defaultRegion: ['北京市', '市辖区', '东城区'], //默认地区
				defaultRegionCode: '110101', //区级编号
				regionName: '',
				storeaccount: '', //门店账号
				idcardposimg: '', //查看证件照正面
				uploadidcardposimg: '', //上传证件照正面
				idcardsideimg: '', //查看证件照反面
				uploadidcardsideimg: '', //上传证件照反面
				idcardname: '', //证件姓名
				idcard: '', //身份证号
				idCardzm: [], //身份证正面
				idCardfm: [], //身份证反面
				larIdCardAddress: '', //身份证地址
				idcardtime: '1', // times:选择时间  longterm: 长期 
				start_date: '开始时间', //开始时间
				end_date: '结束时间', //到期时间
				cardstart_date: '开始时间', // 身份证开始时间
				cardend_date: '结束时间', //身份证结束时间
				storename: '', //门店名称
				storephone: '', //门店电话
				storeimg1: '', //门店图片
				storeimg2: '', //门店图片
				storeimg3: '', //门店图片
				uploadstoreimg1: '', //上传门头图片
				uploadstoreimg2: '', //上传查看收银台图片
				uploadstoreimg3: '', //上传查看室内图片
				aloneSettle: 0, // 是否单独结算
				lementId: '1', //结算id
				lementType: '对公结算', //结算账户类型
				OpenningBankCityCode: '', //开户行地区
				bankNo: '', // 银行卡号
				bankName: '', // 银行卡持有人
				belongbank: '', //所属银行
				bankareaCode: '', //开户行市区编号
				bankregionName: '', //开户行名字
				settleIdCardNationalEmblemImg: '', //非法人私人反面
				uploadsettleIdCardNationalEmblemImg: '', //上传非法人私人反面
				settleIdCardPortraitImg: '', //非法人私人正面 
				uploadsettleIdCardPortraitImg: '', //上传非法人私人正面 
				settleIdCardPeriodStart: '开始时间', // 身份证开始时间
				settleIdCardPeriodEnd: '结束时间', //身份证结束时间
				settleIdPeriodType: '1', // times:选择时间  longterm: 长期
				nonfaidcardname: '', //证件姓名
				nonidcard: '', //身份证号
				nonlarIdCardAddress: '', //身份证地址
				userInfo: app.globalData.userInfo
			}
		},
		computed: {
			//开始时间转化
			startDate() {
				return this.getDate('start');
			},
			//结束时间转化
			endDate() {
				return this.getDate('end');
			},
			//地区转换
			// regionName() {
			// 	// 转为字符串
			// 	this.areaCode = this.region.map(item => item.code)[2];
			// 	return this.region.map(item => item.name).join('-');
			// }
		},
		onShow() {
			if (app.globalData.businessid) {
				this.industrycategory = app.globalData.businessname;
				this.inducateid = app.globalData.businessid;
			}
		},
		methods: {
			//显示商户弹出
			showPopup() {
				this.$refs.popup.show();
			},
			// 选择开始日期
			bindDateChange: function(e) {
				this.start_date = e.target.value;
			},
			// 选择结束日期
			bindDateChange2: function(e) {
				this.end_date = e.target.value;
			},
			// 身份证选择开始日期
			bindCardDateChange: function(e) {
				this.cardstart_date = e.target.value
			},
			// 身份证选择结束日期
			bindCardDateChange2: function(e) {
				this.cardend_date = e.target.value;
			},
			// 非法人身份证选择开始日期
			bindCardDateChange3: function(e) {
				this.settleIdCardPeriodStart = e.target.value
			},
			// 非法人身份证选择结束日期
			bindCardDateChange4: function(e) {
				thissettleIdCardPeriodEnd = e.target.value;
			},
			// 获取当前时间
			getDate(type) {
				const date = new Date();
				let year = date.getFullYear();
				let month = date.getMonth() + 1;
				let day = date.getDate();

				if (type === 'start') {
					year = year - 60;
				} else if (type === 'end') {
					year = year + 2;
				}
				month = month > 9 ? month : '0' + month;
				day = day > 9 ? day : '0' + day;
				return `${year}-${month}-${day}`;
			},
			//选择地区
			handleGetRegion(region) {
				this.region = region;
				this.areaCode = this.region.map(item => item.code)[2];
				this.regionName = this.region.map(item => item.name).join('-');
			},
			//选择开户行
			handleBankCityCode(region) {
				this.region = region;
				this.bankareaCode = this.region.map(item => item.code)[2];
				this.bankregionName = this.region.map(item => item.name).join('-');
			},
			// 放大图片
			perImage(item) {
				uni.previewImage({
					current: 0, //预览图片的下标
					urls: [item] //预览图片的地址，必须要数组形式，如果不是数组形式就转换成数组形式就可以
				})
			},
			//上传图片
			upload(item) {
				let that = this;
				uni.chooseImage({
					count: 1,
					sizeType: ['compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['camera', 'album'],
					success: function(res) {
						const tempFilePaths = res.tempFilePaths;
						that.uploadFile(tempFilePaths[0],item);
					},
					error: function(e) {
						console.log(e);
					},
					complete: function(err) {}
				});
			},

			/**
			 * H5端图片压缩
			 *  参数说明：
			 *  imgSrc 图片url
			 *  scale缩放比例 0-1
			 *  返回base64
			 *  callback 回调设置返回值 
			 */
			translate(imgSrc, scale, callback) {
				var img = new Image();
				img.src = imgSrc;
				img.onload = function() {
					var that = this;
					var h = that.height; // 默认按比例压缩
					var w = that.width;
					var canvas = document.createElement('canvas');
					var ctx = canvas.getContext('2d');
					var width = document.createAttribute("width");
					width.nodeValue = w;
					var height = document.createAttribute("height");
					height.nodeValue = h;
					canvas.setAttributeNode(width);
					canvas.setAttributeNode(height);
					ctx.drawImage(that, 0, 0, w, h);
					var base64 = canvas.toDataURL('image/jpeg', scale); //压缩比例
					canvas = null;
					callback(base64);
				}
			},
			//上传
			uploadFile(item,item1) {
				const that = this
				that.translate(item, 0.2, imgURL => {
					const uploadTask = uni.uploadFile({
						url: that.reqUrl + '/mer/uploadBase64File',
						filePath: imgURL,
						header: {
							"Authorization": app.globalData.token
						},
						name: 'file',
						formData: {
							'merId': that.userInfo.mer.id,
							'base64File': imgURL
						},
						success: function(uploadFileRes) {
							that.getImgSignedUrl(item1, JSON.parse(uploadFileRes.data)
								.return_data);
						}
					});
				})
			},

			//选择结算类型
			changelementtype(item) {
				if (item == 1) {
					this.lementId = 1;
					this.lementType = '对公结算';
				}
				if (item == 2) {
					this.lementId = 2;
					this.lementType = '对私法人结算';
				}
				if (item == 3) {
					this.lementId = 3;
					this.lementType = '对私非法人结算';
				}
				this.$refs.popup.hide();
			},
			//查看临时图片路径
			getImgSignedUrl(item, item1) {
				let that = this;
				let datas = {
					"fileUrl": item1
				}
				getImgSignedUrl(datas).then(res => {
					if (res.return_code == '000000') {

						if (item == 1) {
							that.recognizeBusinessLicense(res.return_data);
							that.uploadbusinimg = item1
						}
						if (item == 2) {
							that.recognizeIdCard(1, res.return_data);
							that.uploadidcardposimg = item1;
						}
						if (item == 3) {
							that.recognizeIdCard(2, res.return_data);
							that.uploadidcardsideimg = item1;
						}
						if (item == 4) {
							that.recognizeIdCard(3, res.return_data);
							that.uploadsettleIdCardPortraitImg = item1;
						}
						if (item == 5) {
							that.recognizeIdCard(4, res.return_data);
							that.uploadsettleIdCardNationalEmblemImg = item1;
						}
						if (item == 6) {
							that.storeimg1 = res.return_data;
							that.uploadstoreimg1 = item1;
						}
						if (item == 7) {
							that.storeimg2 = res.return_data;
							that.uploadstoreimg2 = item1;
						}
						if (item == 8) {
							that.storeimg3 = res.return_data;
							that.uploadstoreimg3 = item1;
						}
					}
				})
			},
			//营业执照识别
			recognizeBusinessLicense(item) {
				uni.showLoading({
					title: '识别中...'
				})
				let params = {
					url: item
				}
				recognizeBusinessLicense(params).then(res => {
					uni.hideLoading();
					if (res.return_code == '000000' && res.return_data) {
						this.businimg = item;
						this.businessLicenselist = JSON.parse(res.return_data.data).data;
						this.companyname = this.businessLicenselist.companyName;
						// this.detailsaddress = this.businessLicenselist.businessAddress;
						this.businnum = this.businessLicenselist.creditCode;
						this.regaddress = this.businessLicenselist.businessAddress;
						this.start_date = this.businessLicenselist.RegistrationDate;
						let times = this.businessLicenselist.validPeriod.split('至');
						if (times[1] == '永久') {
							this.timetype = '2';
						}
						if (times == '长期') {
							this.timetype = '2';
						}
					} else {
						uni.showToast({
							title: '请上传正确的营业执照',
							duration: 2000,
							icon: 'none'
						})
					}
				})
			},
			//身份证识别
			recognizeIdCard(item, items) {
				uni.showLoading({
					title: '识别中...'
				})
				let params = {
					url: items
				}
				recognizeIdCard(params).then(res => {
					uni.hideLoading();
					if (res.return_code == '000000' && res.return_data) {
						if (item == 1) {
							if (JSON.parse(res.return_data.data).data.face != undefined) {
								this.idCardzm = JSON.parse(res.return_data.data).data;
								this.idcardname = this.idCardzm.face.data.name;
								this.idcardposimg = items;
								this.larIdCardAddress = this.idCardzm.face.data.address;
								this.idcard = this.idCardzm.face.data.idNumber;
							} else {
								uni.showToast({
									title: '请上传身份证人脸信息',
									duration: 2000,
									icon: 'none'
								})
							}
						}
						if (item == 2) {
							if (JSON.parse(res.return_data.data).data.back != undefined) {
								this.idCardfm = JSON.parse(res.return_data.data).data;
								let times = this.idCardfm.back.data.validPeriod.split('-');
								this.cardstart_date = times[0];
								this.idcardsideimg = items;
								this.cardend_date = times[1];
							} else {
								uni.showToast({
									title: '请上传身份证国徽信息',
									duration: 2000,
									icon: 'none'
								})
							}
						}
						if (item == 3) {
							if (JSON.parse(res.return_data.data).data.face != undefined) {
								let idCardzm = JSON.parse(res.return_data.data).data;
								this.nonfaidcardname = idCardzm.face.data.name;
								this.settleIdCardPortraitImg = items;
								this.nonlarIdCardAddress = idCardzm.face.data.address;
								this.nonidcard = idCardzm.face.data.idNumber;
							} else {
								uni.showToast({
									title: '请上传身份证人脸信息',
									duration: 2000,
									icon: 'none'
								})
							}
						}
						if (item == 4) {
							if (JSON.parse(res.return_data.data).data.back != undefined) {
								let idCardfm = JSON.parse(res.return_data.data).data;
								let times = idCardfm.back.data.validPeriod.split('-');
								this.settleIdCardPeriodStart = times[0];
								this.settleIdCardNationalEmblemImg = items;
								this.settleIdCardPeriodEnd = times[1];
							} else {
								uni.showToast({
									title: '请上传身份证国徽信息',
									duration: 2000,
									icon: 'none'
								})
							}
						}
					} else {
						uni.showToast({
							title: '请上传正确的身份证信息',
							duration: 2000,
							icon: 'none'
						})
					}
				})
			},
			//选择行业
			showjob() {
				uni.navigateTo({
					url: '../business-category/business-category'
				})
			},
			// 提交门店信息
			configStore() {
				let that = this;
				// if (!that.businimg) {
				// 	uni.showToast({
				// 		title: '请上传营业执照',
				// 		icon: "none",
				// 		duration: 2000
				// 	});
				// 	return;
				// }
				// if (!that.businnum) {
				// 	uni.showToast({
				// 		title: '请填写营业执照号',
				// 		icon: "none",
				// 		duration: 2000
				// 	});
				// 	return;
				// }
				// if (!that.regaddress) {
				// 	uni.showToast({
				// 		title: '请填写注册地址',
				// 		icon: "none",
				// 		duration: 2000
				// 	});
				// 	return;
				// }
				// if (!that.start_date) {
				// 	uni.showToast({
				// 		title: '请填写营业执照开始时间',
				// 		icon: "none",
				// 		duration: 2000
				// 	});
				// 	return;
				// }
				// if (!that.end_date) {
				// 	uni.showToast({
				// 		title: '请填写营业执照结束时间',
				// 		icon: "none",
				// 		duration: 2000
				// 	});
				// 	return;
				// }
				// if (!that.companyname) {
				// 	uni.showToast({
				// 		title: '请填写公司名称',
				// 		icon: "none",
				// 		duration: 2000
				// 	});
				// 	return;
				// }
				if (!that.inducateid) {
					uni.showToast({
						title: '请选择行业类目',
						icon: "none",
						duration: 2000
					});
					return;
				}
				if (!that.areaCode) {
					uni.showToast({
						title: '请选择经营地区',
						icon: "none",
						duration: 2000
					});
					return;
				}
				if (!that.detailsaddress) {
					uni.showToast({
						title: '请填写详情地址',
						icon: "none",
						duration: 2000
					});
					return;
				}
				if (!that.storeaccount) {
					uni.showToast({
						title: '请填写门店账号',
						icon: "none",
						duration: 2000
					});
					return;
				}
				if (!that.storename) {
					uni.showToast({
						title: '请填写门店名称',
						icon: "none",
						duration: 2000
					});
					return;
				}
				if (!that.storephone) {
					uni.showToast({
						title: '请填写门店电话',
						icon: "none",
						duration: 2000
					});
					return;
				}
				if (!that.storeimg1) {
					uni.showToast({
						title: '请上传门头照片',
						icon: "none",
						duration: 2000
					});
					return;
				}
				if (!that.storeimg2) {
					uni.showToast({
						title: '请上传收银台照片',
						icon: "none",
						duration: 2000
					});
					return;
				}
				if (!that.storeimg3) {
					uni.showToast({
						title: '请上传室内照片',
						icon: "none",
						duration: 2000
					});
					return;
				}
				if (that.timetype == 2) {
					that.end_date = '长期有效';
				}
				if (that.idcardtime == 2) {
					that.cardend_date = '长期有效';
				}

				if (that.settleIdPeriodType == 2) {
					that.settleIdCardPeriodEnd = '长期有效';
				}
				let aloneSettle;
				if (that.aloneSettle == 0) {
					aloneSettle = false;
					that.uploadbusinimg = '';
					that.companyname = '';
					that.businnum = '';
					that.start_date = '';
					that.timetype = '';
					that.end_date = '';
					that.regaddress = '';

					that.idcardname = '';
					that.idcard = '';
					that.larIdCardAddress = '';
					that.uploadidcardposimg = '';
					that.uploadidcardsideimg = '';
					that.cardstart_date = '';
					that.idcardtime = '';
					that.cardend_date = '';

					that.lementId = '';
					that.bankNo = '';
					that.bankareaCode = '';
					that.bankName = '';
					that.belongbank = '';
					that.nonfaidcardname = '';
					that.nonidcard = '';
					that.nonlarIdCardAddress = '';
					that.settleIdPeriodType = '';
					that.uploadsettleIdCardPortraitImg = '';
					that.uploadsettleIdCardNationalEmblemImg = '';
					that.settleIdCardPeriodStart = '';
					that.settleIdCardPeriodEnd = '';
				} else {
					aloneSettle = true;
				}
				uni.showModal({
					title: '提交门店',
					content: '确认信息是否正确。',
					success: (res) => {
						if (res.confirm) {
							uni.showLoading({
								title: '提交中...'
							})
							let datas = {
								"account": {
									"loginName": that.storeaccount
								},
								"dutyPeopleName": that.dutyPeopleName, //"负责人名称",
								"dutyPeoplePhone": that.dutyPeoplePhone, //"负责人电话",
								"dutyPeopleEmail": that.dutyPeopleEmail,
								"name": that.storename,
								"telephone": that.storephone,
								"doorHeadImg": that.uploadstoreimg1,
								"cashRegisterImg": that.uploadstoreimg2,
								"internalImg": that.uploadstoreimg3,
								"aloneSettle": aloneSettle,
								"merId": that.userInfo.mer.id,
								"storeIndustry": {
									"childId": that.inducateid
								},
								"storeRegion": {
									"areaCode": that.areaCode,
									"address": that.detailsaddress
								},


								"blisUrl": that.uploadbusinimg,
								"blisName": that.companyname,
								"blisNo": that.businnum,
								"blisPeriodStart": that.start_date,
								"blisPeriodType": that.timetype, // 营业执照期限类型  1：有效期   2：长期
								"blisPeriodEnd": that.end_date,
								"blisRegAddress": that.regaddress,

								"larName": that.idcardname, // "法人名称",
								"larIdCard": that.idcard, //"法人身份证号",
								"larIdCardAddress": that.larIdCardAddress, //"法人身份住址",
								"larIdCardPortraitImg": that.uploadidcardposimg, //"法人身份证【人像】面URL",
								"larIdCardNationalEmblemImg": that.uploadidcardsideimg, //"法人身份证【国徽】面URL",
								"larIdCardPeriodStart": that.cardstart_date, //"身份证开始时间",
								"larIdCardPeriodType": that.idcardtime, // 法人身份证有效期类型  1：有效期   2：长期
								"larIdCardPeriodEnd": that.cardend_date, //"身份证结束时间",


								storeSettleAcct: {
									"settleType": that.lementId, //结算类型 1：对公结算  2：对私法人结算  3：对私非法人结算,
									"bankCardNo": that.bankNo, //"银行卡号",
									"openningBankAreaCode": that.bankareaCode, // 开户地址
									"bankCardHolder": that.bankName, //"银行卡持有人",
									"bankName": that.belongbank, //"开户行名称",
									"settleIdCardName": that.nonfaidcardname, //身份证名字
									"settleIdCardNo": that.nonidcard, //身份证号
									"settleIdCardAddress": that.nonlarIdCardAddress, // 身份证地址
									"settleIdPeriodType": that
										.settleIdPeriodType, //【对私非法人结算】结算人身份证有效期类型  1：有效期   2：长期,
									"settleIdCardPortraitImg": that
										.uploadsettleIdCardPortraitImg, //"【对私非法人结算】结算人身份证人像面图片",
									"settleIdCardNationalEmblemImg": that
										.uploadsettleIdCardNationalEmblemImg, //"【对私非法人结算】结算人身份证国徽面图片",
									"settleIdCardPeriodStart": that
										.settleIdCardPeriodStart, //"【对私非法人结算】结算人身份证有效期开始时间",
									"settleIdCardPeriodEnd": that
										.settleIdCardPeriodEnd, //"【对私非法人结算】结算人身份证有效期结束时间"
								}
							}
							console.log('=======' + JSON.stringify(datas));
							configStore(datas).then(res => {
								uni.hideLoading();
								if (res.return_code == '000000') {
									uni.showToast({
										title: '提交成功',
										icon: 'none',
										duration: 2000,
										success() {
											setTimeout(() => {
												uni.navigateBack({})
											}, 1000);
										}
									})
								} else {
									uni.showToast({
										title: res.return_msg,
										icon: 'none',
										duration: 2000
									})
								}
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			},
		}
	}
</script>

<style lang="scss">
	.btn {
		color: #FFFFFF;
		background-color: #0083f5;
		width: 90%;
		margin-left: 5%;
		margin-top: 80rpx;
		margin-bottom: 50rpx;
		height: 90rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		border-radius: 10rpx;
		font-size: 40rpx;
	}

	.titlename {
		width: calc(100% - 90upx);
		height: 100upx;
		display: flex;
		align-items: center;
		background-color: rgba($color: #ffffff, $alpha: 0.1);
		padding: 0 45upx;
	}

	.username {
		width: calc(100% - 90upx);
		height: 100upx;
		display: flex;
		align-items: center;
		background-color: rgba($color: #ffffff, $alpha: 0.1);
		border-bottom: 1px solid #f6f6f6;
		padding: 8upx 45upx;

		input {
			width: 50%;
			height: 50upx;
			font-size: 16px;
			color: #333333;
			font-weight: blod;
		}

		.get-code {
			position: absolute;
			display: flex;
			align-items: center;
			justify-content: center;
			right: 7px;
			z-index: 3;
			border: 1px solid #bfbfbf;
			width: 25%;
			padding: 3px 5px;
			border-radius: 22px;

			&:after {
				content: " ";
				width: 1upx;
				height: 50upx;
				position: absolute;
				z-index: 3;
				margin-right: 100%;
				left: 0;
				top: 20upx;
			}
		}

		.namecont {
			color: #666666;
			width: 28%;
		}
	}

	.storename {
		width: calc(100% - 40upx);
		height: 100upx;
		display: flex;
		align-items: center;
		background-color: rgba($color: #ffffff, $alpha: 0.1);
		border-bottom: 1px solid #f6f6f6;
		padding: 8upx 20upx;

		.namecont {
			color: #666666;
			width: 25%;
		}
	}

	.notes {
		width: calc(100% - 90upx);
		display: flex;
		align-items: center;
		background-color: rgba($color: #ffffff, $alpha: 0.1);
		border-bottom: 1px solid #f6f6f6;
		padding: 20rpx 45rpx;
		color: #bfbfbf;

	}

	.wybtc {
		width: calc(100% - 90upx);
		display: flex;
		height: 80px;
		align-items: center;
		background-color: #FFFFFF;
		border-bottom: 1px solid #f6f6f6;
		padding: 15rpx 45rpx;
		border-radius: 8px;
		color: #bfbfbf;
	}
</style>
