index.js 31.7 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
(function() {


function _instanceof(left, right) { if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { return !!right[Symbol.hasInstance](left); } else { return left instanceof right; } }

function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

function _classCallCheck(instance, Constructor) { if (!_instanceof(instance, Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }

function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }

function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }

function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }

function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }

var _WeaverMobile = WeaverMobile,
    Tools = _WeaverMobile.Tools,
    Button = _WeaverMobile.Button,
    List = _WeaverMobile.List,
    InputItem = _WeaverMobile.InputItem,
    Bubble = _WeaverMobile.Bubble;
var getLabel = Tools.getLabel,
    callApi = Tools.callApi;
var Item = List.Item;

var SecondPassword =
/*#__PURE__*/
function (_React$Component) {
  _inherits(SecondPassword, _React$Component);

  function SecondPassword(props) {
    var _this;

    _classCallCheck(this, SecondPassword);

    _this = _possibleConstructorReturn(this, _getPrototypeOf(SecondPassword).call(this, props));

    _this.init = function () {
      callApi({
        url: '/api/hrm/login/getSecondAuthForm',
        method: 'POST',
        params: {
          secondAuthType: _this.props.authType
        }
      }).then(function (data) {
        if (data.status == 1) {
          _this.setState({
            notSetting: data.notSetting || false
          });
        } else {
          Bubble.warning(data.message);
        }
      });
    };

    _this.openSendondPwdSetting = function () {
      if (window.em != null && window.em.checkJsApi('openLink')) {
        window.em.openLink({
          url: "/spa/hrm/static4mobile/index.html#/secondaryVerification",
          openType: 2,
          sysId: window.localStorage.emobile_ec_id
        });
      } else {
        window.location.href = '/spa/hrm/static4mobile/index.html#/secondaryVerification';
      }

      var pureClose = _this.props.pureClose;
      pureClose && pureClose();
    };

    _this.setDom = function (dom) {
      if (dom) {
        var link = document.getElementById('link');
        link.addEventListener('click', _this.openSendondPwdSetting);
      }
    };

    _this.state = {
      notSetting: false
    };
    return _this;
  }

  _createClass(SecondPassword, [{
    key: "componentDidMount",
    value: function componentDidMount() {
      this.init();
    }
  }, {
    key: "componentWillUnmount",
    value: function componentWillUnmount() {
      var link = document.getElementById('link');
      link && link.removeEventListener('click', this.openSendondPwdSetting);
    }
  }, {
    key: "render",
    value: function render() {
      var _this2 = this;

      var notSetting = this.state.notSetting;
      return React.createElement("div", {
        style: {
          height: 120
        }
      }, React.createElement(List, null, React.createElement(InputItem, {
        type: "password",
        placeholder: getLabel(501201, "请输入二次验证密码"),
        onChange: this.props.setAuthCode,
        className: "ca-auth-inputitem",
        extra: [React.createElement("span", {
          className: "auth-code-require"
        }, "*")]
      }), notSetting && React.createElement(Item, {
        className: "message-btn"
      }, React.createElement("div", {
        style: {
          clear: 'both'
        },
        dangerouslySetInnerHTML: {
          __html: this.notSetSecondary
        },
        ref: function ref(dom) {
          return _this2.setDom(dom);
        }
      }))));
    }
  }, {
    key: "notSetSecondary",
    get: function get() {
      var label = getLabel('514970', '您还未设置二次验证密码,点击{param}');
      label = label.replace('{param}', "<a id='link'>".concat(getLabel('30747', '设置'), "</a>"));
      return label;
    }
  }]);

  return SecondPassword;
}(React.Component);

ecodeSDK.setCom('0bc5c28009e145e1a5a8f669f3829700', 'SecondPassword', SecondPassword);





function _instanceof(left, right) { if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { return !!right[Symbol.hasInstance](left); } else { return left instanceof right; } }

function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

function _classCallCheck(instance, Constructor) { if (!_instanceof(instance, Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }

function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }

function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }

function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }

function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }

var _WeaverMobile = WeaverMobile,
    Tools = _WeaverMobile.Tools,
    Button = _WeaverMobile.Button,
    List = _WeaverMobile.List,
    InputItem = _WeaverMobile.InputItem,
    Bubble = _WeaverMobile.Bubble;
var getLabel = Tools.getLabel;

var DynamicToken =
/*#__PURE__*/
function (_React$Component) {
  _inherits(DynamicToken, _React$Component);

  function DynamicToken() {
    _classCallCheck(this, DynamicToken);

    return _possibleConstructorReturn(this, _getPrototypeOf(DynamicToken).apply(this, arguments));
  }

  _createClass(DynamicToken, [{
    key: "render",
    value: function render() {
      return React.createElement("div", {
        style: {
          height: 120
        }
      }, React.createElement(List, null, React.createElement(InputItem, {
        type: "password",
        placeholder: getLabel(501200, "请输入动态令牌"),
        onChange: this.props.setAuthCode,
        className: "ca-auth-inputitem",
        extra: [React.createElement("span", {
          className: "auth-code-require"
        }, "*")]
      })));
    }
  }]);

  return DynamicToken;
}(React.Component);

ecodeSDK.setCom('0bc5c28009e145e1a5a8f669f3829700', 'DynamicToken', DynamicToken);





function _instanceof(left, right) { if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { return !!right[Symbol.hasInstance](left); } else { return left instanceof right; } }

function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

function _classCallCheck(instance, Constructor) { if (!_instanceof(instance, Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }

function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }

function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }

function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }

function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }

var _WeaverMobile = WeaverMobile,
    Tools = _WeaverMobile.Tools,
    Button = _WeaverMobile.Button,
    List = _WeaverMobile.List,
    InputItem = _WeaverMobile.InputItem,
    Bubble = _WeaverMobile.Bubble;
var getLabel = Tools.getLabel,
    callApi = Tools.callApi;
var Item = List.Item;

var DynamicPassword =
/*#__PURE__*/
function (_React$Component) {
  _inherits(DynamicPassword, _React$Component);

  function DynamicPassword(props) {
    var _this;

    _classCallCheck(this, DynamicPassword);

    _this = _possibleConstructorReturn(this, _getPrototypeOf(DynamicPassword).call(this, props));

    _this.initTimer = function (seconds) {
      _this.setState({
        showResendBtn: false,
        countDown: seconds
      });

      var checkTimer = setInterval(function () {
        _this.setState({
          countDown: --_this.state.countDown
        });

        if (_this.state.countDown == 0) {
          clearInterval(checkTimer);

          _this.setState({
            showResendBtn: true
          });
        }
      }, 1000);
    };

    _this.sendDynamicPassword = function () {
      callApi({
        url: '/api/hrm/login/getSecDynamicPassword',
        method: 'POST',
        params: {}
      }).then(function (data) {
        if (data.status == 1) _this.initTimer(data.validSecond);else Bubble.warning(data.message);
      });
    };

    _this.init = function () {
      callApi({
        url: '/api/hrm/login/getSecondAuthForm',
        method: 'POST',
        params: {
          secondAuthType: _this.props.authType
        }
      }).then(function (data) {
        if (data.status == 1) {
          _this.sendDynamicPassword();
        } else {
          Bubble.warning(data.message);
        }
      });
    };

    _this.state = {
      showResendBtn: false,
      countDown: 0
    };
    return _this;
  }

  _createClass(DynamicPassword, [{
    key: "componentDidMount",
    value: function componentDidMount() {
      this.init();
    }
  }, {
    key: "render",
    value: function render() {
      var _this2 = this;

      var _this$state = this.state,
          countDown = _this$state.countDown,
          showResendBtn = _this$state.showResendBtn;
      return React.createElement("div", {
        style: {
          height: 120
        }
      }, React.createElement(List, null, React.createElement(InputItem, {
        type: "password",
        placeholder: getLabel(501199, '请输入动态密码'),
        onChange: this.props.setAuthCode,
        className: "ca-auth-inputitem",
        extra: [countDown > 0 ? React.createElement("span", {
          className: "auth-code-timer"
        }, "".concat(countDown, "s")) : null, React.createElement("span", {
          className: "auth-code-require"
        }, "*")]
      }), showResendBtn && React.createElement(Item, {
        className: "message-btn"
      }, React.createElement(Button, {
        type: "ghost",
        size: "small",
        inline: true,
        onClick: function onClick() {
          return _this2.sendDynamicPassword();
        }
      }, getLabel('22408', "重新发送")))));
    }
  }]);

  return DynamicPassword;
}(React.Component);

ecodeSDK.setCom('0bc5c28009e145e1a5a8f669f3829700', 'DynamicPassword', DynamicPassword);





function _instanceof(left, right) { if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { return !!right[Symbol.hasInstance](left); } else { return left instanceof right; } }

function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

function _classCallCheck(instance, Constructor) { if (!_instanceof(instance, Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }

function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }

function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }

function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }

function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }

var _WeaverMobile = WeaverMobile,
    Tools = _WeaverMobile.Tools,
    Button = _WeaverMobile.Button,
    List = _WeaverMobile.List,
    InputItem = _WeaverMobile.InputItem,
    Bubble = _WeaverMobile.Bubble;
var getLabel = Tools.getLabel;

var CAAuth =
/*#__PURE__*/
function (_React$Component) {
  _inherits(CAAuth, _React$Component);

  function CAAuth() {
    _classCallCheck(this, CAAuth);

    return _possibleConstructorReturn(this, _getPrototypeOf(CAAuth).apply(this, arguments));
  }

  _createClass(CAAuth, [{
    key: "render",
    value: function render() {
      var _this = this,
          _React$createElement;

      var _this$props = this.props,
          owner = _this$props.owner,
          startTime = _this$props.startTime,
          endTime = _this$props.endTime,
          signAlg = _this$props.signAlg;
      return React.createElement("div", null, React.createElement(List, null, React.createElement(InputItem, {
        className: "ca-auth-item",
        value: owner,
        editable: false
      }, getLabel(79, '所有者')), React.createElement(InputItem, {
        className: "ca-auth-item",
        value: startTime,
        editable: false
      }, getLabel(501478, '颁发时间')), React.createElement(InputItem, {
        className: "ca-auth-item",
        value: endTime,
        editable: false
      }, getLabel(501479, '失效时间')), React.createElement(InputItem, {
        className: "ca-auth-item",
        value: signAlg,
        editable: false
      }, getLabel(32344, '加密算法')), React.createElement(InputItem, (_React$createElement = {
        className: "ca-auth-inputitem",
        type: "password",
        placeholder: getLabel(501214, '请输入证书密码')
      }, _defineProperty(_React$createElement, "type", "password"), _defineProperty(_React$createElement, "onChange", function onChange(v) {
        return _this.props.setAuthCode(v);
      }), _defineProperty(_React$createElement, "extra", [React.createElement("span", {
        className: "auth-code-require"
      }, "*")]), _React$createElement))));
    }
  }]);

  return CAAuth;
}(React.Component);

ecodeSDK.setCom('0bc5c28009e145e1a5a8f669f3829700', 'CAAuth', CAAuth);





function _instanceof(left, right) { if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { return !!right[Symbol.hasInstance](left); } else { return left instanceof right; } }

function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

function _classCallCheck(instance, Constructor) { if (!_instanceof(instance, Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }

function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }

function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }

function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }

function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }

var _WeaverMobile = WeaverMobile,
    Modal = _WeaverMobile.Modal,
    Tools = _WeaverMobile.Tools,
    Bubble = _WeaverMobile.Bubble;
var getLabel = Tools.getLabel,
    callApi = Tools.callApi;
var DYNAMIC_PASSWORD = 10; //动态密码

var DYNAMIC_TOKEN = 20; //动态令牌

var SECOND_AUTH_PASSWORD = 30; //二次验证密码

var CA_AUTH = 40; //CA验证

var QYS = 50; //契约锁

var suppoertCAAuth = function suppoertCAAuth() {
  var supportCAAuth = window.em && window.em.checkJsApi && window.em.checkJsApi("CAMethod");
  return supportCAAuth;
};

var getCAAuthInfo = function getCAAuthInfo(callback) {
  if (suppoertCAAuth()) {
    window.em.CAMethod({
      func: "getCACertInfo",
      callback: "getCACertInfo",
      success: function success(res) {
        callback && callback(res);
      }
    });
  }
}; //CA认证


var checkCAAuth = function checkCAAuth(original, passWord, callback) {
  if (suppoertCAAuth()) {
    window.em.CAMethod({
      func: "getSignValueNoPass",
      original: original,
      // password: passWord,
      callback: "getSignValue",
      success: function success(res) {
        callback && callback(res);
      }
    });
  }
};

var Main =
/*#__PURE__*/
function (_React$Component) {
  _inherits(Main, _React$Component);

  function Main(props) {
    var _this;

    _classCallCheck(this, Main);

    _this = _possibleConstructorReturn(this, _getPrototypeOf(Main).call(this, props));

    _this.init = function () {
      var authType = _this.props.authType;
      if (authType != CA_AUTH) _this.show();else {
        callApi({
          url: '/api/hrm/login/getSecondAuthForm',
          method: 'POST',
          params: {
            secondAuthType: _this.props.authType
          }
        }).then(function (data) {
          if (data.status == 1) {
            _this.setState({
              uid: data.loginkey
            });

            if (suppoertCAAuth()) {
              checkCAAuth(_this.state.original, null, function (data) {
                var secondAuthStore = _this.props.secondAuthStore;
                var secondAuthType = secondAuthStore.secondAuthType,
                    isProtectDialog = secondAuthStore.isProtectDialog,
                    authKey = secondAuthStore.authKey;

                if (typeof data == "string") {
                  data = JSON.parse(data);
                }

                var signValue = "";

                if (!!data.getSignValue) {
                  var result = data.getSignValue;

                  if (!!result) {
                    signValue = result.signValue;
                  }
                }

                if (!signValue) {
                  Bubble.warning(getLabel(501215, "数据签名失败,未获取到签名后的值"), 2);
                } else {
                  callApi({
                    url: '/api/hrm/login/saveCAAuth',
                    method: 'POST',
                    params: {
                      authCode: _this.state.uid
                    }
                  }).then(function (data) {
                    if (data.status == 1) {
                      _this.close('success');
                    } else {
                      Bubble.warning(data.message);
                    }
                  });
                }
              });
            } else {
              var errorMsg = getLabel(501212, "您当前的客户端不支持CA认证");
              Bubble.warning(errorMsg);
            }
          } else {
            Bubble.warning(data.message);
          }
        });
      }
    };

    _this.show = function () {
      _this.setState({
        visible: true
      });
    };

    _this.close = function (flag) {
      var _this$props = _this.props,
          dialogId = _this$props.dialogId,
          callback = _this$props.callback;

      _this.setState({
        visible: false
      });

      var dom = document.getElementById(dialogId);
      document.body.removeChild(dom);
      callback && callback(flag || 'cancel');
    };

    _this.pureClose = function () {
      var dialogId = _this.props.dialogId;

      _this.setState({
        visible: false
      });

      var dom = document.getElementById(dialogId);
      document.body.removeChild(dom);
    };

    _this.setAuthCode = function (v) {
      return _this.authCode = v;
    };

    _this.onConfirm = function () {
      if (_this.loading) return;
      _this.loading = true;
      var authType = _this.props.authType;

      if (!_this.authCode) {
        var errorMsg = "";

        switch (authType) {
          case DYNAMIC_PASSWORD:
            errorMsg = getLabel(501199, "请输入动态密码");
            break;

          case DYNAMIC_TOKEN:
            errorMsg = getLabel(501200, "请输入动态令牌");
            break;

          case SECOND_AUTH_PASSWORD:
            errorMsg = getLabel(501201, "请输入二次验证密码");
            break;

          case CA_AUTH:
            errorMsg = getLabel(501214, "请输入证书密码");
            break;

          default:
            break;
        }

        if (!!errorMsg) {
          Bubble.warning(errorMsg, 1);
        }

        _this.loading = false;
      } else {
        if (authType != CA_AUTH) {
          callApi({
            url: '/api/hrm/login/doSecondAuth',
            method: 'post',
            params: {
              authType: authType,
              authCode: _this.authCode
            }
          }).then(function (data) {
            _this.loading = false;

            if (data.status == '1') {
              if (!data.api_status) {
                Bubble.warning(data.api_errormsg);
              } else {
                _this.close('success');
              }
            } else {
              Bubble.warning(data.message);
            }
          });
        } else {
          checkCAAuth(_this.state.original, _this.props.authCode, function (data) {
            _this.loading = false;
            var secondAuthStore = _this.props.secondAuthStore;
            var secondAuthType = secondAuthStore.secondAuthType,
                isProtectDialog = secondAuthStore.isProtectDialog,
                authKey = secondAuthStore.authKey;

            if (typeof data == "string") {
              data = JSON.parse(data);
            }

            var signValue = "";

            if (!!data.getSignValue) {
              var result = data.getSignValue;

              if (!!result) {
                signValue = result.signValue;
              }
            }

            if (!signValue) {
              Bubble.warning(getLabel(501215, "数据签名失败,未获取到签名后的值"), 2);
            } else {
              callApi({
                url: '/api/hrm/login/saveCAAuth',
                method: 'POST',
                params: {
                  authCode: _this.state.uid
                }
              }).then(function (data) {
                if (data.status == 1) {
                  _this.close('success');
                } else {
                  Bubble.warning(data.message);
                }
              });
            }
          });
        }
      }
    };

    _this.authCode = '';
    _this.loading = false;
    _this.state = {
      visible: false,
      original: Math.random(),
      uid: ''
    };
    return _this;
  }

  _createClass(Main, [{
    key: "componentDidMount",
    value: function componentDidMount() {
      this.init();
    }
  }, {
    key: "render",
    value: function render() {
      var _this2 = this;

      var visible = this.state.visible;
      var authType = this.props.authType;
      var title = getLabel(501195, '身份验证');
      var footer = [{
        text: getLabel(32694, '取消'),
        onPress: function onPress() {
          return _this2.close();
        }
      }, {
        text: getLabel(826, '确定'),
        onPress: function onPress() {
          return _this2.onConfirm();
        }
      }];
      var comName = '';

      switch (authType) {
        case 10:
          comName = 'DynamicPassword';
          break;

        case 20:
          comName = 'DynamicToken';
          break;

        case 30:
          comName = 'SecondPassword';
          break;

        case 40:
          comName = 'CAAuth';
          break;
      }

      var comParams = {
        appId: '0bc5c28009e145e1a5a8f669f3829700',
        name: comName,
        //模块名称
        isPage: false,
        //是否是路由页面
        noCss: true,
        //是否禁止单独加载css,通常为了减少css数量,css默认前置加载
        props: _objectSpread({
          authType: authType,
          setAuthCode: this.setAuthCode,
          pureClose: this.pureClose
        }, this.state) //组件参数

      };
      var Com = ecodeSDK.getAsyncCom(comParams);
      return React.createElement(Modal, {
        className: "secondary-verify-dialog",
        visible: visible,
        transparent: true,
        maskClosable: false,
        onClose: this.onCancel,
        title: title,
        footer: footer
      }, Com);
    }
  }]);

  return Main;
}(React.Component);

ecodeSDK.setCom('0bc5c28009e145e1a5a8f669f3829700', 'SecondaryVerify', Main);


})();