@pisell/pisellos 0.0.336 → 0.0.338
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/solution/RegisterAndLogin/config.d.ts +1 -0
- package/dist/solution/RegisterAndLogin/config.js +23 -1
- package/dist/solution/RegisterAndLogin/index.d.ts +9 -0
- package/dist/solution/RegisterAndLogin/index.js +710 -542
- package/dist/solution/RegisterAndLogin/types.d.ts +1 -1
- package/lib/solution/RegisterAndLogin/config.d.ts +1 -0
- package/lib/solution/RegisterAndLogin/config.js +19 -1
- package/lib/solution/RegisterAndLogin/index.d.ts +9 -0
- package/lib/solution/RegisterAndLogin/index.js +132 -44
- package/lib/solution/RegisterAndLogin/types.d.ts +1 -1
- package/package.json +1 -1
|
@@ -43,6 +43,8 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
43
43
|
_defineProperty(_assertThisInitialized(_this), "apiCaller", void 0);
|
|
44
44
|
_defineProperty(_assertThisInitialized(_this), "otherParams", {});
|
|
45
45
|
_defineProperty(_assertThisInitialized(_this), "channel", 'default');
|
|
46
|
+
// 内存缓存
|
|
47
|
+
_defineProperty(_assertThisInitialized(_this), "countriesCache", null);
|
|
46
48
|
return _this;
|
|
47
49
|
}
|
|
48
50
|
|
|
@@ -65,7 +67,7 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
65
67
|
error = '没有找到邮箱注册链接的 code,请先调用 sendEmailRegisterLink';
|
|
66
68
|
this.store.error = error;
|
|
67
69
|
return _context.abrupt("return", {
|
|
68
|
-
|
|
70
|
+
status: false,
|
|
69
71
|
message: error
|
|
70
72
|
});
|
|
71
73
|
case 5:
|
|
@@ -77,7 +79,7 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
77
79
|
});
|
|
78
80
|
case 9:
|
|
79
81
|
response = _context.sent;
|
|
80
|
-
if (!response.
|
|
82
|
+
if (!response.status) {
|
|
81
83
|
_context.next = 15;
|
|
82
84
|
break;
|
|
83
85
|
}
|
|
@@ -148,7 +150,7 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
148
150
|
return this.apiCaller.call('emailCodeRegister', params);
|
|
149
151
|
case 7:
|
|
150
152
|
response = _context2.sent;
|
|
151
|
-
if (!(response.
|
|
153
|
+
if (!(response.status && response.data)) {
|
|
152
154
|
_context2.next = 15;
|
|
153
155
|
break;
|
|
154
156
|
}
|
|
@@ -226,7 +228,7 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
226
228
|
return this.apiCaller.call('phoneCodeRegister', params);
|
|
227
229
|
case 7:
|
|
228
230
|
response = _context3.sent;
|
|
229
|
-
if (!(response.
|
|
231
|
+
if (!(response.status && response.data)) {
|
|
230
232
|
_context3.next = 15;
|
|
231
233
|
break;
|
|
232
234
|
}
|
|
@@ -402,7 +404,7 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
402
404
|
return this.apiCaller.call('validateToken', token);
|
|
403
405
|
case 3:
|
|
404
406
|
response = _context6.sent;
|
|
405
|
-
if (!(response.
|
|
407
|
+
if (!(response.status && response.data)) {
|
|
406
408
|
_context6.next = 9;
|
|
407
409
|
break;
|
|
408
410
|
}
|
|
@@ -463,7 +465,7 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
463
465
|
return this.apiCaller.call('sendEmailVerificationCode', params);
|
|
464
466
|
case 5:
|
|
465
467
|
response = _context7.sent;
|
|
466
|
-
if (!response.
|
|
468
|
+
if (!response.status) {
|
|
467
469
|
_context7.next = 13;
|
|
468
470
|
break;
|
|
469
471
|
}
|
|
@@ -518,13 +520,13 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
518
520
|
return sendEmailVerificationCode;
|
|
519
521
|
}()
|
|
520
522
|
/**
|
|
521
|
-
*
|
|
523
|
+
* 发送邮箱登录验证码
|
|
522
524
|
*/
|
|
523
525
|
)
|
|
524
526
|
}, {
|
|
525
|
-
key: "
|
|
527
|
+
key: "sendEmailLoginCode",
|
|
526
528
|
value: (function () {
|
|
527
|
-
var
|
|
529
|
+
var _sendEmailLoginCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params) {
|
|
528
530
|
var response, now;
|
|
529
531
|
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
530
532
|
while (1) switch (_context8.prev = _context8.next) {
|
|
@@ -533,33 +535,33 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
533
535
|
this.store.isLoading = true;
|
|
534
536
|
this.store.error = null;
|
|
535
537
|
_context8.next = 5;
|
|
536
|
-
return this.apiCaller.call('
|
|
538
|
+
return this.apiCaller.call('sendEmailLoginCode', params);
|
|
537
539
|
case 5:
|
|
538
540
|
response = _context8.sent;
|
|
539
|
-
if (!response.
|
|
541
|
+
if (!response.status) {
|
|
540
542
|
_context8.next = 13;
|
|
541
543
|
break;
|
|
542
544
|
}
|
|
543
545
|
// 记录验证码发送状态
|
|
544
546
|
now = Date.now();
|
|
545
|
-
this.store.verificationCodeSent[params.
|
|
547
|
+
this.store.verificationCodeSent[params.target] = {
|
|
546
548
|
sent: true,
|
|
547
549
|
sentAt: now,
|
|
548
550
|
expiresAt: now + 5 * 60 * 1000 // 5分钟过期
|
|
549
551
|
};
|
|
550
552
|
_context8.next = 11;
|
|
551
|
-
return this.core.effects.emit(RegisterAndLoginHooks.
|
|
552
|
-
target: params.
|
|
553
|
-
purpose:
|
|
553
|
+
return this.core.effects.emit(RegisterAndLoginHooks.onEmailVerificationSent, {
|
|
554
|
+
target: params.target,
|
|
555
|
+
purpose: params.purpose
|
|
554
556
|
});
|
|
555
557
|
case 11:
|
|
556
558
|
_context8.next = 16;
|
|
557
559
|
break;
|
|
558
560
|
case 13:
|
|
559
|
-
this.store.error = response.message || '
|
|
561
|
+
this.store.error = response.message || '发送验证码失败';
|
|
560
562
|
_context8.next = 16;
|
|
561
|
-
return this.core.effects.emit(RegisterAndLoginHooks.
|
|
562
|
-
target: params.
|
|
563
|
+
return this.core.effects.emit(RegisterAndLoginHooks.onEmailVerificationFailed, {
|
|
564
|
+
target: params.target,
|
|
563
565
|
error: this.store.error
|
|
564
566
|
});
|
|
565
567
|
case 16:
|
|
@@ -567,10 +569,10 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
567
569
|
case 19:
|
|
568
570
|
_context8.prev = 19;
|
|
569
571
|
_context8.t0 = _context8["catch"](0);
|
|
570
|
-
this.store.error = '
|
|
572
|
+
this.store.error = '发送验证码失败';
|
|
571
573
|
_context8.next = 24;
|
|
572
|
-
return this.core.effects.emit(RegisterAndLoginHooks.
|
|
573
|
-
target: params.
|
|
574
|
+
return this.core.effects.emit(RegisterAndLoginHooks.onEmailVerificationFailed, {
|
|
575
|
+
target: params.target,
|
|
574
576
|
error: this.store.error
|
|
575
577
|
});
|
|
576
578
|
case 24:
|
|
@@ -585,7 +587,80 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
585
587
|
}
|
|
586
588
|
}, _callee8, this, [[0, 19, 25, 28]]);
|
|
587
589
|
}));
|
|
588
|
-
function
|
|
590
|
+
function sendEmailLoginCode(_x7) {
|
|
591
|
+
return _sendEmailLoginCode.apply(this, arguments);
|
|
592
|
+
}
|
|
593
|
+
return sendEmailLoginCode;
|
|
594
|
+
}()
|
|
595
|
+
/**
|
|
596
|
+
* 发送手机号注册验证码
|
|
597
|
+
*/
|
|
598
|
+
)
|
|
599
|
+
}, {
|
|
600
|
+
key: "sendSmsRegisterCode",
|
|
601
|
+
value: (function () {
|
|
602
|
+
var _sendSmsRegisterCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params) {
|
|
603
|
+
var response, now;
|
|
604
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
605
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
606
|
+
case 0:
|
|
607
|
+
_context9.prev = 0;
|
|
608
|
+
this.store.isLoading = true;
|
|
609
|
+
this.store.error = null;
|
|
610
|
+
_context9.next = 5;
|
|
611
|
+
return this.apiCaller.call('sendSmsRegisterCode', params);
|
|
612
|
+
case 5:
|
|
613
|
+
response = _context9.sent;
|
|
614
|
+
if (!response.status) {
|
|
615
|
+
_context9.next = 13;
|
|
616
|
+
break;
|
|
617
|
+
}
|
|
618
|
+
// 记录验证码发送状态
|
|
619
|
+
now = Date.now();
|
|
620
|
+
this.store.verificationCodeSent[params.phone] = {
|
|
621
|
+
sent: true,
|
|
622
|
+
sentAt: now,
|
|
623
|
+
expiresAt: now + 5 * 60 * 1000 // 5分钟过期
|
|
624
|
+
};
|
|
625
|
+
_context9.next = 11;
|
|
626
|
+
return this.core.effects.emit(RegisterAndLoginHooks.onSmsVerificationSent, {
|
|
627
|
+
target: params.phone,
|
|
628
|
+
purpose: VerificationPurpose.REGISTER
|
|
629
|
+
});
|
|
630
|
+
case 11:
|
|
631
|
+
_context9.next = 16;
|
|
632
|
+
break;
|
|
633
|
+
case 13:
|
|
634
|
+
this.store.error = response.message || '发送注册验证码失败';
|
|
635
|
+
_context9.next = 16;
|
|
636
|
+
return this.core.effects.emit(RegisterAndLoginHooks.onSmsVerificationFailed, {
|
|
637
|
+
target: params.phone,
|
|
638
|
+
error: this.store.error
|
|
639
|
+
});
|
|
640
|
+
case 16:
|
|
641
|
+
return _context9.abrupt("return", response);
|
|
642
|
+
case 19:
|
|
643
|
+
_context9.prev = 19;
|
|
644
|
+
_context9.t0 = _context9["catch"](0);
|
|
645
|
+
this.store.error = '发送注册验证码失败';
|
|
646
|
+
_context9.next = 24;
|
|
647
|
+
return this.core.effects.emit(RegisterAndLoginHooks.onSmsVerificationFailed, {
|
|
648
|
+
target: params.phone,
|
|
649
|
+
error: this.store.error
|
|
650
|
+
});
|
|
651
|
+
case 24:
|
|
652
|
+
return _context9.abrupt("return", _context9.t0);
|
|
653
|
+
case 25:
|
|
654
|
+
_context9.prev = 25;
|
|
655
|
+
this.store.isLoading = false;
|
|
656
|
+
return _context9.finish(25);
|
|
657
|
+
case 28:
|
|
658
|
+
case "end":
|
|
659
|
+
return _context9.stop();
|
|
660
|
+
}
|
|
661
|
+
}, _callee9, this, [[0, 19, 25, 28]]);
|
|
662
|
+
}));
|
|
663
|
+
function sendSmsRegisterCode(_x8) {
|
|
589
664
|
return _sendSmsRegisterCode.apply(this, arguments);
|
|
590
665
|
}
|
|
591
666
|
return sendSmsRegisterCode;
|
|
@@ -597,20 +672,20 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
597
672
|
}, {
|
|
598
673
|
key: "sendEmailRegisterLink",
|
|
599
674
|
value: (function () {
|
|
600
|
-
var _sendEmailRegisterLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
675
|
+
var _sendEmailRegisterLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(email) {
|
|
601
676
|
var response, _response$data3, now;
|
|
602
|
-
return _regeneratorRuntime().wrap(function
|
|
603
|
-
while (1) switch (
|
|
677
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
678
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
604
679
|
case 0:
|
|
605
|
-
|
|
680
|
+
_context10.prev = 0;
|
|
606
681
|
this.store.isLoading = true;
|
|
607
682
|
this.store.error = null;
|
|
608
|
-
|
|
683
|
+
_context10.next = 5;
|
|
609
684
|
return this.apiCaller.call('sendEmailRegisterLink', email);
|
|
610
685
|
case 5:
|
|
611
|
-
response =
|
|
612
|
-
if (!response.
|
|
613
|
-
|
|
686
|
+
response = _context10.sent;
|
|
687
|
+
if (!response.status) {
|
|
688
|
+
_context10.next = 14;
|
|
614
689
|
break;
|
|
615
690
|
}
|
|
616
691
|
// 保存返回的 code
|
|
@@ -625,45 +700,45 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
625
700
|
sentAt: now,
|
|
626
701
|
expiresAt: now + 24 * 60 * 60 * 1000 // 24小时过期
|
|
627
702
|
};
|
|
628
|
-
|
|
703
|
+
_context10.next = 12;
|
|
629
704
|
return this.core.effects.emit(RegisterAndLoginHooks.onEmailVerificationSent, {
|
|
630
705
|
target: email,
|
|
631
706
|
purpose: VerificationPurpose.REGISTER
|
|
632
707
|
});
|
|
633
708
|
case 12:
|
|
634
|
-
|
|
709
|
+
_context10.next = 17;
|
|
635
710
|
break;
|
|
636
711
|
case 14:
|
|
637
712
|
this.store.error = response.message || '发送注册邀请链接失败';
|
|
638
|
-
|
|
713
|
+
_context10.next = 17;
|
|
639
714
|
return this.core.effects.emit(RegisterAndLoginHooks.onEmailVerificationFailed, {
|
|
640
715
|
target: email,
|
|
641
716
|
error: this.store.error
|
|
642
717
|
});
|
|
643
718
|
case 17:
|
|
644
|
-
return
|
|
719
|
+
return _context10.abrupt("return", response);
|
|
645
720
|
case 20:
|
|
646
|
-
|
|
647
|
-
|
|
721
|
+
_context10.prev = 20;
|
|
722
|
+
_context10.t0 = _context10["catch"](0);
|
|
648
723
|
this.store.error = '发送注册邀请链接失败';
|
|
649
|
-
|
|
724
|
+
_context10.next = 25;
|
|
650
725
|
return this.core.effects.emit(RegisterAndLoginHooks.onEmailVerificationFailed, {
|
|
651
726
|
target: email,
|
|
652
727
|
error: this.store.error
|
|
653
728
|
});
|
|
654
729
|
case 25:
|
|
655
|
-
return
|
|
730
|
+
return _context10.abrupt("return", _context10.t0);
|
|
656
731
|
case 26:
|
|
657
|
-
|
|
732
|
+
_context10.prev = 26;
|
|
658
733
|
this.store.isLoading = false;
|
|
659
|
-
return
|
|
734
|
+
return _context10.finish(26);
|
|
660
735
|
case 29:
|
|
661
736
|
case "end":
|
|
662
|
-
return
|
|
737
|
+
return _context10.stop();
|
|
663
738
|
}
|
|
664
|
-
},
|
|
739
|
+
}, _callee10, this, [[0, 20, 26, 29]]);
|
|
665
740
|
}));
|
|
666
|
-
function sendEmailRegisterLink(
|
|
741
|
+
function sendEmailRegisterLink(_x9) {
|
|
667
742
|
return _sendEmailRegisterLink.apply(this, arguments);
|
|
668
743
|
}
|
|
669
744
|
return sendEmailRegisterLink;
|
|
@@ -675,61 +750,61 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
675
750
|
}, {
|
|
676
751
|
key: "verifyEmailRegistrationLink",
|
|
677
752
|
value: (function () {
|
|
678
|
-
var _verifyEmailRegistrationLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
753
|
+
var _verifyEmailRegistrationLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(params) {
|
|
679
754
|
var response;
|
|
680
|
-
return _regeneratorRuntime().wrap(function
|
|
681
|
-
while (1) switch (
|
|
755
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
756
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
682
757
|
case 0:
|
|
683
|
-
|
|
758
|
+
_context11.prev = 0;
|
|
684
759
|
this.store.isLoading = true;
|
|
685
760
|
this.store.error = null;
|
|
686
|
-
|
|
761
|
+
_context11.next = 5;
|
|
687
762
|
return this.apiCaller.call('verifyEmailRegistrationLink', params);
|
|
688
763
|
case 5:
|
|
689
|
-
response =
|
|
690
|
-
if (!response.
|
|
691
|
-
|
|
764
|
+
response = _context11.sent;
|
|
765
|
+
if (!response.status) {
|
|
766
|
+
_context11.next = 11;
|
|
692
767
|
break;
|
|
693
768
|
}
|
|
694
|
-
|
|
769
|
+
_context11.next = 9;
|
|
695
770
|
return this.core.effects.emit(RegisterAndLoginHooks.onEmailVerificationVerified, {
|
|
696
771
|
target: 'email-registration-link',
|
|
697
772
|
purpose: VerificationPurpose.REGISTER
|
|
698
773
|
});
|
|
699
774
|
case 9:
|
|
700
|
-
|
|
775
|
+
_context11.next = 14;
|
|
701
776
|
break;
|
|
702
777
|
case 11:
|
|
703
778
|
this.store.error = response.message || '邮箱注册链接验证失败';
|
|
704
|
-
|
|
779
|
+
_context11.next = 14;
|
|
705
780
|
return this.core.effects.emit(RegisterAndLoginHooks.onEmailVerificationFailed, {
|
|
706
781
|
target: 'email-registration-link',
|
|
707
782
|
error: this.store.error
|
|
708
783
|
});
|
|
709
784
|
case 14:
|
|
710
|
-
return
|
|
785
|
+
return _context11.abrupt("return", response);
|
|
711
786
|
case 17:
|
|
712
|
-
|
|
713
|
-
|
|
787
|
+
_context11.prev = 17;
|
|
788
|
+
_context11.t0 = _context11["catch"](0);
|
|
714
789
|
this.store.error = '邮箱注册链接验证失败';
|
|
715
|
-
|
|
790
|
+
_context11.next = 22;
|
|
716
791
|
return this.core.effects.emit(RegisterAndLoginHooks.onEmailVerificationFailed, {
|
|
717
792
|
target: 'email-registration-link',
|
|
718
793
|
error: this.store.error
|
|
719
794
|
});
|
|
720
795
|
case 22:
|
|
721
|
-
return
|
|
796
|
+
return _context11.abrupt("return", _context11.t0);
|
|
722
797
|
case 23:
|
|
723
|
-
|
|
798
|
+
_context11.prev = 23;
|
|
724
799
|
this.store.isLoading = false;
|
|
725
|
-
return
|
|
800
|
+
return _context11.finish(23);
|
|
726
801
|
case 26:
|
|
727
802
|
case "end":
|
|
728
|
-
return
|
|
803
|
+
return _context11.stop();
|
|
729
804
|
}
|
|
730
|
-
},
|
|
805
|
+
}, _callee11, this, [[0, 17, 23, 26]]);
|
|
731
806
|
}));
|
|
732
|
-
function verifyEmailRegistrationLink(
|
|
807
|
+
function verifyEmailRegistrationLink(_x10) {
|
|
733
808
|
return _verifyEmailRegistrationLink.apply(this, arguments);
|
|
734
809
|
}
|
|
735
810
|
return verifyEmailRegistrationLink;
|
|
@@ -741,26 +816,26 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
741
816
|
}, {
|
|
742
817
|
key: "emailPasswordLogin",
|
|
743
818
|
value: (function () {
|
|
744
|
-
var _emailPasswordLogin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
819
|
+
var _emailPasswordLogin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(params) {
|
|
745
820
|
var response;
|
|
746
|
-
return _regeneratorRuntime().wrap(function
|
|
747
|
-
while (1) switch (
|
|
821
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
822
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
748
823
|
case 0:
|
|
749
|
-
|
|
824
|
+
_context12.prev = 0;
|
|
750
825
|
this.store.isLoading = true;
|
|
751
826
|
this.store.error = null;
|
|
752
|
-
|
|
827
|
+
_context12.next = 5;
|
|
753
828
|
return this.core.effects.emit(RegisterAndLoginHooks.onLoginStarted, {
|
|
754
829
|
type: 'email-password',
|
|
755
830
|
email: params.email
|
|
756
831
|
});
|
|
757
832
|
case 5:
|
|
758
|
-
|
|
833
|
+
_context12.next = 7;
|
|
759
834
|
return this.apiCaller.call('emailPasswordLogin', params);
|
|
760
835
|
case 7:
|
|
761
|
-
response =
|
|
762
|
-
if (!(response.
|
|
763
|
-
|
|
836
|
+
response = _context12.sent;
|
|
837
|
+
if (!(response.status && response.data)) {
|
|
838
|
+
_context12.next = 17;
|
|
764
839
|
break;
|
|
765
840
|
}
|
|
766
841
|
// 保存用户信息和 token
|
|
@@ -772,46 +847,46 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
772
847
|
if (response.data.refreshToken) {
|
|
773
848
|
this.store.refreshToken = response.data.refreshToken;
|
|
774
849
|
}
|
|
775
|
-
|
|
850
|
+
_context12.next = 15;
|
|
776
851
|
return this.core.effects.emit(RegisterAndLoginHooks.onLoginSuccess, {
|
|
777
852
|
user: response.data.user,
|
|
778
853
|
token: response.data.token,
|
|
779
854
|
loginType: 'email-password'
|
|
780
855
|
});
|
|
781
856
|
case 15:
|
|
782
|
-
|
|
857
|
+
_context12.next = 20;
|
|
783
858
|
break;
|
|
784
859
|
case 17:
|
|
785
860
|
this.store.error = response.message || '邮箱密码登录失败';
|
|
786
|
-
|
|
861
|
+
_context12.next = 20;
|
|
787
862
|
return this.core.effects.emit(RegisterAndLoginHooks.onLoginFailed, {
|
|
788
863
|
error: this.store.error,
|
|
789
864
|
loginType: 'email-password'
|
|
790
865
|
});
|
|
791
866
|
case 20:
|
|
792
|
-
return
|
|
867
|
+
return _context12.abrupt("return", response);
|
|
793
868
|
case 23:
|
|
794
|
-
|
|
795
|
-
|
|
869
|
+
_context12.prev = 23;
|
|
870
|
+
_context12.t0 = _context12["catch"](0);
|
|
796
871
|
this.store.error = '邮箱密码登录失败';
|
|
797
|
-
|
|
872
|
+
_context12.next = 28;
|
|
798
873
|
return this.core.effects.emit(RegisterAndLoginHooks.onLoginFailed, {
|
|
799
874
|
error: this.store.error,
|
|
800
875
|
loginType: 'email-password'
|
|
801
876
|
});
|
|
802
877
|
case 28:
|
|
803
|
-
return
|
|
878
|
+
return _context12.abrupt("return", _context12.t0);
|
|
804
879
|
case 29:
|
|
805
|
-
|
|
880
|
+
_context12.prev = 29;
|
|
806
881
|
this.store.isLoading = false;
|
|
807
|
-
return
|
|
882
|
+
return _context12.finish(29);
|
|
808
883
|
case 32:
|
|
809
884
|
case "end":
|
|
810
|
-
return
|
|
885
|
+
return _context12.stop();
|
|
811
886
|
}
|
|
812
|
-
},
|
|
887
|
+
}, _callee12, this, [[0, 23, 29, 32]]);
|
|
813
888
|
}));
|
|
814
|
-
function emailPasswordLogin(
|
|
889
|
+
function emailPasswordLogin(_x11) {
|
|
815
890
|
return _emailPasswordLogin.apply(this, arguments);
|
|
816
891
|
}
|
|
817
892
|
return emailPasswordLogin;
|
|
@@ -823,57 +898,57 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
823
898
|
}, {
|
|
824
899
|
key: "verifyCode",
|
|
825
900
|
value: (function () {
|
|
826
|
-
var _verifyCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
901
|
+
var _verifyCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(params) {
|
|
827
902
|
var response, hookName, _hookName;
|
|
828
|
-
return _regeneratorRuntime().wrap(function
|
|
829
|
-
while (1) switch (
|
|
903
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
904
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
830
905
|
case 0:
|
|
831
|
-
|
|
906
|
+
_context13.prev = 0;
|
|
832
907
|
this.store.isLoading = true;
|
|
833
908
|
this.store.error = null;
|
|
834
|
-
|
|
909
|
+
_context13.next = 5;
|
|
835
910
|
return this.apiCaller.call('verifyCode', params);
|
|
836
911
|
case 5:
|
|
837
|
-
response =
|
|
838
|
-
if (!response.
|
|
839
|
-
|
|
912
|
+
response = _context13.sent;
|
|
913
|
+
if (!response.status) {
|
|
914
|
+
_context13.next = 12;
|
|
840
915
|
break;
|
|
841
916
|
}
|
|
842
917
|
hookName = params.type === VerificationCodeType.EMAIL ? RegisterAndLoginHooks.onEmailVerificationVerified : RegisterAndLoginHooks.onSmsVerificationVerified;
|
|
843
|
-
|
|
918
|
+
_context13.next = 10;
|
|
844
919
|
return this.core.effects.emit(hookName, {
|
|
845
920
|
target: params.target,
|
|
846
921
|
purpose: params.purpose
|
|
847
922
|
});
|
|
848
923
|
case 10:
|
|
849
|
-
|
|
924
|
+
_context13.next = 16;
|
|
850
925
|
break;
|
|
851
926
|
case 12:
|
|
852
927
|
this.store.error = response.message || '验证码验证失败';
|
|
853
928
|
_hookName = params.type === VerificationCodeType.EMAIL ? RegisterAndLoginHooks.onEmailVerificationFailed : RegisterAndLoginHooks.onSmsVerificationFailed;
|
|
854
|
-
|
|
929
|
+
_context13.next = 16;
|
|
855
930
|
return this.core.effects.emit(_hookName, {
|
|
856
931
|
target: params.target,
|
|
857
932
|
error: this.store.error
|
|
858
933
|
});
|
|
859
934
|
case 16:
|
|
860
|
-
return
|
|
935
|
+
return _context13.abrupt("return", response);
|
|
861
936
|
case 19:
|
|
862
|
-
|
|
863
|
-
|
|
937
|
+
_context13.prev = 19;
|
|
938
|
+
_context13.t0 = _context13["catch"](0);
|
|
864
939
|
this.store.error = '验证码验证失败';
|
|
865
|
-
return
|
|
940
|
+
return _context13.abrupt("return", _context13.t0);
|
|
866
941
|
case 23:
|
|
867
|
-
|
|
942
|
+
_context13.prev = 23;
|
|
868
943
|
this.store.isLoading = false;
|
|
869
|
-
return
|
|
944
|
+
return _context13.finish(23);
|
|
870
945
|
case 26:
|
|
871
946
|
case "end":
|
|
872
|
-
return
|
|
947
|
+
return _context13.stop();
|
|
873
948
|
}
|
|
874
|
-
},
|
|
949
|
+
}, _callee13, this, [[0, 19, 23, 26]]);
|
|
875
950
|
}));
|
|
876
|
-
function verifyCode(
|
|
951
|
+
function verifyCode(_x12) {
|
|
877
952
|
return _verifyCode.apply(this, arguments);
|
|
878
953
|
}
|
|
879
954
|
return verifyCode;
|
|
@@ -885,23 +960,23 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
885
960
|
}, {
|
|
886
961
|
key: "register",
|
|
887
962
|
value: (function () {
|
|
888
|
-
var _register = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
963
|
+
var _register = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(params) {
|
|
889
964
|
var response, _response$data4, user, token, refreshToken, expiresAt;
|
|
890
|
-
return _regeneratorRuntime().wrap(function
|
|
891
|
-
while (1) switch (
|
|
965
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
966
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
892
967
|
case 0:
|
|
893
|
-
|
|
968
|
+
_context14.prev = 0;
|
|
894
969
|
this.store.isLoading = true;
|
|
895
970
|
this.store.error = null;
|
|
896
|
-
|
|
971
|
+
_context14.next = 5;
|
|
897
972
|
return this.core.effects.emit(RegisterAndLoginHooks.onRegisterStarted, params);
|
|
898
973
|
case 5:
|
|
899
|
-
|
|
974
|
+
_context14.next = 7;
|
|
900
975
|
return this.apiCaller.call('register', params);
|
|
901
976
|
case 7:
|
|
902
|
-
response =
|
|
903
|
-
if (!(response.
|
|
904
|
-
|
|
977
|
+
response = _context14.sent;
|
|
978
|
+
if (!(response.status && response.data)) {
|
|
979
|
+
_context14.next = 15;
|
|
905
980
|
break;
|
|
906
981
|
}
|
|
907
982
|
_response$data4 = response.data, user = _response$data4.user, token = _response$data4.token, refreshToken = _response$data4.refreshToken, expiresAt = _response$data4.expiresAt; // 如果注册成功并返回了 token,说明可以直接登录
|
|
@@ -910,48 +985,48 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
910
985
|
this.store.isLoggedIn = true;
|
|
911
986
|
|
|
912
987
|
// 保存到本地存储
|
|
913
|
-
this.window.localStorage.setItem('auth_token', token);
|
|
914
|
-
this.window.localStorage.setItem('user_info', JSON.stringify(user));
|
|
915
|
-
if (refreshToken) {
|
|
916
|
-
|
|
917
|
-
}
|
|
988
|
+
// this.window.localStorage.setItem('auth_token', token);
|
|
989
|
+
// this.window.localStorage.setItem('user_info', JSON.stringify(user));
|
|
990
|
+
// if (refreshToken) {
|
|
991
|
+
// this.window.localStorage.setItem('refresh_token', refreshToken);
|
|
992
|
+
// }
|
|
918
993
|
}
|
|
919
|
-
|
|
994
|
+
_context14.next = 13;
|
|
920
995
|
return this.core.effects.emit(RegisterAndLoginHooks.onRegisterSuccess, response.data);
|
|
921
996
|
case 13:
|
|
922
|
-
|
|
997
|
+
_context14.next = 18;
|
|
923
998
|
break;
|
|
924
999
|
case 15:
|
|
925
1000
|
this.store.error = response.message || '注册失败';
|
|
926
|
-
|
|
1001
|
+
_context14.next = 18;
|
|
927
1002
|
return this.core.effects.emit(RegisterAndLoginHooks.onRegisterFailed, {
|
|
928
1003
|
error: this.store.error,
|
|
929
1004
|
params: params
|
|
930
1005
|
});
|
|
931
1006
|
case 18:
|
|
932
|
-
return
|
|
1007
|
+
return _context14.abrupt("return", response);
|
|
933
1008
|
case 21:
|
|
934
|
-
|
|
935
|
-
|
|
1009
|
+
_context14.prev = 21;
|
|
1010
|
+
_context14.t0 = _context14["catch"](0);
|
|
936
1011
|
this.store.error = '注册失败';
|
|
937
|
-
|
|
1012
|
+
_context14.next = 26;
|
|
938
1013
|
return this.core.effects.emit(RegisterAndLoginHooks.onRegisterFailed, {
|
|
939
1014
|
error: this.store.error,
|
|
940
1015
|
params: params
|
|
941
1016
|
});
|
|
942
1017
|
case 26:
|
|
943
|
-
throw
|
|
1018
|
+
throw _context14.t0;
|
|
944
1019
|
case 27:
|
|
945
|
-
|
|
1020
|
+
_context14.prev = 27;
|
|
946
1021
|
this.store.isLoading = false;
|
|
947
|
-
return
|
|
1022
|
+
return _context14.finish(27);
|
|
948
1023
|
case 30:
|
|
949
1024
|
case "end":
|
|
950
|
-
return
|
|
1025
|
+
return _context14.stop();
|
|
951
1026
|
}
|
|
952
|
-
},
|
|
1027
|
+
}, _callee14, this, [[0, 21, 27, 30]]);
|
|
953
1028
|
}));
|
|
954
|
-
function register(
|
|
1029
|
+
function register(_x13) {
|
|
955
1030
|
return _register.apply(this, arguments);
|
|
956
1031
|
}
|
|
957
1032
|
return register;
|
|
@@ -963,23 +1038,23 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
963
1038
|
}, {
|
|
964
1039
|
key: "login",
|
|
965
1040
|
value: (function () {
|
|
966
|
-
var _login = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1041
|
+
var _login = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(params) {
|
|
967
1042
|
var response, _response$data5, user, token, refreshToken;
|
|
968
|
-
return _regeneratorRuntime().wrap(function
|
|
969
|
-
while (1) switch (
|
|
1043
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
1044
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
970
1045
|
case 0:
|
|
971
|
-
|
|
1046
|
+
_context15.prev = 0;
|
|
972
1047
|
this.store.isLoading = true;
|
|
973
1048
|
this.store.error = null;
|
|
974
|
-
|
|
1049
|
+
_context15.next = 5;
|
|
975
1050
|
return this.core.effects.emit(RegisterAndLoginHooks.onLoginStarted, params);
|
|
976
1051
|
case 5:
|
|
977
|
-
|
|
1052
|
+
_context15.next = 7;
|
|
978
1053
|
return this.apiCaller.call('login', params);
|
|
979
1054
|
case 7:
|
|
980
|
-
response =
|
|
981
|
-
if (!(response.
|
|
982
|
-
|
|
1055
|
+
response = _context15.sent;
|
|
1056
|
+
if (!(response.status && response.data)) {
|
|
1057
|
+
_context15.next = 16;
|
|
983
1058
|
break;
|
|
984
1059
|
}
|
|
985
1060
|
_response$data5 = response.data, user = _response$data5.user, token = _response$data5.token, refreshToken = _response$data5.refreshToken;
|
|
@@ -987,47 +1062,47 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
987
1062
|
this.store.isLoggedIn = true;
|
|
988
1063
|
|
|
989
1064
|
// 保存到本地存储
|
|
990
|
-
this.window.localStorage.setItem('auth_token', token);
|
|
991
|
-
this.window.localStorage.setItem('user_info', JSON.stringify(user));
|
|
992
|
-
if (refreshToken) {
|
|
993
|
-
|
|
994
|
-
}
|
|
995
|
-
|
|
1065
|
+
// this.window.localStorage.setItem('auth_token', token);
|
|
1066
|
+
// this.window.localStorage.setItem('user_info', JSON.stringify(user));
|
|
1067
|
+
// if (refreshToken) {
|
|
1068
|
+
// this.window.localStorage.setItem('refresh_token', refreshToken);
|
|
1069
|
+
// }
|
|
1070
|
+
_context15.next = 14;
|
|
996
1071
|
return this.core.effects.emit(RegisterAndLoginHooks.onLoginSuccess, response.data);
|
|
997
|
-
case
|
|
998
|
-
|
|
1072
|
+
case 14:
|
|
1073
|
+
_context15.next = 19;
|
|
999
1074
|
break;
|
|
1000
|
-
case
|
|
1075
|
+
case 16:
|
|
1001
1076
|
this.store.error = response.message || '登录失败';
|
|
1002
|
-
|
|
1077
|
+
_context15.next = 19;
|
|
1003
1078
|
return this.core.effects.emit(RegisterAndLoginHooks.onLoginFailed, {
|
|
1004
1079
|
error: this.store.error,
|
|
1005
1080
|
params: params
|
|
1006
1081
|
});
|
|
1082
|
+
case 19:
|
|
1083
|
+
return _context15.abrupt("return", response);
|
|
1007
1084
|
case 22:
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
_context14.prev = 25;
|
|
1011
|
-
_context14.t0 = _context14["catch"](0);
|
|
1085
|
+
_context15.prev = 22;
|
|
1086
|
+
_context15.t0 = _context15["catch"](0);
|
|
1012
1087
|
this.store.error = '登录失败';
|
|
1013
|
-
|
|
1088
|
+
_context15.next = 27;
|
|
1014
1089
|
return this.core.effects.emit(RegisterAndLoginHooks.onLoginFailed, {
|
|
1015
1090
|
error: this.store.error,
|
|
1016
1091
|
params: params
|
|
1017
1092
|
});
|
|
1018
|
-
case
|
|
1019
|
-
throw
|
|
1020
|
-
case
|
|
1021
|
-
|
|
1093
|
+
case 27:
|
|
1094
|
+
throw _context15.t0;
|
|
1095
|
+
case 28:
|
|
1096
|
+
_context15.prev = 28;
|
|
1022
1097
|
this.store.isLoading = false;
|
|
1023
|
-
return
|
|
1024
|
-
case
|
|
1098
|
+
return _context15.finish(28);
|
|
1099
|
+
case 31:
|
|
1025
1100
|
case "end":
|
|
1026
|
-
return
|
|
1101
|
+
return _context15.stop();
|
|
1027
1102
|
}
|
|
1028
|
-
},
|
|
1103
|
+
}, _callee15, this, [[0, 22, 28, 31]]);
|
|
1029
1104
|
}));
|
|
1030
|
-
function login(
|
|
1105
|
+
function login(_x14) {
|
|
1031
1106
|
return _login.apply(this, arguments);
|
|
1032
1107
|
}
|
|
1033
1108
|
return login;
|
|
@@ -1039,23 +1114,23 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1039
1114
|
}, {
|
|
1040
1115
|
key: "oauthLogin",
|
|
1041
1116
|
value: (function () {
|
|
1042
|
-
var _oauthLogin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1117
|
+
var _oauthLogin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(params) {
|
|
1043
1118
|
var response, _response$data6, user, token, refreshToken;
|
|
1044
|
-
return _regeneratorRuntime().wrap(function
|
|
1045
|
-
while (1) switch (
|
|
1119
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
1120
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
1046
1121
|
case 0:
|
|
1047
|
-
|
|
1122
|
+
_context16.prev = 0;
|
|
1048
1123
|
this.store.isLoading = true;
|
|
1049
1124
|
this.store.error = null;
|
|
1050
|
-
|
|
1125
|
+
_context16.next = 5;
|
|
1051
1126
|
return this.core.effects.emit(RegisterAndLoginHooks.onOAuthLoginStarted, params);
|
|
1052
1127
|
case 5:
|
|
1053
|
-
|
|
1128
|
+
_context16.next = 7;
|
|
1054
1129
|
return this.apiCaller.call('oauthLogin', params);
|
|
1055
1130
|
case 7:
|
|
1056
|
-
response =
|
|
1057
|
-
if (!(response.
|
|
1058
|
-
|
|
1131
|
+
response = _context16.sent;
|
|
1132
|
+
if (!(response.status && response.data)) {
|
|
1133
|
+
_context16.next = 16;
|
|
1059
1134
|
break;
|
|
1060
1135
|
}
|
|
1061
1136
|
_response$data6 = response.data, user = _response$data6.user, token = _response$data6.token, refreshToken = _response$data6.refreshToken;
|
|
@@ -1063,47 +1138,47 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1063
1138
|
this.store.isLoggedIn = true;
|
|
1064
1139
|
|
|
1065
1140
|
// 保存到本地存储
|
|
1066
|
-
this.window.localStorage.setItem('auth_token', token);
|
|
1067
|
-
this.window.localStorage.setItem('user_info', JSON.stringify(user));
|
|
1068
|
-
if (refreshToken) {
|
|
1069
|
-
|
|
1070
|
-
}
|
|
1071
|
-
|
|
1141
|
+
// this.window.localStorage.setItem('auth_token', token);
|
|
1142
|
+
// this.window.localStorage.setItem('user_info', JSON.stringify(user));
|
|
1143
|
+
// if (refreshToken) {
|
|
1144
|
+
// this.window.localStorage.setItem('refresh_token', refreshToken);
|
|
1145
|
+
// }
|
|
1146
|
+
_context16.next = 14;
|
|
1072
1147
|
return this.core.effects.emit(RegisterAndLoginHooks.onOAuthLoginSuccess, response.data);
|
|
1073
|
-
case
|
|
1074
|
-
|
|
1148
|
+
case 14:
|
|
1149
|
+
_context16.next = 19;
|
|
1075
1150
|
break;
|
|
1076
|
-
case
|
|
1151
|
+
case 16:
|
|
1077
1152
|
this.store.error = response.message || 'OAuth 登录失败';
|
|
1078
|
-
|
|
1153
|
+
_context16.next = 19;
|
|
1079
1154
|
return this.core.effects.emit(RegisterAndLoginHooks.onOAuthLoginFailed, {
|
|
1080
1155
|
error: this.store.error,
|
|
1081
1156
|
params: params
|
|
1082
1157
|
});
|
|
1158
|
+
case 19:
|
|
1159
|
+
return _context16.abrupt("return", response);
|
|
1083
1160
|
case 22:
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
_context15.prev = 25;
|
|
1087
|
-
_context15.t0 = _context15["catch"](0);
|
|
1161
|
+
_context16.prev = 22;
|
|
1162
|
+
_context16.t0 = _context16["catch"](0);
|
|
1088
1163
|
this.store.error = 'OAuth 登录失败';
|
|
1089
|
-
|
|
1164
|
+
_context16.next = 27;
|
|
1090
1165
|
return this.core.effects.emit(RegisterAndLoginHooks.onOAuthLoginFailed, {
|
|
1091
1166
|
error: this.store.error,
|
|
1092
1167
|
params: params
|
|
1093
1168
|
});
|
|
1094
|
-
case
|
|
1095
|
-
throw
|
|
1096
|
-
case
|
|
1097
|
-
|
|
1169
|
+
case 27:
|
|
1170
|
+
throw _context16.t0;
|
|
1171
|
+
case 28:
|
|
1172
|
+
_context16.prev = 28;
|
|
1098
1173
|
this.store.isLoading = false;
|
|
1099
|
-
return
|
|
1100
|
-
case
|
|
1174
|
+
return _context16.finish(28);
|
|
1175
|
+
case 31:
|
|
1101
1176
|
case "end":
|
|
1102
|
-
return
|
|
1177
|
+
return _context16.stop();
|
|
1103
1178
|
}
|
|
1104
|
-
},
|
|
1179
|
+
}, _callee16, this, [[0, 22, 28, 31]]);
|
|
1105
1180
|
}));
|
|
1106
|
-
function oauthLogin(
|
|
1181
|
+
function oauthLogin(_x15) {
|
|
1107
1182
|
return _oauthLogin.apply(this, arguments);
|
|
1108
1183
|
}
|
|
1109
1184
|
return oauthLogin;
|
|
@@ -1115,30 +1190,30 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1115
1190
|
}, {
|
|
1116
1191
|
key: "logout",
|
|
1117
1192
|
value: (function () {
|
|
1118
|
-
var _logout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1119
|
-
return _regeneratorRuntime().wrap(function
|
|
1120
|
-
while (1) switch (
|
|
1193
|
+
var _logout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
|
|
1194
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1195
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
1121
1196
|
case 0:
|
|
1122
|
-
|
|
1123
|
-
|
|
1197
|
+
_context17.prev = 0;
|
|
1198
|
+
_context17.next = 3;
|
|
1124
1199
|
return this.apiCaller.call('logout');
|
|
1125
1200
|
case 3:
|
|
1126
|
-
|
|
1201
|
+
_context17.next = 8;
|
|
1127
1202
|
break;
|
|
1128
1203
|
case 5:
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
console.warn('[RegisterAndLogin] 登出接口调用失败:',
|
|
1204
|
+
_context17.prev = 5;
|
|
1205
|
+
_context17.t0 = _context17["catch"](0);
|
|
1206
|
+
console.warn('[RegisterAndLogin] 登出接口调用失败:', _context17.t0);
|
|
1132
1207
|
case 8:
|
|
1133
|
-
|
|
1208
|
+
_context17.prev = 8;
|
|
1134
1209
|
// 无论后端接口是否成功,都清除本地状态
|
|
1135
1210
|
this.clearLoginState();
|
|
1136
|
-
return
|
|
1211
|
+
return _context17.finish(8);
|
|
1137
1212
|
case 11:
|
|
1138
1213
|
case "end":
|
|
1139
|
-
return
|
|
1214
|
+
return _context17.stop();
|
|
1140
1215
|
}
|
|
1141
|
-
},
|
|
1216
|
+
}, _callee17, this, [[0, 5, 8, 11]]);
|
|
1142
1217
|
}));
|
|
1143
1218
|
function logout() {
|
|
1144
1219
|
return _logout.apply(this, arguments);
|
|
@@ -1148,19 +1223,19 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1148
1223
|
}, {
|
|
1149
1224
|
key: "sendResetPasswordLink",
|
|
1150
1225
|
value: (function () {
|
|
1151
|
-
var _sendResetPasswordLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1226
|
+
var _sendResetPasswordLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(params) {
|
|
1152
1227
|
var response;
|
|
1153
|
-
return _regeneratorRuntime().wrap(function
|
|
1154
|
-
while (1) switch (
|
|
1228
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1229
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1155
1230
|
case 0:
|
|
1156
|
-
|
|
1231
|
+
_context18.prev = 0;
|
|
1157
1232
|
this.store.isLoading = true;
|
|
1158
1233
|
this.store.error = null;
|
|
1159
|
-
|
|
1234
|
+
_context18.next = 5;
|
|
1160
1235
|
return this.apiCaller.call('sendResetPasswordLink', params);
|
|
1161
1236
|
case 5:
|
|
1162
|
-
response =
|
|
1163
|
-
if (response.
|
|
1237
|
+
response = _context18.sent;
|
|
1238
|
+
if (response.status) {
|
|
1164
1239
|
this.store.verificationCodeSent[params.email] = {
|
|
1165
1240
|
sent: true,
|
|
1166
1241
|
sentAt: Date.now(),
|
|
@@ -1173,23 +1248,23 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1173
1248
|
} else {
|
|
1174
1249
|
this.store.error = response.message || '发送重置密码链接失败';
|
|
1175
1250
|
}
|
|
1176
|
-
return
|
|
1251
|
+
return _context18.abrupt("return", response);
|
|
1177
1252
|
case 10:
|
|
1178
|
-
|
|
1179
|
-
|
|
1253
|
+
_context18.prev = 10;
|
|
1254
|
+
_context18.t0 = _context18["catch"](0);
|
|
1180
1255
|
this.store.error = '发送重置密码链接失败';
|
|
1181
|
-
return
|
|
1256
|
+
return _context18.abrupt("return", _context18.t0);
|
|
1182
1257
|
case 14:
|
|
1183
|
-
|
|
1258
|
+
_context18.prev = 14;
|
|
1184
1259
|
this.store.isLoading = false;
|
|
1185
|
-
return
|
|
1260
|
+
return _context18.finish(14);
|
|
1186
1261
|
case 17:
|
|
1187
1262
|
case "end":
|
|
1188
|
-
return
|
|
1263
|
+
return _context18.stop();
|
|
1189
1264
|
}
|
|
1190
|
-
},
|
|
1265
|
+
}, _callee18, this, [[0, 10, 14, 17]]);
|
|
1191
1266
|
}));
|
|
1192
|
-
function sendResetPasswordLink(
|
|
1267
|
+
function sendResetPasswordLink(_x16) {
|
|
1193
1268
|
return _sendResetPasswordLink.apply(this, arguments);
|
|
1194
1269
|
}
|
|
1195
1270
|
return sendResetPasswordLink;
|
|
@@ -1197,38 +1272,38 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1197
1272
|
}, {
|
|
1198
1273
|
key: "checkResetPasswordCode",
|
|
1199
1274
|
value: (function () {
|
|
1200
|
-
var _checkResetPasswordCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1275
|
+
var _checkResetPasswordCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(params) {
|
|
1201
1276
|
var response;
|
|
1202
|
-
return _regeneratorRuntime().wrap(function
|
|
1203
|
-
while (1) switch (
|
|
1277
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1278
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1204
1279
|
case 0:
|
|
1205
|
-
|
|
1280
|
+
_context19.prev = 0;
|
|
1206
1281
|
this.store.isLoading = true;
|
|
1207
1282
|
this.store.error = null;
|
|
1208
|
-
|
|
1283
|
+
_context19.next = 5;
|
|
1209
1284
|
return this.apiCaller.call('checkResetPasswordCode', params);
|
|
1210
1285
|
case 5:
|
|
1211
|
-
response =
|
|
1212
|
-
if (!response.
|
|
1286
|
+
response = _context19.sent;
|
|
1287
|
+
if (!response.status) {
|
|
1213
1288
|
this.store.error = response.message || '验证码无效';
|
|
1214
1289
|
}
|
|
1215
|
-
return
|
|
1290
|
+
return _context19.abrupt("return", response);
|
|
1216
1291
|
case 10:
|
|
1217
|
-
|
|
1218
|
-
|
|
1292
|
+
_context19.prev = 10;
|
|
1293
|
+
_context19.t0 = _context19["catch"](0);
|
|
1219
1294
|
this.store.error = '验证码验证失败';
|
|
1220
|
-
return
|
|
1295
|
+
return _context19.abrupt("return", _context19.t0);
|
|
1221
1296
|
case 14:
|
|
1222
|
-
|
|
1297
|
+
_context19.prev = 14;
|
|
1223
1298
|
this.store.isLoading = false;
|
|
1224
|
-
return
|
|
1299
|
+
return _context19.finish(14);
|
|
1225
1300
|
case 17:
|
|
1226
1301
|
case "end":
|
|
1227
|
-
return
|
|
1302
|
+
return _context19.stop();
|
|
1228
1303
|
}
|
|
1229
|
-
},
|
|
1304
|
+
}, _callee19, this, [[0, 10, 14, 17]]);
|
|
1230
1305
|
}));
|
|
1231
|
-
function checkResetPasswordCode(
|
|
1306
|
+
function checkResetPasswordCode(_x17) {
|
|
1232
1307
|
return _checkResetPasswordCode.apply(this, arguments);
|
|
1233
1308
|
}
|
|
1234
1309
|
return checkResetPasswordCode;
|
|
@@ -1236,38 +1311,38 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1236
1311
|
}, {
|
|
1237
1312
|
key: "checkEmailLinkCode",
|
|
1238
1313
|
value: (function () {
|
|
1239
|
-
var _checkEmailLinkCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1314
|
+
var _checkEmailLinkCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
|
|
1240
1315
|
var response;
|
|
1241
|
-
return _regeneratorRuntime().wrap(function
|
|
1242
|
-
while (1) switch (
|
|
1316
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1317
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1243
1318
|
case 0:
|
|
1244
|
-
|
|
1319
|
+
_context20.prev = 0;
|
|
1245
1320
|
this.store.isLoading = true;
|
|
1246
1321
|
this.store.error = null;
|
|
1247
|
-
|
|
1322
|
+
_context20.next = 5;
|
|
1248
1323
|
return this.apiCaller.call('checkEmailLinkCode', params);
|
|
1249
1324
|
case 5:
|
|
1250
|
-
response =
|
|
1251
|
-
if (!response.
|
|
1325
|
+
response = _context20.sent;
|
|
1326
|
+
if (!response.status) {
|
|
1252
1327
|
this.store.error = response.message || '邮件链接验证码无效';
|
|
1253
1328
|
}
|
|
1254
|
-
return
|
|
1329
|
+
return _context20.abrupt("return", response);
|
|
1255
1330
|
case 10:
|
|
1256
|
-
|
|
1257
|
-
|
|
1331
|
+
_context20.prev = 10;
|
|
1332
|
+
_context20.t0 = _context20["catch"](0);
|
|
1258
1333
|
this.store.error = '邮件链接验证码验证失败';
|
|
1259
|
-
return
|
|
1334
|
+
return _context20.abrupt("return", _context20.t0);
|
|
1260
1335
|
case 14:
|
|
1261
|
-
|
|
1336
|
+
_context20.prev = 14;
|
|
1262
1337
|
this.store.isLoading = false;
|
|
1263
|
-
return
|
|
1338
|
+
return _context20.finish(14);
|
|
1264
1339
|
case 17:
|
|
1265
1340
|
case "end":
|
|
1266
|
-
return
|
|
1341
|
+
return _context20.stop();
|
|
1267
1342
|
}
|
|
1268
|
-
},
|
|
1343
|
+
}, _callee20, this, [[0, 10, 14, 17]]);
|
|
1269
1344
|
}));
|
|
1270
|
-
function checkEmailLinkCode(
|
|
1345
|
+
function checkEmailLinkCode(_x18) {
|
|
1271
1346
|
return _checkEmailLinkCode.apply(this, arguments);
|
|
1272
1347
|
}
|
|
1273
1348
|
return checkEmailLinkCode;
|
|
@@ -1275,22 +1350,22 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1275
1350
|
}, {
|
|
1276
1351
|
key: "resetPasswordByCode",
|
|
1277
1352
|
value: (function () {
|
|
1278
|
-
var _resetPasswordByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1353
|
+
var _resetPasswordByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(params) {
|
|
1279
1354
|
var response;
|
|
1280
|
-
return _regeneratorRuntime().wrap(function
|
|
1281
|
-
while (1) switch (
|
|
1355
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
1356
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1282
1357
|
case 0:
|
|
1283
|
-
|
|
1358
|
+
_context21.prev = 0;
|
|
1284
1359
|
this.store.isLoading = true;
|
|
1285
1360
|
this.store.error = null;
|
|
1286
1361
|
this.core.effects.emit(RegisterAndLoginHooks.onPasswordResetStarted, {
|
|
1287
1362
|
code: params.code
|
|
1288
1363
|
});
|
|
1289
|
-
|
|
1364
|
+
_context21.next = 6;
|
|
1290
1365
|
return this.apiCaller.call('resetPasswordByCode', params);
|
|
1291
1366
|
case 6:
|
|
1292
|
-
response =
|
|
1293
|
-
if (response.
|
|
1367
|
+
response = _context21.sent;
|
|
1368
|
+
if (response.status) {
|
|
1294
1369
|
this.core.effects.emit(RegisterAndLoginHooks.onPasswordResetSuccess, {
|
|
1295
1370
|
code: params.code
|
|
1296
1371
|
});
|
|
@@ -1301,27 +1376,27 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1301
1376
|
error: this.store.error
|
|
1302
1377
|
});
|
|
1303
1378
|
}
|
|
1304
|
-
return
|
|
1379
|
+
return _context21.abrupt("return", response);
|
|
1305
1380
|
case 11:
|
|
1306
|
-
|
|
1307
|
-
|
|
1381
|
+
_context21.prev = 11;
|
|
1382
|
+
_context21.t0 = _context21["catch"](0);
|
|
1308
1383
|
this.store.error = '密码重置失败';
|
|
1309
1384
|
this.core.effects.emit(RegisterAndLoginHooks.onPasswordResetFailed, {
|
|
1310
1385
|
code: params.code,
|
|
1311
1386
|
error: this.store.error
|
|
1312
1387
|
});
|
|
1313
|
-
return
|
|
1388
|
+
return _context21.abrupt("return", _context21.t0);
|
|
1314
1389
|
case 16:
|
|
1315
|
-
|
|
1390
|
+
_context21.prev = 16;
|
|
1316
1391
|
this.store.isLoading = false;
|
|
1317
|
-
return
|
|
1392
|
+
return _context21.finish(16);
|
|
1318
1393
|
case 19:
|
|
1319
1394
|
case "end":
|
|
1320
|
-
return
|
|
1395
|
+
return _context21.stop();
|
|
1321
1396
|
}
|
|
1322
|
-
},
|
|
1397
|
+
}, _callee21, this, [[0, 11, 16, 19]]);
|
|
1323
1398
|
}));
|
|
1324
|
-
function resetPasswordByCode(
|
|
1399
|
+
function resetPasswordByCode(_x19) {
|
|
1325
1400
|
return _resetPasswordByCode.apply(this, arguments);
|
|
1326
1401
|
}
|
|
1327
1402
|
return resetPasswordByCode;
|
|
@@ -1333,12 +1408,12 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1333
1408
|
}, {
|
|
1334
1409
|
key: "resetPassword",
|
|
1335
1410
|
value: (function () {
|
|
1336
|
-
var _resetPassword = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1337
|
-
var response, key;
|
|
1338
|
-
return _regeneratorRuntime().wrap(function
|
|
1339
|
-
while (1) switch (
|
|
1411
|
+
var _resetPassword = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
|
|
1412
|
+
var response, key;
|
|
1413
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
1414
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1340
1415
|
case 0:
|
|
1341
|
-
|
|
1416
|
+
_context22.prev = 0;
|
|
1342
1417
|
this.store.isLoading = true;
|
|
1343
1418
|
this.store.error = null;
|
|
1344
1419
|
|
|
@@ -1353,33 +1428,33 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1353
1428
|
});
|
|
1354
1429
|
}
|
|
1355
1430
|
if (!(params.type === 'email')) {
|
|
1356
|
-
|
|
1431
|
+
_context22.next = 12;
|
|
1357
1432
|
break;
|
|
1358
1433
|
}
|
|
1359
1434
|
if (params.target.email) {
|
|
1360
|
-
|
|
1435
|
+
_context22.next = 7;
|
|
1361
1436
|
break;
|
|
1362
1437
|
}
|
|
1363
1438
|
throw new Error('邮箱地址不能为空');
|
|
1364
1439
|
case 7:
|
|
1365
|
-
|
|
1440
|
+
_context22.next = 9;
|
|
1366
1441
|
return this.apiCaller.call('resetPasswordByEmail', {
|
|
1367
1442
|
email: params.target.email,
|
|
1368
1443
|
password: params.password,
|
|
1369
1444
|
code: params.code
|
|
1370
1445
|
});
|
|
1371
1446
|
case 9:
|
|
1372
|
-
response =
|
|
1373
|
-
|
|
1447
|
+
response = _context22.sent;
|
|
1448
|
+
_context22.next = 17;
|
|
1374
1449
|
break;
|
|
1375
1450
|
case 12:
|
|
1376
1451
|
if (!(!params.target.phone || !params.target.country_calling_code)) {
|
|
1377
|
-
|
|
1452
|
+
_context22.next = 14;
|
|
1378
1453
|
break;
|
|
1379
1454
|
}
|
|
1380
1455
|
throw new Error('手机号和国家区号不能为空');
|
|
1381
1456
|
case 14:
|
|
1382
|
-
|
|
1457
|
+
_context22.next = 16;
|
|
1383
1458
|
return this.apiCaller.call('resetPasswordByPhone', {
|
|
1384
1459
|
phone: params.target.phone,
|
|
1385
1460
|
password: params.password,
|
|
@@ -1387,9 +1462,9 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1387
1462
|
country_calling_code: params.target.country_calling_code
|
|
1388
1463
|
});
|
|
1389
1464
|
case 16:
|
|
1390
|
-
response =
|
|
1465
|
+
response = _context22.sent;
|
|
1391
1466
|
case 17:
|
|
1392
|
-
if (response.
|
|
1467
|
+
if (response.status) {
|
|
1393
1468
|
// 清除验证码发送状态
|
|
1394
1469
|
key = params.type === 'email' ? params.target.email : params.target.phone;
|
|
1395
1470
|
if (this.store.verificationCodeSent[key]) {
|
|
@@ -1418,10 +1493,10 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1418
1493
|
});
|
|
1419
1494
|
}
|
|
1420
1495
|
}
|
|
1421
|
-
return
|
|
1496
|
+
return _context22.abrupt("return", response);
|
|
1422
1497
|
case 21:
|
|
1423
|
-
|
|
1424
|
-
|
|
1498
|
+
_context22.prev = 21;
|
|
1499
|
+
_context22.t0 = _context22["catch"](0);
|
|
1425
1500
|
this.store.error = '密码重置失败';
|
|
1426
1501
|
if (params.type === 'email') {
|
|
1427
1502
|
this.core.effects.emit(RegisterAndLoginHooks.onPasswordResetFailed, {
|
|
@@ -1434,18 +1509,18 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1434
1509
|
error: this.store.error
|
|
1435
1510
|
});
|
|
1436
1511
|
}
|
|
1437
|
-
return
|
|
1512
|
+
return _context22.abrupt("return", _context22.t0);
|
|
1438
1513
|
case 26:
|
|
1439
|
-
|
|
1514
|
+
_context22.prev = 26;
|
|
1440
1515
|
this.store.isLoading = false;
|
|
1441
|
-
return
|
|
1516
|
+
return _context22.finish(26);
|
|
1442
1517
|
case 29:
|
|
1443
1518
|
case "end":
|
|
1444
|
-
return
|
|
1519
|
+
return _context22.stop();
|
|
1445
1520
|
}
|
|
1446
|
-
},
|
|
1521
|
+
}, _callee22, this, [[0, 21, 26, 29]]);
|
|
1447
1522
|
}));
|
|
1448
|
-
function resetPassword(
|
|
1523
|
+
function resetPassword(_x20) {
|
|
1449
1524
|
return _resetPassword.apply(this, arguments);
|
|
1450
1525
|
}
|
|
1451
1526
|
return resetPassword;
|
|
@@ -1453,20 +1528,20 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1453
1528
|
}, {
|
|
1454
1529
|
key: "sendSmsLoginCode",
|
|
1455
1530
|
value: (function () {
|
|
1456
|
-
var _sendSmsLoginCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1531
|
+
var _sendSmsLoginCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
|
|
1457
1532
|
var response, now;
|
|
1458
|
-
return _regeneratorRuntime().wrap(function
|
|
1459
|
-
while (1) switch (
|
|
1533
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
1534
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
1460
1535
|
case 0:
|
|
1461
|
-
|
|
1536
|
+
_context23.prev = 0;
|
|
1462
1537
|
this.store.isLoading = true;
|
|
1463
1538
|
this.store.error = null;
|
|
1464
|
-
|
|
1539
|
+
_context23.next = 5;
|
|
1465
1540
|
return this.apiCaller.call('sendSmsLoginCode', params);
|
|
1466
1541
|
case 5:
|
|
1467
|
-
response =
|
|
1468
|
-
if (!response.
|
|
1469
|
-
|
|
1542
|
+
response = _context23.sent;
|
|
1543
|
+
if (!response.status) {
|
|
1544
|
+
_context23.next = 13;
|
|
1470
1545
|
break;
|
|
1471
1546
|
}
|
|
1472
1547
|
// 记录验证码发送状态
|
|
@@ -1476,45 +1551,45 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1476
1551
|
sentAt: now,
|
|
1477
1552
|
expiresAt: now + 5 * 60 * 1000 // 5分钟过期
|
|
1478
1553
|
};
|
|
1479
|
-
|
|
1554
|
+
_context23.next = 11;
|
|
1480
1555
|
return this.core.effects.emit(RegisterAndLoginHooks.onSmsVerificationSent, {
|
|
1481
1556
|
target: params.phone,
|
|
1482
1557
|
purpose: VerificationPurpose.LOGIN
|
|
1483
1558
|
});
|
|
1484
1559
|
case 11:
|
|
1485
|
-
|
|
1560
|
+
_context23.next = 16;
|
|
1486
1561
|
break;
|
|
1487
1562
|
case 13:
|
|
1488
1563
|
this.store.error = response.message || '发送登录验证码失败';
|
|
1489
|
-
|
|
1564
|
+
_context23.next = 16;
|
|
1490
1565
|
return this.core.effects.emit(RegisterAndLoginHooks.onSmsVerificationFailed, {
|
|
1491
1566
|
target: params.phone,
|
|
1492
1567
|
error: this.store.error
|
|
1493
1568
|
});
|
|
1494
1569
|
case 16:
|
|
1495
|
-
return
|
|
1570
|
+
return _context23.abrupt("return", response);
|
|
1496
1571
|
case 19:
|
|
1497
|
-
|
|
1498
|
-
|
|
1572
|
+
_context23.prev = 19;
|
|
1573
|
+
_context23.t0 = _context23["catch"](0);
|
|
1499
1574
|
this.store.error = '发送登录验证码失败';
|
|
1500
|
-
|
|
1575
|
+
_context23.next = 24;
|
|
1501
1576
|
return this.core.effects.emit(RegisterAndLoginHooks.onSmsVerificationFailed, {
|
|
1502
1577
|
target: params.phone,
|
|
1503
1578
|
error: this.store.error
|
|
1504
1579
|
});
|
|
1505
1580
|
case 24:
|
|
1506
|
-
return
|
|
1581
|
+
return _context23.abrupt("return", _context23.t0);
|
|
1507
1582
|
case 25:
|
|
1508
|
-
|
|
1583
|
+
_context23.prev = 25;
|
|
1509
1584
|
this.store.isLoading = false;
|
|
1510
|
-
return
|
|
1585
|
+
return _context23.finish(25);
|
|
1511
1586
|
case 28:
|
|
1512
1587
|
case "end":
|
|
1513
|
-
return
|
|
1588
|
+
return _context23.stop();
|
|
1514
1589
|
}
|
|
1515
|
-
},
|
|
1590
|
+
}, _callee23, this, [[0, 19, 25, 28]]);
|
|
1516
1591
|
}));
|
|
1517
|
-
function sendSmsLoginCode(
|
|
1592
|
+
function sendSmsLoginCode(_x21) {
|
|
1518
1593
|
return _sendSmsLoginCode.apply(this, arguments);
|
|
1519
1594
|
}
|
|
1520
1595
|
return sendSmsLoginCode;
|
|
@@ -1522,26 +1597,26 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1522
1597
|
}, {
|
|
1523
1598
|
key: "phoneCodeLogin",
|
|
1524
1599
|
value: (function () {
|
|
1525
|
-
var _phoneCodeLogin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1600
|
+
var _phoneCodeLogin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
|
|
1526
1601
|
var response;
|
|
1527
|
-
return _regeneratorRuntime().wrap(function
|
|
1528
|
-
while (1) switch (
|
|
1602
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
1603
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
1529
1604
|
case 0:
|
|
1530
|
-
|
|
1605
|
+
_context24.prev = 0;
|
|
1531
1606
|
this.store.isLoading = true;
|
|
1532
1607
|
this.store.error = null;
|
|
1533
|
-
|
|
1608
|
+
_context24.next = 5;
|
|
1534
1609
|
return this.core.effects.emit(RegisterAndLoginHooks.onLoginStarted, {
|
|
1535
1610
|
type: 'phone-code',
|
|
1536
1611
|
phone: params.phone
|
|
1537
1612
|
});
|
|
1538
1613
|
case 5:
|
|
1539
|
-
|
|
1614
|
+
_context24.next = 7;
|
|
1540
1615
|
return this.apiCaller.call('phoneCodeLogin', params);
|
|
1541
1616
|
case 7:
|
|
1542
|
-
response =
|
|
1543
|
-
if (!(response.
|
|
1544
|
-
|
|
1617
|
+
response = _context24.sent;
|
|
1618
|
+
if (!(response.status && response.data)) {
|
|
1619
|
+
_context24.next = 17;
|
|
1545
1620
|
break;
|
|
1546
1621
|
}
|
|
1547
1622
|
// 保存用户信息和 token
|
|
@@ -1553,46 +1628,46 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1553
1628
|
if (response.data.refreshToken) {
|
|
1554
1629
|
this.store.refreshToken = response.data.refreshToken;
|
|
1555
1630
|
}
|
|
1556
|
-
|
|
1631
|
+
_context24.next = 15;
|
|
1557
1632
|
return this.core.effects.emit(RegisterAndLoginHooks.onLoginSuccess, {
|
|
1558
1633
|
user: response.data.user,
|
|
1559
1634
|
token: response.data.token,
|
|
1560
1635
|
loginType: 'phone-code'
|
|
1561
1636
|
});
|
|
1562
1637
|
case 15:
|
|
1563
|
-
|
|
1638
|
+
_context24.next = 20;
|
|
1564
1639
|
break;
|
|
1565
1640
|
case 17:
|
|
1566
1641
|
this.store.error = response.message || '手机号验证码登录失败';
|
|
1567
|
-
|
|
1642
|
+
_context24.next = 20;
|
|
1568
1643
|
return this.core.effects.emit(RegisterAndLoginHooks.onLoginFailed, {
|
|
1569
1644
|
error: this.store.error,
|
|
1570
1645
|
loginType: 'phone-code'
|
|
1571
1646
|
});
|
|
1572
1647
|
case 20:
|
|
1573
|
-
return
|
|
1648
|
+
return _context24.abrupt("return", response);
|
|
1574
1649
|
case 23:
|
|
1575
|
-
|
|
1576
|
-
|
|
1650
|
+
_context24.prev = 23;
|
|
1651
|
+
_context24.t0 = _context24["catch"](0);
|
|
1577
1652
|
this.store.error = '手机号验证码登录失败';
|
|
1578
|
-
|
|
1653
|
+
_context24.next = 28;
|
|
1579
1654
|
return this.core.effects.emit(RegisterAndLoginHooks.onLoginFailed, {
|
|
1580
1655
|
error: this.store.error,
|
|
1581
1656
|
loginType: 'phone-code'
|
|
1582
1657
|
});
|
|
1583
1658
|
case 28:
|
|
1584
|
-
return
|
|
1659
|
+
return _context24.abrupt("return", _context24.t0);
|
|
1585
1660
|
case 29:
|
|
1586
|
-
|
|
1661
|
+
_context24.prev = 29;
|
|
1587
1662
|
this.store.isLoading = false;
|
|
1588
|
-
return
|
|
1663
|
+
return _context24.finish(29);
|
|
1589
1664
|
case 32:
|
|
1590
1665
|
case "end":
|
|
1591
|
-
return
|
|
1666
|
+
return _context24.stop();
|
|
1592
1667
|
}
|
|
1593
|
-
},
|
|
1668
|
+
}, _callee24, this, [[0, 23, 29, 32]]);
|
|
1594
1669
|
}));
|
|
1595
|
-
function phoneCodeLogin(
|
|
1670
|
+
function phoneCodeLogin(_x22) {
|
|
1596
1671
|
return _phoneCodeLogin.apply(this, arguments);
|
|
1597
1672
|
}
|
|
1598
1673
|
return phoneCodeLogin;
|
|
@@ -1600,22 +1675,22 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1600
1675
|
}, {
|
|
1601
1676
|
key: "guestLogin",
|
|
1602
1677
|
value: (function () {
|
|
1603
|
-
var _guestLogin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1678
|
+
var _guestLogin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
|
|
1604
1679
|
var response;
|
|
1605
|
-
return _regeneratorRuntime().wrap(function
|
|
1606
|
-
while (1) switch (
|
|
1680
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
1681
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
1607
1682
|
case 0:
|
|
1608
|
-
|
|
1683
|
+
_context25.prev = 0;
|
|
1609
1684
|
this.store.isLoading = true;
|
|
1610
1685
|
this.store.error = null;
|
|
1611
1686
|
this.core.effects.emit(RegisterAndLoginHooks.onLoginStarted, {
|
|
1612
1687
|
type: 'guest'
|
|
1613
1688
|
});
|
|
1614
|
-
|
|
1689
|
+
_context25.next = 6;
|
|
1615
1690
|
return this.apiCaller.call('guestLogin', this.channel);
|
|
1616
1691
|
case 6:
|
|
1617
|
-
response =
|
|
1618
|
-
if (response.
|
|
1692
|
+
response = _context25.sent;
|
|
1693
|
+
if (response.status && response.data) {
|
|
1619
1694
|
// 保存用户信息和 token
|
|
1620
1695
|
this.store.isLoggedIn = true;
|
|
1621
1696
|
this.store.userInfo = response.data.user;
|
|
@@ -1637,25 +1712,25 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1637
1712
|
loginType: 'guest'
|
|
1638
1713
|
});
|
|
1639
1714
|
}
|
|
1640
|
-
return
|
|
1715
|
+
return _context25.abrupt("return", response);
|
|
1641
1716
|
case 11:
|
|
1642
|
-
|
|
1643
|
-
|
|
1717
|
+
_context25.prev = 11;
|
|
1718
|
+
_context25.t0 = _context25["catch"](0);
|
|
1644
1719
|
this.store.error = 'Guest 登录失败';
|
|
1645
1720
|
this.core.effects.emit(RegisterAndLoginHooks.onLoginFailed, {
|
|
1646
1721
|
error: this.store.error,
|
|
1647
1722
|
loginType: 'guest'
|
|
1648
1723
|
});
|
|
1649
|
-
return
|
|
1724
|
+
return _context25.abrupt("return", _context25.t0);
|
|
1650
1725
|
case 16:
|
|
1651
|
-
|
|
1726
|
+
_context25.prev = 16;
|
|
1652
1727
|
this.store.isLoading = false;
|
|
1653
|
-
return
|
|
1728
|
+
return _context25.finish(16);
|
|
1654
1729
|
case 19:
|
|
1655
1730
|
case "end":
|
|
1656
|
-
return
|
|
1731
|
+
return _context25.stop();
|
|
1657
1732
|
}
|
|
1658
|
-
},
|
|
1733
|
+
}, _callee25, this, [[0, 11, 16, 19]]);
|
|
1659
1734
|
}));
|
|
1660
1735
|
function guestLogin() {
|
|
1661
1736
|
return _guestLogin.apply(this, arguments);
|
|
@@ -1665,38 +1740,38 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1665
1740
|
}, {
|
|
1666
1741
|
key: "checkEmailExists",
|
|
1667
1742
|
value: (function () {
|
|
1668
|
-
var _checkEmailExists = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1743
|
+
var _checkEmailExists = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
|
|
1669
1744
|
var response;
|
|
1670
|
-
return _regeneratorRuntime().wrap(function
|
|
1671
|
-
while (1) switch (
|
|
1745
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
1746
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
1672
1747
|
case 0:
|
|
1673
|
-
|
|
1748
|
+
_context26.prev = 0;
|
|
1674
1749
|
this.store.isLoading = true;
|
|
1675
1750
|
this.store.error = null;
|
|
1676
|
-
|
|
1751
|
+
_context26.next = 5;
|
|
1677
1752
|
return this.apiCaller.call('checkEmailExists', params);
|
|
1678
1753
|
case 5:
|
|
1679
|
-
response =
|
|
1680
|
-
if (!response.
|
|
1754
|
+
response = _context26.sent;
|
|
1755
|
+
if (!response.status) {
|
|
1681
1756
|
this.store.error = response.message || '检查邮箱失败';
|
|
1682
1757
|
}
|
|
1683
|
-
return
|
|
1758
|
+
return _context26.abrupt("return", response);
|
|
1684
1759
|
case 10:
|
|
1685
|
-
|
|
1686
|
-
|
|
1760
|
+
_context26.prev = 10;
|
|
1761
|
+
_context26.t0 = _context26["catch"](0);
|
|
1687
1762
|
this.store.error = '检查邮箱失败';
|
|
1688
|
-
return
|
|
1763
|
+
return _context26.abrupt("return", _context26.t0);
|
|
1689
1764
|
case 14:
|
|
1690
|
-
|
|
1765
|
+
_context26.prev = 14;
|
|
1691
1766
|
this.store.isLoading = false;
|
|
1692
|
-
return
|
|
1767
|
+
return _context26.finish(14);
|
|
1693
1768
|
case 17:
|
|
1694
1769
|
case "end":
|
|
1695
|
-
return
|
|
1770
|
+
return _context26.stop();
|
|
1696
1771
|
}
|
|
1697
|
-
},
|
|
1772
|
+
}, _callee26, this, [[0, 10, 14, 17]]);
|
|
1698
1773
|
}));
|
|
1699
|
-
function checkEmailExists(
|
|
1774
|
+
function checkEmailExists(_x23) {
|
|
1700
1775
|
return _checkEmailExists.apply(this, arguments);
|
|
1701
1776
|
}
|
|
1702
1777
|
return checkEmailExists;
|
|
@@ -1704,38 +1779,38 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1704
1779
|
}, {
|
|
1705
1780
|
key: "checkEmailCode",
|
|
1706
1781
|
value: (function () {
|
|
1707
|
-
var _checkEmailCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1782
|
+
var _checkEmailCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
|
|
1708
1783
|
var response;
|
|
1709
|
-
return _regeneratorRuntime().wrap(function
|
|
1710
|
-
while (1) switch (
|
|
1784
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
1785
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
1711
1786
|
case 0:
|
|
1712
|
-
|
|
1787
|
+
_context27.prev = 0;
|
|
1713
1788
|
this.store.isLoading = true;
|
|
1714
1789
|
this.store.error = null;
|
|
1715
|
-
|
|
1790
|
+
_context27.next = 5;
|
|
1716
1791
|
return this.apiCaller.call('checkEmailCode', params);
|
|
1717
1792
|
case 5:
|
|
1718
|
-
response =
|
|
1719
|
-
if (!response.
|
|
1793
|
+
response = _context27.sent;
|
|
1794
|
+
if (!response.status) {
|
|
1720
1795
|
this.store.error = response.message || '检查邮箱验证码失败';
|
|
1721
1796
|
}
|
|
1722
|
-
return
|
|
1797
|
+
return _context27.abrupt("return", response);
|
|
1723
1798
|
case 10:
|
|
1724
|
-
|
|
1725
|
-
|
|
1799
|
+
_context27.prev = 10;
|
|
1800
|
+
_context27.t0 = _context27["catch"](0);
|
|
1726
1801
|
this.store.error = '检查邮箱验证码失败';
|
|
1727
|
-
return
|
|
1802
|
+
return _context27.abrupt("return", _context27.t0);
|
|
1728
1803
|
case 14:
|
|
1729
|
-
|
|
1804
|
+
_context27.prev = 14;
|
|
1730
1805
|
this.store.isLoading = false;
|
|
1731
|
-
return
|
|
1806
|
+
return _context27.finish(14);
|
|
1732
1807
|
case 17:
|
|
1733
1808
|
case "end":
|
|
1734
|
-
return
|
|
1809
|
+
return _context27.stop();
|
|
1735
1810
|
}
|
|
1736
|
-
},
|
|
1811
|
+
}, _callee27, this, [[0, 10, 14, 17]]);
|
|
1737
1812
|
}));
|
|
1738
|
-
function checkEmailCode(
|
|
1813
|
+
function checkEmailCode(_x24) {
|
|
1739
1814
|
return _checkEmailCode.apply(this, arguments);
|
|
1740
1815
|
}
|
|
1741
1816
|
return checkEmailCode;
|
|
@@ -1743,38 +1818,38 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1743
1818
|
}, {
|
|
1744
1819
|
key: "checkMobileCode",
|
|
1745
1820
|
value: (function () {
|
|
1746
|
-
var _checkMobileCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1821
|
+
var _checkMobileCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
|
|
1747
1822
|
var response;
|
|
1748
|
-
return _regeneratorRuntime().wrap(function
|
|
1749
|
-
while (1) switch (
|
|
1823
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
1824
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
1750
1825
|
case 0:
|
|
1751
|
-
|
|
1826
|
+
_context28.prev = 0;
|
|
1752
1827
|
this.store.isLoading = true;
|
|
1753
1828
|
this.store.error = null;
|
|
1754
|
-
|
|
1829
|
+
_context28.next = 5;
|
|
1755
1830
|
return this.apiCaller.call('checkMobileCode', params);
|
|
1756
1831
|
case 5:
|
|
1757
|
-
response =
|
|
1758
|
-
if (!response.
|
|
1832
|
+
response = _context28.sent;
|
|
1833
|
+
if (!response.status) {
|
|
1759
1834
|
this.store.error = response.message || '检查手机验证码失败';
|
|
1760
1835
|
}
|
|
1761
|
-
return
|
|
1836
|
+
return _context28.abrupt("return", response);
|
|
1762
1837
|
case 10:
|
|
1763
|
-
|
|
1764
|
-
|
|
1838
|
+
_context28.prev = 10;
|
|
1839
|
+
_context28.t0 = _context28["catch"](0);
|
|
1765
1840
|
this.store.error = '检查手机验证码失败';
|
|
1766
|
-
return
|
|
1841
|
+
return _context28.abrupt("return", _context28.t0);
|
|
1767
1842
|
case 14:
|
|
1768
|
-
|
|
1843
|
+
_context28.prev = 14;
|
|
1769
1844
|
this.store.isLoading = false;
|
|
1770
|
-
return
|
|
1845
|
+
return _context28.finish(14);
|
|
1771
1846
|
case 17:
|
|
1772
1847
|
case "end":
|
|
1773
|
-
return
|
|
1848
|
+
return _context28.stop();
|
|
1774
1849
|
}
|
|
1775
|
-
},
|
|
1850
|
+
}, _callee28, this, [[0, 10, 14, 17]]);
|
|
1776
1851
|
}));
|
|
1777
|
-
function checkMobileCode(
|
|
1852
|
+
function checkMobileCode(_x25) {
|
|
1778
1853
|
return _checkMobileCode.apply(this, arguments);
|
|
1779
1854
|
}
|
|
1780
1855
|
return checkMobileCode;
|
|
@@ -1782,23 +1857,23 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1782
1857
|
}, {
|
|
1783
1858
|
key: "phonePasswordLogin",
|
|
1784
1859
|
value: (function () {
|
|
1785
|
-
var _phonePasswordLogin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1860
|
+
var _phonePasswordLogin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
|
|
1786
1861
|
var response;
|
|
1787
|
-
return _regeneratorRuntime().wrap(function
|
|
1788
|
-
while (1) switch (
|
|
1862
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
1863
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
1789
1864
|
case 0:
|
|
1790
|
-
|
|
1865
|
+
_context29.prev = 0;
|
|
1791
1866
|
this.store.isLoading = true;
|
|
1792
1867
|
this.store.error = null;
|
|
1793
1868
|
this.core.effects.emit(RegisterAndLoginHooks.onLoginStarted, {
|
|
1794
1869
|
type: 'phone-password',
|
|
1795
1870
|
phone: params.phone
|
|
1796
1871
|
});
|
|
1797
|
-
|
|
1872
|
+
_context29.next = 6;
|
|
1798
1873
|
return this.apiCaller.call('phonePasswordLogin', params);
|
|
1799
1874
|
case 6:
|
|
1800
|
-
response =
|
|
1801
|
-
if (response.
|
|
1875
|
+
response = _context29.sent;
|
|
1876
|
+
if (response.status && response.data) {
|
|
1802
1877
|
// 保存用户信息和 token
|
|
1803
1878
|
this.store.isLoggedIn = true;
|
|
1804
1879
|
this.store.userInfo = response.data.user;
|
|
@@ -1820,27 +1895,27 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1820
1895
|
loginType: 'phone-password'
|
|
1821
1896
|
});
|
|
1822
1897
|
}
|
|
1823
|
-
return
|
|
1898
|
+
return _context29.abrupt("return", response);
|
|
1824
1899
|
case 11:
|
|
1825
|
-
|
|
1826
|
-
|
|
1900
|
+
_context29.prev = 11;
|
|
1901
|
+
_context29.t0 = _context29["catch"](0);
|
|
1827
1902
|
this.store.error = '手机号密码登录失败';
|
|
1828
1903
|
this.core.effects.emit(RegisterAndLoginHooks.onLoginFailed, {
|
|
1829
1904
|
error: this.store.error,
|
|
1830
1905
|
loginType: 'phone-password'
|
|
1831
1906
|
});
|
|
1832
|
-
return
|
|
1907
|
+
return _context29.abrupt("return", _context29.t0);
|
|
1833
1908
|
case 16:
|
|
1834
|
-
|
|
1909
|
+
_context29.prev = 16;
|
|
1835
1910
|
this.store.isLoading = false;
|
|
1836
|
-
return
|
|
1911
|
+
return _context29.finish(16);
|
|
1837
1912
|
case 19:
|
|
1838
1913
|
case "end":
|
|
1839
|
-
return
|
|
1914
|
+
return _context29.stop();
|
|
1840
1915
|
}
|
|
1841
|
-
},
|
|
1916
|
+
}, _callee29, this, [[0, 11, 16, 19]]);
|
|
1842
1917
|
}));
|
|
1843
|
-
function phonePasswordLogin(
|
|
1918
|
+
function phonePasswordLogin(_x26) {
|
|
1844
1919
|
return _phonePasswordLogin.apply(this, arguments);
|
|
1845
1920
|
}
|
|
1846
1921
|
return phonePasswordLogin;
|
|
@@ -1848,19 +1923,19 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1848
1923
|
}, {
|
|
1849
1924
|
key: "sendPasswordResetEmail",
|
|
1850
1925
|
value: (function () {
|
|
1851
|
-
var _sendPasswordResetEmail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1926
|
+
var _sendPasswordResetEmail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
|
|
1852
1927
|
var response, now;
|
|
1853
|
-
return _regeneratorRuntime().wrap(function
|
|
1854
|
-
while (1) switch (
|
|
1928
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
1929
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
1855
1930
|
case 0:
|
|
1856
|
-
|
|
1931
|
+
_context30.prev = 0;
|
|
1857
1932
|
this.store.isLoading = true;
|
|
1858
1933
|
this.store.error = null;
|
|
1859
|
-
|
|
1934
|
+
_context30.next = 5;
|
|
1860
1935
|
return this.apiCaller.call('sendPasswordResetEmail', params);
|
|
1861
1936
|
case 5:
|
|
1862
|
-
response =
|
|
1863
|
-
if (response.
|
|
1937
|
+
response = _context30.sent;
|
|
1938
|
+
if (response.status) {
|
|
1864
1939
|
// 记录验证码发送状态
|
|
1865
1940
|
now = Date.now();
|
|
1866
1941
|
this.store.verificationCodeSent[params.email] = {
|
|
@@ -1879,27 +1954,27 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1879
1954
|
error: this.store.error
|
|
1880
1955
|
});
|
|
1881
1956
|
}
|
|
1882
|
-
return
|
|
1957
|
+
return _context30.abrupt("return", response);
|
|
1883
1958
|
case 10:
|
|
1884
|
-
|
|
1885
|
-
|
|
1959
|
+
_context30.prev = 10;
|
|
1960
|
+
_context30.t0 = _context30["catch"](0);
|
|
1886
1961
|
this.store.error = '发送密码重置验证码失败';
|
|
1887
1962
|
this.core.effects.emit(RegisterAndLoginHooks.onEmailVerificationFailed, {
|
|
1888
1963
|
target: params.email,
|
|
1889
1964
|
error: this.store.error
|
|
1890
1965
|
});
|
|
1891
|
-
return
|
|
1966
|
+
return _context30.abrupt("return", _context30.t0);
|
|
1892
1967
|
case 15:
|
|
1893
|
-
|
|
1968
|
+
_context30.prev = 15;
|
|
1894
1969
|
this.store.isLoading = false;
|
|
1895
|
-
return
|
|
1970
|
+
return _context30.finish(15);
|
|
1896
1971
|
case 18:
|
|
1897
1972
|
case "end":
|
|
1898
|
-
return
|
|
1973
|
+
return _context30.stop();
|
|
1899
1974
|
}
|
|
1900
|
-
},
|
|
1975
|
+
}, _callee30, this, [[0, 10, 15, 18]]);
|
|
1901
1976
|
}));
|
|
1902
|
-
function sendPasswordResetEmail(
|
|
1977
|
+
function sendPasswordResetEmail(_x27) {
|
|
1903
1978
|
return _sendPasswordResetEmail.apply(this, arguments);
|
|
1904
1979
|
}
|
|
1905
1980
|
return sendPasswordResetEmail;
|
|
@@ -1907,43 +1982,43 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1907
1982
|
}, {
|
|
1908
1983
|
key: "sendPasswordResetSms",
|
|
1909
1984
|
value: (function () {
|
|
1910
|
-
var _sendPasswordResetSms = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1985
|
+
var _sendPasswordResetSms = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
|
|
1911
1986
|
var response;
|
|
1912
|
-
return _regeneratorRuntime().wrap(function
|
|
1913
|
-
while (1) switch (
|
|
1987
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
1988
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
1914
1989
|
case 0:
|
|
1915
|
-
|
|
1990
|
+
_context31.prev = 0;
|
|
1916
1991
|
this.store.isLoading = true;
|
|
1917
1992
|
this.store.error = null;
|
|
1918
|
-
|
|
1993
|
+
_context31.next = 5;
|
|
1919
1994
|
return this.apiCaller.call('sendPasswordResetSms', params);
|
|
1920
1995
|
case 5:
|
|
1921
|
-
response =
|
|
1922
|
-
if (!response.
|
|
1923
|
-
|
|
1996
|
+
response = _context31.sent;
|
|
1997
|
+
if (!response.status) {
|
|
1998
|
+
_context31.next = 10;
|
|
1924
1999
|
break;
|
|
1925
2000
|
}
|
|
1926
|
-
return
|
|
2001
|
+
return _context31.abrupt("return", response);
|
|
1927
2002
|
case 10:
|
|
1928
2003
|
this.store.error = response.message || '发送手机号验证码重置密码失败';
|
|
1929
2004
|
case 11:
|
|
1930
|
-
return
|
|
2005
|
+
return _context31.abrupt("return", response);
|
|
1931
2006
|
case 14:
|
|
1932
|
-
|
|
1933
|
-
|
|
2007
|
+
_context31.prev = 14;
|
|
2008
|
+
_context31.t0 = _context31["catch"](0);
|
|
1934
2009
|
this.store.error = '发送手机号验证码重置密码失败';
|
|
1935
|
-
return
|
|
2010
|
+
return _context31.abrupt("return", _context31.t0);
|
|
1936
2011
|
case 18:
|
|
1937
|
-
|
|
2012
|
+
_context31.prev = 18;
|
|
1938
2013
|
this.store.isLoading = false;
|
|
1939
|
-
return
|
|
2014
|
+
return _context31.finish(18);
|
|
1940
2015
|
case 21:
|
|
1941
2016
|
case "end":
|
|
1942
|
-
return
|
|
2017
|
+
return _context31.stop();
|
|
1943
2018
|
}
|
|
1944
|
-
},
|
|
2019
|
+
}, _callee31, this, [[0, 14, 18, 21]]);
|
|
1945
2020
|
}));
|
|
1946
|
-
function sendPasswordResetSms(
|
|
2021
|
+
function sendPasswordResetSms(_x28) {
|
|
1947
2022
|
return _sendPasswordResetSms.apply(this, arguments);
|
|
1948
2023
|
}
|
|
1949
2024
|
return sendPasswordResetSms;
|
|
@@ -2027,11 +2102,11 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2027
2102
|
}, {
|
|
2028
2103
|
key: "initFacebookSDK",
|
|
2029
2104
|
value: (function () {
|
|
2030
|
-
var _initFacebookSDK = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2031
|
-
return _regeneratorRuntime().wrap(function
|
|
2032
|
-
while (1) switch (
|
|
2105
|
+
var _initFacebookSDK = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(token) {
|
|
2106
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
2107
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
2033
2108
|
case 0:
|
|
2034
|
-
return
|
|
2109
|
+
return _context32.abrupt("return", new Promise(function (resolve, reject) {
|
|
2035
2110
|
if (typeof window === 'undefined') {
|
|
2036
2111
|
reject(new Error('Facebook SDK 只能在浏览器环境中使用'));
|
|
2037
2112
|
return;
|
|
@@ -2065,11 +2140,11 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2065
2140
|
}));
|
|
2066
2141
|
case 1:
|
|
2067
2142
|
case "end":
|
|
2068
|
-
return
|
|
2143
|
+
return _context32.stop();
|
|
2069
2144
|
}
|
|
2070
|
-
},
|
|
2145
|
+
}, _callee32);
|
|
2071
2146
|
}));
|
|
2072
|
-
function initFacebookSDK(
|
|
2147
|
+
function initFacebookSDK(_x29) {
|
|
2073
2148
|
return _initFacebookSDK.apply(this, arguments);
|
|
2074
2149
|
}
|
|
2075
2150
|
return initFacebookSDK;
|
|
@@ -2081,11 +2156,11 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2081
2156
|
}, {
|
|
2082
2157
|
key: "initAppleSDK",
|
|
2083
2158
|
value: (function () {
|
|
2084
|
-
var _initAppleSDK = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2085
|
-
return _regeneratorRuntime().wrap(function
|
|
2086
|
-
while (1) switch (
|
|
2159
|
+
var _initAppleSDK = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
|
|
2160
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
2161
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
2087
2162
|
case 0:
|
|
2088
|
-
return
|
|
2163
|
+
return _context33.abrupt("return", new Promise(function (resolve, reject) {
|
|
2089
2164
|
if (typeof window === 'undefined') {
|
|
2090
2165
|
reject(new Error('Apple SDK 只能在浏览器环境中使用'));
|
|
2091
2166
|
return;
|
|
@@ -2120,9 +2195,9 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2120
2195
|
}));
|
|
2121
2196
|
case 1:
|
|
2122
2197
|
case "end":
|
|
2123
|
-
return
|
|
2198
|
+
return _context33.stop();
|
|
2124
2199
|
}
|
|
2125
|
-
},
|
|
2200
|
+
}, _callee33);
|
|
2126
2201
|
}));
|
|
2127
2202
|
function initAppleSDK() {
|
|
2128
2203
|
return _initAppleSDK.apply(this, arguments);
|
|
@@ -2136,51 +2211,51 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2136
2211
|
}, {
|
|
2137
2212
|
key: "loginWithFacebook",
|
|
2138
2213
|
value: (function () {
|
|
2139
|
-
var _loginWithFacebook = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2214
|
+
var _loginWithFacebook = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(token) {
|
|
2140
2215
|
var _this2 = this;
|
|
2141
|
-
return _regeneratorRuntime().wrap(function
|
|
2142
|
-
while (1) switch (
|
|
2216
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context35) {
|
|
2217
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
2143
2218
|
case 0:
|
|
2144
|
-
|
|
2219
|
+
_context35.next = 2;
|
|
2145
2220
|
return this.initFacebookSDK(token);
|
|
2146
2221
|
case 2:
|
|
2147
|
-
return
|
|
2222
|
+
return _context35.abrupt("return", new Promise(function (resolve, reject) {
|
|
2148
2223
|
window.FB.login( /*#__PURE__*/function () {
|
|
2149
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2224
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(response) {
|
|
2150
2225
|
var result;
|
|
2151
|
-
return _regeneratorRuntime().wrap(function
|
|
2152
|
-
while (1) switch (
|
|
2226
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
2227
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
2153
2228
|
case 0:
|
|
2154
2229
|
if (!response.authResponse) {
|
|
2155
|
-
|
|
2230
|
+
_context34.next = 13;
|
|
2156
2231
|
break;
|
|
2157
2232
|
}
|
|
2158
|
-
|
|
2159
|
-
|
|
2233
|
+
_context34.prev = 1;
|
|
2234
|
+
_context34.next = 4;
|
|
2160
2235
|
return _this2.apiCaller.call('facebookLogin', {
|
|
2161
2236
|
token: response.authResponse.accessToken
|
|
2162
2237
|
});
|
|
2163
2238
|
case 4:
|
|
2164
|
-
result =
|
|
2239
|
+
result = _context34.sent;
|
|
2165
2240
|
resolve(result);
|
|
2166
|
-
|
|
2241
|
+
_context34.next = 11;
|
|
2167
2242
|
break;
|
|
2168
2243
|
case 8:
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
reject(
|
|
2244
|
+
_context34.prev = 8;
|
|
2245
|
+
_context34.t0 = _context34["catch"](1);
|
|
2246
|
+
reject(_context34.t0);
|
|
2172
2247
|
case 11:
|
|
2173
|
-
|
|
2248
|
+
_context34.next = 14;
|
|
2174
2249
|
break;
|
|
2175
2250
|
case 13:
|
|
2176
2251
|
reject(new Error('facebook_login_cancel'));
|
|
2177
2252
|
case 14:
|
|
2178
2253
|
case "end":
|
|
2179
|
-
return
|
|
2254
|
+
return _context34.stop();
|
|
2180
2255
|
}
|
|
2181
|
-
},
|
|
2256
|
+
}, _callee34, null, [[1, 8]]);
|
|
2182
2257
|
}));
|
|
2183
|
-
return function (
|
|
2258
|
+
return function (_x31) {
|
|
2184
2259
|
return _ref.apply(this, arguments);
|
|
2185
2260
|
};
|
|
2186
2261
|
}(), {
|
|
@@ -2189,11 +2264,11 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2189
2264
|
}));
|
|
2190
2265
|
case 3:
|
|
2191
2266
|
case "end":
|
|
2192
|
-
return
|
|
2267
|
+
return _context35.stop();
|
|
2193
2268
|
}
|
|
2194
|
-
},
|
|
2269
|
+
}, _callee35, this);
|
|
2195
2270
|
}));
|
|
2196
|
-
function loginWithFacebook(
|
|
2271
|
+
function loginWithFacebook(_x30) {
|
|
2197
2272
|
return _loginWithFacebook.apply(this, arguments);
|
|
2198
2273
|
}
|
|
2199
2274
|
return loginWithFacebook;
|
|
@@ -2205,15 +2280,15 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2205
2280
|
}, {
|
|
2206
2281
|
key: "loginWithApple",
|
|
2207
2282
|
value: (function () {
|
|
2208
|
-
var _loginWithApple = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2283
|
+
var _loginWithApple = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(token) {
|
|
2209
2284
|
var _this3 = this;
|
|
2210
|
-
return _regeneratorRuntime().wrap(function
|
|
2211
|
-
while (1) switch (
|
|
2285
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context37) {
|
|
2286
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
2212
2287
|
case 0:
|
|
2213
|
-
|
|
2288
|
+
_context37.next = 2;
|
|
2214
2289
|
return this.initAppleSDK();
|
|
2215
2290
|
case 2:
|
|
2216
|
-
return
|
|
2291
|
+
return _context37.abrupt("return", new Promise(function (resolve, reject) {
|
|
2217
2292
|
try {
|
|
2218
2293
|
var _AppleID, _AppleID2;
|
|
2219
2294
|
// 动态创建 Apple 登录按钮元素
|
|
@@ -2249,12 +2324,12 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2249
2324
|
// 直接调用 Apple ID 登录,并处理 Promise
|
|
2250
2325
|
if ((_AppleID2 = window.AppleID) !== null && _AppleID2 !== void 0 && (_AppleID2 = _AppleID2.auth) !== null && _AppleID2 !== void 0 && _AppleID2.signIn) {
|
|
2251
2326
|
window.AppleID.auth.signIn().then( /*#__PURE__*/function () {
|
|
2252
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2327
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(authResult) {
|
|
2253
2328
|
var _authResult$authoriza, _authResult$authoriza2, authorizationCode, identityToken, result;
|
|
2254
|
-
return _regeneratorRuntime().wrap(function
|
|
2255
|
-
while (1) switch (
|
|
2329
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
2330
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
2256
2331
|
case 0:
|
|
2257
|
-
|
|
2332
|
+
_context36.prev = 0;
|
|
2258
2333
|
// 清理临时元素
|
|
2259
2334
|
if (document.body.contains(appleSignInDiv)) {
|
|
2260
2335
|
document.body.removeChild(appleSignInDiv);
|
|
@@ -2263,26 +2338,26 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2263
2338
|
// 获取授权码或令牌
|
|
2264
2339
|
authorizationCode = (_authResult$authoriza = authResult.authorization) === null || _authResult$authoriza === void 0 ? void 0 : _authResult$authoriza.code;
|
|
2265
2340
|
identityToken = (_authResult$authoriza2 = authResult.authorization) === null || _authResult$authoriza2 === void 0 ? void 0 : _authResult$authoriza2.id_token; // 使用授权码或身份令牌调用后端接口
|
|
2266
|
-
|
|
2341
|
+
_context36.next = 6;
|
|
2267
2342
|
return _this3.apiCaller.call('appleLogin', {
|
|
2268
2343
|
token: authorizationCode || identityToken
|
|
2269
2344
|
});
|
|
2270
2345
|
case 6:
|
|
2271
|
-
result =
|
|
2346
|
+
result = _context36.sent;
|
|
2272
2347
|
resolve(result);
|
|
2273
|
-
|
|
2348
|
+
_context36.next = 13;
|
|
2274
2349
|
break;
|
|
2275
2350
|
case 10:
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
reject(
|
|
2351
|
+
_context36.prev = 10;
|
|
2352
|
+
_context36.t0 = _context36["catch"](0);
|
|
2353
|
+
reject(_context36.t0);
|
|
2279
2354
|
case 13:
|
|
2280
2355
|
case "end":
|
|
2281
|
-
return
|
|
2356
|
+
return _context36.stop();
|
|
2282
2357
|
}
|
|
2283
|
-
},
|
|
2358
|
+
}, _callee36, null, [[0, 10]]);
|
|
2284
2359
|
}));
|
|
2285
|
-
return function (
|
|
2360
|
+
return function (_x33) {
|
|
2286
2361
|
return _ref2.apply(this, arguments);
|
|
2287
2362
|
};
|
|
2288
2363
|
}()).catch(function (error) {
|
|
@@ -2301,11 +2376,11 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2301
2376
|
}));
|
|
2302
2377
|
case 3:
|
|
2303
2378
|
case "end":
|
|
2304
|
-
return
|
|
2379
|
+
return _context37.stop();
|
|
2305
2380
|
}
|
|
2306
|
-
},
|
|
2381
|
+
}, _callee37, this);
|
|
2307
2382
|
}));
|
|
2308
|
-
function loginWithApple(
|
|
2383
|
+
function loginWithApple(_x32) {
|
|
2309
2384
|
return _loginWithApple.apply(this, arguments);
|
|
2310
2385
|
}
|
|
2311
2386
|
return loginWithApple;
|
|
@@ -2344,66 +2419,159 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2344
2419
|
}, {
|
|
2345
2420
|
key: "getCountries",
|
|
2346
2421
|
value: (function () {
|
|
2347
|
-
var _getCountries = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2348
|
-
var response;
|
|
2349
|
-
return _regeneratorRuntime().wrap(function
|
|
2350
|
-
while (1) switch (
|
|
2422
|
+
var _getCountries = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {
|
|
2423
|
+
var CACHE_KEY, cachedData, cached, response, countries;
|
|
2424
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context38) {
|
|
2425
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
2351
2426
|
case 0:
|
|
2352
|
-
|
|
2427
|
+
CACHE_KEY = 'pisell_countries_cache';
|
|
2428
|
+
_context38.prev = 1;
|
|
2353
2429
|
this.store.isLoading = true;
|
|
2354
2430
|
this.store.error = null;
|
|
2355
|
-
|
|
2431
|
+
|
|
2432
|
+
// 1. 检查内存缓存
|
|
2433
|
+
if (!this.countriesCache) {
|
|
2434
|
+
_context38.next = 7;
|
|
2435
|
+
break;
|
|
2436
|
+
}
|
|
2437
|
+
this.store.isLoading = false;
|
|
2438
|
+
return _context38.abrupt("return", this.countriesCache);
|
|
2439
|
+
case 7:
|
|
2440
|
+
// 2. 检查 localStorage 缓存
|
|
2441
|
+
cachedData = null;
|
|
2442
|
+
try {
|
|
2443
|
+
cached = this.window.localStorage.getItem(CACHE_KEY);
|
|
2444
|
+
if (cached) {
|
|
2445
|
+
cachedData = JSON.parse(cached);
|
|
2446
|
+
}
|
|
2447
|
+
} catch (error) {
|
|
2448
|
+
console.warn('[RegisterAndLogin] localStorage 缓存解析失败:', error);
|
|
2449
|
+
}
|
|
2450
|
+
|
|
2451
|
+
// 3. 如果有 localStorage 缓存,先返回缓存数据
|
|
2452
|
+
if (!(cachedData && Array.isArray(cachedData) && cachedData.length > 0)) {
|
|
2453
|
+
_context38.next = 14;
|
|
2454
|
+
break;
|
|
2455
|
+
}
|
|
2456
|
+
// 设置内存缓存
|
|
2457
|
+
this.countriesCache = cachedData;
|
|
2458
|
+
|
|
2459
|
+
// 异步请求后端数据进行对比和更新
|
|
2460
|
+
this.updateCountriesCache(CACHE_KEY, cachedData);
|
|
2461
|
+
this.store.isLoading = false;
|
|
2462
|
+
return _context38.abrupt("return", cachedData);
|
|
2463
|
+
case 14:
|
|
2464
|
+
_context38.next = 16;
|
|
2356
2465
|
return this.apiCaller.call('getCountries');
|
|
2357
|
-
case
|
|
2358
|
-
response =
|
|
2466
|
+
case 16:
|
|
2467
|
+
response = _context38.sent;
|
|
2359
2468
|
if (!(response.status && response.data)) {
|
|
2360
|
-
|
|
2469
|
+
_context38.next = 24;
|
|
2361
2470
|
break;
|
|
2362
2471
|
}
|
|
2363
|
-
|
|
2364
|
-
|
|
2472
|
+
countries = response.data; // 更新内存缓存
|
|
2473
|
+
this.countriesCache = countries;
|
|
2474
|
+
|
|
2475
|
+
// 更新 localStorage 缓存
|
|
2476
|
+
try {
|
|
2477
|
+
localStorage.setItem(CACHE_KEY, JSON.stringify(countries));
|
|
2478
|
+
} catch (error) {
|
|
2479
|
+
console.warn('[RegisterAndLogin] localStorage 存储失败:', error);
|
|
2480
|
+
}
|
|
2481
|
+
return _context38.abrupt("return", countries);
|
|
2482
|
+
case 24:
|
|
2365
2483
|
this.store.error = response.message || '获取国家区号失败';
|
|
2366
2484
|
throw new Error(this.store.error);
|
|
2367
|
-
case
|
|
2368
|
-
|
|
2485
|
+
case 26:
|
|
2486
|
+
_context38.next = 33;
|
|
2369
2487
|
break;
|
|
2370
|
-
case
|
|
2371
|
-
|
|
2372
|
-
|
|
2488
|
+
case 28:
|
|
2489
|
+
_context38.prev = 28;
|
|
2490
|
+
_context38.t0 = _context38["catch"](1);
|
|
2373
2491
|
this.store.error = '获取国家区号失败';
|
|
2374
|
-
console.error('[RegisterAndLogin] 获取国家区号失败:',
|
|
2375
|
-
throw
|
|
2376
|
-
case
|
|
2377
|
-
|
|
2492
|
+
console.error('[RegisterAndLogin] 获取国家区号失败:', _context38.t0);
|
|
2493
|
+
throw _context38.t0;
|
|
2494
|
+
case 33:
|
|
2495
|
+
_context38.prev = 33;
|
|
2378
2496
|
this.store.isLoading = false;
|
|
2379
|
-
return
|
|
2380
|
-
case
|
|
2497
|
+
return _context38.finish(33);
|
|
2498
|
+
case 36:
|
|
2381
2499
|
case "end":
|
|
2382
|
-
return
|
|
2500
|
+
return _context38.stop();
|
|
2383
2501
|
}
|
|
2384
|
-
},
|
|
2502
|
+
}, _callee38, this, [[1, 28, 33, 36]]);
|
|
2385
2503
|
}));
|
|
2386
2504
|
function getCountries() {
|
|
2387
2505
|
return _getCountries.apply(this, arguments);
|
|
2388
2506
|
}
|
|
2389
2507
|
return getCountries;
|
|
2508
|
+
}()
|
|
2509
|
+
/**
|
|
2510
|
+
* 异步更新国家缓存数据
|
|
2511
|
+
*/
|
|
2512
|
+
)
|
|
2513
|
+
}, {
|
|
2514
|
+
key: "updateCountriesCache",
|
|
2515
|
+
value: (function () {
|
|
2516
|
+
var _updateCountriesCache = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(cacheKey, cachedData) {
|
|
2517
|
+
var response, newData, hasChanged;
|
|
2518
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context39) {
|
|
2519
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
2520
|
+
case 0:
|
|
2521
|
+
_context39.prev = 0;
|
|
2522
|
+
_context39.next = 3;
|
|
2523
|
+
return this.apiCaller.call('getCountries');
|
|
2524
|
+
case 3:
|
|
2525
|
+
response = _context39.sent;
|
|
2526
|
+
if (response.status && response.data) {
|
|
2527
|
+
newData = response.data; // 比较数据是否有变化(简单的长度和内容对比)
|
|
2528
|
+
hasChanged = newData.length !== cachedData.length || JSON.stringify(newData) !== JSON.stringify(cachedData);
|
|
2529
|
+
if (hasChanged) {
|
|
2530
|
+
// 更新内存缓存
|
|
2531
|
+
this.countriesCache = newData;
|
|
2532
|
+
|
|
2533
|
+
// 更新 localStorage 缓存
|
|
2534
|
+
try {
|
|
2535
|
+
localStorage.setItem(cacheKey, JSON.stringify(newData));
|
|
2536
|
+
} catch (error) {
|
|
2537
|
+
console.warn('[RegisterAndLogin] localStorage 更新失败:', error);
|
|
2538
|
+
}
|
|
2539
|
+
console.log('[RegisterAndLogin] 国家数据已更新');
|
|
2540
|
+
}
|
|
2541
|
+
}
|
|
2542
|
+
_context39.next = 10;
|
|
2543
|
+
break;
|
|
2544
|
+
case 7:
|
|
2545
|
+
_context39.prev = 7;
|
|
2546
|
+
_context39.t0 = _context39["catch"](0);
|
|
2547
|
+
console.warn('[RegisterAndLogin] 后台更新国家数据失败:', _context39.t0);
|
|
2548
|
+
case 10:
|
|
2549
|
+
case "end":
|
|
2550
|
+
return _context39.stop();
|
|
2551
|
+
}
|
|
2552
|
+
}, _callee39, this, [[0, 7]]);
|
|
2553
|
+
}));
|
|
2554
|
+
function updateCountriesCache(_x34, _x35) {
|
|
2555
|
+
return _updateCountriesCache.apply(this, arguments);
|
|
2556
|
+
}
|
|
2557
|
+
return updateCountriesCache;
|
|
2390
2558
|
}())
|
|
2391
2559
|
}, {
|
|
2392
2560
|
key: "destroy",
|
|
2393
2561
|
value: function () {
|
|
2394
|
-
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2395
|
-
return _regeneratorRuntime().wrap(function
|
|
2396
|
-
while (1) switch (
|
|
2562
|
+
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40() {
|
|
2563
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
2564
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
2397
2565
|
case 0:
|
|
2398
|
-
|
|
2566
|
+
_context40.next = 2;
|
|
2399
2567
|
return this.core.effects.emit(RegisterAndLoginHooks.onDestroy, {});
|
|
2400
2568
|
case 2:
|
|
2401
2569
|
console.log('[RegisterAndLogin] 已销毁');
|
|
2402
2570
|
case 3:
|
|
2403
2571
|
case "end":
|
|
2404
|
-
return
|
|
2572
|
+
return _context40.stop();
|
|
2405
2573
|
}
|
|
2406
|
-
},
|
|
2574
|
+
}, _callee40, this);
|
|
2407
2575
|
}));
|
|
2408
2576
|
function destroy() {
|
|
2409
2577
|
return _destroy.apply(this, arguments);
|