perfect.vue 31.6 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221
<template>
	<view class="perfect-page">
		<!-- 顶部步骤条 -->
		<view class="steps-bar">
			<view class="step-item" :class="{ active: active >= 0, current: active == 0 }">
				<view class="step-circle">1 </view>
				<view class="step-text">完善信息</view>
			</view>
			<view class="step-line" :class="{ active: active >= 1 }"></view>
			<view class="step-item" :class="{ active: active >= 1, current: active == 1 }">
				<view class="step-circle">2</view>
				<view class="step-text">会员认证</view>
			</view>
		</view>
		<view style="color:#EB6100;text-align: center;font-size: 24rpx;margin-top:10rpx">请完善以下信息,填写完点击提交按钮进行会员认证!</view>

		<view class="page-content" style="padding: 0rpx 30rpx 30rpx;">
			<!-- 步骤1:完善信息 -->
			<view class="wBox" v-if="active == 0">
				<uni-forms ref="baseForm" :modelValue="form" label-width="70">
					<uni-forms-item label="单位名称" required>
						<uni-easyinput class="input-with-border" v-model="form.baseName" :disabled="!editIng" placeholder="单位名称" />
					</uni-forms-item>
					<uni-forms-item label="单位类型" required>
						<uni-data-select  :disabled="!editIng" v-model="form.type" :localdata="typeList"></uni-data-select>
					</uni-forms-item>
					<uni-forms-item label="联系人" required>
						<uni-easyinput class="input-with-border" v-model="form.contact" :disabled="!editIng" placeholder="请输入联系人姓名" />
					</uni-forms-item>
					<uni-forms-item label="联系方式" required>
						<uni-easyinput class="input-with-border" v-model="form.phone" :disabled="!editIng" placeholder="请输入联系方式" />
					</uni-forms-item>
					<uni-forms-item label="机构介绍" required>
						<uni-easyinput class="input-with-border" v-model="form.introduce" placeholder="请输入机构介绍" :disabled="!editIng" type='textarea' />
					</uni-forms-item>
				</uni-forms>
				<view class="fixedBottom">
					<button class="btn-red" @click="submitStep1()">提交,下一步</button>
				</view>
			</view>

			<!-- 步骤2:会员认证 -->
			<view class="wBox" v-if="active == 1">
				<view class="status-box">
					<view class="status-row">
						<text class="status-label">认证状态:</text>
						<text v-if="authenticationStatusa == 0 || !authenticationStatusa" class="text-danger">未认证</text>
						<text v-if="authenticationStatusa == 1" class="text-warning">认证中</text>
						<text v-if="authenticationStatusa == 2" class="text-success">已认证</text>
						<text v-if="authenticationStatusa == 3" class="text-danger">认证未通过</text>
						<text v-if="authenticationStatusa == 4" class="text-warning">即将过期</text>
						<text v-if="authenticationStatusa == 5" class="text-danger">已过期</text>
					</view>
					<view class="btn-row">
						<button  type="primary" :disabled="btn" @click="goPay">去缴费</button>
						<button v-if="form.deptType != 2" type="default" @click="goAuditDetail">审核详情</button>
					</view>
				</view>

				<uni-forms ref="certForm" :modelValue="form" label-width="90">
					<uni-forms-item label="选择所属协会" required>
						<view class="picker-wrapper">
							<uni-data-picker 
								class="custom-picker"
								:disabled="!editIng" 
								v-model="form.parentId" 
								:localdata="assoList" 
								:level="3"
								popup-title="请选择所属协会"
								@change="changCase"
							></uni-data-picker>
						</view>
					</uni-forms-item>
					<uni-forms-item label="机构名称" required>
						<uni-easyinput class="input-with-border" v-model="form.name" :disabled="!editIng" placeholder="请输入机构名称" />
					</uni-forms-item>
					<uni-forms-item label="认证地址" required>
						<view class="picker-wrapper">
							<uni-data-picker 
								class="custom-picker"
								v-model="coordinates1"
								:localdata="regionOptions" 
								popup-title="请选择所在地区"
								@change="changeAddress"
							></uni-data-picker>
						</view>
					</uni-forms-item>
					<uni-forms-item label="认证详细地址" required>
						<uni-easyinput class="input-with-border" v-model="form.adress" :disabled="!editIng" placeholder="请输入详细地址" />
					</uni-forms-item>
					<uni-forms-item label="联系人" required>
						<uni-easyinput class="input-with-border" v-model="form.siteContact" :disabled="!editIng" placeholder="请输入联系人" />
					</uni-forms-item>
					<uni-forms-item label="联系方式" required>
						<uni-easyinput class="input-with-border" v-model="form.siteTel" :disabled="!editIng" placeholder="请输入联系方式" />
					</uni-forms-item>
					<uni-forms-item label="营业执照" required>
						<view class="upload-box">
							<view v-if="!form.businessLicense" class="upload-placeholder" @click="onBusinessLicenseSelect">
								<image :src="config.baseUrl_api + '/fs/static/yyzz@2x.png'" class="placeholder-img"/>
							</view>
							<view v-else class="license-preview">
							<image v-if="typeof form.businessLicense === 'string'" :src="form.businessLicense" class="license-img" @click="previewImage(form.businessLicense)"></image>
							<view class="delete-btn" v-if="editIng" @click="removeBusinessLicense">×</view>
						</view>
						</view>
					</uni-forms-item>
					<uni-forms-item label="营业执照名称" required>
						<uni-easyinput class="input-with-border" v-model="form.companyName" :disabled="!editIng" placeholder="请输入营业执照名称" />
					</uni-forms-item>
					<uni-forms-item label="社会信用代码" required>
						<uni-easyinput class="input-with-border" v-model="form.creditCode" :disabled="!editIng" placeholder="请输入社会信用代码" />
					</uni-forms-item>
					<uni-forms-item label="法人身份证" required>
						<view class="idcard-box">
							<view class="idcard-item">
								<view v-if="!form.legalIdcPhoto1" class="idcard-placeholder" @click="onIdCardFrontSelect">
									<image :src="config.baseUrl_api + '/fs/static/sfz_zm@2x.png'" class="placeholder-img"/>
								</view>
								<view v-else class="idcard-preview">
									<image :src="form.legalIdcPhoto1" class="idcard-img" @click="previewImage(form.legalIdcPhoto1)"></image>
									<view class="delete-btn" v-if="editIng" @click="removeIdCardFront">×</view>
								</view>
							</view>
						</view>
						<view class="idcard-box">
							<view class="idcard-item">
								<view v-if="!form.legalIdcPhoto2" class="idcard-placeholder" @click="onIdCardBackSelect">
									<image :src="config.baseUrl_api + '/fs/static/sfz_fm@2x.png'" class="placeholder-img"/>
								</view>
								<view v-else class="idcard-preview">
									<image :src="form.legalIdcPhoto2" class="idcard-img" @click="previewImage(form.legalIdcPhoto2)"></image>
									<view class="delete-btn" v-if="editIng" @click="removeIdCardBack">×</view>
								</view>
							</view>
						</view>
					</uni-forms-item>
					<uni-forms-item label="法人姓名" required>
						<uni-easyinput class="input-with-border" v-model="form.legal" :disabled="!editIng" placeholder="请输入法人姓名" />
					</uni-forms-item>
					<uni-forms-item label="法人证件号" required>
						<uni-easyinput class="input-with-border" v-model="form.legalIdcCode" :disabled="!editIng" placeholder="请输入法人证件号" />
					</uni-forms-item>
					<uni-forms-item label="上传机构照片" required>
					<view class="pictures-box">
						<view v-if="!form.pictures" class="picture-placeholder" @click="onPicturesSelect">
							<image :src="config.baseUrl_api + '/fs/static/jgzp@2x.png'" class="placeholder-img"/>
						</view>
						<view v-else class="pictures-preview">
							<image :src="form.pictures.split(',')[0]" class="picture-img" @click="previewImage(form.pictures.split(','))"></image>
							<view class="delete-btn" v-if="editIng" @click="removePictures">×</view>
						</view>
					</view>
				</uni-forms-item>
				</uni-forms>

				<view class="fixedBottom">
					<button class="btn-gray" @click="active = 0">上一步</button>
					<button class="btn-red" :disabled="btn" @click="submitStep2()">提 交</button>
				</view>
			</view>
		</view>
	</view>
</template>

<script setup>
	import {
		ref,
		reactive
	} from 'vue';
	import * as api from '@/common/api.js';
	import {
		onLoad,
		onShow
	} from '@dcloudio/uni-app';
	import config from '@/config.js'
	const app = getApp();

	const form = ref({
		type: '1'
	});

	// 类型列表
	const typeList = ref([{
		value: '1',
		text: '企业'
	}, {
		value: '2',
		text: '国家组织'
	}, {
		value: '3',
		text: '社会组织'
	}, {
		value: '4',
		text: '其他'
	}])

	// 地址选项
	const options = ref([])
	const regionOptions = ref([])

	// 协会树
	const assoList = ref([])
	const assoFullName = ref('') // 协会完整路径名称

	// 步骤相关
	const active = ref(0)
	const list1 = ref([{
		title: '完善信息'
	}, {
		title: '会员认证'
	}])

	// 编辑状态
	const editIng = ref(true);

	// 认证状态
	const authenticationStatusa = ref()
	const result = ref(false)

	// 地址级联
	const coordinates1 = ref([])

	// 按钮状态
	const btn = ref(false)

	// 费用相关
	const memberFee = ref('')
	const preferentialPolicy = ref(false)
	const preferentialData = ref({})

	// 考点审核状态
	const auditStatus = ref('0')

	onLoad(option => {
			getTree()
		if (app.globalData.isLogin) {
			init()
		} else {
			app.firstLoadCallback = () => {
				init()
			};
		}
	});

	function init() {
		getDetail()
		getRegionsList()
	
		getMyMemberCertUnitFeeApi()
		canUseDiscountApi()
		getZtxDiscountPolicyApi()
		getMyStatusAPI()
	}

	// 获取详情
	function getDetail() {
		api.getMyOwnMemberInfo().then(res => {
			// if (res.data.memberInfo) {
			// 	Object.assign(form.value, res.data.memberInfo)
			// }
			form.value = { ...res.data.dept, ...res.data.memberInfo }
			authenticationStatusa.value = res.data.authenticationStatus
			result.value = res.data.result

			// 处理地址 - 需要用对象数组格式
			coordinates1.value = []
			if (form.value.provinceId) coordinates1.value.push(form.value.provinceId)
			if (form.value.cityId) coordinates1.value.push(form.value.cityId)
			if (form.value.regionId) coordinates1.value.push(form.value.regionId)

			// 处理协会 - 设置完整路径名称
			if (form.value.parentId) {
				// 尝试从协会树中查找完整路径
				const result = findAssoNodeWithPath(assoList.value, form.value.parentId, [])
				if (result) {
					assoFullName.value = getAssoFullName(result.path.map(id => ({ value: id })))
				} else {
					// 如果树还没加载完,延迟设置
					setTimeout(() => {
						const res = findAssoNodeWithPath(assoList.value, form.value.parentId, [])
						if (res) {
							assoFullName.value = getAssoFullName(res.path.map(id => ({ value: id })))
						}
					}, 500)
				}
			}

			// 处理身份证
			if (form.value.legalIdcPhoto) {
				const photos = form.value.legalIdcPhoto.split(',')
				form.value.legalIdcPhoto1 = photos[0] || ''
				form.value.legalIdcPhoto2 = photos[1] || ''
			}

			// 处理营业执照
			if (form.value.businessLicense) {
				try {
					const license = JSON.parse(form.value.businessLicense)
					form.value.businessLicense = license.url || license
					form.value.businessLicenseName = license.name
				} catch (e) {}
			}

			// 设置认证状态对应的按钮状态
			if (authenticationStatusa.value == 0) {
				btn.value = false
			} else if (authenticationStatusa.value == 1) {
				btn.value = true
			} else {
				btn.value = !result.value
			}

			creditCode.value = form.value.creditCode
			legal.value = form.value.legal
			legalIdcCode.value = form.value.legalIdcCode
			coordinates1.value = form.value.provinceId
			adress.value = form.value.adress
			form.value.name = form.value.baseName
		})
	}

	// 格式化地区树(修复:对齐PC端接口返回的id/name结构)
	function formatRegionTree(node) {
		const result = {
			value: node.id,
			text: node.name
		}
		if (node.children && node.children.length > 0) {
			result.children = node.children.map(child => formatRegionTree(child))
		}
		return result
	}

	// 获取地区列表
	function getRegionsList() {
		api.regionsList().then(res => {
			options.value = res.data
			// 转换为级联选择器格式
			regionOptions.value = res.data
			// map(item => formatRegionTree(item))
		});
	}

	// 获取协会树
	function getTree() {
		console.log('获取协会树')
		api.certifiedDeptTreeRegister({
			selfDeptId: -1, // 修复:传数字类型,避免后端类型转换错误
			webSiteShow: 1,
			showDisabled: 1,
			isBlack: 0
		}).then(res => {
			assoList.value = res.data.map(item => formatTree(item))
			// 树加载完成后,如果有parentId,设置完整路径名称
			if (form.value.parentId) {
				setTimeout(() => {
					restoreAssoFullName()
				}, 100)
			}
		})
	}

	// 格式化协会树
	function formatTree(node) {
		const result = {
			value: node.id,
			text: node.label || node.text
		}
		if (node.children && node.children.length > 0) {
			result.children = node.children.map(child => formatTree(child))
		}
		return result
	}

	// 恢复协会完整路径名称
	function restoreAssoFullName() {
		if (!form.value.parentId || !assoList.value || assoList.value.length === 0) {
			return
		}
		// 查找节点及其路径
		const result = findAssoNodeWithPath(assoList.value, form.value.parentId, [])
		if (result) {
			// 使用路径数组重建完整名称
			assoFullName.value = getAssoFullName(result.path.map(id => ({ value: id })))
		}
	}

	// 查找协会节点及其父路径
	function findAssoNodeWithPath(list, targetId, currentPath) {
		for (const item of list) {
			const newPath = [...currentPath, item.value]
			if (item.value === targetId) {
				return { node: item, path: newPath }
			}
			if (item.children && item.children.length > 0) {
				const found = findAssoNodeWithPath(item.children, targetId, newPath)
				if (found) return found
			}
		}
		return null
	}

	// 协会选择(修复:100%对齐PC端el-cascader emitPath: false逻辑,只取最后一级ID)
	function changCase(e) {
		const valueArr = e.detail?.value || e;
		// 取最后一级的value(纯ID)
		const lastNode = valueArr[valueArr.length - 1];
		form.value.parentId = lastNode?.value || '';
		console.log('最终提交的parentId:', form.value.parentId);
		assoFullName.value = getAssoFullName(valueArr)
		console.log('协会完整路径:', assoFullName.value);
	}

	// 地址选择(核心修复:从对象中提取纯value,对齐PC端格式)
// 地址选择(还原成你之前能用的版本:纯ID数组赋值)
	function changeAddress(e) {
		const selectedValue = e.detail?.value ?? e;
		console.log("选择的地址:", selectedValue);
		
		// 直接赋值纯ID,不要再取 .value
		form.value.provinceId = selectedValue[0] || '';
		form.value.cityId = selectedValue[1] || '';
		form.value.regionId = selectedValue[2] || '';
		
		// 同步更新选择器显示
		coordinates1.value = selectedValue;
		
		console.log('最终地址ID:', form.value.provinceId, form.value.cityId, form.value.regionId);
	}

	// 获取会员认证费用
	function getMyMemberCertUnitFeeApi() {
		api.getMyMemberCertUnitFee().then(res => {
			memberFee.value = res.data
		})
	}

	// 检查是否可用优惠政策
	function canUseDiscountApi() {
		api.canUseDiscount().then(res => {
			preferentialPolicy.value = res.data
		})
	}

	// 获取优惠政策详情
	function getZtxDiscountPolicyApi() {
		api.getZtxDiscountPolicy().then(res => {
			preferentialData.value = res.data
		})
	}

	// 获取考点申请状态
	function getMyStatusAPI() {
		api.getMyStatus().then(res => {
			if (res.data && res.data.auditStatus) {
				auditStatus.value = res.data.auditStatus
			} else {
				auditStatus.value = '0'
			}
		})
	}

	// 步骤1提交
	function submitStep1() {
		// 验证必填项
		if (!form.value.baseName) {
			uni.showToast({ title: '请填写单位名称', duration: 2000, icon: 'none' })
			return
		}
		if (!form.value.type) {
			uni.showToast({ title: '请选择单位类型', duration: 2000, icon: 'none' })
			return
		}
		if (!form.value.contact) {
			uni.showToast({ title: '请填写联系人', duration: 2000, icon: 'none' })
			return
		}
		if (!form.value.phone) {
			uni.showToast({ title: '请填写联系电话', duration: 2000, icon: 'none' })
			return
		}
		if (!form.value.introduce) {
			uni.showToast({ title: '请填写机构介绍', duration: 2000, icon: 'none' })
			return
		}

		api.createMyMember(form.value).then(res => {
			if (res.code === 200) {
				if (res.data.token) {
					uni.setStorageSync('token', 'Bearer ' + res.data.token)
				}
				uni.showToast({ title: '操作成功', duration: 1500, icon: 'success' })
				setTimeout(() => {
					active.value = 1
					getDetail()
				}, 1500)
			} else {
				uni.showToast({ title: res.msg || '操作失败', duration: 2000, icon: 'none' })
			}
		})
	}

	// 步骤2提交
	function submitStep2() {
		// 验证必填项
		if (!form.value.parentId || form.value.parentId == 0 || form.value.parentId == -1) {
			uni.showToast({ title: '请选择所属协会', duration: 2000, icon: 'none' })
			return
		}
		if (!form.value.name) {
			uni.showToast({ title: '请输入机构名称', duration: 2000, icon: 'none' })
			return
		}
		if (coordinates1.value.length === 0) {
			uni.showToast({ title: '请选择认证地址', duration: 2000, icon: 'none' })
			return
		}
		if (!form.value.adress) {
			uni.showToast({ title: '请输入认证详细地址', duration: 2000, icon: 'none' })
			return
		}
		if (!form.value.siteContact) {
			uni.showToast({ title: '请输入联系人', duration: 2000, icon: 'none' })
			return
		}
		if (!form.value.siteTel) {
			uni.showToast({ title: '请输入联系方式', duration: 2000, icon: 'none' })
			return
		}
		if (!form.value.businessLicense) {
			uni.showToast({ title: '请上传营业执照', duration: 2000, icon: 'none' })
			return
		}
		if (!form.value.companyName) {
			uni.showToast({ title: '请输入营业执照名称', duration: 2000, icon: 'none' })
			return
		}
		if (!form.value.creditCode) {
			uni.showToast({ title: '请输入社会信用代码', duration: 2000, icon: 'none' })
			return
		}
		if (!form.value.legalIdcPhoto1 || !form.value.legalIdcPhoto2) {
			uni.showToast({ title: '请上传身份证正反面', duration: 2000, icon: 'none' })
			return
		}
		if (!form.value.legal) {
			uni.showToast({ title: '请输入法人姓名', duration: 2000, icon: 'none' })
			return
		}
		if (!form.value.legalIdcCode) {
			uni.showToast({ title: '请输入法人证件号', duration: 2000, icon: 'none' })
			return
		}
		if (!form.value.pictures) {
			uni.showToast({ title: '请上传机构照片', duration: 2000, icon: 'none' })
			return
		}

		// 验证营业执照和法人信息
		uni.showLoading({ title: '验证中...' })
		api.checkBusinessLicense({
			creditCode: form.value.creditCode,
			companyName: form.value.companyName,
			legalIdcCode: form.value.legalIdcCode,
			legal: form.value.legal
		}).then(checkRes => {
			uni.hideLoading()
			if (checkRes.code !== 200) {
				uni.showModal({
					title: '系统提示',
					content: checkRes.msg || '企业信息异常请检查相关资料信息,确认无误后再次提交!',
					showCancel: true,
					confirmText: '确认无误',
					cancelText: '返回修改',
					success: (res) => {
						if (res.confirm) {
							 submitCertification()
						}
					}
				})
			} else {
				 submitCertification()
			}
		}).catch(() => {
			uni.hideLoading()
			uni.showModal({
				title: '系统提示',
				content: '企业信息异常请检查相关资料信息,确认无误后再次提交!',
				showCancel: true,
				confirmText: '确认无误',
				cancelText: '返回修改',
				success:  (res) => {
					if (res.confirm) {
						 submitCertification()
					}
				}
			})
		})
	}

	// 提交认证信息(100%对齐PC端入参格式)
	function submitCertification() {
		uni.showLoading({ title: '提交中...' })
		api.editMyMemberCertifiedInfo({
			parentId: form.value.parentId,
			creditCode: form.value.creditCode,
			legal: form.value.legal,
			businessLicense: JSON.stringify({
				url: form.value.businessLicense,
				name: form.value.businessLicenseName
			}),
			pictures: form.value.pictures,
			memId: form.value.memId,
			id: form.value.deptId,
			name: form.value.name,
			regionId: form.value.regionId?.value,
			cityId: form.value.cityId.value,
			provinceId: form.value.provinceId.value,
			adress: form.value.adress,
			deptType: app.globalData.deptType,
			legalIdcPhoto: [form.value.legalIdcPhoto1, form.value.legalIdcPhoto2].join(','),
			applyPoints: '0',
			siteContact: form.value.siteContact,
			siteTel: form.value.siteTel,
			companyName: form.value.companyName,
			legalIdcCode: form.value.legalIdcCode
		}).then(res => {
			uni.hideLoading()
			if (res.code === 200) {
				uni.showToast({ title: '提交成功', duration: 1500, icon: 'success' })
				// 跳转缴费页面
				setTimeout(() => {
					const assoName = assoFullName.value
					console.log(888,assoName)
					// 跳转到缴费页面
					uni.navigateTo({
						url: `/myCenter/goPay?payName=${encodeURIComponent(form.value.name || '')}&assoName=${encodeURIComponent(assoName)}`
					})
				}, 1500)
			} else {
				uni.showToast({ title: res.msg || '提交失败', duration: 2000, icon: 'none' })
			}
		}).catch(() => {
			uni.hideLoading()
		})
	}

	// 营业执照上传
	function onBusinessLicenseSelect() {
		uni.chooseImage({
			count: 1,
			sizeType: ['compressed'],
			sourceType: ['album', 'camera'],
			success: (res) => {
				if (res.tempFilePaths && res.tempFilePaths.length > 0) {
					form.value.businessLicense = res.tempFilePaths[0]
					// 调用API识别营业执照
					uni.uploadFile({
						url: config.baseUrl_api + '/member/info/getBusinessLicense',
						filePath: res.tempFilePaths[0],
						name: 'pic',
						header: {
							'Authorization': uni.getStorageSync('token')
						},
						success: (uploadRes) => {
							const data = JSON.parse(uploadRes.data)
							if (data.code === 200 && data.data) {
								form.value.creditCode = data.data.creditCode
								form.value.companyName = data.data.companyName
								form.value.businessLicenseName = data.data.name
							}
						}
					})
				}
			}
		})
	}

	function removeBusinessLicense() {
		form.value.businessLicense = ''
		form.value.businessLicenseName = ''
	}

	// 删除身份证正面
	function removeIdCardFront() {
		form.value.legalIdcPhoto1 = ''
	}

	// 删除身份证反面
	function removeIdCardBack() {
		form.value.legalIdcPhoto2 = ''
	}

	// 身份证上传(修复:正面调用OCR,和PC端逻辑一致)
	function onIdCardFrontSelect() {
		uni.chooseImage({
			count: 1,
			sizeType: ['compressed'],
			sourceType: ['album', 'camera'],
			success: (res) => {
				if (res.tempFilePaths && res.tempFilePaths.length > 0) {
					form.value.legalIdcPhoto1 = res.tempFilePaths[0]
					
				}
			}
		})
	}

	function onIdCardBackSelect() {
		uni.chooseImage({
			count: 1,
			sizeType: ['compressed'],
			sourceType: ['album', 'camera'],
			success: (res) => {
				if (res.tempFilePaths && res.tempFilePaths.length > 0) {
					form.value.legalIdcPhoto2 = res.tempFilePaths[0]
					extractIdCardInfo() // 修复:正面上传后调用OCR提取信息
				}
			}
		})
	}

	// 提取身份证信息(修复:传正面照片legalIdcPhoto1,和PC端逻辑一致)
	function extractIdCardInfo() {
		if (form.value.legalIdcPhoto1) {
			uni.uploadFile({
				url: config.baseUrl_api + '/person/info/getPersonInfoFromCert/0',
				filePath: form.value.legalIdcPhoto2,
				name: 'pic',
				header: {
					'Authorization': uni.getStorageSync('token')
				},
				success: (res) => {
					const data = JSON.parse(res.data)
					if (data.code === 200 && data.data) {
						form.value.legal = data.data.name
						form.value.legalIdcCode = data.data.code
					}
				}
			})
		}
	}

	// 机构照片上传
	function onPicturesSelect() {
		uni.chooseImage({
			count: 3,
			sizeType: ['compressed'],
			sourceType: ['album', 'camera'],
			success: (res) => {
				if (res.tempFilePaths && res.tempFilePaths.length > 0) {
					form.value.pictures = res.tempFilePaths.join(',')
				}
			}
		})
	}

	// 预览图片
	function previewImage(url) {
		if (Array.isArray(url)) {
			uni.previewImage({
				urls: url
			})
		} else {
			uni.previewImage({
				urls: [url]
			})
		}
	}

	// 删除机构照片
	function removePictures() {
		form.value.pictures = ''
	}

	// 去缴费 - 参考PC payTheFees逻辑,先校验基础信息
	function goPay() {
		// 检查基础信息是否完善
		if (!form.value.siteContact) {
			uni.showToast({
				title: '请完善基础信息!',
				icon: 'none'
			})
			return
		}
		// 使用完整的协会路径名称
		const assoName = assoFullName.value || getAssoName(form.value.parentId)
		// 跳转到缴费页面
		uni.navigateTo({
			url: `/myCenter/goPay?payName=${encodeURIComponent(form.value.name || '')}&assoName=${encodeURIComponent(assoName)}`
		})
	}

	// 根据协会ID获取协会名称(只获取最后一级)
	function getAssoName(parentId) {
		if (!parentId || !assoList.value || assoList.value.length === 0) {
			return ''
		}
		// 递归查找协会名称
		function findInTree(list) {
			for (const item of list) {
				if (item.value === parentId) {
					return item.text || ''
				}
				if (item.children && item.children.length > 0) {
					const found = findInTree(item.children)
					if (found) return found
				}
			}
			return null
		}
		return findInTree(assoList.value) || ''
	}

	// 根据选择的值数组获取完整的协会路径名称
	function getAssoFullName(valueArr) {
		if (!valueArr || valueArr.length === 0 || !assoList.value || assoList.value.length === 0) {
			return ''
		}
		const pathNames = []
		let currentList = assoList.value
		for (let i = 0; i < valueArr.length; i++) {
			const node = valueArr[i]
			const found = currentList.find(item => item.value === node?.value || item.value === node)
			if (found) {
				pathNames.push(found.text || found.label || '')
				if (found.children) {
					currentList = found.children
				}
			} else {
				break
			}
		}
		return pathNames.join('/')
	}

	// 去认证 - 提交认证信息
	function doCertification() {
		submitStep2()
	}

	// 审核详情 - 跳转到审核详情页面
	function goAuditDetail() {
		uni.navigateTo({
			url: '/myCenter/certAuditDetail'
		})
	}
</script>

<style lang="scss" scoped>
.perfect-page {
	min-height: 100vh;
	background: #f5f5f5;
	padding-bottom: 120rpx;
}

/* 顶部步骤条 */
.steps-bar {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 15rpx 60rpx;
	background: #fff;
	margin-top: 20rpx;

	.step-item {
		display: flex;
		align-items: center;

		.step-circle {
			width: 48rpx;
			height: 48rpx;
			border-radius: 50%;
			background: #fff;
			border: 2rpx solid #999;
			color: #999;
			font-size: 24rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			margin-right: 10rpx;
			transition: all 0.3s;
		}

		.step-text {
			font-size: 24rpx;
			color: #999;
			transition: all 0.3s;
		}

		&.active .step-circle {
			background: #fff;
			color: #AD181F;
			border-color: #AD181F;
		}

		&.active .step-text {
			color: #AD181F;
			font-weight: 600;
		}

		&.current .step-circle {
			background: #AD181F;
			color: #fff;
			box-shadow: 0 4rpx 12rpx rgba(173, 24, 31, 0.3);
		}

		&.current .step-text {
			color: #AD181F;
			font-weight: 600;
		}
	}

	.step-line {
		width: 120rpx;
		height: 4rpx;
		background: #e0e0e0;
		margin: 0 20rpx;
		transition: all 0.3s;

		&.active {
			background: #AD181F;
		}
	}
}

.wBox {
	width: 700rpx;
	padding: 30rpx;
	margin: 20rpx auto 0;
	background: #FFFFFF;
	box-shadow: 0rpx 12rpx 116rpx 0rpx rgba(196, 203, 214, 0.1);
	border-radius: 15rpx;
}

.status-box {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 20rpx 0;
	margin-bottom: 20rpx;
}

.status-row {
	display: flex;
	align-items: center;
}

.status-label {
	font-size: 28rpx;
	color: #333;
	margin-right: 10rpx;
}

.btn-row {
	display: flex;
	gap: 10rpx;
}

.btn-row button {
	padding: 0 20rpx;
	height: 50rpx;
	line-height: 50rpx;
	border-radius: 25rpx;
	font-size: 22rpx;
}

.btn-row button:first-child {
	background: #e64329;
	color: #fff;
}

.btn-row button:last-child {
	background: #f5f5f5;
	color: #666;
}

.upload-box {
	width: 100%;
}

.upload-placeholder {
	width: 100%;
	height: auto;
	aspect-ratio: 3/2;
	border-radius: 8rpx;
	overflow: hidden;
	vertical-align: middle;
}

.placeholder-img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.license-preview {
	position: relative;
	width: 100%;
}

.license-img {
	width: 100%;
	height: auto;
	aspect-ratio: 3/2;
	border-radius: 8rpx;
	object-fit: cover;
}

.license-name {
	flex: 1;
	font-size: 26rpx;
	color: #666;
}

.idcard-box {
	margin-bottom: 20rpx;
}

.idcard-item {
	width: 100%;
}

.idcard-placeholder {
	width: 100%;
	height: auto;
	aspect-ratio: 3/2;
	border-radius: 8rpx;
	overflow: hidden;
	vertical-align: middle;
}

.idcard-preview {
	position: relative;
	width: 100%;
}

.idcard-img {
	width: 100%;
	height: auto;
	aspect-ratio: 3/2;
	border-radius: 8rpx;
	object-fit: cover;
}

.delete-btn {
	position: absolute;
	top: 10rpx;
	right: 10rpx;
	background: #e64329;
	color: #fff;
	width: 40rpx;
	height: 40rpx;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 28rpx;
	font-weight: bold;
	z-index: 10;
	box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.2);
}

.pictures-box {
	width: 100%;
}

.picture-placeholder {
	width: 100%;
	height: auto;
	aspect-ratio: 4/3;
	border-radius: 8rpx;
	overflow: hidden;
	vertical-align: middle;
}

.pictures-preview {
	position: relative;
	width: 100%;
}

.picture-img {
	width: 100%;
	height: auto;
	aspect-ratio: 4/3;
	border-radius: 8rpx;
	object-fit: cover;
}

.fee-box {
	font-size: 32rpx;
	color: #ff6600;
	font-weight: bold;
}

.fixedBottom {
	display: flex;
	justify-content: center;
	gap: 30rpx;
	padding: 30rpx 0;
	position: fixed;
	bottom: 0;
	left: 0;
	right: 0;
	background: #fff;
	box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);
}

.btn-red {
	width: 300rpx;
	height: 80rpx;
	line-height: 80rpx;
	background: #e64329;
	color: #fff;
	border-radius: 40rpx;
	font-size: 28rpx;
}

.btn-gray {
	width: 300rpx;
	height: 80rpx;
	line-height: 80rpx;
	background: #f5f5f5;
	color: #666;
	border-radius: 40rpx;
	font-size: 28rpx;
}

.text-danger {
	color: #e64329;
}

.text-success {
	color: #07c07e;
}

.text-warning {
	color: #ff9800;
}

/* 输入框边框样式 */
.input-with-border {
	border: 1rpx solid #e0e0e0;
	border-radius: 8rpx;
	padding: 0 20rpx;
	width: 100%;
	box-sizing: border-box;
	
	:deep(.uni-easyinput__input) {
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}
}

/* 级联选择器容器 - 修复边框和宽度问题(删除重复定义) */
.picker-wrapper {
	border: 1rpx solid #e0e0e0;
	border-radius: 8rpx;
	width: 100%;
	box-sizing: border-box;
	overflow: hidden;
}

/* 修复uni-data-picker 文字靠左 + 样式统一(合并重复样式) */
:deep(.uni-data-picker) {
    width: 100%;
    display: block;
}
:deep(.uni-data-picker .selected-area) {
    width: 100%;
    padding: 0 20rpx;
    box-sizing: border-box;
    display: flex;
    justify-content: flex-start;
    text-align: left;
}
:deep(.uni-data-picker .selected-text) {
    font-size: 28rpx;
    color: #333;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
:deep(.uni-data-picker .uni-data-picker__input) {
    text-align: left !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
:deep(.selected-list) {
		justify-content: start;
}

/* 修复高度统一 */
.custom-picker {
	width: 100% !important;
	min-height: 70rpx;
}

/* 修复uni-forms-item中内容超出问题 */
:deep(.uni-forms-item__content) {
	overflow: hidden;
	width: 100%;
}

/* 确保所有表单元素不超出父容器 */
:deep(uni-forms-item) {
	width: 100%;
	overflow: hidden;
}

/* 修复选择器容器宽度问题 */
.picker-wrapper {
	width: 100%;
	box-sizing: border-box;
	overflow: hidden;
}
</style>