@pisell/private-materials 6.11.192 → 6.11.193

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.
@@ -32,7 +32,8 @@ var WebPosLogin = function WebPosLogin(props) {
32
32
  getApp = _context$appHelper$ut2 === void 0 ? function () {
33
33
  return {};
34
34
  } : _context$appHelper$ut2,
35
- reloadAfterLogin = _context$appHelper$ut.reloadAfterLogin;
35
+ reloadAfterLogin = _context$appHelper$ut.reloadAfterLogin,
36
+ pisellos = _context$appHelper$ut.pisellos;
36
37
  var _context$appHelper$co = (_context$appHelper2 = context.appHelper) === null || _context$appHelper2 === void 0 ? void 0 : _context$appHelper2.constants,
37
38
  mediaConfig = _context$appHelper$co.mediaConfig,
38
39
  isIotLogin = _context$appHelper$co.isIotLogin;
@@ -226,6 +227,8 @@ var WebPosLogin = function WebPosLogin(props) {
226
227
  var _shopInfo$tenant, _app$logger;
227
228
  var isShowGoBack,
228
229
  app,
230
+ _pisellos$server,
231
+ _pisellos$server$clea,
229
232
  _app$storage9,
230
233
  _res$mypisell_data,
231
234
  _app$getPlugin2,
@@ -246,7 +249,19 @@ var WebPosLogin = function WebPosLogin(props) {
246
249
  while (1) switch (_context2.prev = _context2.next) {
247
250
  case 0:
248
251
  isShowGoBack = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : true;
249
- app = getApp(); // 如果是iot登录流程,需要判定一下店铺id是否发生变动,如果发生变动需要清除已经选择的设备信息
252
+ app = getApp();
253
+ if (!(lastUsedStoreId !== shopInfo.id)) {
254
+ _context2.next = 6;
255
+ break;
256
+ }
257
+ _context2.next = 5;
258
+ return (_pisellos$server = pisellos.server) === null || _pisellos$server === void 0 || (_pisellos$server$clea = _pisellos$server.clearAllIndexDB) === null || _pisellos$server$clea === void 0 ? void 0 : _pisellos$server$clea.call(_pisellos$server);
259
+ case 5:
260
+ if (pisellos.server) {
261
+ pisellos.server = null;
262
+ }
263
+ case 6:
264
+ // 如果是iot登录流程,需要判定一下店铺id是否发生变动,如果发生变动需要清除已经选择的设备信息
250
265
  if (isIotLogin) {
251
266
  if (lastUsedStoreId !== shopInfo.id) {
252
267
  app === null || app === void 0 || (_app$storage9 = app.storage) === null || _app$storage9 === void 0 || _app$storage9.removeStorage('iotDevice');
@@ -261,38 +276,38 @@ var WebPosLogin = function WebPosLogin(props) {
261
276
  title: '选择店铺页-点击店铺',
262
277
  metadata: shopInfo || {}
263
278
  });
264
- _context2.prev = 8;
265
- _context2.next = 11;
279
+ _context2.prev = 12;
280
+ _context2.next = 15;
266
281
  return getTenantDetail();
267
- case 11:
282
+ case 15:
268
283
  res = _context2.sent;
269
284
  if (res) {
270
- _context2.next = 14;
285
+ _context2.next = 18;
271
286
  break;
272
287
  }
273
288
  return _context2.abrupt("return");
274
- case 14:
289
+ case 18:
275
290
  if (res !== null && res !== void 0 && (_res$mypisell_data = res.mypisell_data) !== null && _res$mypisell_data !== void 0 && _res$mypisell_data.account_token) {
276
- _context2.next = 17;
291
+ _context2.next = 21;
277
292
  break;
278
293
  }
279
294
  PisellToast({
280
295
  content: locales.getText('webpos-login-store-data-missing')
281
296
  });
282
297
  return _context2.abrupt("return");
283
- case 17:
298
+ case 21:
284
299
  app === null || app === void 0 || (_app$getPlugin2 = app.getPlugin('token')) === null || _app$getPlugin2 === void 0 || _app$getPlugin2.set(res === null || res === void 0 || (_res$mypisell_data2 = res.mypisell_data) === null || _res$mypisell_data2 === void 0 ? void 0 : _res$mypisell_data2.account_token, 'pisellV1Token');
285
300
  if (res.nocobase_tenant_token) {
286
301
  app === null || app === void 0 || (_app$getPlugin3 = app.getPlugin('token')) === null || _app$getPlugin3 === void 0 || _app$getPlugin3.set(res.nocobase_tenant_token, 'nocobaseToken');
287
302
  }
288
303
  if (!isIotLogin) {
289
- _context2.next = 29;
304
+ _context2.next = 33;
290
305
  break;
291
306
  }
292
307
  // 如果本地已经存在了设备了,直接进入页面不再重新选择设备
293
308
  _iotDeviceNumber = (_JSON$parse3 = JSON.parse((app === null || app === void 0 || (_app$storage10 = app.storage) === null || _app$storage10 === void 0 ? void 0 : _app$storage10.getStorage('iotDevice')) || '{}')) === null || _JSON$parse3 === void 0 ? void 0 : _JSON$parse3.number;
294
309
  if (!_iotDeviceNumber) {
295
- _context2.next = 26;
310
+ _context2.next = 30;
296
311
  break;
297
312
  }
298
313
  // 从路由中获取参数判定是否是从pin弹窗跳转而来,如果是选择后直接进入主页
@@ -305,14 +320,14 @@ var WebPosLogin = function WebPosLogin(props) {
305
320
  app === null || app === void 0 || (_app$history = app.history) === null || _app$history === void 0 || (_app$history = _app$history.instance) === null || _app$history === void 0 || _app$history.replace('/');
306
321
  }
307
322
  return _context2.abrupt("return");
308
- case 26:
323
+ case 30:
309
324
  setStep('device');
310
- _context2.next = 31;
325
+ _context2.next = 35;
311
326
  break;
312
- case 29:
313
- _context2.next = 31;
327
+ case 33:
328
+ _context2.next = 35;
314
329
  return getDeviceListFunction();
315
- case 31:
330
+ case 35:
316
331
  setIsShowGoBack(isShowGoBack);
317
332
  // 保存店铺信息
318
333
  // app?.storage.setStorage("shopInfo", JSON.stringify(res || {}));
@@ -321,21 +336,21 @@ var WebPosLogin = function WebPosLogin(props) {
321
336
  title: '选择店铺页-选择店铺成功',
322
337
  metadata: res || {}
323
338
  });
324
- _context2.next = 38;
339
+ _context2.next = 42;
325
340
  break;
326
- case 35:
327
- _context2.prev = 35;
328
- _context2.t0 = _context2["catch"](8);
341
+ case 39:
342
+ _context2.prev = 39;
343
+ _context2.t0 = _context2["catch"](12);
329
344
  app === null || app === void 0 || (_app$logger3 = app.logger) === null || _app$logger3 === void 0 || _app$logger3.addLog({
330
345
  type: 'error',
331
346
  title: '登录页-选择店铺失败',
332
347
  metadata: _context2.t0 || {}
333
348
  });
334
- case 38:
349
+ case 42:
335
350
  case "end":
336
351
  return _context2.stop();
337
352
  }
338
- }, _callee2, null, [[8, 35]]);
353
+ }, _callee2, null, [[12, 39]]);
339
354
  }));
340
355
  return function handleStoreSelect(_x2) {
341
356
  return _ref2.apply(this, arguments);
@@ -46,7 +46,11 @@ var useSearchParams = () => {
46
46
  var WebPosLogin = (props) => {
47
47
  var _a, _b, _c, _d, _e, _f;
48
48
  const context = (0, import_useEngineContext.default)();
49
- const { getApp = () => ({}), reloadAfterLogin } = (_a = context.appHelper) == null ? void 0 : _a.utils;
49
+ const {
50
+ getApp = () => ({}),
51
+ reloadAfterLogin,
52
+ pisellos
53
+ } = (_a = context.appHelper) == null ? void 0 : _a.utils;
50
54
  const { mediaConfig, isIotLogin } = (_b = context.appHelper) == null ? void 0 : _b.constants;
51
55
  const {
52
56
  backgroundImage,
@@ -145,18 +149,24 @@ var WebPosLogin = (props) => {
145
149
  }
146
150
  };
147
151
  const handleStoreSelect = async (shopInfo, isShowGoBack2 = true) => {
148
- var _a2, _b2, _c2, _d2, _e2, _f2, _g, _h, _i, _j, _k, _l, _m, _n, _o;
152
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
149
153
  const app = getApp();
154
+ if (lastUsedStoreId !== shopInfo.id) {
155
+ await ((_b2 = (_a2 = pisellos.server) == null ? void 0 : _a2.clearAllIndexDB) == null ? void 0 : _b2.call(_a2));
156
+ if (pisellos.server) {
157
+ pisellos.server = null;
158
+ }
159
+ }
150
160
  if (isIotLogin) {
151
161
  if (lastUsedStoreId !== shopInfo.id) {
152
- (_a2 = app == null ? void 0 : app.storage) == null ? void 0 : _a2.removeStorage("iotDevice");
162
+ (_c2 = app == null ? void 0 : app.storage) == null ? void 0 : _c2.removeStorage("iotDevice");
153
163
  }
154
164
  }
155
- app.storage.setStorage("tenant_domain", (_b2 = shopInfo == null ? void 0 : shopInfo.tenant) == null ? void 0 : _b2.default_domain);
165
+ app.storage.setStorage("tenant_domain", (_d2 = shopInfo == null ? void 0 : shopInfo.tenant) == null ? void 0 : _d2.default_domain);
156
166
  app.storage.setStorage("selectedStore", JSON.stringify(shopInfo));
157
167
  setLastUsedStoreId(shopInfo.id);
158
168
  setSelectedStore(shopInfo);
159
- (_c2 = app == null ? void 0 : app.logger) == null ? void 0 : _c2.addLog({
169
+ (_e2 = app == null ? void 0 : app.logger) == null ? void 0 : _e2.addLog({
160
170
  type: "info",
161
171
  title: "选择店铺页-点击店铺",
162
172
  metadata: shopInfo || {}
@@ -166,28 +176,28 @@ var WebPosLogin = (props) => {
166
176
  if (!res) {
167
177
  return;
168
178
  }
169
- if (!((_d2 = res == null ? void 0 : res.mypisell_data) == null ? void 0 : _d2.account_token)) {
179
+ if (!((_f2 = res == null ? void 0 : res.mypisell_data) == null ? void 0 : _f2.account_token)) {
170
180
  (0, import_materials.PisellToast)({
171
181
  content: import_utils.locales.getText("webpos-login-store-data-missing")
172
182
  });
173
183
  return;
174
184
  }
175
- (_f2 = app == null ? void 0 : app.getPlugin("token")) == null ? void 0 : _f2.set((_e2 = res == null ? void 0 : res.mypisell_data) == null ? void 0 : _e2.account_token, "pisellV1Token");
185
+ (_h = app == null ? void 0 : app.getPlugin("token")) == null ? void 0 : _h.set((_g = res == null ? void 0 : res.mypisell_data) == null ? void 0 : _g.account_token, "pisellV1Token");
176
186
  if (res.nocobase_tenant_token) {
177
- (_g = app == null ? void 0 : app.getPlugin("token")) == null ? void 0 : _g.set(res.nocobase_tenant_token, "nocobaseToken");
187
+ (_i = app == null ? void 0 : app.getPlugin("token")) == null ? void 0 : _i.set(res.nocobase_tenant_token, "nocobaseToken");
178
188
  }
179
189
  if (isIotLogin) {
180
- const _iotDeviceNumber = (_i = JSON.parse(
181
- ((_h = app == null ? void 0 : app.storage) == null ? void 0 : _h.getStorage("iotDevice")) || "{}"
182
- )) == null ? void 0 : _i.number;
190
+ const _iotDeviceNumber = (_k = JSON.parse(
191
+ ((_j = app == null ? void 0 : app.storage) == null ? void 0 : _j.getStorage("iotDevice")) || "{}"
192
+ )) == null ? void 0 : _k.number;
183
193
  if (_iotDeviceNumber) {
184
- const _pageSource = (_j = useSearchParams()) == null ? void 0 : _j.get("pageSource");
194
+ const _pageSource = (_l = useSearchParams()) == null ? void 0 : _l.get("pageSource");
185
195
  console.log(_pageSource, "pageSource");
186
196
  if (_pageSource !== "pinLoginStore") {
187
- (_k = app == null ? void 0 : app.storage) == null ? void 0 : _k.setStorage("isLogin", true);
197
+ (_m = app == null ? void 0 : app.storage) == null ? void 0 : _m.setStorage("isLogin", true);
188
198
  reloadAfterLogin == null ? void 0 : reloadAfterLogin();
189
199
  } else {
190
- (_m = (_l = app == null ? void 0 : app.history) == null ? void 0 : _l.instance) == null ? void 0 : _m.replace("/");
200
+ (_o = (_n = app == null ? void 0 : app.history) == null ? void 0 : _n.instance) == null ? void 0 : _o.replace("/");
191
201
  }
192
202
  return;
193
203
  }
@@ -196,13 +206,13 @@ var WebPosLogin = (props) => {
196
206
  await getDeviceListFunction();
197
207
  }
198
208
  setIsShowGoBack(isShowGoBack2);
199
- (_n = app == null ? void 0 : app.logger) == null ? void 0 : _n.addLog({
209
+ (_p = app == null ? void 0 : app.logger) == null ? void 0 : _p.addLog({
200
210
  type: "info",
201
211
  title: "选择店铺页-选择店铺成功",
202
212
  metadata: res || {}
203
213
  });
204
214
  } catch (err) {
205
- (_o = app == null ? void 0 : app.logger) == null ? void 0 : _o.addLog({
215
+ (_q = app == null ? void 0 : app.logger) == null ? void 0 : _q.addLog({
206
216
  type: "error",
207
217
  title: "登录页-选择店铺失败",
208
218
  metadata: err || {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/private-materials",
3
- "version": "6.11.192",
3
+ "version": "6.11.193",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -67,10 +67,10 @@
67
67
  "react-infinite-scroll-component": "^6.1.0",
68
68
  "react-resizable": "^3.0.5",
69
69
  "styled-components": "^6.0.0-rc.3",
70
- "@pisell/utils": "3.0.2",
71
70
  "@pisell/materials": "6.11.59",
71
+ "@pisell/date-picker": "3.0.8",
72
72
  "@pisell/icon": "0.0.11",
73
- "@pisell/date-picker": "3.0.8"
73
+ "@pisell/utils": "3.0.2"
74
74
  },
75
75
  "peerDependencies": {
76
76
  "react": "^18.0.0",