@pisell/pisellos 0.0.341 → 0.0.343
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/solution/RegisterAndLogin/config.js +2 -4
- package/dist/solution/RegisterAndLogin/index.d.ts +1 -0
- package/dist/solution/RegisterAndLogin/index.js +44 -12
- package/dist/solution/RegisterAndLogin/types.d.ts +1 -0
- package/lib/solution/RegisterAndLogin/config.js +1 -3
- package/lib/solution/RegisterAndLogin/index.d.ts +1 -0
- package/lib/solution/RegisterAndLogin/index.js +22 -1
- package/lib/solution/RegisterAndLogin/types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -154,10 +154,8 @@ var onlineStoreConfig = {
|
|
|
154
154
|
guestLogin: {
|
|
155
155
|
url: '/auth/guest/login',
|
|
156
156
|
method: 'POST',
|
|
157
|
-
transformParams: function transformParams(
|
|
158
|
-
return
|
|
159
|
-
login_channel: channel
|
|
160
|
-
};
|
|
157
|
+
transformParams: function transformParams(params) {
|
|
158
|
+
return params;
|
|
161
159
|
}
|
|
162
160
|
},
|
|
163
161
|
checkEmailExists: {
|
|
@@ -106,6 +106,7 @@ export declare class RegisterAndLoginImpl extends BaseModule implements Module {
|
|
|
106
106
|
sendSmsLoginCode(params: SendSmsLoginCodeParams): Promise<ApiResponse>;
|
|
107
107
|
/** 手机号+短信验证码登录 */
|
|
108
108
|
phoneCodeLogin(params: PhoneCodeLoginParams): Promise<ApiResponse<LoginResponse>>;
|
|
109
|
+
private formatLoginParams;
|
|
109
110
|
/** Guest 登录 */
|
|
110
111
|
guestLogin(): Promise<ApiResponse<GuestLoginResponse>>;
|
|
111
112
|
/** 检查邮箱是否已注册 */
|
|
@@ -1671,12 +1671,28 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1671
1671
|
return _phoneCodeLogin.apply(this, arguments);
|
|
1672
1672
|
}
|
|
1673
1673
|
return phoneCodeLogin;
|
|
1674
|
-
}()
|
|
1674
|
+
}())
|
|
1675
|
+
}, {
|
|
1676
|
+
key: "formatLoginParams",
|
|
1677
|
+
value: function formatLoginParams(params) {
|
|
1678
|
+
// 获取当前浏览器窗口的 URL
|
|
1679
|
+
var currentUrl = this.window.location.href;
|
|
1680
|
+
// 使用 URL 对象解析 URL
|
|
1681
|
+
var urlObj = new URL(currentUrl || '');
|
|
1682
|
+
// 获取 customer 参数的值
|
|
1683
|
+
var source_customer_id = urlObj.searchParams.get('customer');
|
|
1684
|
+
if (source_customer_id) {
|
|
1685
|
+
params.source_customer_id = parseInt(source_customer_id);
|
|
1686
|
+
}
|
|
1687
|
+
return params;
|
|
1688
|
+
}
|
|
1689
|
+
|
|
1690
|
+
/** Guest 登录 */
|
|
1675
1691
|
}, {
|
|
1676
1692
|
key: "guestLogin",
|
|
1677
1693
|
value: (function () {
|
|
1678
1694
|
var _guestLogin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
|
|
1679
|
-
var response;
|
|
1695
|
+
var guestCode, param, response, _response$data7;
|
|
1680
1696
|
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
1681
1697
|
while (1) switch (_context25.prev = _context25.next) {
|
|
1682
1698
|
case 0:
|
|
@@ -1686,9 +1702,20 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1686
1702
|
this.core.effects.emit(RegisterAndLoginHooks.onLoginStarted, {
|
|
1687
1703
|
type: 'guest'
|
|
1688
1704
|
});
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1705
|
+
// 匿名登录 code
|
|
1706
|
+
guestCode = this.window.localStorage.getItem('guest_code') || '';
|
|
1707
|
+
param = {
|
|
1708
|
+
login_channel: this.channel
|
|
1709
|
+
};
|
|
1710
|
+
if (guestCode) {
|
|
1711
|
+
param.guest_code = guestCode;
|
|
1712
|
+
}
|
|
1713
|
+
|
|
1714
|
+
// 获取邀请id
|
|
1715
|
+
param = this.formatLoginParams(param);
|
|
1716
|
+
_context25.next = 10;
|
|
1717
|
+
return this.apiCaller.call('guestLogin', param);
|
|
1718
|
+
case 10:
|
|
1692
1719
|
response = _context25.sent;
|
|
1693
1720
|
if (response.status && response.data) {
|
|
1694
1721
|
// 保存用户信息和 token
|
|
@@ -1700,6 +1727,11 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1700
1727
|
if (response.data.refreshToken) {
|
|
1701
1728
|
this.store.refreshToken = response.data.refreshToken;
|
|
1702
1729
|
}
|
|
1730
|
+
|
|
1731
|
+
// 设置匿名登录code
|
|
1732
|
+
if ((_response$data7 = response.data) !== null && _response$data7 !== void 0 && (_response$data7 = _response$data7.customer) !== null && _response$data7 !== void 0 && _response$data7.guest_code) {
|
|
1733
|
+
this.window.localStorage.setItem('guest_code', response.data.customer.guest_code);
|
|
1734
|
+
}
|
|
1703
1735
|
this.core.effects.emit(RegisterAndLoginHooks.onLoginSuccess, {
|
|
1704
1736
|
user: response.data.user,
|
|
1705
1737
|
token: response.data.token,
|
|
@@ -1713,8 +1745,8 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1713
1745
|
});
|
|
1714
1746
|
}
|
|
1715
1747
|
return _context25.abrupt("return", response);
|
|
1716
|
-
case
|
|
1717
|
-
_context25.prev =
|
|
1748
|
+
case 15:
|
|
1749
|
+
_context25.prev = 15;
|
|
1718
1750
|
_context25.t0 = _context25["catch"](0);
|
|
1719
1751
|
this.store.error = 'Guest 登录失败';
|
|
1720
1752
|
this.core.effects.emit(RegisterAndLoginHooks.onLoginFailed, {
|
|
@@ -1722,15 +1754,15 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1722
1754
|
loginType: 'guest'
|
|
1723
1755
|
});
|
|
1724
1756
|
return _context25.abrupt("return", _context25.t0);
|
|
1725
|
-
case
|
|
1726
|
-
_context25.prev =
|
|
1757
|
+
case 20:
|
|
1758
|
+
_context25.prev = 20;
|
|
1727
1759
|
this.store.isLoading = false;
|
|
1728
|
-
return _context25.finish(
|
|
1729
|
-
case
|
|
1760
|
+
return _context25.finish(20);
|
|
1761
|
+
case 23:
|
|
1730
1762
|
case "end":
|
|
1731
1763
|
return _context25.stop();
|
|
1732
1764
|
}
|
|
1733
|
-
}, _callee25, this, [[0,
|
|
1765
|
+
}, _callee25, this, [[0, 15, 20, 23]]);
|
|
1734
1766
|
}));
|
|
1735
1767
|
function guestLogin() {
|
|
1736
1768
|
return _guestLogin.apply(this, arguments);
|
|
@@ -129,9 +129,7 @@ var onlineStoreConfig = {
|
|
|
129
129
|
guestLogin: {
|
|
130
130
|
url: "/auth/guest/login",
|
|
131
131
|
method: "POST",
|
|
132
|
-
transformParams: (
|
|
133
|
-
login_channel: channel
|
|
134
|
-
})
|
|
132
|
+
transformParams: (params) => params
|
|
135
133
|
},
|
|
136
134
|
checkEmailExists: {
|
|
137
135
|
url: "/auth/email/check-email",
|
|
@@ -106,6 +106,7 @@ export declare class RegisterAndLoginImpl extends BaseModule implements Module {
|
|
|
106
106
|
sendSmsLoginCode(params: SendSmsLoginCodeParams): Promise<ApiResponse>;
|
|
107
107
|
/** 手机号+短信验证码登录 */
|
|
108
108
|
phoneCodeLogin(params: PhoneCodeLoginParams): Promise<ApiResponse<LoginResponse>>;
|
|
109
|
+
private formatLoginParams;
|
|
109
110
|
/** Guest 登录 */
|
|
110
111
|
guestLogin(): Promise<ApiResponse<GuestLoginResponse>>;
|
|
111
112
|
/** 检查邮箱是否已注册 */
|
|
@@ -1015,15 +1015,33 @@ var RegisterAndLoginImpl = class extends import_BaseModule.BaseModule {
|
|
|
1015
1015
|
this.store.isLoading = false;
|
|
1016
1016
|
}
|
|
1017
1017
|
}
|
|
1018
|
+
formatLoginParams(params) {
|
|
1019
|
+
const currentUrl = this.window.location.href;
|
|
1020
|
+
let urlObj = new URL(currentUrl || "");
|
|
1021
|
+
let source_customer_id = urlObj.searchParams.get("customer");
|
|
1022
|
+
if (source_customer_id) {
|
|
1023
|
+
params.source_customer_id = parseInt(source_customer_id);
|
|
1024
|
+
}
|
|
1025
|
+
return params;
|
|
1026
|
+
}
|
|
1018
1027
|
/** Guest 登录 */
|
|
1019
1028
|
async guestLogin() {
|
|
1029
|
+
var _a, _b;
|
|
1020
1030
|
try {
|
|
1021
1031
|
this.store.isLoading = true;
|
|
1022
1032
|
this.store.error = null;
|
|
1023
1033
|
this.core.effects.emit(import_types.RegisterAndLoginHooks.onLoginStarted, {
|
|
1024
1034
|
type: "guest"
|
|
1025
1035
|
});
|
|
1026
|
-
|
|
1036
|
+
let guestCode = this.window.localStorage.getItem("guest_code") || "";
|
|
1037
|
+
let param = {
|
|
1038
|
+
login_channel: this.channel
|
|
1039
|
+
};
|
|
1040
|
+
if (guestCode) {
|
|
1041
|
+
param.guest_code = guestCode;
|
|
1042
|
+
}
|
|
1043
|
+
param = this.formatLoginParams(param);
|
|
1044
|
+
const response = await this.apiCaller.call("guestLogin", param);
|
|
1027
1045
|
if (response.status && response.data) {
|
|
1028
1046
|
this.store.isLoggedIn = true;
|
|
1029
1047
|
this.store.userInfo = response.data.user;
|
|
@@ -1031,6 +1049,9 @@ var RegisterAndLoginImpl = class extends import_BaseModule.BaseModule {
|
|
|
1031
1049
|
if (response.data.refreshToken) {
|
|
1032
1050
|
this.store.refreshToken = response.data.refreshToken;
|
|
1033
1051
|
}
|
|
1052
|
+
if ((_b = (_a = response.data) == null ? void 0 : _a.customer) == null ? void 0 : _b.guest_code) {
|
|
1053
|
+
this.window.localStorage.setItem("guest_code", response.data.customer.guest_code);
|
|
1054
|
+
}
|
|
1034
1055
|
this.core.effects.emit(import_types.RegisterAndLoginHooks.onLoginSuccess, {
|
|
1035
1056
|
user: response.data.user,
|
|
1036
1057
|
token: response.data.token,
|