<template>
	<view class="content">
		<u-overlay :show="overlayShow"></u-overlay>
		<view class="container">
			<headers :titles="titles"><uni-icons type="arrow-left" color="#fff" size="22px"></uni-icons></headers>
			<view class="box_">
				<view class="title_">
					法人或负责人信息
				</view>
				<view class="box_bs">
					<view class="">证件类型</view>
					<view class="right_size">
						<view class="h_">{{formData.legalPerson.certTypeName||""}}</view>
					</view>
				</view>
				<view class="box_bs">
					<view class="">法人姓名</view>
					<view class="right_size">
						<view class="h_">{{formData.legalPerson.participantName||""}}</view>
					</view>
				</view>
				<view class="box_bs">
					<view class="">法人手机号</view>
					<view class="right_size">
						<view class="h_">{{formData.legalPerson.mobileNo||""}}</view>
					</view>
				</view>
				<view class="box_bs">
					<view class="">性别</view>
					<view class="right_size">
						<view class="h_">{{genderName||""}}</view>
					</view>
				</view>
				<view class="box_bs">
					<view class="">国籍</view>
					<view class="right_size">
						<view class="h_">{{formData.legalPerson.nationLabel||""}}</view>
					</view>
				</view>
				<view class="box_bs">
					<view class="">身份证号</view>
					<view class="right_size">
						<view class="h_">{{formData.legalPerson.certNo||""}}</view>
					</view>
				</view>
				<view class="box_bs">
					<view class="">有效期</view>
					<view class="right_size">
						<view class="h_">{{formData.legalPerson.certEffectDate+'-'+formData.legalPerson.certExaDate}}
						</view>
					</view>
				</view>
				<view class="box_bs">
					<view class="">职业</view>
					<view class="right_size">
						<view class="h_">{{formData.legalPerson.firstCareerName||""}}</view>
						<view class="h_">{{formData.legalPerson.secondCareerName||""}}</view>
						<view class="h_">{{formData.legalPerson.thirdCareerName||""}}</view>
					</view>
				</view>
				<view class="box_bs">
					<view class="">归属地</view>
					<view class="right_size">
						<view class="h_">
							{{(formData.legalPerson.provinceName+formData.legalPerson.cityName+formData.legalPerson.countyName)||""}}
						</view>
					</view>
				</view>
				<view class="box_bs">
					<view class="">地址</view>
					<view class="right_size">
						<view class="h_">{{formData.legalPerson.address||""}}</view>
					</view>
				</view>
				<view class="box_bs">
					<view class="">邮箱</view>
					<view class="right_size">
						<view class="h_">{{formData.legalPerson.email||""}}</view>
					</view>
				</view>
			</view>
			<view class="box_">
				<view class="title_">
					商户信息
				</view>
				<view class="box_bs">
					<view class="">商户名称</view>
					<view class="right_size">
						<view class="h_">{{formData.merchantName||""}}</view>
					</view>
				</view>
				<view class="box_bs">
					<view class="">商户简称</view>
					<view class="right_size">
						<view class="h_">{{formData.abbreviation||""}}</view>
					</view>
				</view>
				<view class="box_bs">
					<view class="">商户归属地</view>
					<view class="right_size">
						<view class="h_">
							{{(formData.merProvinceNames+formData.merRegionNames+formData.merCountyNames)||""}}
						</view>
					</view>
				</view>
				<view class="box_bs">
					<view class="">详细信息</view>
					<view class="right_size">
						<view class="h_">{{formData.merAddr||""}}</view>
					</view>
				</view>
				<view class="box_bs">
					<view class="">行业分类</view>
					<view class="right_size">
						<view class="h_">{{formData.merTertiaryBusKindName||""}}</view>
					</view>
				</view>
			</view>
			<view class="box_">
				<view class="title_">
					商户费率
				</view>
				<view class="box_bs">
					<view class="">微信费率(%)</view>
					<view class="right_size">
						<view class="h_">{{formData.wxRate||""}}</view>
					</view>
				</view>
				<view class="box_bs">
					<view class="">支付宝费率(%)</view>
					<view class="right_size">
						<view class="h_">{{formData.aliRate||""}}</view>
					</view>
				</view>
				<view class="box_bs">
					<view class="">云闪付费率(%)</view>
					<view class="right_size">
						<view class="h_">{{formData.unionPayRate||""}}</view>
					</view>
				</view>
			</view>
			<view class="box_">
				<view class="title_">
					结算卡信息
				</view>
				<view class="box_bs">
					<view class="">法人储蓄卡号</view>
					<view class="right_size">
						<view class="h_">{{formData.bankAccountNo||""}}</view>
					</view>
				</view>
				<view class="box_bs">
					<view class="">银行预留手机号</view>
					<view class="right_size">
						<view class="h_">{{formData.settleMobile||""}}</view>
					</view>
				</view>
				<view class="box_bs">
					<view class="">银行名称</view>
					<view class="right_size">
						<view class="h_">{{formData.issBankIdName||""}}</view>
					</view>
				</view>
				<view class="box_bs">
					<view class="">开户行</view>
					<view class="right_size">
						<view class="h_">{{(formData.bankProvinceName+formData.bankCityName)||""}}</view>
					</view>
				</view>
				<view class="box_bs">
					<view class=""></view>
					<view class="right_size">
						<view class="h_">{{(formData.bankOutletsName)||""}}</view>
					</view>
				</view>
				<view class="box_bs">
					<view class="">结算周期</view>
					<view class="right_size">
						<view class="h_">{{(formData.settlementCycleName)||""}}</view>
					</view>
				</view>
				<view class="box_bs">
					<view class="">签约期限</view>
					<view class="right_size">
						<view class="h_">{{(formData.openAccEffectDate+'-'+formData.openAccExpDate)||""}}</view>
					</view>
				</view>
				<view class="right-box">(期满双方如无异议自动续签一年)</view>


			</view>
			<!--  -->
			<u-popup :show="show" mode="center" :round="10" @close="close" @open="open">
				<view class="box_popup">
					<view class="popup-top">
						<view class="popup-title">电子签名协议</view>
						<view class="popup-smalltitle">(需法人签名)</view>
						<view class="popup-ds">
							<view class="" style="width: 10%; ">
								<view class="qiu" v-if="popupShow == false" @click="popupShow =! popupShow "></view>
								<view class="xqiu" v-if="popupShow == true" @click="popupShow =! popupShow ">
									<u-icon name="checkbox-mark" color="#fff" size="14"></u-icon>
								</view>
							</view>
							<view class="" style="width: 90%;text-align: left;font-size: 14px;">
								<text>我已阅读并同意</text>
								<text style="color: #f79d31; font-size: 14px;" @click="goH5(1)">《51收钱商户扫码支付服务协议》</text>
								<text style="color: #f79d31; font-size: 14px;" @click="goH5(2)">《51收钱开户意愿书》</text>
								<text style="color: #f79d31; font-size: 14px;" @click="goH5(3)">《51收钱商户注册及服务协议》</text>
								<text style="color: #f79d31; font-size: 14px;" @click="goH5(4)">《51收钱隐私政策》</text>

							</view>
						</view>
					</view>

					<jushi-signature :settings="settings" base64 @cancel="signatureCancel"
						@change="signatureChange"></jushi-signature>
				</view>
			</u-popup>

			<!-- <view class="" style="margin-top: 20rpx;">
				<text class="text">保存后的签名图片</text>
				<view class="preview">
					<image :src="imgUrl" mode="" style="width: 100%;"></image>
				</view>
			</view> -->
			<view class="button_p" @click="nextStep()">
				<view class="">确认提交</view>
			</view>
		</view>

	</view>
</template>

<script>
	import headers from '../../components/header/headers.vue'
	import request from '../../utils/request.js'
	import upload from '@/utils/upload.js'
	export default {
		data() {
			return {
				overlayShow: false,
				titles: "信息确认",
				msg: "1",
				dataList: [],
				fileList1: [],
				fileList2: [],
				value1: '',
				show: false,
				popupShow: false,
				status: 'loading',
				select: '',
				options: [{
					value: "1",
					label: "人民币"
				}, {
					value: "2",
					label: "刀乐"
				}, {
					value: "3",
					label: "英镑",
					disabled: true
				}],
				settings: { //签名设置
					width: '750', //签名区域的宽
					height: '500', //签名区域的高
					lineWidth: 4, //签名时线宽
					textColor: '#000' //签名文字颜色
				},
				imgUrl: '',
				merchantId: null,
				formData: {
					areaType: "7", //商户类型 7 小微 写死
					openAccEffectDate: "",
					openAccExpDate: "",
					legalPerson: {
						address: "",
						backPic: "",
						backPicUrl: "",
						certEffectDate: "",
						certExaDate: "",
						certNo: "",
						certType: "11",
						certTypeName: "身份证",
						city: "",
						cityName: "",
						county: "",
						countyName: "",
						email: "",
						facePic: "",
						facePicUrl: "",
						firstCareerName: "",
						firstCareerNo: "",
						gender: "1",
						mobileNo: "",
						nation: "CHN",
						nationLabel: "中国",
						participantName: "",
						province: "",
						provinceName: "",
						secondCareerName: "",
						secondCareerNo: "",
						sort: 0,
						thirdCareerName: "",
						thirdCareerNo: ""
					},
					openAccount: "",
					openAccountUrl: "",
					rate: "0.25",
					steps: "5" //步骤当前页面写死第一页，

				},
				sexList: [], //性别  数据字典获取
				merchantId: null

			}
		},
		onLoad(options) {
			if (options && options.merchantId) {
				this.merchantId = options.merchantId
				this.getMerchantInfo()
			}
			this.getSexList()

		},
		computed: {
			genderName() {
				if (this.sexList && this.sexList.length > 0) {
					let tempData = this.sexList.find(item => item.value == this.formData.legalPerson.gender)
					return tempData.label
				} else {
					return '男'
				}
			}
		},
		components: {
			headers,
		},
		methods: {
			goH5(type) {
				let url;
				if (type == 1) {
					url =
						'https://51pay.xlpayment.com/H5/51收钱商户扫码支付服务协议(1).htm'
				} else if (type == 2) {
					url =
						'https://51pay.xlpayment.com/H5/山东高速信联支付有限公司商户开户意愿书.htm'
				} else if (type == 3) {
					url =
						'https://51pay.xlpayment.com/H5/51收钱商户注册及服务协议1.0.htm'
				} else if (type == 4) {
					url =
						'https://51pay.xlpayment.com/H5/51收钱隐私政策.html'
				}
				uni.navigateTo({
					url: '/components/h5/webView?url=' + url
				})
			},
			async submit() {
				uni.showLoading({
					title: '上传中'
				});
				this.overlayShow = true
				let res = await request({
					url: 'app/report/newBaseInfoSaveOrUpdate',
					method: 'post',
					data: this.formData
				})

				if (res.code == 0) {

					let ress = await request({
						url: 'app/report/newReport',
						method: 'post',
						params: {
							merchantId: res.merchantId
						}
					})
					if (ress.code == 0) {
						uni.showToast({
							title: ress.messages,
							icon: 'none'
						})
						uni.hideLoading();
						this.overlayShow = false
						if (ress.reportStatus == '10F') {
							uni.showToast({
								title: '提交成功等待审核',
								icon: 'none'
							})
							uni.navigateTo({
								url: '/homePages/TobeImproved/TobeImproved?merchantId=' + res.merchantId
							})
						} else {
							uni.showToast({
								title: ress.messages,
								icon: 'none'
							})
						}

					} else {
						uni.hideLoading();
						this.overlayShow = false
					}


				} else {
					uni.hideLoading();
					this.overlayShow = false
					uni.showToast({
						title: '信息有误',
						icon: 'none'
					})
				}



			},
			async getSexList() {
				this.sexList = await this.$getDictList('gender')

			},
			async getMerchantInfo() {
				uni.showLoading({
					title: '加载中'
				});
				this.overlayShow = true
				let ress = await request({
					url: 'app/report/newBaseInfo',
					method: 'post',
					data: {
						objectId: this.merchantId
					}
				})
				this.formData = ress.data
				this.formData.steps = '5'
				uni.hideLoading();
				this.overlayShow = false
			},
			close() {
				this.show = false
			},
			open() {
				console.log('打开了');
			},
			signatureCancel() {
				this.show = false
			},
			signatureChange(e) {
				console.log(382382382382382, this.popupShow, 382);
				if (!this.popupShow) {
					uni.showToast({
						title: "请阅读相关协议并同意",
						icon: 'none'
					})

					return
				}
				this.imgUrl = e
				const index = e.lastIndexOf("/")
				let fileName = e.substring(index + 1, e.length)
				this.uploadFile(this.imgUrl, fileName)
				this.show = false
			},
			async uploadFile(url, fileName) {
				uni.showLoading({
					title: '上传中'
				});
				this.overlayShow = true
				let that = this
				upload({
					url: 'app/report/fileUplod',
					filePath: url,
					formData: {
						fileName: fileName,
						type: 29,
						name: this.formData.legalPerson.participantName,
						corporate: this.formData.merchantName,
						merName: this.formData.legalPerson.participantName,
						phone: this.formData.legalPerson.mobileNo,
						email: this.formData.legalPerson.email,
						address: this.formData.merProvinceNames + this.formData.merRegionNames + this.formData
							.merCountyNames + this.formData.merAddr,
						wxRate: this.formData.wxRate,
						aliRate: this.formData.aliRate,
						ysfRate: this.formData.unionPayRate

					}

				}).then((res) => {
					let that = this
					if (res.code == 0) {
						that.formData.networkProtocol = res.data.extraExternalKey
						that.formData.networkProtocolUrl = res.data.imgUrl
						that.formData.openAccountFile = res.data.externalKey

						that.submit()
					} else {
						uni.hideLoading();
						that.overlayShow = false
					}
				})
			},
			change(e) {
				console.log('select = ', this.select)
			},
			nextStep() {
				this.show = true
			},
			goback() {
				uni.navigateBack()
			}
		}
	}
</script>

<style scoped lang="scss">
	.content {
		background: #f4f5f6;

		height: 100vh;
	}

	.container {
		width: 100%;
		background: #f4f5f6;
		box-sizing: border-box;
		padding-top: 88px;
		padding-bottom: 88px;
	}

	.box_ {
		width: 95%;
		border-radius: 8px;
		box-sizing: border-box;
		padding: 10px;
		background: #fff;
		margin: 15px auto;
	}

	.box_bs {
		display: flex;
		align-items: center;
		justify-content: space-between;
		box-sizing: border-box;
		padding: 10px 0px;
		color: #aeaeae;
		border-bottom: 1px solid #eeeeee;
	}

	.dis_ {
		display: flex;
	}

	.size_ {
		margin-right: 5px;
		color: #000;
	}

	.title_ {
		font-size: 18px;
		font-weight: bold;
		margin: 10px 0px;
		margin-bottom: 20px;
	}

	.upload-box {
		width: 100%;
		margin: 5px 0px;

		display: flex;
		text-align: center;
		justify-content: space-between;
		margin-bottom: 20px;
	}

	.upload-title {
		font-size: 16px;
		margin-right: 10%;

	}

	.right_size {
		width: 70%;
		text-align: right;
	}

	.input_color {
		width: 100px;
		display: flex;
		align-items: center;
		height: 36px;
		border: 2px solid #efefef;
		border-radius: 4px;
		box-sizing: border-box;
		padding: 5px;
		margin-left: 10px;
	}

	.button_p {
		width: 100%;
		background: #E4612E;
		height: 55px;
		display: flex;
		align-items: center;
		justify-content: center;
		color: #fff;
		border-radius: 4px;
		position: fixed;
		bottom: 0px;
	}

	.right-box {
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: flex-end;
		color: #aeaeae;
		font-size: 14px;
		margin: 10px 0px;
	}

	.bs_img {
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.fifty {
		width: 50%;
		text-align: center;

		box-sizing: border-box;
		padding-left: 15px;
		font-size: 14px;

	}

	.h_ {
		color: #000;
	}

	.preview {
		margin: 10rpx;
		border: 1rpx solid #aaaaaa;
		border-radius: 10rpx;
	}

	.text {
		margin: 20rpx;
		color: #aaaaaa;
	}

	.box_popup {
		width: 370px;
		box-sizing: border-box;
		overflow: hidden;
		border-radius: 8px;
		background: #fff;
		// background: linear-gradient(90deg, #d7f3e5 0%, #fafdea 100%, );
	}

	.popup-top {
		width: 100%;
		background: linear-gradient(90deg, #d7f3e5 0%, #fafdea 100%, );
		background: linear-gradient(180deg, #d7f3e5 0%, #fafdea 85%, rgba(255, 255, 255, 0.84) 95%, rgba(255, 255, 255, 0.84) 100%);
		text-align: center;
		box-sizing: border-box;
		padding: 15px;
	}

	.popup-ds {
		width: 100%;
		display: flex;

	}

	.popup-title {
		font-size: 18px;
		font-weight: bold;

	}

	.popup-smalltitle {
		font-size: 14px;
		color: #686d66;
		margin-bottom: 10px;
	}

	.qiu {
		width: 16px;
		height: 16px;
		border: 1px solid #686d66;
		border-radius: 50%;
	}

	.xqiu {
		width: 16px;
		height: 16px;
		background: #E4612E;
		border: 1px solid #E4612E;
		border-radius: 50%;
		display: flex;
		align-items: center;
		justify-content: center;
	}
</style>
