@pisell/private-materials 6.3.30 → 6.3.32
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/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/index.js +1 -1
- package/build/lowcode/meta.js +9 -1
- package/build/lowcode/preview.js +146 -146
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +9 -9
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +9 -9
- package/es/components/appointmentBooking/components/Cart/Item/index.d.ts +1 -1
- package/es/components/appointmentBooking/components/Cart/Item/index.js +3 -2
- package/es/components/appointmentBooking/components/ConfirmInformation/index.js +267 -76
- package/es/components/appointmentBooking/components/ConfirmInformation/index.less +15 -0
- package/es/components/appointmentBooking/hooks.d.ts +1 -0
- package/es/components/appointmentBooking/hooks.js +30 -30
- package/es/components/appointmentBooking/locales.d.ts +3 -0
- package/es/components/appointmentBooking/locales.js +9 -6
- package/es/components/booking/addons/model.d.ts +10 -1
- package/es/components/booking/components/footer/index.js +4 -1
- package/es/components/booking/components/footer/utils.js +62 -46
- package/es/components/booking/forms/model.d.ts +10 -1
- package/es/components/booking/info/clientVariant/hooks/useClientFn.js +2 -2
- package/es/components/booking/info/clientVariant/vertical/index.js +1 -1
- package/es/components/booking/info/main.js +3 -2
- package/es/components/booking/info/model.d.ts +10 -1
- package/es/components/booking/info/model.js +5 -0
- package/es/components/booking/info/service/addService/utils.d.ts +1 -1
- package/es/components/booking/info2/index.js +3 -2
- package/es/components/booking/info2/service/addService/utils.d.ts +1 -1
- package/es/components/booking/info2/service/contactInfoMode/index.d.ts +2 -0
- package/es/components/booking/info2/service/contactInfoMode/index.js +94 -0
- package/es/components/booking/locales.d.ts +3 -0
- package/es/components/booking/locales.js +9 -3
- package/es/components/booking/model.d.ts +13 -1
- package/es/components/booking/model.js +3 -0
- package/es/components/booking/notes/model.d.ts +10 -1
- package/es/components/booking/payments/model.d.ts +10 -1
- package/es/components/eftposPay/amount.d.ts +1 -1
- package/es/components/eftposPay/device.d.ts +1 -1
- package/es/components/eftposPay/store/index.d.ts +2 -2
- package/es/components/pay/toC/model.d.ts +9 -1
- package/es/components/schedules/model.d.ts +9 -1
- package/es/components/ticketBooking/components/ticketBooking/index.less +2 -1
- package/es/components/wallet/Detail/model.d.ts +13 -1
- package/es/components/wallet/DiscountCard/model.d.ts +14 -1
- package/es/components/wallet/PointCard/model.d.ts +13 -1
- package/es/components/wallet/RechargeableCard/model.d.ts +29 -1
- package/es/components/wallet/Voucher/model.d.ts +13 -1
- package/es/components/wallet/model.d.ts +9 -1
- package/es/index.d.ts +3 -0
- package/es/index.js +4 -1
- package/es/plus/clientName/index.d.ts +4 -0
- package/es/plus/clientName/index.js +18 -0
- package/es/plus/clientName/index.less +10 -0
- package/es/plus/clientName/type.d.ts +13 -0
- package/es/plus/clientName/type.js +1 -0
- package/es/plus/clientName/utils.d.ts +2 -0
- package/es/plus/clientName/utils.js +18 -0
- package/es/plus/contactInfo/components/Avatar/index.d.ts +10 -0
- package/es/plus/contactInfo/components/Avatar/index.js +30 -0
- package/es/plus/contactInfo/components/SwipeAction/index.d.ts +46 -0
- package/es/plus/contactInfo/components/SwipeAction/index.js +360 -0
- package/es/plus/contactInfo/components/SwipeAction/index.less +74 -0
- package/es/plus/contactInfo/index.d.ts +6 -0
- package/es/plus/contactInfo/index.js +198 -0
- package/es/plus/contactInfo/index.less +621 -0
- package/es/plus/contactInfo/locales.d.ts +15 -0
- package/es/plus/contactInfo/locales.js +14 -0
- package/es/plus/contactInfo/types.d.ts +91 -0
- package/es/plus/contactInfo/types.js +1 -0
- package/es/plus/contactInfo/utils.d.ts +7 -0
- package/es/plus/contactInfo/utils.js +50 -0
- package/es/plus/contactInfoModal/ContactInfoContent.d.ts +3 -0
- package/es/plus/contactInfoModal/ContactInfoContent.js +74 -0
- package/es/plus/contactInfoModal/index.d.ts +40 -0
- package/es/plus/contactInfoModal/index.js +154 -0
- package/es/plus/contactInfoModal/index.less +19 -0
- package/es/plus/contactInfoModal/locales.d.ts +66 -0
- package/es/plus/contactInfoModal/locales.js +65 -0
- package/es/pro/Login2.0/AuthModal.d.ts +143 -0
- package/es/pro/Login2.0/AuthModal.js +624 -0
- package/es/pro/Login2.0/Login2.d.ts +61 -0
- package/es/pro/Login2.0/Login2.js +2157 -0
- package/es/pro/Login2.0/Register2.d.ts +65 -0
- package/es/pro/Login2.0/Register2.js +1501 -0
- package/es/pro/Login2.0/components/ForgotPasswordFlow.d.ts +31 -0
- package/es/pro/Login2.0/components/ForgotPasswordFlow.js +330 -0
- package/es/pro/Login2.0/components/LegalTerms.d.ts +8 -0
- package/es/pro/Login2.0/components/LegalTerms.js +51 -0
- package/es/pro/Login2.0/components/LegalTerms.less +74 -0
- package/es/pro/Login2.0/components/LoginCodeInput.d.ts +27 -0
- package/es/pro/Login2.0/components/LoginCodeInput.js +207 -0
- package/es/pro/Login2.0/components/OAuthButtonGroup.d.ts +22 -0
- package/es/pro/Login2.0/components/OAuthButtonGroup.js +55 -0
- package/es/pro/Login2.0/components/PhoneInput.d.ts +53 -0
- package/es/pro/Login2.0/components/PhoneInput.js +414 -0
- package/es/pro/Login2.0/components/PhoneInput.less +148 -0
- package/es/pro/Login2.0/components/phoneValidation.d.ts +17 -0
- package/es/pro/Login2.0/components/phoneValidation.js +228 -0
- package/es/pro/Login2.0/hooks/index.d.ts +2 -0
- package/es/pro/Login2.0/hooks/index.js +1 -0
- package/es/pro/Login2.0/hooks/usePasswordValidationRules.d.ts +24 -0
- package/es/pro/Login2.0/hooks/usePasswordValidationRules.js +87 -0
- package/es/pro/Login2.0/hooks/useRegisterFlow.d.ts +39 -0
- package/es/pro/Login2.0/hooks/useRegisterFlow.js +158 -0
- package/es/pro/Login2.0/hooks/useRegistrationMethods.d.ts +9 -0
- package/es/pro/Login2.0/hooks/useRegistrationMethods.js +31 -0
- package/es/pro/Login2.0/index.js +8 -0
- package/es/pro/Login2.0/index.less +993 -0
- package/es/pro/Login2.0/locales.d.ts +543 -0
- package/es/pro/Login2.0/locales.js +622 -0
- package/es/pro/Login2.0/shared/Header.d.ts +11 -0
- package/es/pro/Login2.0/shared/Header.js +42 -0
- package/es/pro/Login2.0/shared/OAuthButtons.d.ts +11 -0
- package/es/pro/Login2.0/shared/OAuthButtons.js +59 -0
- package/es/pro/Login2.0/shared/registerFlow.d.ts +116 -0
- package/es/pro/Login2.0/shared/registerFlow.js +171 -0
- package/es/pro/Login2.0/shared/types.d.ts +232 -0
- package/es/pro/Login2.0/shared/types.js +1 -0
- package/es/pro/Login2.0/steps/CodeInput.d.ts +24 -0
- package/es/pro/Login2.0/steps/CodeInput.js +209 -0
- package/es/pro/Login2.0/steps/EmailAlreadyRegistered.d.ts +12 -0
- package/es/pro/Login2.0/steps/EmailAlreadyRegistered.js +35 -0
- package/es/pro/Login2.0/steps/EmailLinkAlreadyUsed.d.ts +7 -0
- package/es/pro/Login2.0/steps/EmailLinkAlreadyUsed.js +25 -0
- package/es/pro/Login2.0/steps/EmailLinkExpired.d.ts +9 -0
- package/es/pro/Login2.0/steps/EmailLinkExpired.js +33 -0
- package/es/pro/Login2.0/steps/SetPassword.d.ts +19 -0
- package/es/pro/Login2.0/steps/SetPassword.js +148 -0
- package/es/pro/Login2.0/steps/VerificationSuccess.d.ts +8 -0
- package/es/pro/Login2.0/steps/VerificationSuccess.js +35 -0
- package/es/pro/Login2.0/steps/VerifyingEmailLink.d.ts +7 -0
- package/es/pro/Login2.0/steps/VerifyingEmailLink.js +17 -0
- package/es/pro/Login2.0/steps/WaitEmailLink.d.ts +18 -0
- package/es/pro/Login2.0/steps/WaitEmailLink.js +54 -0
- package/es/pro/Login2.0/steps/index.d.ts +19 -0
- package/es/pro/Login2.0/steps/index.js +11 -0
- package/es/pro/Login2.0/steps/steps.less +423 -0
- package/es/pro/Login2.0/types.d.ts +167 -0
- package/es/pro/Login2.0/types.js +1 -0
- package/lib/components/appointmentBooking/components/Cart/Item/index.d.ts +1 -1
- package/lib/components/appointmentBooking/components/Cart/Item/index.js +5 -3
- package/lib/components/appointmentBooking/components/ConfirmInformation/index.js +151 -13
- package/lib/components/appointmentBooking/components/ConfirmInformation/index.less +15 -0
- package/lib/components/appointmentBooking/hooks.d.ts +1 -0
- package/lib/components/appointmentBooking/hooks.js +73 -35
- package/lib/components/appointmentBooking/locales.d.ts +3 -0
- package/lib/components/appointmentBooking/locales.js +6 -3
- package/lib/components/booking/addons/model.d.ts +10 -1
- package/lib/components/booking/components/footer/index.js +4 -1
- package/lib/components/booking/components/footer/utils.js +70 -38
- package/lib/components/booking/forms/model.d.ts +10 -1
- package/lib/components/booking/info/clientVariant/hooks/useClientFn.js +1 -1
- package/lib/components/booking/info/clientVariant/vertical/index.js +34 -17
- package/lib/components/booking/info/main.js +5 -4
- package/lib/components/booking/info/model.d.ts +10 -1
- package/lib/components/booking/info/model.js +5 -0
- package/lib/components/booking/info/service/addService/utils.d.ts +1 -1
- package/lib/components/booking/info2/index.js +5 -4
- package/lib/components/booking/info2/service/addService/utils.d.ts +1 -1
- package/lib/components/booking/info2/service/contactInfoMode/index.d.ts +2 -0
- package/lib/components/booking/info2/service/contactInfoMode/index.js +111 -0
- package/lib/components/booking/locales.d.ts +3 -0
- package/lib/components/booking/locales.js +9 -3
- package/lib/components/booking/model.d.ts +13 -1
- package/lib/components/booking/model.js +3 -0
- package/lib/components/booking/notes/model.d.ts +10 -1
- package/lib/components/booking/payments/model.d.ts +10 -1
- package/lib/components/eftposPay/amount.d.ts +1 -1
- package/lib/components/eftposPay/device.d.ts +1 -1
- package/lib/components/eftposPay/store/index.d.ts +2 -2
- package/lib/components/pay/toC/model.d.ts +9 -1
- package/lib/components/schedules/model.d.ts +9 -1
- package/lib/components/ticketBooking/components/ticketBooking/index.less +2 -1
- package/lib/components/wallet/Detail/model.d.ts +13 -1
- package/lib/components/wallet/DiscountCard/model.d.ts +14 -1
- package/lib/components/wallet/PointCard/model.d.ts +13 -1
- package/lib/components/wallet/RechargeableCard/model.d.ts +29 -1
- package/lib/components/wallet/Voucher/model.d.ts +13 -1
- package/lib/components/wallet/model.d.ts +9 -1
- package/lib/index.d.ts +3 -0
- package/lib/index.js +13 -0
- package/lib/plus/clientName/index.d.ts +4 -0
- package/lib/plus/clientName/index.js +53 -0
- package/lib/plus/clientName/index.less +10 -0
- package/lib/plus/clientName/type.d.ts +13 -0
- package/lib/plus/clientName/type.js +17 -0
- package/lib/plus/clientName/utils.d.ts +2 -0
- package/lib/plus/clientName/utils.js +43 -0
- package/lib/plus/contactInfo/components/Avatar/index.d.ts +10 -0
- package/lib/plus/contactInfo/components/Avatar/index.js +56 -0
- package/lib/plus/contactInfo/components/SwipeAction/index.d.ts +46 -0
- package/lib/plus/contactInfo/components/SwipeAction/index.js +373 -0
- package/lib/plus/contactInfo/components/SwipeAction/index.less +74 -0
- package/lib/plus/contactInfo/index.d.ts +6 -0
- package/lib/plus/contactInfo/index.js +226 -0
- package/lib/plus/contactInfo/index.less +621 -0
- package/lib/plus/contactInfo/locales.d.ts +15 -0
- package/lib/plus/contactInfo/locales.js +38 -0
- package/lib/plus/contactInfo/types.d.ts +91 -0
- package/lib/plus/contactInfo/types.js +17 -0
- package/lib/plus/contactInfo/utils.d.ts +7 -0
- package/lib/plus/contactInfo/utils.js +64 -0
- package/lib/plus/contactInfoModal/ContactInfoContent.d.ts +3 -0
- package/lib/plus/contactInfoModal/ContactInfoContent.js +129 -0
- package/lib/plus/contactInfoModal/index.d.ts +40 -0
- package/lib/plus/contactInfoModal/index.js +138 -0
- package/lib/plus/contactInfoModal/index.less +19 -0
- package/lib/plus/contactInfoModal/locales.d.ts +66 -0
- package/lib/plus/contactInfoModal/locales.js +89 -0
- package/lib/pro/Login2.0/AuthModal.d.ts +143 -0
- package/lib/pro/Login2.0/AuthModal.js +498 -0
- package/lib/pro/Login2.0/Login2.d.ts +61 -0
- package/lib/pro/Login2.0/Login2.js +1468 -0
- package/lib/pro/Login2.0/Register2.d.ts +65 -0
- package/lib/pro/Login2.0/Register2.js +1062 -0
- package/lib/pro/Login2.0/components/ForgotPasswordFlow.d.ts +31 -0
- package/lib/pro/Login2.0/components/ForgotPasswordFlow.js +213 -0
- package/lib/pro/Login2.0/components/LegalTerms.d.ts +8 -0
- package/lib/pro/Login2.0/components/LegalTerms.js +76 -0
- package/lib/pro/Login2.0/components/LegalTerms.less +74 -0
- package/lib/pro/Login2.0/components/LoginCodeInput.d.ts +27 -0
- package/lib/pro/Login2.0/components/LoginCodeInput.js +161 -0
- package/lib/pro/Login2.0/components/OAuthButtonGroup.d.ts +22 -0
- package/lib/pro/Login2.0/components/OAuthButtonGroup.js +87 -0
- package/lib/pro/Login2.0/components/PhoneInput.d.ts +53 -0
- package/lib/pro/Login2.0/components/PhoneInput.js +263 -0
- package/lib/pro/Login2.0/components/PhoneInput.less +148 -0
- package/lib/pro/Login2.0/components/phoneValidation.d.ts +17 -0
- package/lib/pro/Login2.0/components/phoneValidation.js +153 -0
- package/lib/pro/Login2.0/hooks/index.d.ts +2 -0
- package/lib/pro/Login2.0/hooks/index.js +29 -0
- package/lib/pro/Login2.0/hooks/usePasswordValidationRules.d.ts +24 -0
- package/lib/pro/Login2.0/hooks/usePasswordValidationRules.js +140 -0
- package/lib/pro/Login2.0/hooks/useRegisterFlow.d.ts +39 -0
- package/lib/pro/Login2.0/hooks/useRegisterFlow.js +149 -0
- package/lib/pro/Login2.0/hooks/useRegistrationMethods.d.ts +9 -0
- package/lib/pro/Login2.0/hooks/useRegistrationMethods.js +51 -0
- package/lib/pro/Login2.0/index.js +45 -0
- package/lib/pro/Login2.0/index.less +993 -0
- package/lib/pro/Login2.0/locales.d.ts +543 -0
- package/lib/pro/Login2.0/locales.js +646 -0
- package/lib/pro/Login2.0/shared/Header.d.ts +11 -0
- package/lib/pro/Login2.0/shared/Header.js +81 -0
- package/lib/pro/Login2.0/shared/OAuthButtons.d.ts +11 -0
- package/lib/pro/Login2.0/shared/OAuthButtons.js +78 -0
- package/lib/pro/Login2.0/shared/registerFlow.d.ts +116 -0
- package/lib/pro/Login2.0/shared/registerFlow.js +235 -0
- package/lib/pro/Login2.0/shared/types.d.ts +232 -0
- package/lib/pro/Login2.0/shared/types.js +17 -0
- package/lib/pro/Login2.0/steps/CodeInput.d.ts +24 -0
- package/lib/pro/Login2.0/steps/CodeInput.js +160 -0
- package/lib/pro/Login2.0/steps/EmailAlreadyRegistered.d.ts +12 -0
- package/lib/pro/Login2.0/steps/EmailAlreadyRegistered.js +46 -0
- package/lib/pro/Login2.0/steps/EmailLinkAlreadyUsed.d.ts +7 -0
- package/lib/pro/Login2.0/steps/EmailLinkAlreadyUsed.js +51 -0
- package/lib/pro/Login2.0/steps/EmailLinkExpired.d.ts +9 -0
- package/lib/pro/Login2.0/steps/EmailLinkExpired.js +51 -0
- package/lib/pro/Login2.0/steps/SetPassword.d.ts +19 -0
- package/lib/pro/Login2.0/steps/SetPassword.js +131 -0
- package/lib/pro/Login2.0/steps/VerificationSuccess.d.ts +8 -0
- package/lib/pro/Login2.0/steps/VerificationSuccess.js +49 -0
- package/lib/pro/Login2.0/steps/VerifyingEmailLink.d.ts +7 -0
- package/lib/pro/Login2.0/steps/VerifyingEmailLink.js +41 -0
- package/lib/pro/Login2.0/steps/WaitEmailLink.d.ts +18 -0
- package/lib/pro/Login2.0/steps/WaitEmailLink.js +67 -0
- package/lib/pro/Login2.0/steps/index.d.ts +19 -0
- package/lib/pro/Login2.0/steps/index.js +60 -0
- package/lib/pro/Login2.0/steps/steps.less +423 -0
- package/lib/pro/Login2.0/types.d.ts +167 -0
- package/lib/pro/Login2.0/types.js +17 -0
- package/lowcode/authmodal/meta.ts +395 -0
- package/lowcode/contact-info/fragments/cardStyle.ts +68 -0
- package/lowcode/contact-info/fragments/nameStyle.ts +33 -0
- package/lowcode/contact-info/fragments/pisellAvatar.ts +103 -0
- package/lowcode/contact-info/fragments/textStyle.ts +33 -0
- package/lowcode/contact-info/meta.ts +199 -0
- package/lowcode/contact-info-modal/meta.ts +98 -0
- package/lowcode/login2/CONFIG.md +447 -0
- package/lowcode/login2/TEST_CONFIG.md +324 -0
- package/lowcode/login2/VERIFICATION_METHODS.md +364 -0
- package/lowcode/login2/meta.ts +560 -0
- package/lowcode/login2/snippets.ts +124 -0
- package/lowcode/register2/meta.ts +562 -0
- package/lowcode/register2/snippets.ts +257 -0
- package/package.json +7 -5
|
@@ -0,0 +1,2157 @@
|
|
|
1
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
8
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
9
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
10
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
11
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
12
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
13
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
14
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
15
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
16
|
+
import React, { useState, useEffect, useCallback, useMemo } from 'react';
|
|
17
|
+
import { Form, message } from 'antd';
|
|
18
|
+
import { Input, Button, Checkbox } from '@pisell/materials';
|
|
19
|
+
import classNames from 'classnames';
|
|
20
|
+
import { locales } from '@pisell/utils';
|
|
21
|
+
import { useDebounceFn } from 'ahooks';
|
|
22
|
+
import localeTexts from "./locales";
|
|
23
|
+
import Header from "./shared/Header";
|
|
24
|
+
import LoginCodeInput from "./components/LoginCodeInput";
|
|
25
|
+
import ForgotPasswordFlow from "./components/ForgotPasswordFlow";
|
|
26
|
+
import SetPassword from "./steps/SetPassword";
|
|
27
|
+
import PhoneInput from "./components/PhoneInput";
|
|
28
|
+
import { createPhoneValidationRules } from "./components/phoneValidation";
|
|
29
|
+
import LegalTerms from "./components/LegalTerms";
|
|
30
|
+
import "./index.less";
|
|
31
|
+
import { usePisellOS } from "../../hooks/useEngineContext";
|
|
32
|
+
import useEngineContext from "../../hooks/useEngineContext";
|
|
33
|
+
import { Iconfont } from '@pisell/materials';
|
|
34
|
+
import usePasswordValidationRules from "./hooks/usePasswordValidationRules";
|
|
35
|
+
import OAuthButtonGroup from "./components/OAuthButtonGroup";
|
|
36
|
+
|
|
37
|
+
/** 登录组件配置 */
|
|
38
|
+
|
|
39
|
+
/** 登录组件事件 */
|
|
40
|
+
|
|
41
|
+
/** 登录组件属性 */
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* 登录 2.0 组件
|
|
45
|
+
* 支持邮箱、手机、三方登录
|
|
46
|
+
* 组件宽度固定 360px
|
|
47
|
+
*/
|
|
48
|
+
var Login2 = function Login2(_ref) {
|
|
49
|
+
var _context$appHelper, _config$ui, _config$emailLinkVeri, _config$emailLinkVeri2, _config$emailLinkVeri4;
|
|
50
|
+
var config = _ref.config,
|
|
51
|
+
_ref$visible = _ref.visible,
|
|
52
|
+
visible = _ref$visible === void 0 ? true : _ref$visible,
|
|
53
|
+
onClose = _ref.onClose,
|
|
54
|
+
className = _ref.className,
|
|
55
|
+
style = _ref.style,
|
|
56
|
+
onLogin = _ref.onLogin,
|
|
57
|
+
onOAuthLogin = _ref.onOAuthLogin,
|
|
58
|
+
onSendVerificationCode = _ref.onSendVerificationCode,
|
|
59
|
+
onForgotPassword = _ref.onForgotPassword,
|
|
60
|
+
onSwitchToRegister = _ref.onSwitchToRegister,
|
|
61
|
+
onError = _ref.onError;
|
|
62
|
+
var _Form$useForm = Form.useForm(),
|
|
63
|
+
_Form$useForm2 = _slicedToArray(_Form$useForm, 1),
|
|
64
|
+
form = _Form$useForm2[0];
|
|
65
|
+
var _useState = useState(false),
|
|
66
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
67
|
+
loading = _useState2[0],
|
|
68
|
+
setLoading = _useState2[1];
|
|
69
|
+
var _useState3 = useState(0),
|
|
70
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
71
|
+
countdown = _useState4[0],
|
|
72
|
+
setCountdown = _useState4[1];
|
|
73
|
+
var _useState5 = useState([]),
|
|
74
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
75
|
+
countries = _useState6[0],
|
|
76
|
+
setCountries = _useState6[1];
|
|
77
|
+
var pisellOS = usePisellOS();
|
|
78
|
+
var registerAndLogin = pisellOS === null || pisellOS === void 0 ? void 0 : pisellOS.getModule('registerAndLogin');
|
|
79
|
+
var context = useEngineContext();
|
|
80
|
+
var storage = context === null || context === void 0 || (_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 || (_context$appHelper = _context$appHelper.utils) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.storage;
|
|
81
|
+
|
|
82
|
+
// 初始化国际化
|
|
83
|
+
useEffect(function () {
|
|
84
|
+
var _context$appHelper$ut, _context$appHelper$ut2, _context$appHelper$ut3, _context$appHelper$ut4;
|
|
85
|
+
locales.init(localeTexts, ((_context$appHelper$ut = context.appHelper.utils) === null || _context$appHelper$ut === void 0 || (_context$appHelper$ut2 = _context$appHelper$ut.getApp) === null || _context$appHelper$ut2 === void 0 || (_context$appHelper$ut2 = _context$appHelper$ut2.call(_context$appHelper$ut)) === null || _context$appHelper$ut2 === void 0 || (_context$appHelper$ut2 = _context$appHelper$ut2.locales) === null || _context$appHelper$ut2 === void 0 || (_context$appHelper$ut3 = _context$appHelper$ut2.getLocale) === null || _context$appHelper$ut3 === void 0 ? void 0 : _context$appHelper$ut3.call(_context$appHelper$ut2)) || ((_context$appHelper$ut4 = context.appHelper.utils) === null || _context$appHelper$ut4 === void 0 || (_context$appHelper$ut4 = _context$appHelper$ut4.storage) === null || _context$appHelper$ut4 === void 0 ? void 0 : _context$appHelper$ut4.get('umi_locale')) || 'en');
|
|
86
|
+
}, []);
|
|
87
|
+
|
|
88
|
+
// 登录方式配置
|
|
89
|
+
var loginMethods = config.loginMethods || [];
|
|
90
|
+
var passwordValidationRules = usePasswordValidationRules((_config$ui = config.ui) === null || _config$ui === void 0 ? void 0 : _config$ui.passwordRules, {
|
|
91
|
+
translate: locales.getText,
|
|
92
|
+
fallbackMinLength: 6,
|
|
93
|
+
messageKeys: {
|
|
94
|
+
required: locales.getText('pisell-login2-password-required'),
|
|
95
|
+
minLength: locales.getText('pisell-set-password-min-length'),
|
|
96
|
+
requireUppercase: locales.getText('pisell-set-password-require-uppercase'),
|
|
97
|
+
requireLowercase: locales.getText('pisell-set-password-require-lowercase'),
|
|
98
|
+
requireNumber: locales.getText('pisell-set-password-require-number'),
|
|
99
|
+
requireSpecialCharacters: locales.getText('pisell-set-password-require-special'),
|
|
100
|
+
summary: locales.getText('pisell-set-password-must-contain')
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
// 当前激活的登录方式(第一个为默认)
|
|
105
|
+
var _useState7 = useState(null),
|
|
106
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
107
|
+
currentLoginMethod = _useState8[0],
|
|
108
|
+
setCurrentLoginMethod = _useState8[1];
|
|
109
|
+
|
|
110
|
+
// 当前验证方式(针对 email/phone)
|
|
111
|
+
var _useState9 = useState('password'),
|
|
112
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
113
|
+
currentVerificationMethod = _useState10[0],
|
|
114
|
+
setCurrentVerificationMethod = _useState10[1];
|
|
115
|
+
|
|
116
|
+
// 初始化 currentLoginMethod(当 loginMethods 变化时)
|
|
117
|
+
useEffect(function () {
|
|
118
|
+
if (loginMethods.length > 0 && !currentLoginMethod) {
|
|
119
|
+
// 优先选择非OAuth类型的登录方式作为当前激活方式
|
|
120
|
+
var nonOAuthMethod = loginMethods.find(function (method) {
|
|
121
|
+
return method.type === 'email' || method.type === 'phone';
|
|
122
|
+
});
|
|
123
|
+
var first = nonOAuthMethod || loginMethods[0];
|
|
124
|
+
setCurrentLoginMethod(first);
|
|
125
|
+
|
|
126
|
+
// 设置默认验证方式
|
|
127
|
+
if (first.type === 'email' || first.type === 'phone') {
|
|
128
|
+
var _first$verificationMe;
|
|
129
|
+
setCurrentVerificationMethod(((_first$verificationMe = first.verificationMethods) === null || _first$verificationMe === void 0 ? void 0 : _first$verificationMe[0]) || 'password');
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}, [loginMethods, currentLoginMethod]);
|
|
133
|
+
|
|
134
|
+
// 检测浏览器记忆的凭据和 Remember me 状态
|
|
135
|
+
useEffect(function () {
|
|
136
|
+
if (((currentLoginMethod === null || currentLoginMethod === void 0 ? void 0 : currentLoginMethod.type) === 'email' || (currentLoginMethod === null || currentLoginMethod === void 0 ? void 0 : currentLoginMethod.type) === 'phone') && currentVerificationMethod === 'password') {
|
|
137
|
+
// 检查是否有存储的 Remember me 状态
|
|
138
|
+
var storedRememberMe = storage.get('login_remember_me') === 'true';
|
|
139
|
+
setRememberMe(storedRememberMe);
|
|
140
|
+
// 检查是否有存储的邮箱/手机号
|
|
141
|
+
var _account = storage.get('login_account');
|
|
142
|
+
try {
|
|
143
|
+
_account = JSON.parse(_account || '{}');
|
|
144
|
+
} catch (e) {
|
|
145
|
+
console.error(e);
|
|
146
|
+
}
|
|
147
|
+
if (_account && storedRememberMe) {
|
|
148
|
+
// 检查存储的账号类型是否匹配当前的登录方式
|
|
149
|
+
var accountString = typeof _account === 'string' ? _account : _account.phone || _account.email || '';
|
|
150
|
+
var isEmail = accountString.includes('@');
|
|
151
|
+
var isPhone = /^\d+$/.test(accountString.replace(/\+/g, '').replace(/\s/g, ''));
|
|
152
|
+
|
|
153
|
+
// 只有当存储的账号类型与当前登录方式匹配时,才使用存储的凭据
|
|
154
|
+
var shouldUseStoredAccount = currentLoginMethod.type === 'email' && isEmail || currentLoginMethod.type === 'phone' && isPhone;
|
|
155
|
+
if (shouldUseStoredAccount) {
|
|
156
|
+
setEnteredAccount(_account);
|
|
157
|
+
setHasStoredCredentials(true);
|
|
158
|
+
|
|
159
|
+
// 如果表单此时没有值,则填充一个
|
|
160
|
+
if (isEmail && !form.getFieldValue('email')) {
|
|
161
|
+
form.setFieldsValue({
|
|
162
|
+
email: _account
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
if (isPhone && !form.getFieldValue('phone')) {
|
|
166
|
+
form.setFieldsValue({
|
|
167
|
+
phone: _account
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// 如果是分步登录且有存储的凭据,直接跳到密码步骤
|
|
172
|
+
if (currentLoginMethod !== null && currentLoginMethod !== void 0 && currentLoginMethod.stepByStep) {
|
|
173
|
+
setLoginStep('password');
|
|
174
|
+
}
|
|
175
|
+
} else {
|
|
176
|
+
// 如果不匹配,清空相关状态
|
|
177
|
+
setHasStoredCredentials(false);
|
|
178
|
+
setEnteredAccount('');
|
|
179
|
+
}
|
|
180
|
+
} else {
|
|
181
|
+
// 如果没有存储的凭据或 remember me,清空状态
|
|
182
|
+
setHasStoredCredentials(false);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}, [currentLoginMethod, currentVerificationMethod]);
|
|
186
|
+
|
|
187
|
+
// 当组件关闭时,清空密码字段,防止浏览器弹出保存密码提示
|
|
188
|
+
useEffect(function () {
|
|
189
|
+
if (!visible) {
|
|
190
|
+
// 清空密码字段,防止浏览器检测到凭据变化而弹出保存提示
|
|
191
|
+
form.setFieldsValue({
|
|
192
|
+
password: ''
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
// 可选:重置整个表单(如果希望更彻底的清理)
|
|
196
|
+
// form.resetFields();
|
|
197
|
+
}
|
|
198
|
+
}, [visible, form]);
|
|
199
|
+
|
|
200
|
+
// 登录步骤状态:
|
|
201
|
+
// - 'account': 输入账号(密码分步登录的第一步 或 验证码登录的第一步)
|
|
202
|
+
// - 'password': 输入密码(仅密码分步登录的第二步)
|
|
203
|
+
// - 'code': 输入验证码(验证码登录的第二步)
|
|
204
|
+
var _useState11 = useState('account'),
|
|
205
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
206
|
+
loginStep = _useState12[0],
|
|
207
|
+
setLoginStep = _useState12[1];
|
|
208
|
+
|
|
209
|
+
// 已输入的账号
|
|
210
|
+
var _useState13 = useState(''),
|
|
211
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
212
|
+
enteredAccount = _useState14[0],
|
|
213
|
+
setEnteredAccount = _useState14[1];
|
|
214
|
+
|
|
215
|
+
// 验证码输入错误信息
|
|
216
|
+
var _useState15 = useState(''),
|
|
217
|
+
_useState16 = _slicedToArray(_useState15, 2),
|
|
218
|
+
codeError = _useState16[0],
|
|
219
|
+
setCodeError = _useState16[1];
|
|
220
|
+
|
|
221
|
+
// 记住我状态
|
|
222
|
+
var _useState17 = useState(false),
|
|
223
|
+
_useState18 = _slicedToArray(_useState17, 2),
|
|
224
|
+
rememberMe = _useState18[0],
|
|
225
|
+
setRememberMe = _useState18[1];
|
|
226
|
+
|
|
227
|
+
// 检测浏览器记忆的凭据
|
|
228
|
+
var _useState19 = useState(false),
|
|
229
|
+
_useState20 = _slicedToArray(_useState19, 2),
|
|
230
|
+
hasStoredCredentials = _useState20[0],
|
|
231
|
+
setHasStoredCredentials = _useState20[1];
|
|
232
|
+
|
|
233
|
+
// 上次登录方式
|
|
234
|
+
var _useState21 = useState(null),
|
|
235
|
+
_useState22 = _slicedToArray(_useState21, 2),
|
|
236
|
+
lastLoginMethod = _useState22[0],
|
|
237
|
+
setLastLoginMethod = _useState22[1];
|
|
238
|
+
|
|
239
|
+
// 是否显示忘记密码流程
|
|
240
|
+
var _useState23 = useState(false),
|
|
241
|
+
_useState24 = _slicedToArray(_useState23, 2),
|
|
242
|
+
showForgotPassword = _useState24[0],
|
|
243
|
+
setShowForgotPassword = _useState24[1];
|
|
244
|
+
|
|
245
|
+
// 邮件链接验证相关状态
|
|
246
|
+
var _useState25 = useState(null),
|
|
247
|
+
_useState26 = _slicedToArray(_useState25, 2),
|
|
248
|
+
emailLinkVerifyStatus = _useState26[0],
|
|
249
|
+
setEmailLinkVerifyStatus = _useState26[1];
|
|
250
|
+
var _useState27 = useState(''),
|
|
251
|
+
_useState28 = _slicedToArray(_useState27, 2),
|
|
252
|
+
emailLinkError = _useState28[0],
|
|
253
|
+
setEmailLinkError = _useState28[1];
|
|
254
|
+
var _useState29 = useState(''),
|
|
255
|
+
_useState30 = _slicedToArray(_useState29, 2),
|
|
256
|
+
resetPasswordUserEmail = _useState30[0],
|
|
257
|
+
setResetPasswordUserEmail = _useState30[1];
|
|
258
|
+
|
|
259
|
+
// 检查是否是邮件链接验证模式
|
|
260
|
+
var isEmailLinkVerification = ((_config$emailLinkVeri = config.emailLinkVerification) === null || _config$emailLinkVeri === void 0 ? void 0 : _config$emailLinkVeri.enabled) && ((_config$emailLinkVeri2 = config.emailLinkVerification) === null || _config$emailLinkVeri2 === void 0 ? void 0 : _config$emailLinkVeri2.code);
|
|
261
|
+
|
|
262
|
+
// 邮件链接验证初始化
|
|
263
|
+
useEffect(function () {
|
|
264
|
+
var _config$emailLinkVeri3;
|
|
265
|
+
if (isEmailLinkVerification && (_config$emailLinkVeri3 = config.emailLinkVerification) !== null && _config$emailLinkVeri3 !== void 0 && _config$emailLinkVeri3.code) {
|
|
266
|
+
setEmailLinkVerifyStatus('verifying');
|
|
267
|
+
|
|
268
|
+
// 调用检测重置密码代码的API
|
|
269
|
+
var checkCode = /*#__PURE__*/function () {
|
|
270
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
271
|
+
var result, _result$data;
|
|
272
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
273
|
+
while (1) switch (_context.prev = _context.next) {
|
|
274
|
+
case 0:
|
|
275
|
+
_context.prev = 0;
|
|
276
|
+
if (!(registerAndLogin !== null && registerAndLogin !== void 0 && registerAndLogin.checkResetPasswordCode)) {
|
|
277
|
+
_context.next = 8;
|
|
278
|
+
break;
|
|
279
|
+
}
|
|
280
|
+
_context.next = 4;
|
|
281
|
+
return registerAndLogin.checkResetPasswordCode({
|
|
282
|
+
code: config.emailLinkVerification.code
|
|
283
|
+
});
|
|
284
|
+
case 4:
|
|
285
|
+
result = _context.sent;
|
|
286
|
+
if (result.status) {
|
|
287
|
+
setEmailLinkVerifyStatus('success');
|
|
288
|
+
// 保存用户邮箱信息,如果API返回了邮箱
|
|
289
|
+
if ((_result$data = result.data) !== null && _result$data !== void 0 && _result$data.email) {
|
|
290
|
+
setResetPasswordUserEmail(result.data.email);
|
|
291
|
+
}
|
|
292
|
+
// 验证成功后不需要显示忘记密码流程,直接显示重置密码页面
|
|
293
|
+
} else {
|
|
294
|
+
setEmailLinkVerifyStatus('error');
|
|
295
|
+
setEmailLinkError(result.message || '验证码无效或已过期');
|
|
296
|
+
}
|
|
297
|
+
_context.next = 10;
|
|
298
|
+
break;
|
|
299
|
+
case 8:
|
|
300
|
+
setEmailLinkVerifyStatus('error');
|
|
301
|
+
setEmailLinkError('系统错误,请稍后重试');
|
|
302
|
+
case 10:
|
|
303
|
+
_context.next = 16;
|
|
304
|
+
break;
|
|
305
|
+
case 12:
|
|
306
|
+
_context.prev = 12;
|
|
307
|
+
_context.t0 = _context["catch"](0);
|
|
308
|
+
setEmailLinkVerifyStatus('error');
|
|
309
|
+
setEmailLinkError('网络错误,请稍后重试');
|
|
310
|
+
case 16:
|
|
311
|
+
case "end":
|
|
312
|
+
return _context.stop();
|
|
313
|
+
}
|
|
314
|
+
}, _callee, null, [[0, 12]]);
|
|
315
|
+
}));
|
|
316
|
+
return function checkCode() {
|
|
317
|
+
return _ref2.apply(this, arguments);
|
|
318
|
+
};
|
|
319
|
+
}();
|
|
320
|
+
checkCode();
|
|
321
|
+
}
|
|
322
|
+
}, [isEmailLinkVerification, (_config$emailLinkVeri4 = config.emailLinkVerification) === null || _config$emailLinkVeri4 === void 0 ? void 0 : _config$emailLinkVeri4.code, registerAndLogin]);
|
|
323
|
+
|
|
324
|
+
// 验证码倒计时
|
|
325
|
+
useEffect(function () {
|
|
326
|
+
if (countdown > 0) {
|
|
327
|
+
var timer = setTimeout(function () {
|
|
328
|
+
setCountdown(countdown - 1);
|
|
329
|
+
}, 1000);
|
|
330
|
+
return function () {
|
|
331
|
+
return clearTimeout(timer);
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
}, [countdown]);
|
|
335
|
+
|
|
336
|
+
// 获取国家列表
|
|
337
|
+
useEffect(function () {
|
|
338
|
+
var fetchCountries = /*#__PURE__*/function () {
|
|
339
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
340
|
+
var countriesList;
|
|
341
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
342
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
343
|
+
case 0:
|
|
344
|
+
_context2.prev = 0;
|
|
345
|
+
if (!(registerAndLogin !== null && registerAndLogin !== void 0 && registerAndLogin.getCountries)) {
|
|
346
|
+
_context2.next = 6;
|
|
347
|
+
break;
|
|
348
|
+
}
|
|
349
|
+
_context2.next = 4;
|
|
350
|
+
return registerAndLogin.getCountries();
|
|
351
|
+
case 4:
|
|
352
|
+
countriesList = _context2.sent;
|
|
353
|
+
setCountries(countriesList || []);
|
|
354
|
+
case 6:
|
|
355
|
+
_context2.next = 11;
|
|
356
|
+
break;
|
|
357
|
+
case 8:
|
|
358
|
+
_context2.prev = 8;
|
|
359
|
+
_context2.t0 = _context2["catch"](0);
|
|
360
|
+
console.error('Failed to fetch countries:', _context2.t0);
|
|
361
|
+
case 11:
|
|
362
|
+
case "end":
|
|
363
|
+
return _context2.stop();
|
|
364
|
+
}
|
|
365
|
+
}, _callee2, null, [[0, 8]]);
|
|
366
|
+
}));
|
|
367
|
+
return function fetchCountries() {
|
|
368
|
+
return _ref3.apply(this, arguments);
|
|
369
|
+
};
|
|
370
|
+
}();
|
|
371
|
+
fetchCountries();
|
|
372
|
+
}, [registerAndLogin]);
|
|
373
|
+
|
|
374
|
+
// 读取上次登录方式和记住的密码
|
|
375
|
+
useEffect(function () {
|
|
376
|
+
try {
|
|
377
|
+
var storedLoginMethod = storage.get('pisell_last_login_method');
|
|
378
|
+
if (storedLoginMethod) {
|
|
379
|
+
var parsedMethod = JSON.parse(storedLoginMethod);
|
|
380
|
+
setLastLoginMethod(parsedMethod);
|
|
381
|
+
}
|
|
382
|
+
var _rememberMe = storage.get('login_remember_me') === 'true';
|
|
383
|
+
var _account2 = storage.get('login_account');
|
|
384
|
+
var password = storage.get('login_password');
|
|
385
|
+
if (_rememberMe && _account2 && password) {
|
|
386
|
+
var accountData;
|
|
387
|
+
try {
|
|
388
|
+
accountData = JSON.parse(_account2 || '{}');
|
|
389
|
+
} catch (e) {
|
|
390
|
+
accountData = _account2;
|
|
391
|
+
}
|
|
392
|
+
var isEmail = typeof accountData === 'string' && accountData.includes('@');
|
|
393
|
+
var loginMethod = loginMethods.find(function (m) {
|
|
394
|
+
return m.type === (isEmail ? 'email' : 'phone');
|
|
395
|
+
});
|
|
396
|
+
if (loginMethod) {
|
|
397
|
+
setCurrentLoginMethod(loginMethod);
|
|
398
|
+
setCurrentVerificationMethod('password');
|
|
399
|
+
setEnteredAccount(accountData);
|
|
400
|
+
var accountFieldName = isEmail ? 'email' : 'phone';
|
|
401
|
+
form.setFieldsValue(_defineProperty(_defineProperty(_defineProperty({}, accountFieldName, accountData), "password", password), "remember_me", true));
|
|
402
|
+
setLoginStep('password');
|
|
403
|
+
setRememberMe(true);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
} catch (error) {
|
|
407
|
+
console.error('Failed to parse last login method:', error);
|
|
408
|
+
}
|
|
409
|
+
}, [loginMethods]);
|
|
410
|
+
|
|
411
|
+
// 检查是否是上次登录方式
|
|
412
|
+
var isLastLoginMethod = useCallback(function (methodType) {
|
|
413
|
+
if (!lastLoginMethod) return false;
|
|
414
|
+
return lastLoginMethod.type === methodType;
|
|
415
|
+
}, [lastLoginMethod]);
|
|
416
|
+
|
|
417
|
+
// 切换验证方式
|
|
418
|
+
var switchVerificationMethod = useCallback(function (method) {
|
|
419
|
+
form.resetFields();
|
|
420
|
+
// 重置登录步骤到第一步
|
|
421
|
+
setLoginStep('account');
|
|
422
|
+
setEnteredAccount('');
|
|
423
|
+
// 更新当前验证方式
|
|
424
|
+
setCurrentVerificationMethod(method);
|
|
425
|
+
}, [form]);
|
|
426
|
+
|
|
427
|
+
// 切换登录方式
|
|
428
|
+
var switchLoginMethod = useCallback(function (method) {
|
|
429
|
+
// 清空所有表单值
|
|
430
|
+
form.resetFields();
|
|
431
|
+
|
|
432
|
+
// 如果在第二步(密码输入步骤)或其他步骤,都回到第一步
|
|
433
|
+
setLoginStep('account');
|
|
434
|
+
setEnteredAccount('');
|
|
435
|
+
|
|
436
|
+
// 清空存储的凭据状态,防止 useEffect 重新应用不匹配的凭据
|
|
437
|
+
setHasStoredCredentials(false);
|
|
438
|
+
setCurrentLoginMethod(method);
|
|
439
|
+
|
|
440
|
+
// 设置新登录方式的默认验证方式
|
|
441
|
+
if (method.type === 'email' || method.type === 'phone') {
|
|
442
|
+
setCurrentVerificationMethod(method.verificationMethods[0]);
|
|
443
|
+
}
|
|
444
|
+
}, [form]);
|
|
445
|
+
|
|
446
|
+
// 处理继续(分步骤登录:验证账号后进入密码页)
|
|
447
|
+
var handleContinueWithAccountInternal = /*#__PURE__*/function () {
|
|
448
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
449
|
+
var accountFieldName, accountValues, _account3, _context$appHelper2, _utils$getStore, _utils$getStore$getSt, utils, shopId, result;
|
|
450
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
451
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
452
|
+
case 0:
|
|
453
|
+
_context3.prev = 0;
|
|
454
|
+
setLoading(true);
|
|
455
|
+
// 根据当前登录方式确定字段名
|
|
456
|
+
accountFieldName = (currentLoginMethod === null || currentLoginMethod === void 0 ? void 0 : currentLoginMethod.type) === 'email' ? 'email' : 'phone';
|
|
457
|
+
_context3.next = 5;
|
|
458
|
+
return form.validateFields([accountFieldName]);
|
|
459
|
+
case 5:
|
|
460
|
+
accountValues = _context3.sent;
|
|
461
|
+
_account3 = accountValues[accountFieldName]; // 如果是邮箱登录,先检查邮箱是否存在
|
|
462
|
+
if (!((currentLoginMethod === null || currentLoginMethod === void 0 ? void 0 : currentLoginMethod.type) === 'email' && registerAndLogin)) {
|
|
463
|
+
_context3.next = 28;
|
|
464
|
+
break;
|
|
465
|
+
}
|
|
466
|
+
// 获取 shop_id
|
|
467
|
+
utils = (context === null || context === void 0 || (_context$appHelper2 = context.appHelper) === null || _context$appHelper2 === void 0 ? void 0 : _context$appHelper2.utils) || {};
|
|
468
|
+
shopId = ((_utils$getStore = utils.getStore) === null || _utils$getStore === void 0 || (_utils$getStore = _utils$getStore.call(utils)) === null || _utils$getStore === void 0 || (_utils$getStore$getSt = _utils$getStore.getState) === null || _utils$getStore$getSt === void 0 || (_utils$getStore$getSt = _utils$getStore$getSt.call(_utils$getStore)) === null || _utils$getStore$getSt === void 0 || (_utils$getStore$getSt = _utils$getStore$getSt.global) === null || _utils$getStore$getSt === void 0 || (_utils$getStore$getSt = _utils$getStore$getSt.shop) === null || _utils$getStore$getSt === void 0 ? void 0 : _utils$getStore$getSt.id) || 9;
|
|
469
|
+
_context3.next = 12;
|
|
470
|
+
return registerAndLogin.checkEmailExists({
|
|
471
|
+
email: _account3,
|
|
472
|
+
shop_id: shopId
|
|
473
|
+
});
|
|
474
|
+
case 12:
|
|
475
|
+
result = _context3.sent;
|
|
476
|
+
if (!(result.status && result.data)) {
|
|
477
|
+
_context3.next = 24;
|
|
478
|
+
break;
|
|
479
|
+
}
|
|
480
|
+
if (!result.data.exists) {
|
|
481
|
+
_context3.next = 20;
|
|
482
|
+
break;
|
|
483
|
+
}
|
|
484
|
+
// 邮箱已注册,可以继续登录流程
|
|
485
|
+
setEnteredAccount(_account3);
|
|
486
|
+
setLoginStep('password');
|
|
487
|
+
// 预填充账号到表单
|
|
488
|
+
form.setFieldsValue(_defineProperty({}, accountFieldName, _account3));
|
|
489
|
+
_context3.next = 22;
|
|
490
|
+
break;
|
|
491
|
+
case 20:
|
|
492
|
+
// 邮箱未注册,提示用户
|
|
493
|
+
message.error(locales.getText('pisell-login2-email-not-registered'));
|
|
494
|
+
return _context3.abrupt("return");
|
|
495
|
+
case 22:
|
|
496
|
+
_context3.next = 26;
|
|
497
|
+
break;
|
|
498
|
+
case 24:
|
|
499
|
+
// API 调用失败
|
|
500
|
+
message.error(result.message || locales.getText('pisell-login2-check-email-failed'));
|
|
501
|
+
return _context3.abrupt("return");
|
|
502
|
+
case 26:
|
|
503
|
+
_context3.next = 31;
|
|
504
|
+
break;
|
|
505
|
+
case 28:
|
|
506
|
+
// 非邮箱登录或其他情况,直接继续
|
|
507
|
+
setEnteredAccount(_account3);
|
|
508
|
+
setLoginStep('password');
|
|
509
|
+
// 预填充账号到表单
|
|
510
|
+
form.setFieldsValue(_defineProperty({}, accountFieldName, _account3));
|
|
511
|
+
case 31:
|
|
512
|
+
_context3.next = 39;
|
|
513
|
+
break;
|
|
514
|
+
case 33:
|
|
515
|
+
_context3.prev = 33;
|
|
516
|
+
_context3.t0 = _context3["catch"](0);
|
|
517
|
+
if (!_context3.t0.errorFields) {
|
|
518
|
+
_context3.next = 37;
|
|
519
|
+
break;
|
|
520
|
+
}
|
|
521
|
+
return _context3.abrupt("return");
|
|
522
|
+
case 37:
|
|
523
|
+
console.error('Continue with account error:', _context3.t0);
|
|
524
|
+
message.error((_context3.t0 === null || _context3.t0 === void 0 ? void 0 : _context3.t0.message) || locales.getText('pisell-login2-continue-failed'));
|
|
525
|
+
case 39:
|
|
526
|
+
_context3.prev = 39;
|
|
527
|
+
setLoading(false);
|
|
528
|
+
return _context3.finish(39);
|
|
529
|
+
case 42:
|
|
530
|
+
case "end":
|
|
531
|
+
return _context3.stop();
|
|
532
|
+
}
|
|
533
|
+
}, _callee3, null, [[0, 33, 39, 42]]);
|
|
534
|
+
}));
|
|
535
|
+
return function handleContinueWithAccountInternal() {
|
|
536
|
+
return _ref4.apply(this, arguments);
|
|
537
|
+
};
|
|
538
|
+
}();
|
|
539
|
+
|
|
540
|
+
// 使用防抖的继续按钮处理函数
|
|
541
|
+
var _useDebounceFn = useDebounceFn(handleContinueWithAccountInternal, {
|
|
542
|
+
wait: 200,
|
|
543
|
+
leading: true,
|
|
544
|
+
trailing: false
|
|
545
|
+
}),
|
|
546
|
+
handleContinueWithAccount = _useDebounceFn.run;
|
|
547
|
+
// 返回到账号输入页
|
|
548
|
+
// 返回到账号输入页
|
|
549
|
+
var handleBackToAccountInternal = function handleBackToAccountInternal() {
|
|
550
|
+
setLoginStep('account');
|
|
551
|
+
form.resetFields(['password']);
|
|
552
|
+
};
|
|
553
|
+
|
|
554
|
+
// 使用防抖的返回账号页处理函数
|
|
555
|
+
var _useDebounceFn2 = useDebounceFn(handleBackToAccountInternal, {
|
|
556
|
+
wait: 200,
|
|
557
|
+
leading: true,
|
|
558
|
+
trailing: false
|
|
559
|
+
}),
|
|
560
|
+
handleBackToAccount = _useDebounceFn2.run;
|
|
561
|
+
|
|
562
|
+
// 发送验证码(验证码登录第一步)
|
|
563
|
+
var handleSendCode = /*#__PURE__*/function () {
|
|
564
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
565
|
+
var accountFieldName, _account4, _type, _res, res, phoneData, _countries$find, _res2;
|
|
566
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
567
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
568
|
+
case 0:
|
|
569
|
+
_context4.prev = 0;
|
|
570
|
+
accountFieldName = (currentLoginMethod === null || currentLoginMethod === void 0 ? void 0 : currentLoginMethod.type) === 'email' ? 'email' : 'phone'; // 先进行表单验证
|
|
571
|
+
_context4.next = 4;
|
|
572
|
+
return form.validateFields([accountFieldName]);
|
|
573
|
+
case 4:
|
|
574
|
+
_account4 = form.getFieldValue(accountFieldName);
|
|
575
|
+
if (_account4) {
|
|
576
|
+
_context4.next = 8;
|
|
577
|
+
break;
|
|
578
|
+
}
|
|
579
|
+
message.error(locales.getText('pisell-login2-account-required'));
|
|
580
|
+
return _context4.abrupt("return");
|
|
581
|
+
case 8:
|
|
582
|
+
setLoading(true);
|
|
583
|
+
_type = (currentLoginMethod === null || currentLoginMethod === void 0 ? void 0 : currentLoginMethod.type) === 'email' ? 'email' : 'phone'; // 调用实际的 API
|
|
584
|
+
if (!registerAndLogin) {
|
|
585
|
+
_context4.next = 23;
|
|
586
|
+
break;
|
|
587
|
+
}
|
|
588
|
+
if (!(_type === 'email')) {
|
|
589
|
+
_context4.next = 17;
|
|
590
|
+
break;
|
|
591
|
+
}
|
|
592
|
+
_context4.next = 14;
|
|
593
|
+
return registerAndLogin.sendEmailLoginCode({
|
|
594
|
+
type: 'email',
|
|
595
|
+
target: _account4,
|
|
596
|
+
purpose: 'login'
|
|
597
|
+
});
|
|
598
|
+
case 14:
|
|
599
|
+
res = _context4.sent;
|
|
600
|
+
_context4.next = 21;
|
|
601
|
+
break;
|
|
602
|
+
case 17:
|
|
603
|
+
// 处理手机号数据
|
|
604
|
+
|
|
605
|
+
if (typeof _account4 === 'string') {
|
|
606
|
+
// 如果是字符串格式,需要解析
|
|
607
|
+
phoneData = {
|
|
608
|
+
phone: _account4,
|
|
609
|
+
country_calling_code: ((_countries$find = countries.find(function (country) {
|
|
610
|
+
return country.value === _account4;
|
|
611
|
+
})) === null || _countries$find === void 0 ? void 0 : _countries$find.calling_code) || ''
|
|
612
|
+
};
|
|
613
|
+
} else {
|
|
614
|
+
// 如果是对象格式,直接使用
|
|
615
|
+
phoneData = _account4;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
// 发送手机登录验证码
|
|
619
|
+
_context4.next = 20;
|
|
620
|
+
return registerAndLogin.sendSmsLoginCode(phoneData);
|
|
621
|
+
case 20:
|
|
622
|
+
res = _context4.sent;
|
|
623
|
+
case 21:
|
|
624
|
+
if (!(((_res = res) === null || _res === void 0 ? void 0 : _res.code) !== 200)) {
|
|
625
|
+
_context4.next = 23;
|
|
626
|
+
break;
|
|
627
|
+
}
|
|
628
|
+
throw new Error(((_res2 = res) === null || _res2 === void 0 ? void 0 : _res2.message) || locales.getText('pisell-login2-code-send-failed'));
|
|
629
|
+
case 23:
|
|
630
|
+
_context4.next = 25;
|
|
631
|
+
return onSendVerificationCode === null || onSendVerificationCode === void 0 ? void 0 : onSendVerificationCode(_account4, _type, config.channel);
|
|
632
|
+
case 25:
|
|
633
|
+
// 保存账号并跳转到验证码输入页面
|
|
634
|
+
setEnteredAccount(_account4);
|
|
635
|
+
setLoginStep('code');
|
|
636
|
+
setCountdown(60);
|
|
637
|
+
message.success(locales.getText('pisell-login2-code-sent'));
|
|
638
|
+
_context4.next = 36;
|
|
639
|
+
break;
|
|
640
|
+
case 31:
|
|
641
|
+
_context4.prev = 31;
|
|
642
|
+
_context4.t0 = _context4["catch"](0);
|
|
643
|
+
if (!(_context4.t0 !== null && _context4.t0 !== void 0 && _context4.t0.errorFields)) {
|
|
644
|
+
_context4.next = 35;
|
|
645
|
+
break;
|
|
646
|
+
}
|
|
647
|
+
return _context4.abrupt("return");
|
|
648
|
+
case 35:
|
|
649
|
+
message.error((_context4.t0 === null || _context4.t0 === void 0 ? void 0 : _context4.t0.message) || locales.getText('pisell-login2-code-send-failed'));
|
|
650
|
+
case 36:
|
|
651
|
+
_context4.prev = 36;
|
|
652
|
+
setLoading(false);
|
|
653
|
+
return _context4.finish(36);
|
|
654
|
+
case 39:
|
|
655
|
+
case "end":
|
|
656
|
+
return _context4.stop();
|
|
657
|
+
}
|
|
658
|
+
}, _callee4, null, [[0, 31, 36, 39]]);
|
|
659
|
+
}));
|
|
660
|
+
return function handleSendCode() {
|
|
661
|
+
return _ref5.apply(this, arguments);
|
|
662
|
+
};
|
|
663
|
+
}();
|
|
664
|
+
|
|
665
|
+
// 处理验证码提交(验证码登录第二步)
|
|
666
|
+
var handleCodeSubmit = /*#__PURE__*/function () {
|
|
667
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(code) {
|
|
668
|
+
var _method, result, _result, phoneData, _countries$find2, _result2, errorMessage, _error, loginData;
|
|
669
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
670
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
671
|
+
case 0:
|
|
672
|
+
_context5.prev = 0;
|
|
673
|
+
setLoading(true);
|
|
674
|
+
setCodeError(''); // 清除之前的错误
|
|
675
|
+
_method = (currentLoginMethod === null || currentLoginMethod === void 0 ? void 0 : currentLoginMethod.type) || 'email';
|
|
676
|
+
if (!registerAndLogin) {
|
|
677
|
+
_context5.next = 22;
|
|
678
|
+
break;
|
|
679
|
+
}
|
|
680
|
+
if (!(_method === 'email')) {
|
|
681
|
+
_context5.next = 11;
|
|
682
|
+
break;
|
|
683
|
+
}
|
|
684
|
+
_context5.next = 8;
|
|
685
|
+
return registerAndLogin.emailCodeLogin({
|
|
686
|
+
email: enteredAccount,
|
|
687
|
+
code: code
|
|
688
|
+
});
|
|
689
|
+
case 8:
|
|
690
|
+
result = _context5.sent;
|
|
691
|
+
_context5.next = 16;
|
|
692
|
+
break;
|
|
693
|
+
case 11:
|
|
694
|
+
if (!(_method === 'phone')) {
|
|
695
|
+
_context5.next = 16;
|
|
696
|
+
break;
|
|
697
|
+
}
|
|
698
|
+
// 处理手机号数据
|
|
699
|
+
|
|
700
|
+
if (typeof enteredAccount === 'string') {
|
|
701
|
+
// 如果是字符串格式,需要解析
|
|
702
|
+
phoneData = {
|
|
703
|
+
phone: enteredAccount,
|
|
704
|
+
country_calling_code: ((_countries$find2 = countries.find(function (country) {
|
|
705
|
+
return country.value === enteredAccount;
|
|
706
|
+
})) === null || _countries$find2 === void 0 ? void 0 : _countries$find2.calling_code) || ''
|
|
707
|
+
};
|
|
708
|
+
} else {
|
|
709
|
+
// 如果是对象格式,直接使用
|
|
710
|
+
phoneData = enteredAccount;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
// 手机验证码登录
|
|
714
|
+
_context5.next = 15;
|
|
715
|
+
return registerAndLogin.phoneCodeLogin({
|
|
716
|
+
phone: phoneData.phone,
|
|
717
|
+
country_calling_code: phoneData.country_calling_code,
|
|
718
|
+
code: code
|
|
719
|
+
});
|
|
720
|
+
case 15:
|
|
721
|
+
result = _context5.sent;
|
|
722
|
+
case 16:
|
|
723
|
+
if (!(((_result = result) === null || _result === void 0 ? void 0 : _result.code) !== 200)) {
|
|
724
|
+
_context5.next = 22;
|
|
725
|
+
break;
|
|
726
|
+
}
|
|
727
|
+
errorMessage = ((_result2 = result) === null || _result2 === void 0 ? void 0 : _result2.message) || locales.getText('pisell-login2-login-failed');
|
|
728
|
+
_error = new Error(errorMessage); // 调用错误处理回调
|
|
729
|
+
onError === null || onError === void 0 || onError(_error, _method);
|
|
730
|
+
// 设置错误信息,不抛出错误,让组件显示错误并清空输入
|
|
731
|
+
setCodeError(errorMessage);
|
|
732
|
+
return _context5.abrupt("return");
|
|
733
|
+
case 22:
|
|
734
|
+
// 调用外部回调
|
|
735
|
+
loginData = {
|
|
736
|
+
account: enteredAccount,
|
|
737
|
+
password: undefined,
|
|
738
|
+
verification_code: code,
|
|
739
|
+
remember_me: false
|
|
740
|
+
};
|
|
741
|
+
_context5.next = 25;
|
|
742
|
+
return onLogin === null || onLogin === void 0 ? void 0 : onLogin(result.data, _method, loginData, config.channel);
|
|
743
|
+
case 25:
|
|
744
|
+
message.success(locales.getText('pisell-login2-login-success'));
|
|
745
|
+
_context5.next = 31;
|
|
746
|
+
break;
|
|
747
|
+
case 28:
|
|
748
|
+
_context5.prev = 28;
|
|
749
|
+
_context5.t0 = _context5["catch"](0);
|
|
750
|
+
// 设置错误信息,显示在组件下方
|
|
751
|
+
setCodeError((_context5.t0 === null || _context5.t0 === void 0 ? void 0 : _context5.t0.message) || locales.getText('pisell-login2-login-failed'));
|
|
752
|
+
case 31:
|
|
753
|
+
_context5.prev = 31;
|
|
754
|
+
setLoading(false);
|
|
755
|
+
return _context5.finish(31);
|
|
756
|
+
case 34:
|
|
757
|
+
case "end":
|
|
758
|
+
return _context5.stop();
|
|
759
|
+
}
|
|
760
|
+
}, _callee5, null, [[0, 28, 31, 34]]);
|
|
761
|
+
}));
|
|
762
|
+
return function handleCodeSubmit(_x) {
|
|
763
|
+
return _ref6.apply(this, arguments);
|
|
764
|
+
};
|
|
765
|
+
}();
|
|
766
|
+
|
|
767
|
+
// 从验证码页面返回
|
|
768
|
+
var handleBackFromCode = function handleBackFromCode() {
|
|
769
|
+
setLoginStep('account');
|
|
770
|
+
form.resetFields();
|
|
771
|
+
setCodeError(''); // 清除验证码错误
|
|
772
|
+
};
|
|
773
|
+
|
|
774
|
+
// 打开忘记密码流程
|
|
775
|
+
// 打开忘记密码流程
|
|
776
|
+
var handleForgotPasswordClickInternal = function handleForgotPasswordClickInternal() {
|
|
777
|
+
var accountFieldName = (currentLoginMethod === null || currentLoginMethod === void 0 ? void 0 : currentLoginMethod.type) === 'email' ? 'email' : 'phone';
|
|
778
|
+
var account = form.getFieldValue(accountFieldName);
|
|
779
|
+
setEnteredAccount(account || '');
|
|
780
|
+
setShowForgotPassword(true);
|
|
781
|
+
};
|
|
782
|
+
|
|
783
|
+
// 使用防抖的忘记密码处理函数
|
|
784
|
+
var _useDebounceFn3 = useDebounceFn(handleForgotPasswordClickInternal, {
|
|
785
|
+
wait: 200,
|
|
786
|
+
leading: true,
|
|
787
|
+
trailing: false
|
|
788
|
+
}),
|
|
789
|
+
handleForgotPasswordClick = _useDebounceFn3.run;
|
|
790
|
+
|
|
791
|
+
// 关闭忘记密码流程
|
|
792
|
+
var handleCloseForgotPassword = function handleCloseForgotPassword() {
|
|
793
|
+
setShowForgotPassword(false);
|
|
794
|
+
setCountdown(0);
|
|
795
|
+
};
|
|
796
|
+
|
|
797
|
+
// 忘记密码 - 发送重置密码链接
|
|
798
|
+
var handleForgotPasswordSendLink = /*#__PURE__*/function () {
|
|
799
|
+
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(account) {
|
|
800
|
+
var res;
|
|
801
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
802
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
803
|
+
case 0:
|
|
804
|
+
_context6.prev = 0;
|
|
805
|
+
setLoading(true);
|
|
806
|
+
if (!registerAndLogin) {
|
|
807
|
+
_context6.next = 8;
|
|
808
|
+
break;
|
|
809
|
+
}
|
|
810
|
+
_context6.next = 5;
|
|
811
|
+
return registerAndLogin.sendResetPasswordLink({
|
|
812
|
+
email: account
|
|
813
|
+
});
|
|
814
|
+
case 5:
|
|
815
|
+
res = _context6.sent;
|
|
816
|
+
if (res.status) {
|
|
817
|
+
_context6.next = 8;
|
|
818
|
+
break;
|
|
819
|
+
}
|
|
820
|
+
throw new Error(res.message || '发送重置密码链接失败');
|
|
821
|
+
case 8:
|
|
822
|
+
message.success(locales.getText('pisell-forgot-password-link-sent'));
|
|
823
|
+
_context6.next = 15;
|
|
824
|
+
break;
|
|
825
|
+
case 11:
|
|
826
|
+
_context6.prev = 11;
|
|
827
|
+
_context6.t0 = _context6["catch"](0);
|
|
828
|
+
message.error((_context6.t0 === null || _context6.t0 === void 0 ? void 0 : _context6.t0.message) || '发送重置密码链接失败');
|
|
829
|
+
throw _context6.t0;
|
|
830
|
+
case 15:
|
|
831
|
+
_context6.prev = 15;
|
|
832
|
+
setLoading(false);
|
|
833
|
+
return _context6.finish(15);
|
|
834
|
+
case 18:
|
|
835
|
+
case "end":
|
|
836
|
+
return _context6.stop();
|
|
837
|
+
}
|
|
838
|
+
}, _callee6, null, [[0, 11, 15, 18]]);
|
|
839
|
+
}));
|
|
840
|
+
return function handleForgotPasswordSendLink(_x2) {
|
|
841
|
+
return _ref7.apply(this, arguments);
|
|
842
|
+
};
|
|
843
|
+
}();
|
|
844
|
+
|
|
845
|
+
// 忘记密码 - 发送验证码
|
|
846
|
+
var handleForgotPasswordSendCode = /*#__PURE__*/function () {
|
|
847
|
+
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(account) {
|
|
848
|
+
var _type2, res, phoneAccount, _res3;
|
|
849
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
850
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
851
|
+
case 0:
|
|
852
|
+
_context7.prev = 0;
|
|
853
|
+
setLoading(true);
|
|
854
|
+
_type2 = (currentLoginMethod === null || currentLoginMethod === void 0 ? void 0 : currentLoginMethod.type) === 'email' ? 'email' : 'phone';
|
|
855
|
+
if (!registerAndLogin) {
|
|
856
|
+
_context7.next = 18;
|
|
857
|
+
break;
|
|
858
|
+
}
|
|
859
|
+
if (!(_type2 === 'email')) {
|
|
860
|
+
_context7.next = 12;
|
|
861
|
+
break;
|
|
862
|
+
}
|
|
863
|
+
_context7.next = 7;
|
|
864
|
+
return registerAndLogin.sendPasswordResetEmail({
|
|
865
|
+
email: account
|
|
866
|
+
});
|
|
867
|
+
case 7:
|
|
868
|
+
res = _context7.sent;
|
|
869
|
+
if (res.status) {
|
|
870
|
+
_context7.next = 10;
|
|
871
|
+
break;
|
|
872
|
+
}
|
|
873
|
+
throw new Error(res.message || locales.getText('pisell-login2-code-send-failed'));
|
|
874
|
+
case 10:
|
|
875
|
+
_context7.next = 18;
|
|
876
|
+
break;
|
|
877
|
+
case 12:
|
|
878
|
+
// 处理手机号对象格式
|
|
879
|
+
phoneAccount = account;
|
|
880
|
+
_context7.next = 15;
|
|
881
|
+
return registerAndLogin.sendPasswordResetSms({
|
|
882
|
+
phone: phoneAccount.phone,
|
|
883
|
+
country_calling_code: phoneAccount.country_calling_code
|
|
884
|
+
});
|
|
885
|
+
case 15:
|
|
886
|
+
_res3 = _context7.sent;
|
|
887
|
+
if (_res3.status) {
|
|
888
|
+
_context7.next = 18;
|
|
889
|
+
break;
|
|
890
|
+
}
|
|
891
|
+
throw new Error(_res3.message || locales.getText('pisell-login2-code-send-failed'));
|
|
892
|
+
case 18:
|
|
893
|
+
setCountdown(60);
|
|
894
|
+
message.success(locales.getText('pisell-login2-code-sent'));
|
|
895
|
+
_context7.next = 26;
|
|
896
|
+
break;
|
|
897
|
+
case 22:
|
|
898
|
+
_context7.prev = 22;
|
|
899
|
+
_context7.t0 = _context7["catch"](0);
|
|
900
|
+
message.error((_context7.t0 === null || _context7.t0 === void 0 ? void 0 : _context7.t0.message) || locales.getText('pisell-login2-code-send-failed'));
|
|
901
|
+
throw _context7.t0;
|
|
902
|
+
case 26:
|
|
903
|
+
_context7.prev = 26;
|
|
904
|
+
setLoading(false);
|
|
905
|
+
return _context7.finish(26);
|
|
906
|
+
case 29:
|
|
907
|
+
case "end":
|
|
908
|
+
return _context7.stop();
|
|
909
|
+
}
|
|
910
|
+
}, _callee7, null, [[0, 22, 26, 29]]);
|
|
911
|
+
}));
|
|
912
|
+
return function handleForgotPasswordSendCode(_x3) {
|
|
913
|
+
return _ref8.apply(this, arguments);
|
|
914
|
+
};
|
|
915
|
+
}();
|
|
916
|
+
|
|
917
|
+
// 忘记密码 - 验证验证码
|
|
918
|
+
var handleForgotPasswordVerifyCode = /*#__PURE__*/function () {
|
|
919
|
+
var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(account, code) {
|
|
920
|
+
var _context$appHelper3, _utils$getStore2, _utils$getStore2$getS, utils, shopId, isPhoneAccount, res, phoneData;
|
|
921
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
922
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
923
|
+
case 0:
|
|
924
|
+
_context8.prev = 0;
|
|
925
|
+
setLoading(true);
|
|
926
|
+
if (!registerAndLogin) {
|
|
927
|
+
_context8.next = 20;
|
|
928
|
+
break;
|
|
929
|
+
}
|
|
930
|
+
// 获取 shop_id
|
|
931
|
+
utils = (context === null || context === void 0 || (_context$appHelper3 = context.appHelper) === null || _context$appHelper3 === void 0 ? void 0 : _context$appHelper3.utils) || {};
|
|
932
|
+
shopId = ((_utils$getStore2 = utils.getStore) === null || _utils$getStore2 === void 0 || (_utils$getStore2 = _utils$getStore2.call(utils)) === null || _utils$getStore2 === void 0 || (_utils$getStore2$getS = _utils$getStore2.getState) === null || _utils$getStore2$getS === void 0 || (_utils$getStore2$getS = _utils$getStore2$getS.call(_utils$getStore2)) === null || _utils$getStore2$getS === void 0 || (_utils$getStore2$getS = _utils$getStore2$getS.global) === null || _utils$getStore2$getS === void 0 || (_utils$getStore2$getS = _utils$getStore2$getS.shop) === null || _utils$getStore2$getS === void 0 ? void 0 : _utils$getStore2$getS.id) || 9; // 判断账号类型
|
|
933
|
+
isPhoneAccount = _typeof(account) === 'object' && 'phone' in account;
|
|
934
|
+
if (isPhoneAccount) {
|
|
935
|
+
_context8.next = 12;
|
|
936
|
+
break;
|
|
937
|
+
}
|
|
938
|
+
_context8.next = 9;
|
|
939
|
+
return registerAndLogin.checkEmailCode({
|
|
940
|
+
email: account,
|
|
941
|
+
shop_id: shopId,
|
|
942
|
+
code: code,
|
|
943
|
+
action: 'customer_reset_password_code'
|
|
944
|
+
});
|
|
945
|
+
case 9:
|
|
946
|
+
res = _context8.sent;
|
|
947
|
+
_context8.next = 16;
|
|
948
|
+
break;
|
|
949
|
+
case 12:
|
|
950
|
+
// 手机验证码
|
|
951
|
+
phoneData = account;
|
|
952
|
+
_context8.next = 15;
|
|
953
|
+
return registerAndLogin.checkMobileCode({
|
|
954
|
+
phone: phoneData.phone,
|
|
955
|
+
country_calling_code: phoneData.country_calling_code,
|
|
956
|
+
code: code
|
|
957
|
+
});
|
|
958
|
+
case 15:
|
|
959
|
+
res = _context8.sent;
|
|
960
|
+
case 16:
|
|
961
|
+
if (res.status) {
|
|
962
|
+
_context8.next = 18;
|
|
963
|
+
break;
|
|
964
|
+
}
|
|
965
|
+
throw new Error(res.message || '验证码验证失败');
|
|
966
|
+
case 18:
|
|
967
|
+
if (res.data.valid) {
|
|
968
|
+
_context8.next = 20;
|
|
969
|
+
break;
|
|
970
|
+
}
|
|
971
|
+
throw new Error(locales.getText('pisell-login2-code-verify-failed'));
|
|
972
|
+
case 20:
|
|
973
|
+
_context8.next = 26;
|
|
974
|
+
break;
|
|
975
|
+
case 22:
|
|
976
|
+
_context8.prev = 22;
|
|
977
|
+
_context8.t0 = _context8["catch"](0);
|
|
978
|
+
message.error((_context8.t0 === null || _context8.t0 === void 0 ? void 0 : _context8.t0.message) || '验证码验证失败');
|
|
979
|
+
throw _context8.t0;
|
|
980
|
+
case 26:
|
|
981
|
+
_context8.prev = 26;
|
|
982
|
+
setLoading(false);
|
|
983
|
+
return _context8.finish(26);
|
|
984
|
+
case 29:
|
|
985
|
+
case "end":
|
|
986
|
+
return _context8.stop();
|
|
987
|
+
}
|
|
988
|
+
}, _callee8, null, [[0, 22, 26, 29]]);
|
|
989
|
+
}));
|
|
990
|
+
return function handleForgotPasswordVerifyCode(_x4, _x5) {
|
|
991
|
+
return _ref9.apply(this, arguments);
|
|
992
|
+
};
|
|
993
|
+
}();
|
|
994
|
+
|
|
995
|
+
// 忘记密码 - 重置密码
|
|
996
|
+
var handleForgotPasswordReset = /*#__PURE__*/function () {
|
|
997
|
+
var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(account, password, code) {
|
|
998
|
+
var _isPhoneAccount, resetPasswordParams, res, isPhoneAccount, phoneMethod, emailMethod;
|
|
999
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
1000
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
1001
|
+
case 0:
|
|
1002
|
+
_context9.prev = 0;
|
|
1003
|
+
setLoading(true);
|
|
1004
|
+
if (!registerAndLogin) {
|
|
1005
|
+
_context9.next = 10;
|
|
1006
|
+
break;
|
|
1007
|
+
}
|
|
1008
|
+
// 判断账号类型
|
|
1009
|
+
_isPhoneAccount = _typeof(account) === 'object' && 'phone' in account;
|
|
1010
|
+
if (_isPhoneAccount) {
|
|
1011
|
+
// 手机号格式
|
|
1012
|
+
resetPasswordParams = {
|
|
1013
|
+
type: 'phone',
|
|
1014
|
+
target: {
|
|
1015
|
+
phone: account.phone,
|
|
1016
|
+
country_calling_code: account.country_calling_code
|
|
1017
|
+
},
|
|
1018
|
+
password: password,
|
|
1019
|
+
code: code
|
|
1020
|
+
};
|
|
1021
|
+
} else {
|
|
1022
|
+
// 邮箱格式
|
|
1023
|
+
resetPasswordParams = {
|
|
1024
|
+
type: 'email',
|
|
1025
|
+
target: {
|
|
1026
|
+
email: account
|
|
1027
|
+
},
|
|
1028
|
+
password: password,
|
|
1029
|
+
code: code
|
|
1030
|
+
};
|
|
1031
|
+
}
|
|
1032
|
+
_context9.next = 7;
|
|
1033
|
+
return registerAndLogin.resetPassword(resetPasswordParams);
|
|
1034
|
+
case 7:
|
|
1035
|
+
res = _context9.sent;
|
|
1036
|
+
if (!((res === null || res === void 0 ? void 0 : res.code) !== 200)) {
|
|
1037
|
+
_context9.next = 10;
|
|
1038
|
+
break;
|
|
1039
|
+
}
|
|
1040
|
+
throw new Error((res === null || res === void 0 ? void 0 : res.message) || '密码重置失败');
|
|
1041
|
+
case 10:
|
|
1042
|
+
// 重置成功后关闭忘记密码流程
|
|
1043
|
+
handleCloseForgotPassword();
|
|
1044
|
+
|
|
1045
|
+
// 根据账号类型自动切换登录方式并预填充账号
|
|
1046
|
+
isPhoneAccount = _typeof(account) === 'object' && 'phone' in account;
|
|
1047
|
+
if (isPhoneAccount) {
|
|
1048
|
+
// 手机号重置密码成功,切换到手机号登录
|
|
1049
|
+
phoneMethod = config.loginMethods.find(function (method) {
|
|
1050
|
+
return method.type === 'phone';
|
|
1051
|
+
});
|
|
1052
|
+
if (phoneMethod) {
|
|
1053
|
+
setCurrentLoginMethod(phoneMethod);
|
|
1054
|
+
setCurrentVerificationMethod(phoneMethod.verificationMethods[0]);
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
// 预填充手机号到表单
|
|
1058
|
+
form.setFieldsValue({
|
|
1059
|
+
phone: account
|
|
1060
|
+
});
|
|
1061
|
+
setEnteredAccount(account);
|
|
1062
|
+
} else {
|
|
1063
|
+
// 邮箱重置密码成功,切换到邮箱登录
|
|
1064
|
+
emailMethod = config.loginMethods.find(function (method) {
|
|
1065
|
+
return method.type === 'email';
|
|
1066
|
+
});
|
|
1067
|
+
if (emailMethod) {
|
|
1068
|
+
setCurrentLoginMethod(emailMethod);
|
|
1069
|
+
setCurrentVerificationMethod(emailMethod.verificationMethods[0]);
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
// 预填充邮箱到表单
|
|
1073
|
+
form.setFieldsValue({
|
|
1074
|
+
email: account
|
|
1075
|
+
});
|
|
1076
|
+
setEnteredAccount(account);
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
// 重置登录步骤到账号输入页面
|
|
1080
|
+
setLoginStep('account');
|
|
1081
|
+
_context9.next = 19;
|
|
1082
|
+
break;
|
|
1083
|
+
case 16:
|
|
1084
|
+
_context9.prev = 16;
|
|
1085
|
+
_context9.t0 = _context9["catch"](0);
|
|
1086
|
+
message.error((_context9.t0 === null || _context9.t0 === void 0 ? void 0 : _context9.t0.message) || '密码重置失败');
|
|
1087
|
+
// throw error;
|
|
1088
|
+
case 19:
|
|
1089
|
+
_context9.prev = 19;
|
|
1090
|
+
setLoading(false);
|
|
1091
|
+
return _context9.finish(19);
|
|
1092
|
+
case 22:
|
|
1093
|
+
case "end":
|
|
1094
|
+
return _context9.stop();
|
|
1095
|
+
}
|
|
1096
|
+
}, _callee9, null, [[0, 16, 19, 22]]);
|
|
1097
|
+
}));
|
|
1098
|
+
return function handleForgotPasswordReset(_x6, _x7, _x8) {
|
|
1099
|
+
return _ref10.apply(this, arguments);
|
|
1100
|
+
};
|
|
1101
|
+
}();
|
|
1102
|
+
|
|
1103
|
+
// 邮件链接重置密码
|
|
1104
|
+
var handleEmailLinkResetPassword = /*#__PURE__*/function () {
|
|
1105
|
+
var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(account, password, code) {
|
|
1106
|
+
var res;
|
|
1107
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
1108
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
1109
|
+
case 0:
|
|
1110
|
+
_context10.prev = 0;
|
|
1111
|
+
setLoading(true);
|
|
1112
|
+
if (!registerAndLogin) {
|
|
1113
|
+
_context10.next = 8;
|
|
1114
|
+
break;
|
|
1115
|
+
}
|
|
1116
|
+
_context10.next = 5;
|
|
1117
|
+
return registerAndLogin.resetPasswordByCode({
|
|
1118
|
+
code: config.emailLinkVerification.code,
|
|
1119
|
+
password: password
|
|
1120
|
+
});
|
|
1121
|
+
case 5:
|
|
1122
|
+
res = _context10.sent;
|
|
1123
|
+
if (!((res === null || res === void 0 ? void 0 : res.code) !== 200)) {
|
|
1124
|
+
_context10.next = 8;
|
|
1125
|
+
break;
|
|
1126
|
+
}
|
|
1127
|
+
throw new Error((res === null || res === void 0 ? void 0 : res.message) || '密码重置失败');
|
|
1128
|
+
case 8:
|
|
1129
|
+
// 重置成功后关闭忘记密码流程并重置邮件链接验证状态
|
|
1130
|
+
handleCloseForgotPassword();
|
|
1131
|
+
setEmailLinkVerifyStatus(null);
|
|
1132
|
+
message.success('密码重置成功');
|
|
1133
|
+
_context10.next = 17;
|
|
1134
|
+
break;
|
|
1135
|
+
case 13:
|
|
1136
|
+
_context10.prev = 13;
|
|
1137
|
+
_context10.t0 = _context10["catch"](0);
|
|
1138
|
+
message.error((_context10.t0 === null || _context10.t0 === void 0 ? void 0 : _context10.t0.message) || '密码重置失败');
|
|
1139
|
+
throw _context10.t0;
|
|
1140
|
+
case 17:
|
|
1141
|
+
_context10.prev = 17;
|
|
1142
|
+
setLoading(false);
|
|
1143
|
+
return _context10.finish(17);
|
|
1144
|
+
case 20:
|
|
1145
|
+
case "end":
|
|
1146
|
+
return _context10.stop();
|
|
1147
|
+
}
|
|
1148
|
+
}, _callee10, null, [[0, 13, 17, 20]]);
|
|
1149
|
+
}));
|
|
1150
|
+
return function handleEmailLinkResetPassword(_x9, _x10, _x11) {
|
|
1151
|
+
return _ref11.apply(this, arguments);
|
|
1152
|
+
};
|
|
1153
|
+
}();
|
|
1154
|
+
|
|
1155
|
+
// 处理 Guest 登录
|
|
1156
|
+
var handleGuestLoginInternal = /*#__PURE__*/function () {
|
|
1157
|
+
var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
1158
|
+
var result, loginMethodInfo;
|
|
1159
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
1160
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
1161
|
+
case 0:
|
|
1162
|
+
_context11.prev = 0;
|
|
1163
|
+
setLoading(true);
|
|
1164
|
+
if (!registerAndLogin) {
|
|
1165
|
+
_context11.next = 7;
|
|
1166
|
+
break;
|
|
1167
|
+
}
|
|
1168
|
+
_context11.next = 5;
|
|
1169
|
+
return registerAndLogin.guestLogin();
|
|
1170
|
+
case 5:
|
|
1171
|
+
result = _context11.sent;
|
|
1172
|
+
if (result.code === 200) {
|
|
1173
|
+
message.success(locales.getText('pisell-login2-login-success'));
|
|
1174
|
+
|
|
1175
|
+
// 记录本次登录方式到localStorage
|
|
1176
|
+
loginMethodInfo = {
|
|
1177
|
+
type: 'guest',
|
|
1178
|
+
verificationMethod: null,
|
|
1179
|
+
timestamp: Date.now()
|
|
1180
|
+
};
|
|
1181
|
+
storage.set('pisell_last_login_method', JSON.stringify(loginMethodInfo));
|
|
1182
|
+
onLogin === null || onLogin === void 0 || onLogin(result.data, 'guest', {
|
|
1183
|
+
account: 'guest',
|
|
1184
|
+
password: undefined
|
|
1185
|
+
}, config.channel);
|
|
1186
|
+
} else {
|
|
1187
|
+
message.error(result.message || locales.getText('pisell-login2-login-failed'));
|
|
1188
|
+
}
|
|
1189
|
+
case 7:
|
|
1190
|
+
_context11.next = 13;
|
|
1191
|
+
break;
|
|
1192
|
+
case 9:
|
|
1193
|
+
_context11.prev = 9;
|
|
1194
|
+
_context11.t0 = _context11["catch"](0);
|
|
1195
|
+
console.error('Guest login error:', _context11.t0);
|
|
1196
|
+
message.error(locales.getText('pisell-login2-login-failed'));
|
|
1197
|
+
case 13:
|
|
1198
|
+
_context11.prev = 13;
|
|
1199
|
+
setLoading(false);
|
|
1200
|
+
return _context11.finish(13);
|
|
1201
|
+
case 16:
|
|
1202
|
+
case "end":
|
|
1203
|
+
return _context11.stop();
|
|
1204
|
+
}
|
|
1205
|
+
}, _callee11, null, [[0, 9, 13, 16]]);
|
|
1206
|
+
}));
|
|
1207
|
+
return function handleGuestLoginInternal() {
|
|
1208
|
+
return _ref12.apply(this, arguments);
|
|
1209
|
+
};
|
|
1210
|
+
}();
|
|
1211
|
+
|
|
1212
|
+
// 使用防抖的Guest登录处理函数
|
|
1213
|
+
var _useDebounceFn4 = useDebounceFn(handleGuestLoginInternal, {
|
|
1214
|
+
wait: 200,
|
|
1215
|
+
leading: true,
|
|
1216
|
+
trailing: false
|
|
1217
|
+
}),
|
|
1218
|
+
handleGuestLogin = _useDebounceFn4.run;
|
|
1219
|
+
var oauthProviders = useMemo(function () {
|
|
1220
|
+
return loginMethods.filter(function (method) {
|
|
1221
|
+
return ['google', 'facebook', 'apple', 'guest'].includes(method.type);
|
|
1222
|
+
}).map(function (method) {
|
|
1223
|
+
var isLast = isLastLoginMethod(method.type);
|
|
1224
|
+
var commonConfig = {
|
|
1225
|
+
className: classNames('login2-oauth-button', method.type, {
|
|
1226
|
+
'has-last-login-badge': isLast
|
|
1227
|
+
}),
|
|
1228
|
+
badge: isLast ? locales.getText('pisell-login2-last-login-badge') : undefined,
|
|
1229
|
+
badgeClassName: 'last-login-badge'
|
|
1230
|
+
};
|
|
1231
|
+
switch (method.type) {
|
|
1232
|
+
case 'google':
|
|
1233
|
+
return _objectSpread({
|
|
1234
|
+
key: 'google',
|
|
1235
|
+
label: /*#__PURE__*/React.createElement("span", null, locales.getText('pisell-login2-continue-with'), " Google"),
|
|
1236
|
+
icon: /*#__PURE__*/React.createElement(Iconfont, {
|
|
1237
|
+
type: "pisell2-google"
|
|
1238
|
+
}),
|
|
1239
|
+
onClick: function onClick() {
|
|
1240
|
+
return handleOAuthClick('google');
|
|
1241
|
+
}
|
|
1242
|
+
}, commonConfig);
|
|
1243
|
+
case 'facebook':
|
|
1244
|
+
return _objectSpread({
|
|
1245
|
+
key: 'facebook',
|
|
1246
|
+
label: /*#__PURE__*/React.createElement("span", null, locales.getText('pisell-login2-continue-with'), " Facebook"),
|
|
1247
|
+
icon: /*#__PURE__*/React.createElement(Iconfont, {
|
|
1248
|
+
type: "pisell2-facebook"
|
|
1249
|
+
}),
|
|
1250
|
+
onClick: function onClick() {
|
|
1251
|
+
return handleOAuthClick('facebook');
|
|
1252
|
+
}
|
|
1253
|
+
}, commonConfig);
|
|
1254
|
+
case 'apple':
|
|
1255
|
+
return _objectSpread({
|
|
1256
|
+
key: 'apple',
|
|
1257
|
+
label: /*#__PURE__*/React.createElement("span", null, locales.getText('pisell-login2-continue-with'), " Apple"),
|
|
1258
|
+
icon: /*#__PURE__*/React.createElement(Iconfont, {
|
|
1259
|
+
type: "pisell2-apple"
|
|
1260
|
+
}),
|
|
1261
|
+
onClick: function onClick() {
|
|
1262
|
+
return handleOAuthClick('apple');
|
|
1263
|
+
}
|
|
1264
|
+
}, commonConfig);
|
|
1265
|
+
case 'guest':
|
|
1266
|
+
return _objectSpread({
|
|
1267
|
+
key: 'guest',
|
|
1268
|
+
label: locales.getText('pisell-login2-login-as-guest'),
|
|
1269
|
+
icon: /*#__PURE__*/React.createElement(Iconfont, {
|
|
1270
|
+
type: "pisell2-user-01"
|
|
1271
|
+
}),
|
|
1272
|
+
onClick: handleGuestLogin
|
|
1273
|
+
}, commonConfig);
|
|
1274
|
+
default:
|
|
1275
|
+
return null;
|
|
1276
|
+
}
|
|
1277
|
+
}).filter(Boolean);
|
|
1278
|
+
}, [handleGuestLogin, handleOAuthClick, isLastLoginMethod, loginMethods]);
|
|
1279
|
+
|
|
1280
|
+
// 处理登录
|
|
1281
|
+
var handleLoginInternal = /*#__PURE__*/function () {
|
|
1282
|
+
var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
1283
|
+
var values, accountFieldName, _account5, loginData, _method2, result, _result3, phoneData, _countries$find3, _result4, loginMethodInfo;
|
|
1284
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
1285
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
1286
|
+
case 0:
|
|
1287
|
+
_context12.prev = 0;
|
|
1288
|
+
setLoading(true);
|
|
1289
|
+
_context12.next = 4;
|
|
1290
|
+
return form.validateFields();
|
|
1291
|
+
case 4:
|
|
1292
|
+
values = _context12.sent;
|
|
1293
|
+
// 在分步骤登录模式下,账号从表单字段获取(支持编辑)
|
|
1294
|
+
accountFieldName = (currentLoginMethod === null || currentLoginMethod === void 0 ? void 0 : currentLoginMethod.type) === 'email' ? 'email' : 'phone';
|
|
1295
|
+
_account5 = values[accountFieldName] || values.account; // 兼容旧的 account
|
|
1296
|
+
loginData = {
|
|
1297
|
+
account: _account5,
|
|
1298
|
+
password: currentVerificationMethod === 'password' ? values.password : undefined,
|
|
1299
|
+
verification_code: currentVerificationMethod === 'verification_code' ? values.verification_code : undefined,
|
|
1300
|
+
remember_me: values.remember_me
|
|
1301
|
+
};
|
|
1302
|
+
_method2 = (currentLoginMethod === null || currentLoginMethod === void 0 ? void 0 : currentLoginMethod.type) || 'email';
|
|
1303
|
+
if (!registerAndLogin) {
|
|
1304
|
+
_context12.next = 35;
|
|
1305
|
+
break;
|
|
1306
|
+
}
|
|
1307
|
+
if (!(_method2 === 'email')) {
|
|
1308
|
+
_context12.next = 22;
|
|
1309
|
+
break;
|
|
1310
|
+
}
|
|
1311
|
+
if (!(currentVerificationMethod === 'password')) {
|
|
1312
|
+
_context12.next = 17;
|
|
1313
|
+
break;
|
|
1314
|
+
}
|
|
1315
|
+
_context12.next = 14;
|
|
1316
|
+
return registerAndLogin.emailPasswordLogin({
|
|
1317
|
+
email: _account5,
|
|
1318
|
+
password: values.password
|
|
1319
|
+
});
|
|
1320
|
+
case 14:
|
|
1321
|
+
result = _context12.sent;
|
|
1322
|
+
_context12.next = 20;
|
|
1323
|
+
break;
|
|
1324
|
+
case 17:
|
|
1325
|
+
_context12.next = 19;
|
|
1326
|
+
return registerAndLogin.emailCodeLogin({
|
|
1327
|
+
email: _account5,
|
|
1328
|
+
code: values.verification_code
|
|
1329
|
+
});
|
|
1330
|
+
case 19:
|
|
1331
|
+
result = _context12.sent;
|
|
1332
|
+
case 20:
|
|
1333
|
+
_context12.next = 33;
|
|
1334
|
+
break;
|
|
1335
|
+
case 22:
|
|
1336
|
+
if (!(_method2 === 'phone')) {
|
|
1337
|
+
_context12.next = 33;
|
|
1338
|
+
break;
|
|
1339
|
+
}
|
|
1340
|
+
// 处理手机号数据
|
|
1341
|
+
|
|
1342
|
+
if (typeof _account5 === 'string') {
|
|
1343
|
+
// 如果是字符串格式,需要解析
|
|
1344
|
+
phoneData = {
|
|
1345
|
+
phone: _account5,
|
|
1346
|
+
country_calling_code: ((_countries$find3 = countries.find(function (country) {
|
|
1347
|
+
return country.value === _account5;
|
|
1348
|
+
})) === null || _countries$find3 === void 0 ? void 0 : _countries$find3.calling_code) || ''
|
|
1349
|
+
};
|
|
1350
|
+
} else {
|
|
1351
|
+
// 如果是对象格式,直接使用
|
|
1352
|
+
phoneData = _account5;
|
|
1353
|
+
}
|
|
1354
|
+
if (!(currentVerificationMethod === 'password')) {
|
|
1355
|
+
_context12.next = 30;
|
|
1356
|
+
break;
|
|
1357
|
+
}
|
|
1358
|
+
_context12.next = 27;
|
|
1359
|
+
return registerAndLogin.phonePasswordLogin({
|
|
1360
|
+
phone: phoneData.phone,
|
|
1361
|
+
country_calling_code: phoneData.country_calling_code,
|
|
1362
|
+
password: values.password
|
|
1363
|
+
});
|
|
1364
|
+
case 27:
|
|
1365
|
+
result = _context12.sent;
|
|
1366
|
+
_context12.next = 33;
|
|
1367
|
+
break;
|
|
1368
|
+
case 30:
|
|
1369
|
+
_context12.next = 32;
|
|
1370
|
+
return registerAndLogin.phoneCodeLogin({
|
|
1371
|
+
phone: phoneData.phone,
|
|
1372
|
+
country_calling_code: phoneData.country_calling_code,
|
|
1373
|
+
code: values.verification_code
|
|
1374
|
+
});
|
|
1375
|
+
case 32:
|
|
1376
|
+
result = _context12.sent;
|
|
1377
|
+
case 33:
|
|
1378
|
+
if (!(((_result3 = result) === null || _result3 === void 0 ? void 0 : _result3.code) !== 200)) {
|
|
1379
|
+
_context12.next = 35;
|
|
1380
|
+
break;
|
|
1381
|
+
}
|
|
1382
|
+
throw new Error(((_result4 = result) === null || _result4 === void 0 ? void 0 : _result4.message) || locales.getText('pisell-login2-login-failed'));
|
|
1383
|
+
case 35:
|
|
1384
|
+
_context12.next = 37;
|
|
1385
|
+
return onLogin === null || onLogin === void 0 ? void 0 : onLogin(result.data, _method2, loginData, config.channel);
|
|
1386
|
+
case 37:
|
|
1387
|
+
// 记录本次登录方式到localStorage
|
|
1388
|
+
loginMethodInfo = {
|
|
1389
|
+
type: _method2,
|
|
1390
|
+
verificationMethod: currentVerificationMethod,
|
|
1391
|
+
timestamp: Date.now()
|
|
1392
|
+
};
|
|
1393
|
+
storage.set('pisell_last_login_method', JSON.stringify(loginMethodInfo));
|
|
1394
|
+
|
|
1395
|
+
// 登录成功后处理 Remember me
|
|
1396
|
+
if (values.remember_me && _account5) {
|
|
1397
|
+
storage.set('login_account', JSON.stringify(_account5));
|
|
1398
|
+
storage.set('login_remember_me', 'true');
|
|
1399
|
+
if (currentVerificationMethod === 'password') {
|
|
1400
|
+
storage.set('login_password', values.password);
|
|
1401
|
+
}
|
|
1402
|
+
// 同步更新 enteredAccount 状态
|
|
1403
|
+
setEnteredAccount(_account5);
|
|
1404
|
+
} else {
|
|
1405
|
+
storage.remove('login_account');
|
|
1406
|
+
storage.remove('login_remember_me');
|
|
1407
|
+
storage.remove('login_password');
|
|
1408
|
+
}
|
|
1409
|
+
message.success(locales.getText('pisell-login2-login-success'));
|
|
1410
|
+
_context12.next = 48;
|
|
1411
|
+
break;
|
|
1412
|
+
case 43:
|
|
1413
|
+
_context12.prev = 43;
|
|
1414
|
+
_context12.t0 = _context12["catch"](0);
|
|
1415
|
+
if (!_context12.t0.errorFields) {
|
|
1416
|
+
_context12.next = 47;
|
|
1417
|
+
break;
|
|
1418
|
+
}
|
|
1419
|
+
return _context12.abrupt("return");
|
|
1420
|
+
case 47:
|
|
1421
|
+
message.error((_context12.t0 === null || _context12.t0 === void 0 ? void 0 : _context12.t0.message) || locales.getText('pisell-login2-login-failed'));
|
|
1422
|
+
case 48:
|
|
1423
|
+
_context12.prev = 48;
|
|
1424
|
+
setLoading(false);
|
|
1425
|
+
return _context12.finish(48);
|
|
1426
|
+
case 51:
|
|
1427
|
+
case "end":
|
|
1428
|
+
return _context12.stop();
|
|
1429
|
+
}
|
|
1430
|
+
}, _callee12, null, [[0, 43, 48, 51]]);
|
|
1431
|
+
}));
|
|
1432
|
+
return function handleLoginInternal() {
|
|
1433
|
+
return _ref13.apply(this, arguments);
|
|
1434
|
+
};
|
|
1435
|
+
}();
|
|
1436
|
+
|
|
1437
|
+
// 使用防抖的登录处理函数
|
|
1438
|
+
var _useDebounceFn5 = useDebounceFn(handleLoginInternal, {
|
|
1439
|
+
wait: 1000,
|
|
1440
|
+
leading: true,
|
|
1441
|
+
trailing: false
|
|
1442
|
+
}),
|
|
1443
|
+
handleLogin = _useDebounceFn5.run;
|
|
1444
|
+
|
|
1445
|
+
// 处理三方登录
|
|
1446
|
+
var handleOAuthClickInternal = /*#__PURE__*/function () {
|
|
1447
|
+
var _ref14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(provider) {
|
|
1448
|
+
var _config$loginMethods, fbConfig, token, _config$loginMethods2, appleConfig, _token;
|
|
1449
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
1450
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
1451
|
+
case 0:
|
|
1452
|
+
_context13.prev = 0;
|
|
1453
|
+
setLoading(true);
|
|
1454
|
+
if (!(provider === 'facebook')) {
|
|
1455
|
+
_context13.next = 13;
|
|
1456
|
+
break;
|
|
1457
|
+
}
|
|
1458
|
+
fbConfig = config === null || config === void 0 || (_config$loginMethods = config.loginMethods) === null || _config$loginMethods === void 0 ? void 0 : _config$loginMethods.find(function (n) {
|
|
1459
|
+
return n.type === 'facebook';
|
|
1460
|
+
});
|
|
1461
|
+
token = fbConfig === null || fbConfig === void 0 ? void 0 : fbConfig.appId;
|
|
1462
|
+
if (!token) {
|
|
1463
|
+
_context13.next = 10;
|
|
1464
|
+
break;
|
|
1465
|
+
}
|
|
1466
|
+
_context13.next = 8;
|
|
1467
|
+
return registerAndLogin.loginWithFacebook(token);
|
|
1468
|
+
case 8:
|
|
1469
|
+
_context13.next = 11;
|
|
1470
|
+
break;
|
|
1471
|
+
case 10:
|
|
1472
|
+
throw new Error('Facebook app_id not configured');
|
|
1473
|
+
case 11:
|
|
1474
|
+
_context13.next = 26;
|
|
1475
|
+
break;
|
|
1476
|
+
case 13:
|
|
1477
|
+
if (!(provider === 'apple')) {
|
|
1478
|
+
_context13.next = 24;
|
|
1479
|
+
break;
|
|
1480
|
+
}
|
|
1481
|
+
appleConfig = config === null || config === void 0 || (_config$loginMethods2 = config.loginMethods) === null || _config$loginMethods2 === void 0 ? void 0 : _config$loginMethods2.find(function (n) {
|
|
1482
|
+
return n.type === 'apple';
|
|
1483
|
+
});
|
|
1484
|
+
_token = appleConfig === null || appleConfig === void 0 ? void 0 : appleConfig.clientId;
|
|
1485
|
+
if (!_token) {
|
|
1486
|
+
_context13.next = 21;
|
|
1487
|
+
break;
|
|
1488
|
+
}
|
|
1489
|
+
_context13.next = 19;
|
|
1490
|
+
return registerAndLogin.loginWithApple(_token);
|
|
1491
|
+
case 19:
|
|
1492
|
+
_context13.next = 22;
|
|
1493
|
+
break;
|
|
1494
|
+
case 21:
|
|
1495
|
+
throw new Error('Apple client_id not configured');
|
|
1496
|
+
case 22:
|
|
1497
|
+
_context13.next = 26;
|
|
1498
|
+
break;
|
|
1499
|
+
case 24:
|
|
1500
|
+
_context13.next = 26;
|
|
1501
|
+
return onOAuthLogin === null || onOAuthLogin === void 0 ? void 0 : onOAuthLogin(provider, config.channel);
|
|
1502
|
+
case 26:
|
|
1503
|
+
_context13.next = 31;
|
|
1504
|
+
break;
|
|
1505
|
+
case 28:
|
|
1506
|
+
_context13.prev = 28;
|
|
1507
|
+
_context13.t0 = _context13["catch"](0);
|
|
1508
|
+
message.error((_context13.t0 === null || _context13.t0 === void 0 ? void 0 : _context13.t0.message) || locales.getText('pisell-login2-login-failed'));
|
|
1509
|
+
case 31:
|
|
1510
|
+
_context13.prev = 31;
|
|
1511
|
+
setLoading(false);
|
|
1512
|
+
return _context13.finish(31);
|
|
1513
|
+
case 34:
|
|
1514
|
+
case "end":
|
|
1515
|
+
return _context13.stop();
|
|
1516
|
+
}
|
|
1517
|
+
}, _callee13, null, [[0, 28, 31, 34]]);
|
|
1518
|
+
}));
|
|
1519
|
+
return function handleOAuthClickInternal(_x12) {
|
|
1520
|
+
return _ref14.apply(this, arguments);
|
|
1521
|
+
};
|
|
1522
|
+
}();
|
|
1523
|
+
|
|
1524
|
+
// 使用防抖的OAuth登录处理函数
|
|
1525
|
+
var _useDebounceFn6 = useDebounceFn(handleOAuthClickInternal, {
|
|
1526
|
+
wait: 200,
|
|
1527
|
+
leading: true,
|
|
1528
|
+
trailing: false
|
|
1529
|
+
}),
|
|
1530
|
+
handleOAuthClick = _useDebounceFn6.run;
|
|
1531
|
+
|
|
1532
|
+
// 渲染主登录表单
|
|
1533
|
+
var renderMainLoginForm = function renderMainLoginForm() {
|
|
1534
|
+
var _config$ui2, _config$ui3, _config$ui4, _config$ui5, _config$ui8, _config$ui9;
|
|
1535
|
+
if (!currentLoginMethod) return null;
|
|
1536
|
+
var type = currentLoginMethod.type;
|
|
1537
|
+
|
|
1538
|
+
// OAuth 类型和 Guest 登录不在主表单区域显示,而是在 switch-options 区域显示
|
|
1539
|
+
if (type === 'google' || type === 'facebook' || type === 'apple' || type === 'guest') {
|
|
1540
|
+
return null;
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1543
|
+
// 检查是否有邮箱或手机登录方法
|
|
1544
|
+
var hasEmailOrPhoneMethod = loginMethods.some(function (method) {
|
|
1545
|
+
return method.type === 'email' || method.type === 'phone';
|
|
1546
|
+
});
|
|
1547
|
+
|
|
1548
|
+
// 如果没有邮箱或手机登录方法,不渲染主输入表单
|
|
1549
|
+
if (!hasEmailOrPhoneMethod) {
|
|
1550
|
+
return null;
|
|
1551
|
+
}
|
|
1552
|
+
var isEmail = type === 'email';
|
|
1553
|
+
var isPhone = type === 'phone';
|
|
1554
|
+
|
|
1555
|
+
// 根据当前模式获取账号字段名(用于区分浏览器自动填充)
|
|
1556
|
+
var accountFieldName = isEmail ? 'email' : 'phone';
|
|
1557
|
+
|
|
1558
|
+
// 辅助函数:根据当前模式获取账号值
|
|
1559
|
+
var getAccountValue = function getAccountValue(values) {
|
|
1560
|
+
if (values) {
|
|
1561
|
+
return values[accountFieldName] || values.account; // 兼容旧的 account
|
|
1562
|
+
}
|
|
1563
|
+
return form.getFieldValue(accountFieldName) || form.getFieldValue('account');
|
|
1564
|
+
};
|
|
1565
|
+
var accountLabel = isEmail ? ((_config$ui2 = config.ui) === null || _config$ui2 === void 0 || (_config$ui2 = _config$ui2.formLabels) === null || _config$ui2 === void 0 || (_config$ui2 = _config$ui2.email) === null || _config$ui2 === void 0 ? void 0 : _config$ui2.show) !== false ? ((_config$ui3 = config.ui) === null || _config$ui3 === void 0 || (_config$ui3 = _config$ui3.formLabels) === null || _config$ui3 === void 0 || (_config$ui3 = _config$ui3.email) === null || _config$ui3 === void 0 ? void 0 : _config$ui3.text) || locales.getText('pisell-login2-email-label') : undefined : ((_config$ui4 = config.ui) === null || _config$ui4 === void 0 || (_config$ui4 = _config$ui4.formLabels) === null || _config$ui4 === void 0 || (_config$ui4 = _config$ui4.phone) === null || _config$ui4 === void 0 ? void 0 : _config$ui4.show) !== false ? ((_config$ui5 = config.ui) === null || _config$ui5 === void 0 || (_config$ui5 = _config$ui5.formLabels) === null || _config$ui5 === void 0 || (_config$ui5 = _config$ui5.phone) === null || _config$ui5 === void 0 ? void 0 : _config$ui5.text) || locales.getText('pisell-login2-phone-label') : undefined;
|
|
1566
|
+
var accountPlaceholder = isEmail ? locales.getText('pisell-login2-email-placeholder') : locales.getText('pisell-login2-phone-placeholder');
|
|
1567
|
+
var accountRules = isEmail ? [{
|
|
1568
|
+
required: true,
|
|
1569
|
+
message: locales.getText('pisell-login2-email-required')
|
|
1570
|
+
}, {
|
|
1571
|
+
type: 'email',
|
|
1572
|
+
message: locales.getText('pisell-login2-email-invalid')
|
|
1573
|
+
}] : createPhoneValidationRules(locales.getText, true);
|
|
1574
|
+
|
|
1575
|
+
// 判断是否使用分步骤登录
|
|
1576
|
+
var useStepByStep = (currentLoginMethod === null || currentLoginMethod === void 0 ? void 0 : currentLoginMethod.stepByStep) && currentVerificationMethod === 'password';
|
|
1577
|
+
|
|
1578
|
+
// 分步骤登录 - 合并步骤1和步骤2为同一表单,通过条件渲染控制显示
|
|
1579
|
+
if (useStepByStep) {
|
|
1580
|
+
var _getAccountValue, _getAccountValue2, _config$ui6, _config$ui7;
|
|
1581
|
+
var isPasswordStep = loginStep === 'password';
|
|
1582
|
+
var showPasswordField = isPasswordStep;
|
|
1583
|
+
|
|
1584
|
+
// 处理表单提交(仅用于用户主动触发,防止自动触发)
|
|
1585
|
+
var handleFormSubmit = function handleFormSubmit(e) {
|
|
1586
|
+
e === null || e === void 0 || e.preventDefault();
|
|
1587
|
+
if (isPasswordStep) {
|
|
1588
|
+
handleLogin();
|
|
1589
|
+
} else {
|
|
1590
|
+
handleContinueWithAccount();
|
|
1591
|
+
}
|
|
1592
|
+
};
|
|
1593
|
+
return /*#__PURE__*/React.createElement(Form, {
|
|
1594
|
+
form: form,
|
|
1595
|
+
layout: "vertical",
|
|
1596
|
+
className: "login2-form",
|
|
1597
|
+
size: "large"
|
|
1598
|
+
}, (isEmail || isPhone) && !showPasswordField && /*#__PURE__*/React.createElement("div", {
|
|
1599
|
+
style: {
|
|
1600
|
+
position: 'absolute',
|
|
1601
|
+
left: '-9999px',
|
|
1602
|
+
opacity: 0,
|
|
1603
|
+
pointerEvents: 'none'
|
|
1604
|
+
}
|
|
1605
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
1606
|
+
type: "text",
|
|
1607
|
+
name: "username",
|
|
1608
|
+
autoComplete: "username",
|
|
1609
|
+
tabIndex: -1,
|
|
1610
|
+
readOnly: true,
|
|
1611
|
+
"aria-hidden": "true"
|
|
1612
|
+
})), showPasswordField && /*#__PURE__*/React.createElement("div", {
|
|
1613
|
+
className: "login2-account-show-text-edit"
|
|
1614
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
1615
|
+
className: "login2-account-show-text-edit-text"
|
|
1616
|
+
}, isPhone && "+".concat((_getAccountValue = getAccountValue()) === null || _getAccountValue === void 0 ? void 0 : _getAccountValue.country_calling_code).concat((_getAccountValue2 = getAccountValue()) === null || _getAccountValue2 === void 0 ? void 0 : _getAccountValue2.phone) || '', isEmail && getAccountValue() || ''), /*#__PURE__*/React.createElement("span", {
|
|
1617
|
+
className: "login2-account-show-text-edit-icon",
|
|
1618
|
+
onClick: handleBackToAccount
|
|
1619
|
+
}, /*#__PURE__*/React.createElement(Iconfont, {
|
|
1620
|
+
type: "pisell2-edit-05"
|
|
1621
|
+
}))), /*#__PURE__*/React.createElement(Form.Item, {
|
|
1622
|
+
style: {
|
|
1623
|
+
display: showPasswordField ? 'none' : 'block'
|
|
1624
|
+
},
|
|
1625
|
+
label: accountLabel,
|
|
1626
|
+
name: isEmail ? 'email' : 'phone',
|
|
1627
|
+
rules: accountRules,
|
|
1628
|
+
validateTrigger: ['onBlur', 'onSubmit'],
|
|
1629
|
+
className: isPhone ? 'phone-input-form-item' : ''
|
|
1630
|
+
}, isPhone ? /*#__PURE__*/React.createElement(PhoneInput, {
|
|
1631
|
+
size: "large",
|
|
1632
|
+
placeholder: accountPlaceholder,
|
|
1633
|
+
className: "login2-phone-input",
|
|
1634
|
+
countries: countries,
|
|
1635
|
+
valueFormat: "object",
|
|
1636
|
+
value: isPasswordStep ? enteredAccount : getAccountValue() || undefined,
|
|
1637
|
+
onChange: function onChange(value) {
|
|
1638
|
+
if (isPasswordStep) {
|
|
1639
|
+
setEnteredAccount(value);
|
|
1640
|
+
}
|
|
1641
|
+
form.setFieldsValue(_defineProperty({}, accountFieldName, value));
|
|
1642
|
+
}
|
|
1643
|
+
}) : /*#__PURE__*/React.createElement(Input, {
|
|
1644
|
+
size: "large",
|
|
1645
|
+
placeholder: accountPlaceholder,
|
|
1646
|
+
className: "login2-input",
|
|
1647
|
+
type: "email",
|
|
1648
|
+
autoComplete: "email",
|
|
1649
|
+
value: getAccountValue() || enteredAccount || '',
|
|
1650
|
+
onChange: function onChange(e) {
|
|
1651
|
+
var newValue = e.target.value;
|
|
1652
|
+
if (isPasswordStep) {
|
|
1653
|
+
setEnteredAccount(newValue);
|
|
1654
|
+
}
|
|
1655
|
+
form.setFieldsValue(_defineProperty({}, accountFieldName, newValue));
|
|
1656
|
+
},
|
|
1657
|
+
onKeyDown: function onKeyDown(e) {
|
|
1658
|
+
if (e.key === 'Enter' && !e.shiftKey && !e.ctrlKey && !e.metaKey) {
|
|
1659
|
+
e.preventDefault();
|
|
1660
|
+
handleFormSubmit(e);
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
})), /*#__PURE__*/React.createElement(Form.Item, {
|
|
1664
|
+
style: {
|
|
1665
|
+
display: showPasswordField ? 'block' : 'none'
|
|
1666
|
+
},
|
|
1667
|
+
label: ((_config$ui6 = config.ui) === null || _config$ui6 === void 0 || (_config$ui6 = _config$ui6.formLabels) === null || _config$ui6 === void 0 || (_config$ui6 = _config$ui6.password) === null || _config$ui6 === void 0 ? void 0 : _config$ui6.show) !== false ? ((_config$ui7 = config.ui) === null || _config$ui7 === void 0 || (_config$ui7 = _config$ui7.formLabels) === null || _config$ui7 === void 0 || (_config$ui7 = _config$ui7.password) === null || _config$ui7 === void 0 ? void 0 : _config$ui7.text) || locales.getText('pisell-login2-password-label') : undefined,
|
|
1668
|
+
name: "password",
|
|
1669
|
+
validateTrigger: ['onBlur', 'onSubmit'],
|
|
1670
|
+
rules: passwordValidationRules
|
|
1671
|
+
}, /*#__PURE__*/React.createElement(Input.Password, {
|
|
1672
|
+
size: "large",
|
|
1673
|
+
placeholder: locales.getText('pisell-login2-password-placeholder'),
|
|
1674
|
+
className: "login2-input",
|
|
1675
|
+
name: "password",
|
|
1676
|
+
autoComplete: "current-password",
|
|
1677
|
+
type: "password",
|
|
1678
|
+
autoFocus: hasStoredCredentials,
|
|
1679
|
+
onKeyDown: function onKeyDown(e) {
|
|
1680
|
+
if (e.key === 'Enter' && !e.shiftKey && !e.ctrlKey && !e.metaKey) {
|
|
1681
|
+
e.preventDefault();
|
|
1682
|
+
handleFormSubmit(e);
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
})), showPasswordField && /*#__PURE__*/React.createElement("div", {
|
|
1686
|
+
className: "login2-form-footer"
|
|
1687
|
+
}, /*#__PURE__*/React.createElement(Form.Item, {
|
|
1688
|
+
name: "remember_me",
|
|
1689
|
+
valuePropName: "checked",
|
|
1690
|
+
noStyle: true
|
|
1691
|
+
}, /*#__PURE__*/React.createElement(Checkbox, {
|
|
1692
|
+
defaultChecked: rememberMe
|
|
1693
|
+
}, locales.getText('pisell-login2-remember-me'))), /*#__PURE__*/React.createElement("a", {
|
|
1694
|
+
className: "login2-link",
|
|
1695
|
+
onClick: handleForgotPasswordClick
|
|
1696
|
+
}, locales.getText('pisell-login2-forgot-password'))), /*#__PURE__*/React.createElement(Button, {
|
|
1697
|
+
type: "primary",
|
|
1698
|
+
size: "large",
|
|
1699
|
+
block: true,
|
|
1700
|
+
htmlType: "button",
|
|
1701
|
+
loading: loading,
|
|
1702
|
+
onClick: handleFormSubmit,
|
|
1703
|
+
className: "login2-submit-button"
|
|
1704
|
+
}, isPasswordStep ? locales.getText('pisell-login2-login-button') : isEmail ? locales.getText('pisell-login2-continue-with-email') : locales.getText('pisell-login2-continue-with-phone')), showPasswordField && /*#__PURE__*/React.createElement(Button, {
|
|
1705
|
+
size: "large",
|
|
1706
|
+
block: true,
|
|
1707
|
+
onClick: handleBackToAccount,
|
|
1708
|
+
className: "login2-back-button"
|
|
1709
|
+
}, locales.getText('pisell-login2-back')));
|
|
1710
|
+
}
|
|
1711
|
+
|
|
1712
|
+
// 验证码登录 - 第一步:仅输入账号
|
|
1713
|
+
if (currentVerificationMethod === 'verification_code' && loginStep === 'account') {
|
|
1714
|
+
// 处理表单提交(仅用于用户主动触发,防止自动触发)
|
|
1715
|
+
var _handleFormSubmit = function _handleFormSubmit(e) {
|
|
1716
|
+
e === null || e === void 0 || e.preventDefault();
|
|
1717
|
+
handleSendCode();
|
|
1718
|
+
};
|
|
1719
|
+
return /*#__PURE__*/React.createElement(Form, {
|
|
1720
|
+
form: form,
|
|
1721
|
+
layout: "vertical",
|
|
1722
|
+
className: "login2-form",
|
|
1723
|
+
size: "large"
|
|
1724
|
+
}, isEmail && /*#__PURE__*/React.createElement("div", {
|
|
1725
|
+
style: {
|
|
1726
|
+
position: 'absolute',
|
|
1727
|
+
left: '-9999px',
|
|
1728
|
+
opacity: 0,
|
|
1729
|
+
pointerEvents: 'none'
|
|
1730
|
+
}
|
|
1731
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
1732
|
+
type: "text",
|
|
1733
|
+
name: "username",
|
|
1734
|
+
autoComplete: "username",
|
|
1735
|
+
tabIndex: -1,
|
|
1736
|
+
readOnly: true,
|
|
1737
|
+
"aria-hidden": "true"
|
|
1738
|
+
})), /*#__PURE__*/React.createElement(Form.Item, {
|
|
1739
|
+
label: accountLabel,
|
|
1740
|
+
name: accountFieldName,
|
|
1741
|
+
rules: accountRules,
|
|
1742
|
+
className: isPhone ? 'phone-input-form-item' : '',
|
|
1743
|
+
validateTrigger: ['onBlur', 'onSubmit']
|
|
1744
|
+
}, isPhone ? /*#__PURE__*/React.createElement(PhoneInput, {
|
|
1745
|
+
size: "large",
|
|
1746
|
+
placeholder: accountPlaceholder,
|
|
1747
|
+
className: "login2-phone-input",
|
|
1748
|
+
countries: countries,
|
|
1749
|
+
valueFormat: "object",
|
|
1750
|
+
onKeyDown: function onKeyDown(e) {
|
|
1751
|
+
if (e.key === 'Enter' && !e.shiftKey && !e.ctrlKey && !e.metaKey) {
|
|
1752
|
+
e.preventDefault();
|
|
1753
|
+
_handleFormSubmit(e);
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
}) : /*#__PURE__*/React.createElement(Input, {
|
|
1757
|
+
size: "large",
|
|
1758
|
+
placeholder: accountPlaceholder,
|
|
1759
|
+
className: "login2-input",
|
|
1760
|
+
type: "email",
|
|
1761
|
+
autoComplete: "email",
|
|
1762
|
+
onKeyDown: function onKeyDown(e) {
|
|
1763
|
+
if (e.key === 'Enter' && !e.shiftKey && !e.ctrlKey && !e.metaKey) {
|
|
1764
|
+
e.preventDefault();
|
|
1765
|
+
_handleFormSubmit(e);
|
|
1766
|
+
}
|
|
1767
|
+
}
|
|
1768
|
+
})), /*#__PURE__*/React.createElement(Button, {
|
|
1769
|
+
type: "primary",
|
|
1770
|
+
size: "large",
|
|
1771
|
+
block: true,
|
|
1772
|
+
htmlType: "button",
|
|
1773
|
+
loading: loading,
|
|
1774
|
+
onClick: _handleFormSubmit,
|
|
1775
|
+
className: "login2-submit-button"
|
|
1776
|
+
}, isEmail ? locales.getText('pisell-login2-continue-with-email') : locales.getText('pisell-login2-continue-with-phone')));
|
|
1777
|
+
}
|
|
1778
|
+
|
|
1779
|
+
// 密码登录 - 单步完成
|
|
1780
|
+
return /*#__PURE__*/React.createElement(Form, {
|
|
1781
|
+
form: form,
|
|
1782
|
+
layout: "vertical",
|
|
1783
|
+
className: "login2-form",
|
|
1784
|
+
size: "large",
|
|
1785
|
+
onFinish: handleLogin
|
|
1786
|
+
}, isEmail && /*#__PURE__*/React.createElement("div", {
|
|
1787
|
+
style: {
|
|
1788
|
+
position: 'absolute',
|
|
1789
|
+
left: '-9999px',
|
|
1790
|
+
opacity: 0,
|
|
1791
|
+
pointerEvents: 'none'
|
|
1792
|
+
}
|
|
1793
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
1794
|
+
type: "text",
|
|
1795
|
+
name: "username",
|
|
1796
|
+
autoComplete: "username",
|
|
1797
|
+
tabIndex: -1,
|
|
1798
|
+
readOnly: true,
|
|
1799
|
+
"aria-hidden": "true"
|
|
1800
|
+
})), isEmail ? /*#__PURE__*/React.createElement(Form.Item, {
|
|
1801
|
+
label: accountLabel,
|
|
1802
|
+
name: accountFieldName,
|
|
1803
|
+
rules: accountRules,
|
|
1804
|
+
validateTrigger: ['onBlur', 'onSubmit']
|
|
1805
|
+
}, /*#__PURE__*/React.createElement(Input, {
|
|
1806
|
+
size: "large",
|
|
1807
|
+
placeholder: accountPlaceholder,
|
|
1808
|
+
className: "login2-input",
|
|
1809
|
+
type: "email",
|
|
1810
|
+
autoComplete: "email",
|
|
1811
|
+
value: getAccountValue() || enteredAccount || '',
|
|
1812
|
+
onChange: function onChange(e) {
|
|
1813
|
+
var newValue = e.target.value;
|
|
1814
|
+
setEnteredAccount(newValue);
|
|
1815
|
+
form.setFieldsValue(_defineProperty({}, accountFieldName, newValue));
|
|
1816
|
+
}
|
|
1817
|
+
})) : /*#__PURE__*/React.createElement(Form.Item, {
|
|
1818
|
+
label: accountLabel,
|
|
1819
|
+
name: accountFieldName,
|
|
1820
|
+
rules: accountRules,
|
|
1821
|
+
validateTrigger: ['onBlur', 'onSubmit']
|
|
1822
|
+
}, /*#__PURE__*/React.createElement(PhoneInput, {
|
|
1823
|
+
size: "large",
|
|
1824
|
+
placeholder: accountPlaceholder,
|
|
1825
|
+
className: "login2-phone-input",
|
|
1826
|
+
countries: countries,
|
|
1827
|
+
valueFormat: "object"
|
|
1828
|
+
})), /*#__PURE__*/React.createElement(Form.Item, {
|
|
1829
|
+
label: ((_config$ui8 = config.ui) === null || _config$ui8 === void 0 || (_config$ui8 = _config$ui8.formLabels) === null || _config$ui8 === void 0 || (_config$ui8 = _config$ui8.password) === null || _config$ui8 === void 0 ? void 0 : _config$ui8.show) !== false ? ((_config$ui9 = config.ui) === null || _config$ui9 === void 0 || (_config$ui9 = _config$ui9.formLabels) === null || _config$ui9 === void 0 || (_config$ui9 = _config$ui9.password) === null || _config$ui9 === void 0 ? void 0 : _config$ui9.text) || locales.getText('pisell-login2-password-label') : undefined,
|
|
1830
|
+
name: "password",
|
|
1831
|
+
rules: passwordValidationRules,
|
|
1832
|
+
validateTrigger: ['onBlur', 'onSubmit']
|
|
1833
|
+
}, /*#__PURE__*/React.createElement(Input.Password, {
|
|
1834
|
+
size: "large",
|
|
1835
|
+
placeholder: locales.getText('pisell-login2-password-placeholder'),
|
|
1836
|
+
className: "login2-input",
|
|
1837
|
+
name: "password",
|
|
1838
|
+
autoComplete: "current-password",
|
|
1839
|
+
type: "password"
|
|
1840
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
1841
|
+
className: "login2-form-footer"
|
|
1842
|
+
}, /*#__PURE__*/React.createElement(Form.Item, {
|
|
1843
|
+
name: "remember_me",
|
|
1844
|
+
valuePropName: "checked",
|
|
1845
|
+
noStyle: true
|
|
1846
|
+
}, /*#__PURE__*/React.createElement(Checkbox, null, locales.getText('pisell-login2-remember-me'))), currentVerificationMethod === 'password' && /*#__PURE__*/React.createElement("a", {
|
|
1847
|
+
className: "login2-link",
|
|
1848
|
+
onClick: handleForgotPasswordClick
|
|
1849
|
+
}, locales.getText('pisell-login2-forgot-password'))), /*#__PURE__*/React.createElement(Button, {
|
|
1850
|
+
type: "primary",
|
|
1851
|
+
size: "large",
|
|
1852
|
+
block: true,
|
|
1853
|
+
htmlType: "submit",
|
|
1854
|
+
loading: loading,
|
|
1855
|
+
onClick: handleLogin,
|
|
1856
|
+
className: "login2-submit-button"
|
|
1857
|
+
}, locales.getText('pisell-login2-login-button')));
|
|
1858
|
+
};
|
|
1859
|
+
|
|
1860
|
+
// 渲染底部切换选项区域
|
|
1861
|
+
var renderSwitchOptions = function renderSwitchOptions() {
|
|
1862
|
+
if (!currentLoginMethod) return null;
|
|
1863
|
+
var nonOauthButtons = [];
|
|
1864
|
+
if (currentLoginMethod.type === 'email' || currentLoginMethod.type === 'phone') {
|
|
1865
|
+
(currentLoginMethod.verificationMethods || []).filter(function (method) {
|
|
1866
|
+
return method !== currentVerificationMethod;
|
|
1867
|
+
}).forEach(function (method) {
|
|
1868
|
+
if (method === 'verification_code') {
|
|
1869
|
+
var text = currentLoginMethod.type === 'email' ? locales.getText('pisell-login2-switch-to-email-code') : locales.getText('pisell-login2-switch-to-sms-code');
|
|
1870
|
+
nonOauthButtons.push( /*#__PURE__*/React.createElement("button", {
|
|
1871
|
+
key: "switch-to-code",
|
|
1872
|
+
className: "login2-switch-option-button",
|
|
1873
|
+
onClick: function onClick() {
|
|
1874
|
+
return switchVerificationMethod('verification_code');
|
|
1875
|
+
}
|
|
1876
|
+
}, currentLoginMethod.type === 'email' ? /*#__PURE__*/React.createElement(Iconfont, {
|
|
1877
|
+
type: "pisell2-mail-01"
|
|
1878
|
+
}) : /*#__PURE__*/React.createElement(Iconfont, {
|
|
1879
|
+
type: "pisell2-phone"
|
|
1880
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
1881
|
+
className: "option-text"
|
|
1882
|
+
}, text)));
|
|
1883
|
+
} else {
|
|
1884
|
+
nonOauthButtons.push( /*#__PURE__*/React.createElement("button", {
|
|
1885
|
+
key: "switch-to-password",
|
|
1886
|
+
className: "login2-switch-option-button",
|
|
1887
|
+
onClick: function onClick() {
|
|
1888
|
+
return switchVerificationMethod('password');
|
|
1889
|
+
}
|
|
1890
|
+
}, /*#__PURE__*/React.createElement(Iconfont, {
|
|
1891
|
+
type: "pisell2-key-01"
|
|
1892
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
1893
|
+
className: "option-text"
|
|
1894
|
+
}, locales.getText('pisell-login2-switch-to-password'))));
|
|
1895
|
+
}
|
|
1896
|
+
});
|
|
1897
|
+
}
|
|
1898
|
+
loginMethods.forEach(function (method, index) {
|
|
1899
|
+
if (method.type === 'email' || method.type === 'phone') {
|
|
1900
|
+
if (method.type === currentLoginMethod.type) {
|
|
1901
|
+
return;
|
|
1902
|
+
}
|
|
1903
|
+
var isLast = isLastLoginMethod(method.type);
|
|
1904
|
+
var _className = classNames('login2-switch-option-button', {
|
|
1905
|
+
'has-last-login-badge': isLast
|
|
1906
|
+
});
|
|
1907
|
+
nonOauthButtons.push( /*#__PURE__*/React.createElement("button", {
|
|
1908
|
+
key: "".concat(method.type, "-").concat(index),
|
|
1909
|
+
className: _className,
|
|
1910
|
+
onClick: function onClick() {
|
|
1911
|
+
return switchLoginMethod(method);
|
|
1912
|
+
}
|
|
1913
|
+
}, isLast && /*#__PURE__*/React.createElement("div", {
|
|
1914
|
+
className: "last-login-badge"
|
|
1915
|
+
}, locales.getText('pisell-login2-last-login-badge')), /*#__PURE__*/React.createElement(Iconfont, {
|
|
1916
|
+
type: method.type === 'email' ? 'pisell2-mail-01' : 'pisell2-phone'
|
|
1917
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
1918
|
+
className: "option-text"
|
|
1919
|
+
}, method.type === 'email' ? locales.getText('pisell-login2-switch-to-email') : locales.getText('pisell-login2-switch-to-phone'))));
|
|
1920
|
+
}
|
|
1921
|
+
});
|
|
1922
|
+
var showDivider = nonOauthButtons.length > 0 && oauthProviders.length > 0;
|
|
1923
|
+
var registerPrompt = onSwitchToRegister && /*#__PURE__*/React.createElement("div", {
|
|
1924
|
+
className: "login2-register-prompt"
|
|
1925
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
1926
|
+
className: "register-prompt-text"
|
|
1927
|
+
}, locales.getText('pisell-login2-no-account')), /*#__PURE__*/React.createElement("button", {
|
|
1928
|
+
className: "register-prompt-link",
|
|
1929
|
+
onClick: onSwitchToRegister
|
|
1930
|
+
}, locales.getText('pisell-login2-register-link')));
|
|
1931
|
+
if (!nonOauthButtons.length && !oauthProviders.length) {
|
|
1932
|
+
return registerPrompt;
|
|
1933
|
+
}
|
|
1934
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, showDivider && /*#__PURE__*/React.createElement("div", {
|
|
1935
|
+
className: "login2-divider"
|
|
1936
|
+
}, locales.getText('pisell-login2-or')), nonOauthButtons.length > 0 && /*#__PURE__*/React.createElement("div", {
|
|
1937
|
+
className: "login2-switch-options"
|
|
1938
|
+
}, nonOauthButtons), oauthProviders.length > 0 && /*#__PURE__*/React.createElement(OAuthButtonGroup, {
|
|
1939
|
+
providers: oauthProviders,
|
|
1940
|
+
wrapperClassName: "login2-oauth-buttons",
|
|
1941
|
+
buttonClassName: "login2-oauth-button",
|
|
1942
|
+
gap: 12
|
|
1943
|
+
}), registerPrompt);
|
|
1944
|
+
};
|
|
1945
|
+
|
|
1946
|
+
// 渲染 OAuth 按钮
|
|
1947
|
+
if (!visible) {
|
|
1948
|
+
return null;
|
|
1949
|
+
}
|
|
1950
|
+
var ui = config.ui;
|
|
1951
|
+
|
|
1952
|
+
// 如果是邮件链接验证模式,显示相应的页面
|
|
1953
|
+
if (isEmailLinkVerification) {
|
|
1954
|
+
if (emailLinkVerifyStatus === 'verifying') {
|
|
1955
|
+
// 显示验证中页面
|
|
1956
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
1957
|
+
className: classNames('login2-container', className),
|
|
1958
|
+
style: _objectSpread(_objectSpread({}, style), {}, {
|
|
1959
|
+
'--theme-color': (ui === null || ui === void 0 ? void 0 : ui.themeColor) || '#7F56D9'
|
|
1960
|
+
})
|
|
1961
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
1962
|
+
className: "login2-email-link-verifying"
|
|
1963
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
1964
|
+
className: "verifying-content"
|
|
1965
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
1966
|
+
className: "verifying-icon"
|
|
1967
|
+
}, /*#__PURE__*/React.createElement(Iconfont, {
|
|
1968
|
+
type: "icon-loading",
|
|
1969
|
+
spin: true
|
|
1970
|
+
})), /*#__PURE__*/React.createElement("h2", {
|
|
1971
|
+
className: "verifying-title"
|
|
1972
|
+
}, "Verifying your email..."), /*#__PURE__*/React.createElement("p", {
|
|
1973
|
+
className: "verifying-desc"
|
|
1974
|
+
}, "Please wait while we verify your email link."))));
|
|
1975
|
+
}
|
|
1976
|
+
if (emailLinkVerifyStatus === 'success') {
|
|
1977
|
+
// 验证成功,显示重置密码页面
|
|
1978
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
1979
|
+
className: classNames('login2-container', className),
|
|
1980
|
+
style: _objectSpread(_objectSpread({}, style), {}, {
|
|
1981
|
+
'--theme-color': (ui === null || ui === void 0 ? void 0 : ui.themeColor) || '#7F56D9'
|
|
1982
|
+
})
|
|
1983
|
+
}, /*#__PURE__*/React.createElement(SetPassword, {
|
|
1984
|
+
scenario: "reset",
|
|
1985
|
+
flowData: {
|
|
1986
|
+
account: resetPasswordUserEmail || '',
|
|
1987
|
+
accountType: 'email',
|
|
1988
|
+
verificationMethod: 'verification_code'
|
|
1989
|
+
},
|
|
1990
|
+
onSubmit: ( /*#__PURE__*/function () {
|
|
1991
|
+
var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(password, confirmPassword) {
|
|
1992
|
+
var result, emailMethod;
|
|
1993
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
1994
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1995
|
+
case 0:
|
|
1996
|
+
_context14.prev = 0;
|
|
1997
|
+
if (!(registerAndLogin !== null && registerAndLogin !== void 0 && registerAndLogin.resetPasswordByCode)) {
|
|
1998
|
+
_context14.next = 8;
|
|
1999
|
+
break;
|
|
2000
|
+
}
|
|
2001
|
+
_context14.next = 4;
|
|
2002
|
+
return registerAndLogin.resetPasswordByCode({
|
|
2003
|
+
code: config.emailLinkVerification.code,
|
|
2004
|
+
password: password
|
|
2005
|
+
});
|
|
2006
|
+
case 4:
|
|
2007
|
+
result = _context14.sent;
|
|
2008
|
+
if (result.status) {
|
|
2009
|
+
message.success('密码重置成功');
|
|
2010
|
+
// 重置状态
|
|
2011
|
+
setEmailLinkVerifyStatus(null);
|
|
2012
|
+
setEmailLinkError('');
|
|
2013
|
+
|
|
2014
|
+
// 根据用户邮箱自动切换到邮箱登录并预填充
|
|
2015
|
+
if (resetPasswordUserEmail) {
|
|
2016
|
+
// 切换到邮箱登录方式
|
|
2017
|
+
emailMethod = config.loginMethods.find(function (method) {
|
|
2018
|
+
return method.type === 'email';
|
|
2019
|
+
});
|
|
2020
|
+
if (emailMethod) {
|
|
2021
|
+
setCurrentLoginMethod(emailMethod);
|
|
2022
|
+
setCurrentVerificationMethod(emailMethod.verificationMethods[0]);
|
|
2023
|
+
}
|
|
2024
|
+
|
|
2025
|
+
// 预填充邮箱到表单
|
|
2026
|
+
form.setFieldsValue({
|
|
2027
|
+
email: resetPasswordUserEmail
|
|
2028
|
+
});
|
|
2029
|
+
setEnteredAccount(resetPasswordUserEmail);
|
|
2030
|
+
|
|
2031
|
+
// 重置登录步骤到账号输入页面
|
|
2032
|
+
setLoginStep('account');
|
|
2033
|
+
}
|
|
2034
|
+
} else {
|
|
2035
|
+
message.error(result.message || '密码重置失败');
|
|
2036
|
+
}
|
|
2037
|
+
_context14.next = 9;
|
|
2038
|
+
break;
|
|
2039
|
+
case 8:
|
|
2040
|
+
message.error('系统错误,请稍后重试');
|
|
2041
|
+
case 9:
|
|
2042
|
+
_context14.next = 14;
|
|
2043
|
+
break;
|
|
2044
|
+
case 11:
|
|
2045
|
+
_context14.prev = 11;
|
|
2046
|
+
_context14.t0 = _context14["catch"](0);
|
|
2047
|
+
message.error((_context14.t0 === null || _context14.t0 === void 0 ? void 0 : _context14.t0.message) || '密码重置失败');
|
|
2048
|
+
case 14:
|
|
2049
|
+
case "end":
|
|
2050
|
+
return _context14.stop();
|
|
2051
|
+
}
|
|
2052
|
+
}, _callee14, null, [[0, 11]]);
|
|
2053
|
+
}));
|
|
2054
|
+
return function (_x13, _x14) {
|
|
2055
|
+
return _ref15.apply(this, arguments);
|
|
2056
|
+
};
|
|
2057
|
+
}()),
|
|
2058
|
+
onBack: function onBack() {
|
|
2059
|
+
setEmailLinkVerifyStatus(null);
|
|
2060
|
+
setEmailLinkError('');
|
|
2061
|
+
},
|
|
2062
|
+
loading: loading
|
|
2063
|
+
}));
|
|
2064
|
+
}
|
|
2065
|
+
if (emailLinkVerifyStatus === 'error') {
|
|
2066
|
+
// 显示错误页面
|
|
2067
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
2068
|
+
className: classNames('login2-container', className),
|
|
2069
|
+
style: _objectSpread(_objectSpread({}, style), {}, {
|
|
2070
|
+
'--theme-color': (ui === null || ui === void 0 ? void 0 : ui.themeColor) || '#7F56D9'
|
|
2071
|
+
})
|
|
2072
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
2073
|
+
className: "login2-email-link-error"
|
|
2074
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
2075
|
+
className: "error-content"
|
|
2076
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
2077
|
+
className: "error-icon"
|
|
2078
|
+
}, /*#__PURE__*/React.createElement(Iconfont, {
|
|
2079
|
+
type: "icon-error"
|
|
2080
|
+
})), /*#__PURE__*/React.createElement("h2", {
|
|
2081
|
+
className: "error-title"
|
|
2082
|
+
}, locales.getText('pisell-login2-verification-failed-title')), /*#__PURE__*/React.createElement("p", {
|
|
2083
|
+
className: "error-desc"
|
|
2084
|
+
}, emailLinkError), /*#__PURE__*/React.createElement(Button, {
|
|
2085
|
+
type: "primary",
|
|
2086
|
+
size: "large",
|
|
2087
|
+
block: true,
|
|
2088
|
+
className: "login2-error-main-button",
|
|
2089
|
+
onClick: function onClick() {
|
|
2090
|
+
setEmailLinkVerifyStatus(null);
|
|
2091
|
+
setEmailLinkError('');
|
|
2092
|
+
}
|
|
2093
|
+
}, locales.getText('pisell-login2-login-button')))));
|
|
2094
|
+
}
|
|
2095
|
+
}
|
|
2096
|
+
|
|
2097
|
+
// 如果显示忘记密码流程
|
|
2098
|
+
if (showForgotPassword) {
|
|
2099
|
+
var accountType = (currentLoginMethod === null || currentLoginMethod === void 0 ? void 0 : currentLoginMethod.type) === 'email' ? 'email' : 'phone';
|
|
2100
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
2101
|
+
className: classNames('login2-container', className),
|
|
2102
|
+
style: _objectSpread(_objectSpread({}, style), {}, {
|
|
2103
|
+
'--theme-color': (ui === null || ui === void 0 ? void 0 : ui.themeColor) || '#7F56D9'
|
|
2104
|
+
})
|
|
2105
|
+
}, /*#__PURE__*/React.createElement(ForgotPasswordFlow, {
|
|
2106
|
+
initialEmail: enteredAccount,
|
|
2107
|
+
accountType: accountType,
|
|
2108
|
+
onSendCode: handleForgotPasswordSendCode,
|
|
2109
|
+
onVerifyCode: handleForgotPasswordVerifyCode,
|
|
2110
|
+
onResetPassword: isEmailLinkVerification ? handleEmailLinkResetPassword : handleForgotPasswordReset,
|
|
2111
|
+
onSendResetLink: handleForgotPasswordSendLink,
|
|
2112
|
+
onBack: handleCloseForgotPassword,
|
|
2113
|
+
loading: loading,
|
|
2114
|
+
countdown: countdown,
|
|
2115
|
+
countries: countries
|
|
2116
|
+
}));
|
|
2117
|
+
}
|
|
2118
|
+
|
|
2119
|
+
// 如果在验证码输入步骤,显示验证码输入页面
|
|
2120
|
+
if (loginStep === 'code') {
|
|
2121
|
+
var _accountType = (currentLoginMethod === null || currentLoginMethod === void 0 ? void 0 : currentLoginMethod.type) === 'email' ? 'email' : 'phone';
|
|
2122
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
2123
|
+
className: classNames('login2-container', className),
|
|
2124
|
+
style: _objectSpread(_objectSpread({}, style), {}, {
|
|
2125
|
+
'--theme-color': (ui === null || ui === void 0 ? void 0 : ui.themeColor) || '#7F56D9'
|
|
2126
|
+
})
|
|
2127
|
+
}, /*#__PURE__*/React.createElement(LoginCodeInput, {
|
|
2128
|
+
account: typeof enteredAccount === 'string' ? enteredAccount : enteredAccount.phone,
|
|
2129
|
+
accountType: _accountType,
|
|
2130
|
+
codeLength: 4,
|
|
2131
|
+
onSubmit: handleCodeSubmit,
|
|
2132
|
+
onResend: handleSendCode,
|
|
2133
|
+
onBack: handleBackFromCode,
|
|
2134
|
+
countdown: countdown,
|
|
2135
|
+
loading: loading,
|
|
2136
|
+
error: codeError,
|
|
2137
|
+
onClearError: function onClearError() {
|
|
2138
|
+
return setCodeError('');
|
|
2139
|
+
}
|
|
2140
|
+
}));
|
|
2141
|
+
}
|
|
2142
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
2143
|
+
className: classNames('login2-container', 'register2-container', className),
|
|
2144
|
+
style: _objectSpread(_objectSpread({}, style), {}, {
|
|
2145
|
+
'--theme-color': (ui === null || ui === void 0 ? void 0 : ui.themeColor) || '#7F56D9'
|
|
2146
|
+
})
|
|
2147
|
+
}, /*#__PURE__*/React.createElement(Header, {
|
|
2148
|
+
ui: ui
|
|
2149
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
2150
|
+
className: "login2-content"
|
|
2151
|
+
}, renderMainLoginForm(), renderSwitchOptions()), /*#__PURE__*/React.createElement(LegalTerms, {
|
|
2152
|
+
config: _objectSpread(_objectSpread({}, config.legalTerms), {}, {
|
|
2153
|
+
mode: 'login'
|
|
2154
|
+
})
|
|
2155
|
+
}));
|
|
2156
|
+
};
|
|
2157
|
+
export default Login2;
|