editinfo.js 53.8 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 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548
var format = require('../../../../utils/util.js');
var app = getApp();
var baseUrl = app.globalData.baseUrl;
// var countryInfo = require('../../../../utils/country.js');
// const cardTypeArray = ['居民身份证', '中国护照', '港澳居民来往内地通行证', '港澳居民居住证', '台湾居民来往大陆通行证', '台湾居民居住证', '外国护照', '外国人永久居留身份证', '外国人工作许可证(A类)', '外国人工作许可证(B类)', '外国人工作许可证(C类)'];
const cardTypeArray8 = ['居民身份证', '中国护照', '港澳居民居住证', '台湾居民居住证', '外国人永久居留身份证', '外国人工作许可证(A类)', '外国人工作许可证(B类)', '外国人工作许可证(C类)'];
// const cardTypeDicts = [{ 'code': '1', 'name': '居民身份证' }, { 'code': '2', 'name': '中国护照' }, { 'code': '3', 'name': '港澳居民来往内地通行证' }, { 'code': '4', 'name': '港澳居民居住证' }, { 'code': '5', 'name': '台湾居民来往大陆通行证' }, { 'code': '6', 'name': '台湾居民居住证' }, { 'code': '7', 'name': '外国护照' }, { 'code': '8', 'name': '外国人永久居留身份证' }, { 'code': '9', 'name': '外国人工作许可证(A类)' }, { 'code': '10', 'name': '外国人工作许可证(B类)' }, { 'code': '11', 'name': '外国人工作许可证(C类)'}];
// const cardTypes8 = [{ 'code': '1', 'name': '居民身份证' }, { 'code': '2', 'name': '中国护照' }, { 'code': '4', 'name': '港澳居民居住证' }, { 'code': '6', 'name': '台湾居民居住证' }, { 'code': '8', 'name': '外国人永久居留身份证' }, { 'code': '9', 'name': '外国人工作许可证(A类)' }, { 'code': '10', 'name': '外国人工作许可证(B类)' }, { 'code': '11', 'name': '外国人工作许可证(C类)' }];

Page({

  /**
   * 页面的初始数据
   */
  data: {
    isshow01: false,
    isshow02: false,
    isshow03: false,
    hasOtherCard:false,
    taxInfo: {},
    proffessionlist: {},
    banklist: {},
    cur_id: '',
    isself: true,
    isIdCard: true,
    profession_haschanges: false,
    name: '',
    mobile: '',
    birthday: '',
    idInfoData: '',
    id_error: false,
    has_certify:false,
    curAddress_haschanged: false,
    birthAddress_haschanged: false,
    contactAddress_haschanged: false,
    card_number: '',
    long_birth_date: 0,
    long_start_date: 0,
    long_end_date: 0,
    personal_equity_total:0,
    company_equity_total:0,
    huji_address_detail: '',
    personstatusData: {
      isrequre: true,
      label: '纳税人状态',
      bindtype: 'personstatus',
      placeholder: '请选择纳税人状态',
      selected: '',
      values: ["正常", "非正常"],
      onChange: 'onPickerSelect'
    },
    cardtypeData: {
      isrequre: true,
      label: '证照类型',
      bindtype: 'cardtype',
      placeholder: '请选择证照类型',
      selected: '',
      values: cardTypeArray8,
      // range_key:'name',
      // values: ["居民身份证", "军官证", '士兵证', '武警警官证', '港澳居民来往内地通行证', '外交官证', '中国护照',
      //   '外国护照', '香港永久性居民身份证', '澳门特别行政区永久性居民身份证', '台湾身份证', '台湾居民来往大陆通行证', '外国人永久居留证'
      // ],
      onChange: 'onPickerSelect'
    },
    otherCardtypeData: {
      isrequre: true,
      label: '其他证照类型',
      bindtype: 'other_cardtype',
      placeholder: '请选择证照类型',
      selected: '',
      values: [],
      // range_key: 'name',
      onChange: 'onPickerSelect'
    },
    countryData: {
      label: '国籍',
      bindtype: 'country',
      isrequre: true,
      selected: '',
      // range_key:'name',
      placeholder: '请选择国籍',
      onChange: 'onPickerSelect',
    },
    birthCountryData: {
      isrequre: true,
      label: '出生国家(地区)',
      bindtype: 'brith_country',
      placeholder: '请选择出生国家(地区)',
      onChange: 'onPickerSelect',
    },
    taxpayerTypeData: {
      isrequre: true,
      label: '纳税人类型',
      bindtype: 'taxpayerType',
      placeholder: '请选择纳税人类型',
      values: ["居民", "非居民"],
      onChange: 'onPickerSelect'
    },
    forignerInfo: {
      isrequre: true,
      label: '是否境外人员',
      bindtype: 'forigner',
      placeholder: '请选择',
      disabled: true,
      values: ["否", "是"],
      onChange: 'onPickerSelect'
    },
    bankInfo: {
      label: '开户银行',
      bindtype: 'bank',
      maxWidth:490,
      placeholder: '请选择开户银行',
      selected: '',
      onChange: 'onPickerSelect'
    },
    genderData: {
      label: '性别',
      isrequre: true,
      bindtype: 'gender',
      // disabled: true,
      placeholder: '性别',
      values: ["男", "女"],
      selected: '',
      onChange: 'onPickerSelect'
    },
    professionData: {
      mode: 'multiSelector',
      label: '职业',
      bindtype: 'profession',
      multiIndex: [0, 0, 0],
      placeholder: '请选择职业',
      selected: '',
      range_key: 'label',
      onChange: 'onPickerSelect'
    },
    degreeData: {
      label: '学历',
      bindtype: 'degree',
      placeholder: '请选择学历',
      selected: '',
      values: ["研究生", "大学本科", '大学本科以下'],
      onChange: 'onPickerSelect'
    },
    disabilityInfo: {
      label: '是否残疾',
      bindtype: 'disable',
      placeholder: '请选择是否残疾',
      selected: '',
      values: ["否", "是"],
      onChange: 'onPickerSelect'
    },
    lieshuInfo: {
      label: '是否烈属',
      bindtype: 'lieshu',
      placeholder: '请选择是否烈属',
      selected: '',
      values: ["否", "是"],
      onChange: 'onPickerSelect'
    },
    lonelyolderInfo: {
      label: '是否孤老',
      bindtype: 'lonelyolder',
      placeholder: '请选择是否孤老',
      selected: '',
      values: ["否", "是"],
      onChange: 'onPickerSelect'
    },
    investInfo: {
      isrequre: true,
      label: '是否股东、投资者',
      bindtype: 'invest',
      placeholder: '请选择是否股东、投资者',
      selected: '',
      values: ["否", "是"],
      onChange: 'onPickerSelect'
    },
    specificIndustryInfo: {
      isrequre: true,
      label: '是否特定行业',
      bindtype: 'specificIndustry',
      placeholder: '请选择是否特定行业',
      selected: '',
      values: ["否", "是"],
      onChange: 'onPickerSelect'
    },
    employeeInfo: {
      isrequre: true,
      label: '是否雇员',
      bindtype: 'employee',
      placeholder: '请选择是否雇员',
      selected: '',
      values: ["否", "是"],
      onChange: 'onPickerSelect'
    },
    investpersonalInfo: {
      label: '是否天使投资个人',
      bindtype: 'investpersonal',
      placeholder: '请选择是否天使投资个人',
      selected: '',
      values: ["否", "是"],
      onChange: 'onPickerSelect'
    },
    // 时间picker
    birthDate: {
      label: '出生日期',
      isrequre:true,
      bindtype: 'birthday',
      placeholder: '出生日期',
      selected: '',
      mode: "date",
      fields: "day",
      start: '1949-01-01',
      end: format.curDateTime(),
      onChange: 'birthdayChange',
    },
    startDate: {
      label: '任职受雇日期',
      bindtype: 'startday',
      placeholder: '请选择受雇日期',
      selected: '',
      mode: "date",
      fields: "day",
      start: '1990-01-01',
      onChange: 'startChange',
    },
    endDate: {
      label: '离职日期',
      bindtype: 'endday',
      placeholder: '请选择离职日期',
      selected: '',
      mode: "date",
      fields: "day",
      start: '2010-01-01',
      onChange: 'endChange',
    },

    firstEntryDate: {
      label: '首次入境时间',
      isrequre: true,
      bindtype: 'entry_date',
      placeholder: '请选择首次入境时间',
      selected: '',
      mode: "date",
      fields: "day",
      onChange: 'onPickerSelect',
    },
    predictLeaveDate: {
      label: '预计离境时间',
      isrequre: true,
      bindtype: 'leave_date',
      placeholder: '请选择预计离境时间',
      selected: '',
      mode: "date",
      fields: "day",
      onChange: 'onPickerSelect',
    },
    // 地址选择器
    contactaddressInfo: {
      label: '联系地址',
      mode: 'region',
      maxWidth: 490,
      address_code: ['', '', ''],
      address_value: ['', '', ''],
      selected: '',
      placeholder: '请选择联系地址',
      onChange: 'contactAddressSelect'
    },
    currentaddressInfo: {
      label: '经常居住地址',
      maxWidth: 430,
      mode: 'region',
      address_code: ['', '', ''],
      address_value: ['', '', ''],
      selected: '',
      placeholder: '请选择居住地',
      onChange: 'currentAddressSelect'
    },
    birthaddressInfo: {
      label: '户籍地址',
      mode: 'region',
      maxWidth: 490,
      address_code: ['', '', ''],
      address_value: ['', '', ''],
      selected: '',
      placeholder: '请选择户籍所在地',
      onChange: 'birthAddressSelect'
    },
    title: '',
    condition: false
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    
    console.log('options.id', options.id)
    if (options.id && options.id.length > 0) {
      this.setData({
        cur_id: options.id
      })
      this.getpersonalTax(options.id)
    }
    this.getproffessiondata()
    this.getbanklist()
    this.getCountry()
  },
//****************获取国籍数据************/
  getCountry: function () {
    var that = this
    wx.showLoading({
      title: '',
    })
    var Authorization = app.globalData.Authorization;
    wx.request({
      url: baseUrl + 'persontax/v1/nation-list',
      method: "GET",
      header: {
        'content-type': 'application/json', // 默认值
        "Authorization": Authorization
      },
      success: function (res) {
        var countrys = res.data.concat()
        that.data.birthCountryData.values = res.data
        if (countrys.indexOf('中国') > -1) {
          countrys.splice(countrys.indexOf('中国'), 1);
        }
        if (countrys.indexOf('中国台湾') > -1) {
          countrys.splice(countrys.indexOf('中国台湾'), 1);
        }
        if (countrys.indexOf('香港') > -1) {
          countrys.splice(countrys.indexOf('香港'), 1);
        }
        if (countrys.indexOf('澳门') > -1) {
          countrys.splice(countrys.indexOf('澳门'), 1);
        }
        that.data.countryData.values = countrys
        that.countrys = countrys
        that.setData({
          countryData: that.data.countryData,
          birthCountryData: that.data.birthCountryData
        })
      },
      fail(res) {
        wx.hideLoading()
      },
      complete() {
        wx.hideLoading()
      }
    })
  },


//****************获取自然人数据************/
  getpersonalTax: function(id) {
    var that = this
    wx.showLoading({
      title: '',
    })
    var Authorization = app.globalData.Authorization;
    wx.request({
      url: baseUrl + 'persontax/v1/personal-taxes/' + id,
      method: "GET",
      header: {
        'content-type': 'application/json', // 默认值
        "Authorization": Authorization
      },
      success: function(res) {
        console.log('taxInfo', res)
        that.setData({
          taxInfo: res.data,
          // isself: '魏先森' != res.data.name ? false : true
          isself: res.data.family_ties=="本人" ? true : false
        })
        that.handleDatas(res.data)
      },
      fail(res) {
        console.log(res)
        wx.hideLoading()
      },
      complete() {
        wx.hideLoading()
      }
    })
  },

  //对各参数初始赋值
  handleDatas: function (tax_info) {
    //todo
    console.log('tax_info', tax_info)
    var curdate = format.curDateTime()
    this.dealCardType(tax_info.id_card_type)//为防止干扰其他字段,需要先执行

    this.data.name = tax_info.name
    this.data.other_name = tax_info.other_name
    if (tax_info.certification_status == 'active' && tax_info.id_card_no.length) {//已通过拍摄身份证认证过,不能修改
      this.data.genderData.disabled = true
      this.data.birthDate.disabled = true
      this.data.cardtypeData.disabled = true
    }

    this.data.personstatusData.selected = tax_info.taxpayer_status
    this.data.cardtypeData.selected = tax_info.id_card_type //cardTypeDicts[parseInt(tax_info.id_card_type) - 1]['name']
    // this.data.cardtypeData.selected_code = tax_info.id_card_type
    this.data.card_number = tax_info.id_card_no

    this.data.otherCardtypeData.selected = tax_info.other_id_card_type //cardTypeDicts[parseInt(tax_info.other_id_card_type) - 1]['name']
    // this.data.otherCardtypeData.selected_code = tax_info.other_id_card_type

    this.data.other_card_number = tax_info.other_id_card_no
    this.data.overseas = tax_info.is_overseas_personnel
    this.data.countryData.selected = tax_info.native
    this.data.birthCountryData.selected = tax_info.birth_native
    if (tax_info.taxpayer_type == 'non-resident') {
      this.data.taxpayerTypeData.selected = '非居民'
    } else if (tax_info.taxpayer_type == 'resident') {
      this.data.taxpayerTypeData.selected = '居民'
    }
    this.data.mobile = tax_info.mobile
    this.data.investInfo.selected = tax_info.is_investor
    this.data.specificIndustryInfo.selected = tax_info.is_specific_profession
    
    this.data.genderData.selected = tax_info.gender
    if (tax_info.birth_date == -62135596800 || tax_info.birth_date == 0) {
      this.data.birthDate.selected = ''
    } else {
      // this.data.birthDate.selected = format.yearFormString(tax_info.birth_date) + '-' + format.monthFormString(tax_info.birth_date) + '-' + format.dayFormString(tax_info.birth_date)
      this.data.birthDate.selected = tax_info.birth_date_str //format.formatTime_date(tax_info.birth_date) 
    }
//非必填
    if (tax_info.join_date > 1000) {
      // this.data.startDate.selected = format.yearFormString(tax_info.join_date) + '-' + format.monthFormString(tax_info.join_date) + '-' + format.dayFormString(tax_info.join_date)
      this.data.startDate.selected = format.formatTime_date(tax_info.join_date) 
    }
    if (tax_info.separate_date > 1000) {
      this.data.endDate.selected = format.formatTime_date(tax_info.separate_date) 
    }
    const firstEntryDate = format.formatTime_date(tax_info.first_entry_date)
    const predictLeaveDate = format.formatTime_date(tax_info.predict_leave_date)
    this.data.firstEntryDate.selected = (firstEntryDate.indexOf("01-01-01") == -1) ? firstEntryDate:''
    this.data.firstEntryDate.datelong = tax_info.first_entry_date
    this.data.predictLeaveDate.selected = (predictLeaveDate.indexOf("01-01-01") == -1) ? predictLeaveDate : ''
    this.data.predictLeaveDate.datelong = tax_info.predict_leave_date
    // this.data.professionData.selected = tax_info.profession.three_level_name

    this.data.birthDate.end = curdate
    this.data.startDate.end = curdate
    this.data.endDate.end = curdate
    this.data.degreeData.selected = tax_info.education
    this.data.disabilityInfo.selected = tax_info.is_disability
    this.data.lieshuInfo.selected = tax_info.is_martyr_family
    this.data.lonelyolderInfo.selected = tax_info.is_lonely_man
    this.data.bankInfo.selected = tax_info.bank
    this.data.contactaddressInfo.selected = tax_info.contact_address.province + tax_info.contact_address.city + tax_info.contact_address.district
    this.data.currentaddressInfo.selected = tax_info.current_address.province + tax_info.current_address.city + tax_info.current_address.district
    this.data.birthaddressInfo.selected = (tax_info.huji_address.province + tax_info.huji_address.city + tax_info.huji_address.district).replace(/(^\s*)|(\s*$)/g, "")
    this.data.employeeInfo.selected = tax_info.is_employee
    this.data.investpersonalInfo.selected = tax_info.is_business_angel
    this.setData({
      // huji_address_detail: tax_info.huji_address_detail.replace(/(^\s*)|(\s*$)/g, ""),
      name: this.data.name,
      other_name: this.data.other_name,
      personstatusData: this.data.personstatusData,
      cardtypeData: this.data.cardtypeData,
      otherCardtypeData: this.data.otherCardtypeData,
      mobile: this.data.mobile,
      investInfo: this.data.investInfo,
      specificIndustryInfo: this.data.specificIndustryInfo,
      genderData: this.data.genderData,
      bankInfo: this.data.bankInfo,
      personal_equity_total: tax_info.personal_equity_total ? tax_info.personal_equity_total : 0,
      company_equity_total: tax_info.company_equity_total ? tax_info.company_equity_total: 0,

      professionData: this.data.professionData,
      degreeData: this.data.degreeData,
      disabilityInfo: this.data.disabilityInfo,
      lieshuInfo: this.data.lieshuInfo,
      lonelyolderInfo: this.data.lonelyolderInfo,
      contactaddressInfo: this.data.contactaddressInfo,
      currentaddressInfo: this.data.currentaddressInfo,
      birthaddressInfo: this.data.birthaddressInfo,
      employeeInfo: this.data.employeeInfo,
      investpersonalInfo: this.data.investpersonalInfo,

      long_birth_date: tax_info.birth_date,
      birthDate: this.data.birthDate,
      long_start_date: tax_info.join_date ? tax_info.join_date:0,
      startDate: this.data.startDate,
      long_end_date: tax_info.separate_date ? tax_info.separate_date : 0,
      endDate: this.data.endDate,
      firstEntryDate: this.data.firstEntryDate,
      predictLeaveDate: this.data.predictLeaveDate,
      isIdCard: '居民身份证' == tax_info.id_card_type ? true : false,
      card_number: this.data.card_number,
      other_card_number: this.data.other_card_number,
      countryData: this.data.countryData,
      birthCountryData: this.data.birthCountryData,
      overseas: this.data.overseas,
      taxpayerTypeData: this.data.taxpayerTypeData
    })

  },

  getproffessiondata: function() {
    var that = this
    var Authorization = app.globalData.Authorization;
    var proffession_info = that.data.professionData
    wx.request({
      url: baseUrl + 'common/v1/professions',
      method: "GET",
      header: {
        'content-type': 'application/json', // 默认值
        "Authorization": Authorization
      },
      success: function(res) {
        if (res.data.items.length<1){
          return
        }
        proffession_info.values = that.handleProfession(res.data.items)
        console.log('proffession_info------', proffession_info)
        that.setData({
          proffessionlist: res.data.items,
          professionData: proffession_info
        })
      },
      fail(res) {
        console.log(res)
      },
      complete() {
        wx.hideLoading()
      }
    })
  },

  handleProfession: function(items) {
    var new_profession_data = []
    var list = [],
      tempTwo = {},
      tempOne = {},
      tempThree = {};
    items.map((d) => {
      if (!tempOne[d.one_level_code]) {
        tempOne[d.one_level_code] = {
          "value": d.one_level_code,
          "label": d.one_level_name,
          "children": []
        };
      }
      if (!tempTwo[d.two_level_code]) {
        var districtArray = [];
        districtArray.push({
          "value": d.three_level_code,
          "label": d.three_level_name,
          "children": []
        });

        tempTwo[d.two_level_code] = {
          "value": d.two_level_code,
          "label": d.two_level_name,
          "children": districtArray
        };

      } else {
        if (!tempThree[d.three_level_code]) {
          tempTwo[d.two_level_code].children.push({
            "value": d.three_level_code,
            "label": d.three_level_name,
            "children": []
          });
          tempThree[d.three_level_code] = "y"
        }
      }
    });
    items.map((d) => {
      if (tempTwo[d.two_level_code]) {
        tempOne[d.one_level_code].children.push(tempTwo[d.two_level_code]);
        tempTwo[d.two_level_code] = null;
      }
    });
    for (var key in tempOne) {
      list.push(tempOne[key]);
    }
    new_profession_data = [list, list[0].children, list[0].children[0].children]
    console.log('new_profession_data', new_profession_data)
    return new_profession_data;

  },

  getbanklist: function() {
    var that = this
    var Authorization = app.globalData.Authorization;
    var bank_info = that.data.bankInfo
    wx.request({
      url: baseUrl + 'persontax/v1/bank-list',
      method: "GET",
      header: {
        'content-type': 'application/json', // 默认值
        "Authorization": Authorization
      },
      success: function(res) {
        console.log(res)
        bank_info.values = res.data.banks//that.handleBankinfo(res.data.items)

        that.setData({
          // banklist: res.data.items,
          bankInfo: bank_info
        })
        console.log("bankInfo", that.data.bankInfo)
      },
      fail(res) {
        console.log(res)
      },
      complete() {
        wx.hideLoading()
      }
    })
  },

  handleBankinfo: function(data) {
    var bank_name = []
    for (var i = 0; i < data.length; i++) {
      bank_name.push(data[i].bank_name)
    }
    return bank_name
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
    var that = this
    var id_error = this.data.id_error
    wx.getStorage({
      key: 'id_info',
      success: function(res) {
        console.log('id_info', res.data)
        if (res.data && res.data.length > 0) {
          var id_info = JSON.parse(res.data)
          var birth_day
          if (id_info.birthday.month > 9 && id_info.birthday.day > 9) {
            birth_day = id_info.birthday.year + '-' + id_info.birthday.month + '-' + id_info.birthday.day;
          } else if (id_info.birthday.month > 9 && id_info.birthday.day < 10) {
            birth_day = id_info.birthday.year + '-' + id_info.birthday.month + '-0' + id_info.birthday.day;
          } else if (id_info.birthday.month < 10 && id_info.birthday.day > 9) {
            birth_day = id_info.birthday.year + '-0' + id_info.birthday.month + '-' + id_info.birthday.day;
          } else if (id_info.birthday.month < 10 && id_info.birthday.day < 10) {
            birth_day = id_info.birthday.year + '-0' + id_info.birthday.month + '-0' + id_info.birthday.day;
          }

          var cardtypeData = that.data.cardtypeData
          cardtypeData.selected = '居民身份证'
          // cardtypeData.selected_code = '1'
          var gender_Data = that.data.genderData
          gender_Data.selected = id_info.gender

          that.data.birthDate.selected = birth_day
          console.log('name***card_number', that.data.name + '***' + that.data.card_number)

          // if (that.data.name.length > 0 && id_info.name != that.data.name) {
          //   that.showtoast("姓名冲突")
          //   id_error = true
          //   return
          // }
          // if (that.data.card_number.length > 0 && id_info.id_card_number != that.data.card_number) {
          //   that.showtoast("证照号码冲突")
          //   id_error = true
          //   return
          // }
          that.setData({
            has_certify:true,
            idInfoData: id_info,
            name: id_info.name,
            birthday: birth_day,
            cardtypeData: cardtypeData,
            genderData: gender_Data,
            long_birth_date: Date.parse(new Date(birth_day)) / 1000,
            birthDate: that.data.birthDate,
            card_number: id_info.id_card_number
          })
          console.log('-cardtypeData--', that.data.cardtypeData)

        }
      },
    })
    wx.removeStorage({
      key: 'id_info',
      success: function(res) {
        console.log('remove_idinfo', res)
      },
    })
  },

  span: function(e) {
    console.log(e,'9808909')
    if ("1" == e.currentTarget.id) {
      this.setData({
        isshow01: !this.data.isshow01
      })
    } else if ("2" == e.currentTarget.id) {
      this.setData({
        isshow02: !this.data.isshow02
      })
    } else if ("3" == e.currentTarget.id) {
      this.setData({
        isshow03: !this.data.isshow03
      })
    }

  },

  dealCardType: function (new_type){
    // console.log('cardtype_code', new_type_code)
    console.log('cardtype', new_type)
    var is_idcard = this.data.isIdCard
    // const new_type = cardTypeDicts[parseInt(new_type_code)-1]['name']
    // this.data.cardtypeData.selected_code = new_type_code
    this.data.cardtypeData.selected = new_type
    this.data.nameText = ''
    if ('居民身份证' == new_type) {
      is_idcard = true
      this.data.genderData.disabled = true
      this.data.birthDate.disabled = true
    } else {
      is_idcard = false
      this.data.genderData.disabled = false
      this.data.birthDate.disabled = false
    }
    this.data.hasOtherCard = true
    this.data.overseas = '是'
    this.data.taxpayerTypeData.disabled = false
    this.data.taxpayerTypeData.selected = ''
    if ('居民身份证' == new_type || '中国护照' == new_type) {
      this.data.overseas = '否'
      this.data.countryData.selected = '中国'
      this.data.countryData.disabled = true
      this.data.hasOtherCard = false
      this.data.taxpayerTypeData.selected = '居民'
      this.data.taxpayerTypeData.disabled = true
    } else if (new_type.indexOf("港澳") != -1) {
      this.data.countryData.values = ['中国香港', '中国澳门']
      this.data.countryData.selected = ''
      this.data.countryData.disabled = false
      this.data.nameText = '英文名'
      // if (new_type.indexOf('通行证') != -1){
        // this.data.otherCardtypeData.values = [{ 'code': '4', 'name': '港澳居民居住证'}];
      // }else{
      this.data.otherCardtypeData.values = ['港澳居民来往内地通行证'];// [{ 'code': '3', 'name': '港澳居民来往内地通行证'}];
      this.data.otherCardtypeData.selected = '港澳居民来往内地通行证'; 
      // }
    } else if (new_type.indexOf("台湾") != -1) {
      this.data.countryData.selected = '中国台湾'
      this.data.countryData.disabled = true
      this.data.nameText = '英文名'
      // if (new_type.indexOf('通行证') != -1) {
        // this.data.otherCardtypeData.values = [{ 'code': '6', 'name': '台湾居民居住证' }];
      // } else {
      this.data.otherCardtypeData.values = ['台湾居民来往大陆通行证']; //[{ 'code': '5', 'name': '台湾居民来往大陆通行证' }];
      this.data.otherCardtypeData.selected = '台湾居民来往大陆通行证'; 
      // }

    } else {
      this.data.countryData.selected = ''
      this.data.countryData.values = this.countrys ? this.countrys : []
      this.data.countryData.disabled = false
      this.data.nameText = '中文名'
      // if (new_type.indexOf("外国护照") != -1) {
      //   this.data.otherCardtypeData.values = [{ 'code': '8', 'name': '外国人永久居留身份证' }, { 'code': '9', 'name': '外国人工作许可证(A类)' }, { 'code': '10', 'name': '外国人工作许可证(B类)' }, { 'code': '11', 'name': '外国人工作许可证(C类)' }];
      // } else {
      this.data.otherCardtypeData.values = ['外国护照']; //[{ 'code': '7', 'name': '外国护照' }];
      this.data.otherCardtypeData.selected = '外国护照'; 
      // }
    }
    this.setData({
      isIdCard: is_idcard,
      hasOtherCard: this.data.hasOtherCard,
      genderData: this.data.genderData,
      birthDate: this.data.birthDate,
      countryData: this.data.countryData,
      cardtypeData: this.data.cardtypeData,
      otherCardtypeData: this.data.otherCardtypeData,
      nameText: this.data.nameText,
      overseas: this.data.overseas,
      taxpayerTypeData: this.data.taxpayerTypeData
    })
    
    
  },


  onPickerSelect: function(e) {
    console.log('picker发送选择改变,携带值为', e)
    switch (e.currentTarget.id) {
      case 'personstatus':
        var personstatus_data = this.data.personstatusData
        personstatus_data.selected = personstatus_data.values[e.detail.value]
        this.setData({
          personstatusData: personstatus_data
        })
        break;
      case 'cardtype':
        var cardtypeData = this.data.cardtypeData
        var new_type = cardtypeData.values[e.detail.value] //['name']
        // var new_type_code = cardtypeData.values[e.detail.value]['code']
        var selected = cardtypeData.selected
        if (new_type != selected) {
          this.dealCardType(new_type)
          var setData = { card_number: ''}
          if ((new_type.indexOf('外国人') != -1) && (selected.indexOf('外国人') != -1)) {
            console.log('外国人', new_type, selected)
          }else {
            // this.data.otherCardtypeData.selected = ''
            // setData.otherCardtypeData = this.data.otherCardtypeData
            setData.other_card_number = ''
          }
          this.setData(setData)
        }
        break;
      case 'other_cardtype':
        var otherCardtypeData = this.data.otherCardtypeData
        var new_type = otherCardtypeData.values[e.detail.value] //['name']
        // var new_type_code = otherCardtypeData.values[e.detail.value]['code']

        if (new_type != otherCardtypeData.selected) {
          otherCardtypeData.selected = new_type
          // otherCardtypeData.selected_code = new_type_code
          this.setData({
            other_card_number: "",
            otherCardtypeData: this.data.otherCardtypeData
          })
        }
        break;
      case 'country':
        var countryData = this.data.countryData
        var new_country = countryData.values[e.detail.value]
        if (new_country != countryData.selected) {
          countryData.selected = new_country
          this.setData({
            countryData: countryData
          })
        }
        break;
      case 'brith_country':
        var birthCountryData = this.data.birthCountryData
        var new_country = birthCountryData.values[e.detail.value]
        if (new_country != birthCountryData.selected) {
          birthCountryData.selected = new_country
          this.setData({
            birthCountryData: birthCountryData
          })
        }
        break;
      case 'taxpayerType':
        var taxpayerTypeData = this.data.taxpayerTypeData
          taxpayerTypeData.selected = taxpayerTypeData.values[e.detail.value]
        this.setData({
          taxpayerTypeData: taxpayerTypeData
        })
        break;
      case 'forigner':
        var forigner_data = this.data.forignerInfo
        forigner_data.selected = forigner_data.values[e.detail.value]
        this.setData({
          forignerInfo: forigner_data
        })
        break;
      case 'bank':
        var bank_data = this.data.bankInfo
        bank_data.selected = bank_data.values[e.detail.value]
        this.setData({
          bankInfo: bank_data
        })
        break;
      case 'gender':
        var gender_data = this.data.genderData
        gender_data.selected = gender_data.values[e.detail.value]
        this.setData({
          genderData: gender_data
        })
        break;
      case 'profession':
        var profession_data = this.data.professionData
        console.log(profession_data.values[e.detail.value[e.detail.value[0]]][0])
        var profession_name = profession_data.values[e.detail.value[e.detail.value[0]]][0].children[e.detail.value[1]].children[e.detail.value[2]].label
        profession_data.selected = profession_name
        this.setData({
          profession_haschanges: true,
          profession_index: e.detail.value,
          professionData: profession_data
        })
        break;
      case 'degree':
        var degree_data = this.data.degreeData
        degree_data.selected = degree_data.values[e.detail.value]
        this.setData({
          degreeData: degree_data
        })
        break;
      case 'disable':
        var disable_data = this.data.disabilityInfo
        disable_data.selected = disable_data.values[e.detail.value]
        this.setData({
          disabilityInfo: disable_data
        })
        break;
      case 'lieshu':
        var lieshu_data = this.data.lieshuInfo
        lieshu_data.selected = lieshu_data.values[e.detail.value]
        this.setData({
          lieshuInfo: lieshu_data
        })
        break;
      case 'lonelyolder':
        var lonelyolder_data = this.data.lonelyolderInfo
        lonelyolder_data.selected = lonelyolder_data.values[e.detail.value]
        this.setData({
          lonelyolderInfo: lonelyolder_data
        })
        break;
      case 'invest':
        var invest_data = this.data.investInfo
        invest_data.selected = invest_data.values[e.detail.value]
        this.setData({
          investInfo: invest_data
        })
        break;
      case 'specificIndustry':
        var specificIndustry_data = this.data.specificIndustryInfo
        specificIndustry_data.selected = specificIndustry_data.values[e.detail.value]
        this.setData({
          specificIndustryInfo: specificIndustry_data
        })
        break;
      case 'employee':
        var employee_data = this.data.employeeInfo
        employee_data.selected = employee_data.values[e.detail.value]
        this.setData({
          employeeInfo: employee_data
        })
        break;
      case 'investpersonal':
        var investpersonal_data = this.data.investpersonalInfo
        investpersonal_data.selected = investpersonal_data.values[e.detail.value]
        this.setData({
          investpersonalInfo: investpersonal_data
        })
        break;
      case 'entry_date':
        this.data.firstEntryDate.selected = e.detail.value
        this.data.firstEntryDate.datelong = Date.parse(new Date(e.detail.value)) / 1000
        this.data.predictLeaveDate.start = e.detail.value
        if (this.data.firstEntryDate.datelong>this.data.predictLeaveDate.datelong){
          this.data.predictLeaveDate.selected = ''
        }
        this.setData({
          firstEntryDate: this.data.firstEntryDate,
          predictLeaveDate: this.data.predictLeaveDate
        })
        break;
      case 'leave_date':
        this.data.predictLeaveDate.selected = e.detail.value
        this.data.predictLeaveDate.datelong = Date.parse(new Date(e.detail.value)) / 1000
        this.setData({
          predictLeaveDate: this.data.predictLeaveDate
        })
        break;
    }

  },

  // =============日期picker选中处理==============
  birthdayChange: function(e) {
    var birth_date = this.data.birthDate;
    birth_date.selected = e.detail.value
    console.log('birthdayChange', Date.parse(new Date(e.detail.value)))
    this.setData({
      long_birth_date: Date.parse(new Date(e.detail.value)) / 1000,
      birthDate: birth_date
    })
  },

  startChange: function(e) {
    var start_date = this.data.startDate;
    start_date.selected = e.detail.value
    this.setData({
      startDate: start_date
    })
  },

  endChange: function(e) {
    var end_date = this.data.endDate;
    end_date.selected = e.detail.value
    this.setData({
      endDate: end_date
    })
  },

  // =============地区picker选中处理==============

  contactAddressSelect: function(e) {
    // console.log('contactAddressSelect', e)
    var contact_address = this.data.contactaddressInfo;
    contact_address.selected = e.detail.value[0] + e.detail.value[1] + e.detail.value[2]
    contact_address.address_value = e.detail.value
    contact_address.address_code = e.detail.code
    this.setData({
      contactAddress_haschanged: true,
      contactaddressInfo: contact_address
    })
    console.log('contactaddressInfo', this.data.contactaddressInfo)
  },

  currentAddressSelect: function(e) {
    console.log('currentAddressSelect', e)
    var current_address = this.data.currentaddressInfo;
    current_address.selected = e.detail.value[0] + e.detail.value[1] + e.detail.value[2]
    current_address.address_value = e.detail.value
    current_address.address_code = e.detail.code
    this.setData({
      curAddress_haschanged: true,
      currentaddressInfo: current_address
    })
  },

  birthAddressSelect: function(e) {
    // console.log('birthAddressSelect', e)
    var birth_address = this.data.birthaddressInfo;
    birth_address.selected = e.detail.value[0] + e.detail.value[1] + e.detail.value[2]
    birth_address.address_value = e.detail.value
    birth_address.address_code = e.detail.code
    this.setData({
      birthAddress_haschanged: true,
      birthaddressInfo: birth_address
    })
    console.log('birthaddressInfo', this.data.birthaddressInfo)
  },

  // =============其他数据选中处理==============


  getIdInfo: function(e) {
    if (this.data.isIdCard) {
      wx.navigateTo({
        url: '../idinfo/idinfo',
        success: function(res) {},
      })
    }
  },

  bindinputmobile: function(e) {
    if (e.detail.value.length == 11 && !format.isMobile(e.detail.value)) {
      this.showtoast("手机号码有误")
    }
    this.setData({
      mobile: e.detail.value
    })
  },

  bindinputname: function(e) {
    this.setData({
      name: e.detail.value
    })
  },
  bindOtherName: function(e) {
    this.setData({
      other_name: e.detail.value
    })
  },
  idcardblur: function (e) {
    var idCardNo = e.detail.value
    this.setData({
      card_number: idCardNo
    })
    if (!this.data.isIdCard) {
      return;
    }
    if (!idCardNo.length) {
      wx.showToast({
        image: "../../../../images/warn.png",
        title: '请输入身份证号'
      })
      return;
    }
    if (!format.isIDCardNum(idCardNo)) {
      wx.showToast({
        image: "../../../../images/warn.png",
        title: '身份证格式有误'
      })
      return;
    }
  },
  bindinputcardnum: function(e) {
    var idCardNo = e.detail.value
    this.setData({
      card_number: idCardNo
    })
    if (!this.data.isIdCard) {
      return;
    }
    if (e.detail.value.length == 18) {
      if (!format.isIDCardNum(idCardNo)) {
        wx.showToast({
          image: "../../../../images/warn.png",
          title: '身份证格式有误'
        })
        return;
      }
      this.dealIdInfo(idCardNo)
    }
  },
  //根据身份证号码,获取相关信息
  dealIdInfo: function (idCardNum) {
    var info = format.analyzeIDCard(idCardNum)
    console.log('info', info.age, info.sex)
    if (info.age) {
      this.data.birthDate.selected = info.birthDay
      this.setData({
        age: info.age,
        long_birth_date: Date.parse(new Date(info.birthDay)) / 1000,
        birthDate: this.data.birthDate
      })
    }
    if (info.sex) {
      var gender_data = this.data.genderData
      gender_data.selected = info.sex
      this.setData({
        genderData: gender_data
      })
    }
  },
  personalmoney:function(e){
    console.log('personalmoney', e)
    this.setData({
      personal_equity_total: e.detail.value
    })
  },

  companymoney:function(e){
    console.log('companymoney', e)
    this.setData({
      company_equity_total: e.detail.value
    })
  },

  formSubmit: function(e) {
    var regEmail = new RegExp("^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,20}[a-z0-9]+$");
    var regMobile = /^(13[0-9]|14[5-9]|15[012356789]|166|17[0-8]|18[0-9]|19[8-9])[0-9]{8}$/;
    // var regname = /^[\u4E00-\u9FA5A-Za-z·s]{2,20}$/;          
    var regname_c = /^[\u4E00-\u9FA5\uf900-\ufa2d·s]{2,30}$/;  //中文
    var regname_e = /^[A-Za-z][A-Za-z\s]*[A-Za-z]$/;         //英文
    // var regname = /^[\u4E00-\u9FA5\uf900-\ufa2d·s]{2,20}$/;
    // var regMoney = /^[0-9]*(\.[0,9]{1,2})?$/;
    var regMoney = /^([1-9][\d]{0,10}|0)(\.[\d]{1,2})?$/
    var formdata = e.detail.value;
    console.log("formdata", formdata)
    if (this.data.cardtypeData.selected.length < 1) {
      this.showtoast('请选择证照类型');
      return
    } 
    if (this.data.card_number.length < 1) {
      this.showtoast('请填写证照号码');
      return
    } else if (this.data.isIdCard && this.data.card_number.length > 0 && !format.isIDCardNum(this.data.card_number)) {
      this.showtoast('证照号码有误');
      return
    }
    if (this.data.name.length < 1) {
      this.showtoast('请输入姓名');
      return
    } else if (this.data.name.length > 0 && !regname_c.test(this.data.name)) {
      // this.showtoast('请输入正确姓名');
      // return
    } 
    if (this.data.genderData.selected.length < 1) {
      this.showtoast('请选择性别');
      return
    }
    if (this.data.birthDate.selected.length < 1) {
      this.showtoast('请选择出生日期');
      return
    } 
    if (this.data.countryData.selected.length < 1) {
      this.showtoast('请选择国籍');
      return
    }
    if (this.data.taxpayerTypeData.selected.length < 1) {
      this.showtoast('请选择纳税人类型');
      return
    } 
    if (this.data.hasOtherCard && !this.data.firstEntryDate.selected) {
      this.showtoast('请选择首次入境时间');
      return
    } 
    if (this.data.hasOtherCard && !this.data.predictLeaveDate.selected) {
      this.showtoast('请选择预计离境时间');
      return
    }
    if (this.data.hasOtherCard && !this.data.otherCardtypeData.selected) {
      this.showtoast('请选择其他证照类型');
      return
    } 
    if (this.data.hasOtherCard && !formdata.other_card_number.length) {
      this.showtoast('请输入其他证照号码');
      return
    } 
    if (this.data.hasOtherCard && !this.data.birthCountryData.selected) {
      this.showtoast('请选择出生国家');
      return
    } 
    if (this.data.other_name.length > 0) {
      if (this.data.cardtypeData.selected != '居民身份证' && this.data.cardtypeData.selected != '中国护照'){
        var regname = (this.data.nameText == '中文名') ? regname_c : regname_e
        this.data.other_name = this.data.other_name.replace(/(^\s*)|(\s*$)/g, "");
        if (!regname.test(this.data.other_name)) {
          this.showtoast('请输入正确的' + this.data.nameText);
          return
        }
      }
    } 
    if (this.data.mobile.length < 1) {
      this.showtoast('请输入手机号码');
      return
    } else if (this.data.mobile.length > 0 && !regMobile.test(this.data.mobile)) {
      this.showtoast('手机号码有误');
      return
    }
    if (formdata.current_address_detail.length > 0 && this.data.currentaddressInfo.selected.length < 1) {
      this.showtoast('请选择居住地址');
      return
    }
    if (this.data.currentaddressInfo.selected.length > 0) {
      if (formdata.current_address_detail.length < 1) {
        this.showtoast('请填写详细居住地址');
        return
      }
    }
    if (formdata.huji_address_detail.length > 0 && this.data.birthaddressInfo.selected.length < 1) {
      this.showtoast('请选择户籍地址');
      return
    }
    if (this.data.birthaddressInfo.selected.length > 0) {
      if (formdata.huji_address_detail.length < 1) {
        this.showtoast('请填写详细户籍地址');
        return
      }
    }
    if (this.data.hasOtherCard && formdata.contact_address_detail.length > 0) {
      if (this.data.contactaddressInfo.selected.length < 1) {
        this.showtoast('请选择联系地址');
        return
      }
    }
    if (this.data.hasOtherCard && this.data.contactaddressInfo.selected.length > 0) {
      if (formdata.contact_address_detail.length < 1) {
        this.showtoast('请填写详细联系地址');
        return
      }
    }
    if (formdata.email && formdata.email.length > 0 && !regEmail.test(formdata.email)) {
      this.showtoast('邮箱格式有误');
      return
    }
    // if (formdata.email && formdata.email.length > 0 && !format.checkEmail(formdata.email)) {
    //   this.showtoast('邮箱格式有误');
    //   return
    // }
    if (this.data.bankInfo.selected.length > 0 && formdata.bank_account.length < 1) {
      this.showtoast('请输入银行卡号')
      return
    }
    if (formdata.bank_account && formdata.bank_account.length > 0) {
      if (!format.banknoCheck(formdata.bank_account)){
        this.showtoast('银行卡号格式有误')
        return
      }
      if (!this.data.bankInfo.selected) {
        this.showtoast('请选择开户银行')
        return
      }
    }
    this.goCommit(formdata);
    // else if (this.data.personstatusData.selected.length < 1) {
    //   this.showtoast('有必填项未填写');
    //   return
    // } 
    // else if (this.data.cardtypeData.selected.length < 1) {
    //   this.showtoast('有必填项未填写');
    //   return
    // } else 
    // else if (!this.data.isIdCard && (this.data.card_number.length < 1 &&  formdata.id_card_no.length < 1)) {
    //   this.showtoast('有必填项未填写');
    //   return
    // } 
    // else if (this.data.mobile.length < 1) {
    //   this.showtoast('有必填项未填写');
    //   return
    // } else 
    //else if (this.data.investInfo.selected.length < 1) {
    //   this.showtoast('有必填项未填写');
    //   return
    // } else if (this.data.specificIndustryInfo.selected.length < 1) {
    //   this.showtoast('有必填项未填写');
    //   return
    // } else if (this.data.employeeInfo.selected.length < 1) {
    //   this.showtoast('有必填项未填写');
    //   return
    // } else 
    
    //  else if (this.data.company_equity_total && this.data.company_equity_total.length > 0 && !regMoney.test(this.data.company_equity_total)) {
    //   this.showtoast('请输入正确金额');
    //   return
    // } else if (this.data.personal_equity_total && this.data.personal_equity_total.length > 0 && !regMoney.test(this.data.personal_equity_total)) {
    //   this.showtoast('请输入正确金额');
    //   return
    // }
    // var new_ard_num = ''
    // if (this.data.isIdCard && this.data.card_number.length > 0) {
    //   new_ard_num = this.data.card_number
    // }
    // if (!this.data.isIdCard && formdata.id_card_no && formdata.id_card_no.length > 0) {
    //   new_ard_num = formdata.id_card_no
    // }
    // this.setData({
    //   card_number: new_ard_num,
    // })
  },

  goCommit: function(data) {
    var that = this
    var formdata = data
    console.log("form_data", formdata);
    var request_profession = that.getProfessionRequest()
    var request_contact_address = that.getContactAddressRequest()
    var request_current_address = that.getCurrentAddressRequest()
    var request_birth_address = that.getBirthAddressRequest()
    var Authorization = app.globalData.Authorization;
    wx.request({
      url: baseUrl + 'persontax/v1/personal-taxes/' + that.data.cur_id,
      method: "PUT",
      data: {
        'certification_status': that.getCertifyStatus(formdata),
        "name": that.data.name,
        "other_name": that.data.hasOtherCard ? that.data.other_name : '',
        "family_ties": '本人',//that.data.relativeData.selected,
        "native": that.data.countryData.selected,
        "taxpayer_type": that.data.taxpayerTypeData.selected == '居民' ? 'resident' :'non-resident',
        "is_overseas_personnel": that.data.overseas,
        'birth_native': that.data.hasOtherCard ? that.data.birthCountryData.selected : '',
        "id_card_type": that.data.cardtypeData.selected, //selected_code,
        "id_card_no": that.data.card_number,
        "other_id_card_type": that.data.hasOtherCard ?  that.data.otherCardtypeData.selected : '', //selected_code,
        "other_id_card_no": that.data.hasOtherCard ? formdata.other_card_number : '',
        "gender": that.data.genderData.selected,
        "birth_date": that.data.long_birth_date,
        "first_entry_date": that.data.hasOtherCard ? that.data.firstEntryDate.datelong : null,
        "predict_leave_date": that.data.hasOtherCard ? that.data.predictLeaveDate.datelong : null,
        "mobile": that.data.mobile,
        "current_address": request_current_address,
        "current_address_detail": formdata.current_address_detail,
        "huji_address": request_birth_address,
        "huji_address_detail": formdata.huji_address_detail.replace(/(^\s*)|(\s*$)/g, ""),
        "email": formdata.email,

        "profession": request_profession,
        "education": that.data.degreeData.selected,
        "bank": that.data.bankInfo.selected,
        "bank_account": formdata.bank_account,
        // "taxpayer_no": formdata.taxpayer_no ? formdata.taxpayer_no : that.data.taxInfo.taxpayer_no,
        // "taxpayer_status": that.data.personstatusData.selected,
        "is_disability": that.data.disabilityInfo.selected,
        "disability_no": that.data.disabilityInfo.selected == '否' ? '' : formdata.disability_no,
        "is_martyr_family": that.data.lieshuInfo.selected,
        "martyr_family_no": that.data.lieshuInfo.selected == '否' ? '' : formdata.martyr_family_no,
        "is_lonely_man": that.data.lonelyolderInfo.selected,
        "comment": formdata.comment,
        
        "contact_address": that.data.hasOtherCard ? request_contact_address : {},
        "contact_address_detail": that.data.hasOtherCard ? formdata.contact_address_detail: '',
        
        // "join_date": that.data.startDate.selected.length > 0 ? Date.parse(new Date(that.data.startDate.selected)) / 1000 : this.data.taxInfo.join_date,
        // "separate_date": that.data.endDate.selected.length > 0 ? Date.parse(new Date(that.data.endDate.selected)) / 1000 : this.data.taxInfo.separate_date,
        // "is_employee": that.data.employeeInfo.selected,
        // "is_specific_profession": that.data.specificIndustryInfo.selected,
        // "is_investor": that.data.investInfo.selected,
        // "is_business_angel": that.data.investpersonalInfo.selected,
        // "company_equity_total": parseFloat(that.data.company_equity_total) ,
        // "personal_equity_total":parseFloat(that.data.personal_equity_total) ,
        // "employee_no": formdata.employee_no.length > 0 ? formdata.employee_no : that.data.taxInfo.employee_no,
      },
      header: {
        'content-type': 'application/json', // 默认值
        "Authorization": Authorization
      },
      success: function(res) {
        console.log(res)
        if (res.statusCode == 200) {
          wx.navigateBack({
            delta:1
          })
          // ({
          //   url: '../home/home',
          // })
        } else if (res.data.code == 400){
          if (res.data.errors.email){
            that.showtoast('邮箱格式有误')
          }else{
            that.showtoast(res.data.message)
          }
        }
      },
      fail(res) {
        console.log(res)
      }
    })
  },

  getProfessionRequest: function() {
    var that = this
    var pro_index = that.data.profession_index
    if (that.data.profession_haschanges && pro_index.length == 3) {
      var profession_data_info = that.data.professionData.values[pro_index[pro_index[0]]][0]
      console.log('profession_datas', profession_data_info)
      return {
        "one_level_code": profession_data_info.value,
        "one_level_name": profession_data_info.label,
        "two_level_code": profession_data_info.children[pro_index[1]].value,
        "two_level_name": profession_data_info.children[pro_index[1]].label,
        "three_level_code": profession_data_info.children[pro_index[1]].children[pro_index[2]].value,
        "three_level_name": profession_data_info.children[pro_index[1]].children[pro_index[2]].label
      }
    } else {
      return that.data.taxInfo.profession
    }
  },

  getContactAddressRequest: function() {
    var that = this
    if (that.data.contactAddress_haschanged) {
      return {
        "province_code": that.data.contactaddressInfo.address_code[0],
        "province": that.data.contactaddressInfo.address_value[0],
        "city_code": that.data.contactaddressInfo.address_code[1],
        "city": that.data.contactaddressInfo.address_value[1],
        "district_code": that.data.contactaddressInfo.address_code[2],
        "district": that.data.contactaddressInfo.address_value[2]
      }
    } else {
      return that.data.taxInfo.contact_address
    }
  },

  getCurrentAddressRequest: function() {
    var that = this
    if (that.data.curAddress_haschanged) {
      return {
        "province_code": that.data.currentaddressInfo.address_code[0],
        "province": that.data.currentaddressInfo.address_value[0],
        "city_code": that.data.currentaddressInfo.address_code[1],
        "city": that.data.currentaddressInfo.address_value[1],
        "district_code": that.data.currentaddressInfo.address_code[2],
        "district": that.data.currentaddressInfo.address_value[2]
      }
    } else {
      return that.data.taxInfo.current_address
    }
  },

  getBirthAddressRequest: function() {
    var that = this
    if (that.data.birthAddress_haschanged) {
      return {
        "province_code": that.data.birthaddressInfo.address_code[0],
        "province": that.data.birthaddressInfo.address_value[0],
        "city_code": that.data.birthaddressInfo.address_code[1],
        "city": that.data.birthaddressInfo.address_value[1],
        "district_code": that.data.birthaddressInfo.address_code[2],
        "district": that.data.birthaddressInfo.address_value[2]
      }
    } else {
      return that.data.taxInfo.huji_address
    }
  },

  showtoast: function(str) {
    wx.showToast({
      title: str,
      duration: 2000,
      icon:'none'
      // image: '/images/error.png'
    })
  },

  getCertifyStatus: function(formdata) {
    var iddata = this.data.idInfoData;
    var name = this.data.name.length > 0 ? this.data.name : formdata.name;
    var cardtype = this.data.cardtypeData.selected;
    var card_no = formdata.id_card_no ? formdata.id_card_no : this.data.card_number;
    var gender = this.data.genderData.selected;
    var long_birth_date = Date.parse(new Date(this.data.birthDate.selected)) / 1000;
    console.log("birth_day", long_birth_date + "---" + this.data.long_birth_date)
    if ((this.data.has_certify&&name == iddata.name && cardtype == '居民身份证' && card_no == iddata.id_card_number && gender == iddata.gender && long_birth_date == this.data.long_birth_date)) {
      return 'active'
    } else {
      return ''
    }
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})