@pisell/pisellos 0.0.340 → 0.0.342

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.
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "normal" | "duration" | "session";
52
+ getProductType(): "duration" | "session" | "normal";
53
53
  }
@@ -141,9 +141,16 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
141
141
  sortedList = (productsData.data.list || []).slice().sort(function (a, b) {
142
142
  return Number(b.sort) - Number(a.sort);
143
143
  });
144
+ if (sortedList.length) {
145
+ sortedList.forEach(function (n) {
146
+ if (n.is_eject !== 1 && n['schedule.ids'] && n['schedule.ids'].length) {
147
+ n.is_eject = 1;
148
+ }
149
+ });
150
+ }
144
151
  this.addProduct(sortedList);
145
152
  return _context3.abrupt("return", sortedList);
146
- case 10:
153
+ case 11:
147
154
  case "end":
148
155
  return _context3.stop();
149
156
  }
@@ -1197,7 +1197,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1197
1197
  date: date
1198
1198
  });
1199
1199
  // 如果 quantity 大于 1,且是预约商品,则进入购物车拆散成多条数据
1200
- if (addItemParams.quantity > 1 && !isNormalProduct(productData.origin)) {
1200
+ if (addItemParams.quantity > 1 && !isNormalProduct(productData)) {
1201
1201
  for (var i = 0; i < addItemParams.quantity; i++) {
1202
1202
  var newAddItemParams = cloneDeep(addItemParams);
1203
1203
  newAddItemParams.quantity = 1;
@@ -154,10 +154,8 @@ var onlineStoreConfig = {
154
154
  guestLogin: {
155
155
  url: '/auth/guest/login',
156
156
  method: 'POST',
157
- transformParams: function transformParams(channel) {
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
- }() /** Guest 登录 */)
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;
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
- _context25.next = 6;
1690
- return this.apiCaller.call('guestLogin', this.channel);
1691
- case 6:
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
@@ -1713,8 +1740,8 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
1713
1740
  });
1714
1741
  }
1715
1742
  return _context25.abrupt("return", response);
1716
- case 11:
1717
- _context25.prev = 11;
1743
+ case 15:
1744
+ _context25.prev = 15;
1718
1745
  _context25.t0 = _context25["catch"](0);
1719
1746
  this.store.error = 'Guest 登录失败';
1720
1747
  this.core.effects.emit(RegisterAndLoginHooks.onLoginFailed, {
@@ -1722,15 +1749,15 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
1722
1749
  loginType: 'guest'
1723
1750
  });
1724
1751
  return _context25.abrupt("return", _context25.t0);
1725
- case 16:
1726
- _context25.prev = 16;
1752
+ case 20:
1753
+ _context25.prev = 20;
1727
1754
  this.store.isLoading = false;
1728
- return _context25.finish(16);
1729
- case 19:
1755
+ return _context25.finish(20);
1756
+ case 23:
1730
1757
  case "end":
1731
1758
  return _context25.stop();
1732
1759
  }
1733
- }, _callee25, this, [[0, 11, 16, 19]]);
1760
+ }, _callee25, this, [[0, 15, 20, 23]]);
1734
1761
  }));
1735
1762
  function guestLogin() {
1736
1763
  return _guestLogin.apply(this, arguments);
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "normal" | "duration" | "session";
52
+ getProductType(): "duration" | "session" | "normal";
53
53
  }
@@ -103,6 +103,13 @@ var ProductList = class extends import_BaseModule.BaseModule {
103
103
  { useCache: true }
104
104
  );
105
105
  const sortedList = (productsData.data.list || []).slice().sort((a, b) => Number(b.sort) - Number(a.sort));
106
+ if (sortedList.length) {
107
+ sortedList.forEach((n) => {
108
+ if (n.is_eject !== 1 && n["schedule.ids"] && n["schedule.ids"].length) {
109
+ n.is_eject = 1;
110
+ }
111
+ });
112
+ }
106
113
  this.addProduct(sortedList);
107
114
  return sortedList;
108
115
  }
@@ -637,7 +637,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
637
637
  addItemParams.account = account;
638
638
  }
639
639
  this.addProductCheck({ date });
640
- if (addItemParams.quantity > 1 && !(0, import_utils5.isNormalProduct)(productData.origin)) {
640
+ if (addItemParams.quantity > 1 && !(0, import_utils5.isNormalProduct)(productData)) {
641
641
  for (let i = 0; i < addItemParams.quantity; i++) {
642
642
  const newAddItemParams = (0, import_lodash_es.cloneDeep)(addItemParams);
643
643
  newAddItemParams.quantity = 1;
@@ -122,6 +122,12 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
122
122
  throw error;
123
123
  }
124
124
  }
125
+ /**
126
+ * 初始化外设扫码结果监听
127
+ */
128
+ initPeripheralsListener() {
129
+ this.scan.initPeripheralsListener();
130
+ }
125
131
  /**
126
132
  * 获取商品列表(不加载到模块中)
127
133
  * @returns 商品列表
@@ -129,9 +129,7 @@ var onlineStoreConfig = {
129
129
  guestLogin: {
130
130
  url: "/auth/guest/login",
131
131
  method: "POST",
132
- transformParams: (channel) => ({
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,6 +1015,15 @@ 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() {
1020
1029
  try {
@@ -1023,7 +1032,15 @@ var RegisterAndLoginImpl = class extends import_BaseModule.BaseModule {
1023
1032
  this.core.effects.emit(import_types.RegisterAndLoginHooks.onLoginStarted, {
1024
1033
  type: "guest"
1025
1034
  });
1026
- const response = await this.apiCaller.call("guestLogin", this.channel);
1035
+ let guestCode = this.window.localStorage.getItem("guest_code") || "";
1036
+ let param = {
1037
+ login_channel: this.channel
1038
+ };
1039
+ if (guestCode) {
1040
+ param.guest_code = guestCode;
1041
+ }
1042
+ param = this.formatLoginParams(param);
1043
+ const response = await this.apiCaller.call("guestLogin", param);
1027
1044
  if (response.status && response.data) {
1028
1045
  this.store.isLoggedIn = true;
1029
1046
  this.store.userInfo = response.data.user;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.340",
4
+ "version": "0.0.342",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",