member.vue 35.9 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
<template>
  <div>
    <div v-if="showDirectly&&directUnderFlag==0&&associateId==0" class="box mb20">
      <div class="flexRow">
        <div style="width: 120px;">
          <h3 class="m0">团队会员认证</h3>
        </div>
        <div v-if="authenticationStatusa == 2" style="width: 180px;">
          <label> 有效日期至({{ parseTime(form?.validityDate, '{y}-{m}-{d}') }}) </label>
        </div>

        <div style="width: 140px;">
          <div class="fitem">
            <label>认证状态:</label>
            <span v-if="activeStatus==0&&authenticationStatusa" class="text-danger">未激活</span>
            <span v-else>
              <span v-if="authenticationStatusa == 0 ||!authenticationStatusa" class="text-danger">未认证</span>
              <span v-if="authenticationStatusa == 1" class="text-success">认证中</span>
              <span v-if="authenticationStatusa == 2" class="text-success">已认证</span>
              <span v-if="authenticationStatusa == 3" class="text-danger">认证未通过</span>
              <span v-if="authenticationStatusa == 4" class="text-danger">即将过期</span>
              <span v-if="authenticationStatusa == 5" class="text-danger">已过期</span>
            </span>

          </div>
        </div>
        <div v-if="activeStatus==0&&authenticationStatusa" class="row-btn">
          <el-button type="primary" @click="payTheFees">激活</el-button>
        </div>
        <div v-else :class="{'association':deptType!=6}" class="row-btn">
          <el-button :disabled="btn" type="primary" @click="payTheFees">去缴费</el-button>
          <el-button v-if="form.deptType!=1" type="primary" @click="auditEditFN">审核详情</el-button>
          <!--          <el-button-->
          <!--            v-if="deptType==6"-->
          <!--            type="primary"-->
          <!--            :disabled="auditStatus==1||auditStatus==2||form.isPoints==0"-->
          <!--            @click="handelPoints"-->
          <!--          >考点申请-->
          <!--          </el-button>-->
          <!--          <el-button v-if="deptType==6" type="primary" @click="handelView">考点详情</el-button>-->
        </div>
      </div>

    </div>

    <div class="box">
      <el-form :model="form" class="rightForm" label-width="160px">

        <el-form-item v-if="form.memCode" label="会员编号" prop="menCode">
          <div class="left">{{ form.memCode }}</div>
        </el-form-item>
        <el-form-item label="营业执照" prop="businessLicense">
          <el-image
            v-if="businessLicenseValue" :src="fillImgUrl(form.certBusinessLicense)" class="left"
            it="fit" style="width: 220px; height: 130px;"
          />

          <a v-if="businessLicenseValue" :src="fillImgUrl(form.certBusinessLicense)" :underline="false" target="_blank">
            <el-button class="left" link type="primary">营业执照</el-button>
          </a>
          <a v-else :href="fillImgUrl(form?.certBusinessLicense?.[0]?.url)" :underline="false" target="_blank">
            <el-button class="left" link type="primary">{{ form?.certBusinessLicense?.[0]?.name }}
            </el-button>
          </a>
        </el-form-item>
        <el-form-item label="营业执照名称" prop="legal">
          <div class="left">{{ form.companyName }}</div>
        </el-form-item>
        <el-form-item
          v-if="authenticationStatusa != 1&&authenticationStatusa != 0&&authenticationStatusa != 3&&newResult||form.associateId&&form.associateId>0||activeStatus==1"
          label="社会信用代码" prop="creditCode"
        >
          <div class="left">{{ form.creditCode }}</div>
        </el-form-item>
        <el-form-item label="机构名称" prop="name">
          <div class="left">{{ form.name }}</div>
        </el-form-item>
        <el-form-item label="认证地址" prop="coordinates1">
          <div class="left">{{ address }}</div>
        </el-form-item>
        <el-form-item label="认证详细地址" prop="adress">
          <div class="left">{{ form.certAddress }}</div>
        </el-form-item>
        <el-form-item v-if="form.aname" label="所属协会" prop="parentId">
          <div v-if="authenticationStatusa != 1&&authenticationStatusa != 0&&authenticationStatusa != 3" class="left">
            {{ form.aname }}
          </div>
        </el-form-item>

        <el-form-item label="法人身份证" prop="legal">
          <el-image
            :src="fillImgUrl(form.legalIdcPhoto3)" class="left idCard"
            fit="fill"
            style="width: 360px; height: 225px;"
          />
          <el-image
            :src="fillImgUrl(form.legalIdcPhoto4)" class="left idCard"
            fit="fill"
            style="width: 360px; height: 225px;"
          />
        </el-form-item>
        <el-form-item label="法人姓名" prop="legal">
          <div class="left">{{ form.certLegal }}</div>
        </el-form-item>
        <el-form-item label="法人证件号" prop="legal">
          <div class="left">{{ form.legalIdcCode }}</div>
        </el-form-item>
        <!--        <el-form-item v-if="form.deptType==6" label="是否为考点" prop="isPoints">-->
        <!--          <el-radio-group v-model.trim="form.isPoints" class="left" disabled>-->
        <!--            <el-radio label="0"></el-radio>-->
        <!--            <el-radio label="1"></el-radio>-->
        <!--          </el-radio-group>-->
        <!--        </el-form-item>-->

        <el-form-item label="联系人" prop="legal">
          <div class="left">{{ form.certSiteContact }}</div>
        </el-form-item>
        <el-form-item label="联系方式" prop="legal">
          <div class="left">{{ form.certSiteTel }}</div>
        </el-form-item>
        <el-form-item label="机构照片" prop="pictures">
          <div class="left">
            <el-image
              v-for="item in imgList" :key="item" :src="fillImgUrl(item)" class="right"
              fit="fill"
              style="width: 220px; height: 130px;"
            />
          </div>
        </el-form-item>
        <br>
        <br>
      </el-form>
    </div>

    <!-- 编辑 -->
    <el-dialog
      v-if="showEdit" v-model.trim="showEdit" :title="activeStatus==0&&authenticationStatusa?'去激活':'去缴费'" align-center
      append-to-body
      destroy-on-close="true"
      width="1000px"
    >
      <el-form
        ref="formData" :model="form" :rules="rules" class="rightForm"
        label-width="160px"
      >
        <el-form-item class="cas" label="选择所属协会" prop="parentId">
          <el-cascader
            v-model.trim="form.parentId"
            :disabled="type&&parentId!=-1&&parentId!=0"
            :options="list"
            :props="props2"
            clearable
            filterable
            style="width: 100%;"
          />
        </el-form-item>
        <!--        <el-form-item v-if="form.memCode" label="会员编号" prop="menCode">-->
        <!--          <el-input v-model.trim="form.memCode" :disabled="true" style="width: 100%" />-->
        <!--        </el-form-item>-->
        <el-form-item class="FileUpload" label="上传营业执照" prop="businessLicense">
          <FileUpload
            v-model.trim="form.businessLicense" v-model:file="file2" :file-size="100"
            :file-type="['png','jpg','jpeg','gif']"
            :limit="1"
            class="father"
          />
        </el-form-item>
        <el-form-item label="营业执照名称" prop="companyName">
          <el-input v-model.trim="form.companyName" style="width: 100%;" />
        </el-form-item>
        <el-form-item label="社会信用代码" prop="creditCode">
          <el-input v-model.trim="form.creditCode" style="width: 100%;" />
        </el-form-item>

        <el-form-item label="机构名称" prop="name">
          <el-input v-model.trim="form.name" :disabled="type" style="width: 100%;" />
          <!--          <el-input v-model="form.name" :disabled="type" style="width: 100%" />-->
        </el-form-item>
        <!--        <el-form-item label="所属省份" prop="belongProvinceId">-->
        <!--          <el-select-->
        <!--            v-model="form.belongProvinceId"-->
        <!--            placeholder="请选择"-->
        <!--            style="width: 100%"-->
        <!--            :disabled="type&&(belongProvinceId||belongProvinceId==0)"-->
        <!--          >-->
        <!--            <el-option label="全国" :value="0" />-->
        <!--            <el-option v-for=" item in options " :key="item.value" :label="item.text" :value="item.value" />-->
        <!--          </el-select>-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="社会信用代码" prop="creditCode">-->
        <!--          <el-input v-model="form.creditCode" style="width: 100%" />-->
        <!--        </el-form-item>-->

        <el-form-item label="认证地址" prop="coordinates1">
          <el-cascader
            ref="cascaderA"
            v-model.trim="form.coordinates1"
            :options="options"
            :props="defaultProps"
            filterable
            placeholder="请选择"
            style="width: 100%;"
            @change="changeAddress"
          />
        </el-form-item>
        <el-form-item label="认证详细地址" prop="adress">
          <el-input v-model.trim="form.adress" style="width: 100%;" />
        </el-form-item>
        <!--        <el-form-item label="联系人" prop="siteContact">-->
        <!--          <el-input v-model.trim="form.siteContact" style="width: 100%" />-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="联系方式" prop="siteTel">-->
        <!--          <el-input v-model.trim="form.siteTel" style="width: 100%" />-->
        <!--        </el-form-item>-->
        <!--        <el-form-item v-if="form.deptType==6&&activeStatus!= 0" label="是否申请考点" prop="applyPoints">-->
        <!--          <el-radio-group v-model.trim="form.applyPoints">-->
        <!--            <el-radio label="1"></el-radio>-->
        <!--            <el-radio label="0"></el-radio>-->
        <!--          </el-radio-group>-->
        <!--        </el-form-item>-->

        <el-form-item class="legalCard" label="法人身份证" prop="legalIdcPhoto1">
          <el-row style="width: 100%;">
            <el-col :span="12">
              <ImageUpload2
                v-model.trim="form.legalIdcPhoto1" :crop-height="260" :crop-width="440" :limit="1"
                class="card1"
              />
            </el-col>
            <el-col :span="12">
              <ImageUpload2
                v-model.trim="form.legalIdcPhoto2" v-model:file="file1" :crop-height="260" :crop-width="440"
                :limit="1"
                class="card2"
              />
            </el-col>
          </el-row>
        </el-form-item>
        <el-form-item label="法人姓名" prop="legal">
          <el-input v-model.trim="form.legal" style="width: 100%;" />
        </el-form-item>
        <el-form-item label="法人证件号" prop="legalIdcCode">
          <el-input v-model.trim="form.legalIdcCode" style="width: 100%;" />
        </el-form-item>
        <el-form-item label="联系人" prop="siteContact">
          <el-input v-model="form.siteContact" style="width: 100%" />
        </el-form-item>
        <el-form-item label="联系方式" prop="siteTel">
          <el-input v-model="form.siteTel" style="width: 100%" />
        </el-form-item>
        <el-form-item label="上传机构照片" prop="pictures">
          <ImageUpload2 v-model.trim="form.pictures" :limit="3" crop-height="260" crop-width="440" />
        </el-form-item>
        <el-form-item v-if="authenticationStatusa != 1" label="&nbsp;" prop="notice">
          <el-row>
            <el-checkbox v-model="form.notice" style="margin-right: 10px;" />
            <span>我已阅读并同意</span>
            <el-button link style="margin:0;" type="primary" @click="handelNotice(1)">《注册须知》</el-button>
            <el-button link style="margin:0;" type="primary" @click="handelNotice(2)">《入会须知》</el-button>
            <el-button link style="margin:0;" type="primary" @click="handelNotice(3)">《免责声明》</el-button>
          </el-row>
        </el-form-item>
        <br>
        <br>
      </el-form>
      <template #footer>
        <div style="text-align: center;">
          <el-button class="btn" round @click="showEdit=false"> </el-button>
          <el-button class="btn" round type="primary" @click="submit">下一步</el-button>
        </div>
      </template>
    </el-dialog>

    <auditEdit ref="auditEditRef" />
    <examView ref="examViewRef" />
    <applyNow ref="applyNowRef" @handel-submit="handelSubmit" />
    <goPay
      ref="goPayRef" :a-name="form.aname" :name="form.name" @payment-success="paymentSuccess"
      @payment-view="paymentView"
    />
    <payOk ref="payOkRef" />
    <payView ref="payViewRef" />
    <zhuCeXuZhi ref="zhuCeXuZhiRef" />
    <ruHuiXuZhi ref="ruHuiXuZhiRef" />
    <mianZeShengMing ref="mianZeShengMingRef" />
  </div>

</template>

<script setup>
import {
  editMyMemberCertifiedInfo,
  getMyOwnMemberInfo,
  certifiedDeptTreeRegister,
  // commit,
  regionsList, active, getBusinessLicense, checkBusinessLicense, getMyStatus, creditCodeExist
} from '@/api/system/userInfo.js'
import { getMyRecent } from '@/api/system/config'
import applyNow from '@/views/system/user/profile/components/applyNow'
import goPay from '@/views/system/user/profile/components/goPay'
import payOk from '@/components/memberComponents/payOk.vue'
import mianZeShengMing from '@/views/groupMember/components/mianZeShengMing.vue'
import ruHuiXuZhi from '@/views/groupMember/components/ruHuiXuZhi.vue'
import zhuCeXuZhi from '@/views/groupMember/components/zhuCeXuZhi.vue'
import payView from '@/views/system/user/profile/components/payView.vue'
import { carUrl } from '@/api/person/info'
import { deptTreeSelect } from '@/api/system/user'
import { ref, reactive, toRefs, watch, getCurrentInstance, computed, onMounted } from 'vue'
import auditEdit from './auditEdit'
import examView from './examView.vue'
import { ElMessageBox } from 'element-plus'
import useUserStore from '@/store/modules/user'
import { useRouter } from 'vue-router'
import { cancelOrder } from '@/api/order'

const router = useRouter()
const deptType = computed(() => useUserStore().deptType)
const pr = ref([])
const { proxy } = getCurrentInstance()
const authenticationStatusa = ref()
const list = ref([])
const options = ref([])
const btn = ref(true)
const address = ref()
const defaultProps = {
  children: 'children',
  label: 'text',
  checkStrictly: true
}

// 激活    0 未激活 1 已激活
const activeStatus = ref(0)
const file1 = ref()
const file2 = ref()
const timer = ref()
const associateId = ref(1) // 是否绑定直属 0未绑定
const showDirectly = ref(false)
const showDialog = ref(false)
const showEdit = ref(false)
const type = ref(false) // 第一次选择认证认证类型
const flag = ref(false)
const result = ref(false)
const resultNoProvince = ref(false)
const materials1 = ref()
const applicationForMembership1 = ref()
const pictures = ref()
const legal = ref()
const creditCode = ref()
const adress = ref()
const coordinates1 = ref()
const parentId = ref()
const props2 = {
  checkStrictly: true,
  children: 'children',
  value: 'id',
  emitPath: false,
  disabled: 'disabled'
}

const data = reactive({
  form: {
    type: 1,
    notice: false
  },
  rules: {
    parentId: [{ required: true, trigger: 'blur', message: '请选择所属协会' }],
    notice: [
      { required: true, trigger: 'blur', message: '请先阅读并勾选注册须知,入会须知,免责声明' },
      { validator: validateNotice, trigger: ['blur', 'change'] }
    ],
    date1: [{ required: true, trigger: 'blur', message: '请选择有效期' }],
    creditCode: [
      { required: true, trigger: 'blur', message: '请输入社会信用代码' },
      { validator: validateCreditCode, trigger: ['blur', 'change'] }
    ],
    businessLicense: [
      { required: true, trigger: 'blur', message: '请上传营业执照' }
    ],
    companyName: [
      { required: true, trigger: 'blur', message: '请输入营业执照名称' }
    ],
    legal: [{ required: true, trigger: 'blur', message: '请输入法人姓名' }],
    legalIdcCode: [{ required: true, trigger: 'blur', message: '请输入法人证件号' }],
    siteContact: [{ required: true, trigger: 'blur', message: '请输入联系人' }],
    siteTel: [{ required: true, trigger: 'blur', message: '请输入联系方式' }],
    applyPoints: [{ required: true, trigger: 'blur', message: '请选择是否为考点' }],
    isPoints: [{ required: true, trigger: 'blur', message: '请选择是否为考点' }],
    pictures: [{ required: true, trigger: 'blur', message: '请上传机构照片' }],
    name: [{ required: true, trigger: 'blur', message: '请输入机构名称' }],
    materials1: [{ required: true, trigger: 'blur', message: '请上传入会材料' }],
    applicationForMembership1: [{ required: true, trigger: 'blur', message: '请上传入会申请书' }],
    renewYear: [{ required: true, trigger: 'blur', message: '请选择认证年限' }],
    deptType: [{ required: true, trigger: 'blur', message: '请选择认证类型' }],
    orgName: [{ required: true, trigger: 'blur', message: '请输入机构名称' }],
    check: [{ required: true, trigger: 'blur', message: '请勾选入会须知' }],
    adress: [{ required: true, trigger: 'blur', message: '请输入认证详细地址' }],
    coordinates1: [{ required: true, trigger: 'blur', message: '认证地址不能为空' }],
    leaseValidity: [{ required: true, trigger: 'blur', message: '请选择租赁有效期' }],
    legalIdcPhoto1: [
      { required: true, trigger: 'blur', message: '请上传身份证正反面' },
      { validator: validateID, trigger: 'blur' }
    ],
    belongProvinceId: [{ required: true, trigger: 'change', message: '请选着所属省份' }],
    ownFlag: [{ required: true, trigger: 'change', message: '请选择是否为自选考场' }],
    leaseTime: [{ required: true, trigger: 'change', message: '请选着租赁合同有效期' }],
    leaseContract: [{ required: true, trigger: 'blur', message: '请上传租赁合同' }]
  },
  rules1: {
    renewYear: [{ required: true, trigger: 'blur', message: '请选择缴费年限' }]
  }
})
const { form, rules } = toRefs(data)
const imgList = ref([])
const newResult = ref(false) // 认证流程至少通过一次
const leaseTime = ref()
const leaseTimeS = ref()
const directUnderFlag = ref(0)
const businessLicenseValue = ref()
const validating = ref(false)
// 考点审核状态  0 未提交 1 审核中 2 审核成功 3 审核失败
const auditStatus = ref(0)
const payForm = ref({})
onMounted(() => {
  // ElMessageBox.confirm(
  //   '您有一笔订单尚未支付,请及时支付 或 取消订单。',
  //   '系统提示', {
  //     confirmButtonText: '去支付',
  //     cancelButtonText: '取消订单',
  //     type: 'warning',
  //     showClose: false,
  //     closeOnClickModal: false,
  //     closeOnPressEscape: false
  //   }).then(() => {
  //   proxy.$refs['goPayRef'].open(payForm.value)
  // }).catch((err) => {
  //   console.log(err)
  //   // 取消订
  //   handelCancelOrder()
  // })
  addressFn()
  if (deptType.value !== '1') {
    getMyStatusAPI()
  }
  handelGetMyRecent()
})

/** 取消订单 */
async function handelCancelOrder() {
  await proxy.$modal.confirm(`是否确认取消订单?`)
  if (!payForm.value.id) return
  await cancelOrder(payForm.value.id)
  await initData()
  await proxy.$modal.msgSuccess('操作成功')
}

function handelGetMyRecent() {
  return new Promise(async(resolve, reject) => {
    const res = await getMyRecent() ?? {}
    if (res.data) payForm.value = res.data.comOrder ?? {}
    if (payForm.value.content)payForm.value.content = JSON.parse(payForm.value.content)
    // `pay_status` char(1) DEFAULT '0' COMMENT '支付状态 0 未支付 1 已支付 2 已取消 3 无需支付',
    if (payForm.value.payStatus === '0') {
      ElMessageBox.confirm(
        '您有一笔订单尚未支付,请及时支付 或 取消订单。',
        '系统提示', {
          confirmButtonText: '去支付',
          cancelButtonText: '取消订单',
          type: 'warning',
          showClose: false,
          closeOnClickModal: false,
          closeOnPressEscape: false
        }).then(() => {
        proxy.$refs['goPayRef'].open(payForm.value)
        return reject(res)
      }).catch((err) => {
        console.log(err)
        // 取消订
        handelCancelOrder()
        return reject(res)
      })
      // await proxy.$modal.confirm('您有1笔订单尚未支付,请及时支付 或 取消订单。').final(() => {
      //   router.push({ path: '/group/groupOrder' })
      // })
    } else {
      return resolve(true)  
    }
  })
}

async function getMyStatusAPI() {
  const { data } = await getMyStatus()
  if (data && data.auditStatus) {
    auditStatus.value = data.auditStatus
  } else {
    auditStatus.value = 0
  }
}


async function addressFn() {
  const res = await regionsList()
  options.value = res.data
  await initData()
}

function handelSubmit() {
  getMyStatusAPI()
}

function paymentSuccess() {
  showEdit.value = false
  showDialog.value = false
  proxy.$refs['payOkRef'].open()

  // proxy.$modal.confirm('支付成功,等待审核中')
  initData()
}

function paymentView(row) {
  showEdit.value = false
  showDialog.value = false
  proxy.$refs['payViewRef'].open(row.orderId)
  initData()
}

// 身份证校验
function validateID(rule, value, callback) {
  if (!form.value.legalIdcPhoto1) {
    callback(new Error('请上传您的身份证国徽面'))
  }
  if (!form.value.legalIdcPhoto2) {
    callback(new Error('请上传您的身份证头像面'))
  }
  return callback()
}

function validateNotice(rule, value, callback) {
  if (!value) {
    callback(new Error('请先阅读并勾选注册须知,入会须知,免责声明'))
  } else {
    callback()
  }
}

// true 有
// 营业执照编号校验
async function validateCreditCode(rule, value, callback) {
  if (!value) return callback(new Error('请输入社会信用代码'))
  if (validating.value) return
  validating.value = true
  try {
    // 模拟异步请求
    const res = await creditCodeExist(value)
    if (res.data) {
      proxy.$modal.confirm('该社会统一信用代码已存在,请联系中国跆拳道协会010-87188971')
      callback(new Error('社会信用代码已存在请联系中跆协修改'))
    } else {
      callback()
    }
  } finally {
    validating.value = false
  }
}

async function initData() {
  const res = await getMyOwnMemberInfo()
  newResult.value = res.data.newResult//
  result.value = res.data.result// 认证缴费状态
  // resultNoProvince2.value = res.data.resultNoProvince2
  resultNoProvince.value = res.data.resultNoProvince2
  authenticationStatusa.value = res.data.authenticationStatus
  showDirectly.value = !res.data.memberInfo.associateId
  activeStatus.value = res.data.memberInfo.activeStatus
  pr.value = res.data.pr
  directUnderFlag.value = res.data.memberInfo.directUnderFlag
  associateId.value = res.data.memberInfo.associateId
  if (authenticationStatusa.value == 0) {
    btn.value = false
  } else if (authenticationStatusa.value == 1) {
    btn.value = true
  } else {
    // btn.value = !result.value
    btn.value = !resultNoProvince.value
  }

  // 认证地址
  const arr = []
  for (const item of options.value) {
    if (res.data.memberInfo.certProvinceId == item.value) {
      arr.push(item.text)
      for (const val of item.children) {
        if (res.data.memberInfo.certCityId == val.value) {
          arr.push(val.text)
          for (const inx of val.children) {
            if (res.data.memberInfo.certRegionId == inx.value) {
              arr.push(inx.text)
              break
            }
          }
          break
        }
      }
      break
    }
  }
  address.value = arr.join('/')

  // 认证信息
  if (authenticationStatusa.value == 0 || authenticationStatusa.value == 3) {
    type.value = false
  } else {
    type.value = true
  }
  // 至少审核通过一次
  if (authenticationStatusa.value != 0) {
    if (newResult.value) {
      // 至少认证过一次
      flag.value = true
    } else {
      // 没有认证
      flag.value = false
    }
  }

  form.value.isPoints == null ? form.value.isPoints = 1 : ''
  if (!res.data.memberInfo) res.data.memberInfo = {}
  if (!res.data.dept) res.data.dept = {}
  form.value = { ...res.data.dept, ...res.data.memberInfo }
  // form.value.notice = false
  // 入会材料
  if (form.value.materials) {
    form.value.materials1 = JSON.parse(form.value.materials)
    // form.value.materials = JSON.parse(form.value.materials)
  }
  // 入会申请书
  if (form.value.applicationForMembership) {
    form.value.applicationForMembership1 = JSON.parse(form.value.applicationForMembership)
    // form.value.applicationForMembership = JSON.parse(form.value.applicationForMembership)
  }
  applicationForMembership1.value = form.value.applicationForMembership || []

  // 认证地址
  form.value.coordinates1 = []
  if (form.value.provinceId) form.value.coordinates1.push(form.value.provinceId)
  if (form.value.cityId) form.value.coordinates1.push(form.value.cityId) // 省份/市/区/州 选择框中的选择
  if (form.value.regionId) form.value.coordinates1.push(form.value.regionId) // 省份/市/区/州 选择框中的选择
  // 机构照片
  imgList.value = form?.value?.certPictures?.split(',')
  // 法人证件照
  form.value.legalIdcPhoto1 = form.value.legalIdcPhoto?.split(',')?.[0] || ''
  form.value.legalIdcPhoto3 = form.value.certLegalIdcPhoto?.split(',')?.[0] || ''
  form.value.legalIdcPhoto2 = form.value.legalIdcPhoto?.split(',')?.[1] || ''
  form.value.legalIdcPhoto4 = form.value.certLegalIdcPhoto?.split(',')?.[1] || ''
  // 合同/租赁合同
  if (form.value.leaseContract) form.value.leaseContract = JSON.parse(form.value.leaseContract)

  // 所属省份
  // belongProvinceId.value = form.value.belongProvinceId

  // 租赁合同有效期
  leaseTime.value = form.value.leaseTime
  leaseTimeS.value = form.value.leaseTime

  // 是否为自有场所
  form.value.ownFlag = form.value.ownFlag ? form.value.ownFlag : '0'
  form.value.leaseTime = form.value.leaseTime?.split(',') || []
  let res1 = []
  if (authenticationStatusa.value == 0 || authenticationStatusa.value == 3 || authenticationStatusa.value == 1) {
    res1 = await certifiedDeptTreeRegister({ selfDeptId: '-1', webSiteShow: 1, showDisabled: 1, isBlack: 0 })
  } else {
    res1 = await deptTreeSelect({
      selfDeptId: '-1',
      showDisabled: 1,
      showDirect: authenticationStatusa.value == 2 || authenticationStatusa.value == 5 || authenticationStatusa.value == 4 ? 1 : null
    })
  }
  form.value.deptType = res.data.dept.deptType
  list.value = res1.data
  // if (typeof list.value[0].id == 'number') {
  //   form.value.parentId = form.value.parentId * 1
  // } else {
  //   form.value.parentId = form.value.parentId.toString()
  // }
  form.value.parentId = form.value.parentId.toString()

  materials1.value = form.value.materials || []
  pictures.value = form.value.pictures

  try {
    // businessLicense.value = form.value.certBusinessLicense = JSON.parse(form.value.certBusinessLicense)
    // form.value.businessLicense = JSON.parse(form.value.businessLicense)
    form.value.certBusinessLicense = form.value.businessLicense = JSON.parse((form.value.certBusinessLicense))
  } catch (e) {
    // businessLicense.value = businessLicenseValue.value = form.value.certBusinessLicense
    form.value.certBusinessLicense = form.value.businessLicense = form.value.certBusinessLicense
    businessLicenseValue.value = true
    console.log(form.value.certBusinessLicense)
  }
  creditCode.value = form.value.creditCode
  legal.value = form.value.legal
  coordinates1.value = form.value.provinceId
  adress.value = form.value.adress
  parentId.value = form.value.parentId
}

function changeAddress(value) {
  form.value.provinceId = value?.[0]?.toString()
  form.value.cityId = value?.[1]?.toString()
  form.value.regionId = value?.[2]?.toString()
}

function submit() {
  proxy.$refs['formData'].validate(async(valid) => {
    if (!form.value.notice) {
      proxy.$modal.msgError('请先阅读并勾选注册须知,入会须知,免责声明')
      return
    }
    const res1 = await handelVerify()
    if (!res1.passFlag) {
      await ElMessageBox.alert(
        `<p>${res1.msg} <br/><span style="color: #F56C6C">企业信息异常请检查相关资料信息,确认无误后再次提交!</span></p>`,
        '系统提示', {
          type: 'warning',
          dangerouslyUseHTMLString: true,
          showCancelButton: true,
          confirmButtonText: '确认无误',
          cancelButtonText: '返回修改'
        })
      // await proxy.$modal.confirm(`${res1.msg},是否继续提交?`)
    }
    if (valid) {
      if (form.value.parentId == -1 || form.value.parentId == 0) {
        return proxy.$modal.msgError('请选择所属协会')
      }
      let res = null
      const dataInfo = {
        parentId: form.value.parentId,
        creditCode: form.value.creditCode,
        legal: form.value.legal,
        // legalPhoto: form.value.legalPhoto,
        businessLicense: Array.isArray(form.value.businessLicense) ? JSON.stringify(form.value.businessLicense) : form.value.businessLicense,
        pictures: form.value.pictures,
        materials: JSON.stringify(form.value.materials1),
        applicationForMembership: JSON.stringify(form.value.applicationForMembership1),
        memId: form.value.memId,
        id: form.value.deptId,
        name: form.value.name,
        regionId: form.value.regionId,
        cityId: form.value.cityId,
        provinceId: form.value.provinceId,
        adress: form.value.adress,
        // belongProvinceId: form.value.belongProvinceId,
        deptType: form.value.deptType,
        leaseValidity: form.value.leaseValidity,
        legalIdcPhoto: [form.value.legalIdcPhoto1, form.value.legalIdcPhoto2]?.join(','),
        leaseContract: JSON.stringify(form.value.leaseContract),
        leaseTime: form.value.leaseTime ? [...form.value.leaseTime].join() : '',
        applyPoints: form.value.applyPoints ?? 0,
        siteContact: form.value.siteContact,
        siteTel: form.value.siteTel,
        companyName: form.value.companyName,
        legalIdcCode: form.value.legalIdcCode

        // isPoints: form.value.isPoints
      }
      if (activeStatus.value == 0) {
        res = await active(dataInfo)
        if (res.code == 200) {
          proxy.$modal.msgSuccess('激活成功!')
          // 重新加载
          window.location.reload()
        }
      } else {
        res = await editMyMemberCertifiedInfo(dataInfo)
        if (res.code === 200) {
          // showDialog.value = true

          proxy.$refs['goPayRef'].open()
          // await initData()
        }
      }
    } else {
      proxy.$modal.msgError('请完善信息')
    }
  })
}

// 审核详情
function auditEditFN() {
  proxy.$refs['auditEditRef'].open(pr.value)
}

// 考点申请
function handelPoints() {
  proxy.$refs['applyNowRef'].open(form.value.memId)
}

function handelView() {
  proxy.$refs['examViewRef'].open()
}

async function payTheFees() {
  await handelGetMyRecent()
  if (!form.value.name) {
    return proxy.$modal.msgError('请先完善单位信息!')
  }
  form.value.applyPoints = '0'
  showEdit.value = true
}

function handelNotice(v) {
  if (v == 1) {
    proxy.$refs['zhuCeXuZhiRef'].open()
  }
  if (v == 2) {
    proxy.$refs['ruHuiXuZhiRef'].open()
  }
  if (v == 3) {
    proxy.$refs['mianZeShengMingRef'].open()
  }
}

watch(() => file1.value, (v) => {
  if (v) {
    clearTimeout(timer.value)
    timer.value = setTimeout(() => {
      cardExtract()
    }, 500)
  }
})

watch(() => file2.value, (v) => {
  if (v) {
    clearTimeout(timer.value)
    timer.value = setTimeout(() => {
      licenseFn()
    }, 500)
  }
})

// 身份证提取
async function cardExtract() {
  try {
    const formData = new FormData()
    formData.append('pic', file1.value)
    const res = await carUrl(formData, '0')
    form.value.legal = res.data.name
    form.value.legalIdcCode = res.data.code
  } catch (e) {
    form.value.legal = null
    form.value.legalIdcCode = null
  } finally {
    clearTimeout(timer.value)
  }
}

// 营业执照提取
async function licenseFn() {
  try {
    const formData = new FormData()
    formData.append('pic', file2.value)
    const res = await getBusinessLicense(formData)
    form.value.creditCode = res.data.creditCode
    form.value.companyName = res.data.companyName
  } catch (e) {
    form.value.creditCode = null
    form.value.companyName = null
  } finally {
    clearTimeout(timer.value)
  }
}

function handelVerify() {
  return new Promise(async(resolve, reject) => {
    if (!form.value.legalIdcCode || !form.value.legal) {
      proxy.$modal.msgError('请重新上传身份证')
      return reject()
    }
    if (!form.value.companyName || !form.value.creditCode) {
      proxy.$modal.msgError('请重新上传营业执照')
      return reject()
    }
    const res = await checkBusinessLicense({
      creditCode: form.value.creditCode,
      companyName: form.value.companyName,
      legalIdcCode: form.value.legalIdcCode,
      legal: form.value.legal
    })
    if (res.code == 200) {
      return resolve(res.data)
    } else {
      return reject(res)
    }
  })
}

</script>

<style lang="scss" scoped>
.box {
  padding: 30px;
}

.ping {
  display: flex;
  justify-content: center;
}

.title-header {
  border: 1px solid black;
  padding: 10px;
}

.header {
  padding-left: 40px;
}

.header-1 {
  font-size: 20px;
}

.heder-right {
  padding-left: 20px;
  padding-top: 20px;
}

.quBtn {
  background-color: #920f20;
  color: #fff;
}

.idCard {
  margin-top: 5px;
  margin-bottom: 5px;
}

.m0 {
  margin: 0
}

.mb20 {
  margin-bottom: 20px;
}

.flexRow {
  display: flex;
  //align-items: center;
  justify-content: space-between;

  flex-wrap: wrap;
  height: 90px;

  label {
    font-size: 16px;
    color: #7B7F83;
  }

  .row-btn {
    width: 40%;
    min-width: 400px;
    //display: flex;
    //height: 80px;
    //justify-content: end;
    //flex-wrap: wrap;
    //button {
    //  margin: 0;
    //  width: 6em;
    //}

    text-align: right;
  }

  .association {
    width: 200px;
    min-width: 200px;
  }
}


:deep(.el-upload--picture-card) {
  width: 220px;
  height: 130px;
}

:deep(.el-upload-list__item) {
  width: 220px;
  height: 130px;
}

:deep( .FileUpload .el-upload-list__item) {
  width: auto;
  height: 32px;

  .el-upload-list {
    margin: 0 0 10px 0
  }
}

:deep( .FileUpload ) {
  .el-upload-list {
    margin: 0 0 10px 0
  }
}

:deep(.el-upload-list--picture-card .el-upload-list__item) {
  width: 220px;
  height: 130px;
}

:deep(.component-upload-image) {
  display: flex;

  .el-upload__tip {
    width: 200px;
    margin-left: 20px;
  }
}

.father {
  position: relative;
}

// .son1{
//   position: absolute;
//   top: 6px;
//   left: 100px ;
// }
.son2 {
  position: absolute;
  top: 6px;
  left: 250px;
}

.hint {
  text-align: left;
  font-size: 12px;
  color: #f56c6c;
  margin: 0;
  padding: 0;
}

.textFather {
  position: relative;
}

.TextSon {
  position: absolute;
  top: 125px;
  z-index: 2;
  padding: 0;
  margin: 0;
  width: 100%;
}

.tex1 {
  z-index: 9;
  font-size: 10px;
  font-weight: 600;
  transform: scale(0.45);
  margin: 0;
  padding: 0;
  width: 100% !important;
}

.right {
  margin-right: 10px;
}


:deep(.legalCard) {
  :deep(.el-form-item__label) {
    color: #7B7F83
  }

  .el-upload__tip {
    display: none;
  }

  .card1 {
    .el-upload--picture-card {
      background-image: url(@/assets/images/card2.png);
      background-size: 100%;
    }
  }

  .card2 {
    .el-upload--picture-card {
      background-image: url(@/assets/images/card1.png);
      background-size: 100%;
    }
  }

  .el-upload-list--picture-card {
    width: 360px;
    height: 225px;

    .el-upload--picture-card {
      width: 100%;
      height: 100%;
    }
  }

  .el-upload-list__item {
    width: 360px;
    height: 225px;
    // border-radius: 10px;
    // border: 1px dashed #4e4c4c;
  }
}

.checkBox {
  position: relative;
  top: 3px

}

.btn {
  width: 200px;
  height: 38px;
}


</style>