@pisell/private-materials 6.7.1 → 6.7.3

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.
Files changed (76) hide show
  1. package/build/lowcode/assets-daily.json +11 -11
  2. package/build/lowcode/assets-dev.json +2 -2
  3. package/build/lowcode/assets-prod.json +11 -11
  4. package/build/lowcode/index.js +1 -1
  5. package/build/lowcode/meta.js +2 -2
  6. package/build/lowcode/preview.js +7 -7
  7. package/build/lowcode/render/default/view.css +1 -1
  8. package/build/lowcode/render/default/view.js +2 -2
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +2 -2
  11. package/es/index.d.ts +1 -0
  12. package/es/index.js +2 -1
  13. package/es/plus/webPosLogin/WebPosLogin.d.ts +11 -0
  14. package/es/plus/webPosLogin/WebPosLogin.js +551 -0
  15. package/es/plus/webPosLogin/WebPosLoginCpt.d.ts +9 -0
  16. package/es/plus/webPosLogin/WebPosLoginCpt.js +170 -0
  17. package/es/plus/webPosLogin/WebPosLoginCpt.less +170 -0
  18. package/es/plus/webPosLogin/components/BrandPanel/index.d.ts +9 -0
  19. package/es/plus/webPosLogin/components/BrandPanel/index.js +52 -0
  20. package/es/plus/webPosLogin/components/BrandPanel/index.less +58 -0
  21. package/es/plus/webPosLogin/components/LoginPanel/index.d.ts +21 -0
  22. package/es/plus/webPosLogin/components/LoginPanel/index.js +73 -0
  23. package/es/plus/webPosLogin/components/LoginPanel/index.less +43 -0
  24. package/es/plus/webPosLogin/components/SelectDevice/index.d.ts +28 -0
  25. package/es/plus/webPosLogin/components/SelectDevice/index.js +258 -0
  26. package/es/plus/webPosLogin/components/SelectDevice/index.less +167 -0
  27. package/es/plus/webPosLogin/components/SelectStore/index.d.ts +24 -0
  28. package/es/plus/webPosLogin/components/SelectStore/index.js +198 -0
  29. package/es/plus/webPosLogin/components/SelectStore/index.less +157 -0
  30. package/es/plus/webPosLogin/components/UserFooter/index.d.ts +28 -0
  31. package/es/plus/webPosLogin/components/UserFooter/index.js +110 -0
  32. package/es/plus/webPosLogin/components/UserFooter/index.less +70 -0
  33. package/es/plus/webPosLogin/index.d.ts +12 -0
  34. package/es/plus/webPosLogin/index.js +15 -0
  35. package/es/plus/webPosLogin/locales.d.ts +49 -0
  36. package/es/plus/webPosLogin/locales.js +57 -0
  37. package/es/plus/webPosLogin/service.d.ts +44 -0
  38. package/es/plus/webPosLogin/service.js +198 -0
  39. package/es/plus/webPosLogin/types.d.ts +286 -0
  40. package/es/plus/webPosLogin/types.js +1 -0
  41. package/es/pro/Login2.0/Login2.js +9 -3
  42. package/es/pro/Login2.0/index.less +0 -12
  43. package/lib/index.d.ts +1 -0
  44. package/lib/index.js +3 -0
  45. package/lib/plus/webPosLogin/WebPosLogin.d.ts +11 -0
  46. package/lib/plus/webPosLogin/WebPosLogin.js +331 -0
  47. package/lib/plus/webPosLogin/WebPosLoginCpt.d.ts +9 -0
  48. package/lib/plus/webPosLogin/WebPosLoginCpt.js +170 -0
  49. package/lib/plus/webPosLogin/WebPosLoginCpt.less +170 -0
  50. package/lib/plus/webPosLogin/components/BrandPanel/index.d.ts +9 -0
  51. package/lib/plus/webPosLogin/components/BrandPanel/index.js +63 -0
  52. package/lib/plus/webPosLogin/components/BrandPanel/index.less +58 -0
  53. package/lib/plus/webPosLogin/components/LoginPanel/index.d.ts +21 -0
  54. package/lib/plus/webPosLogin/components/LoginPanel/index.js +98 -0
  55. package/lib/plus/webPosLogin/components/LoginPanel/index.less +43 -0
  56. package/lib/plus/webPosLogin/components/SelectDevice/index.d.ts +28 -0
  57. package/lib/plus/webPosLogin/components/SelectDevice/index.js +158 -0
  58. package/lib/plus/webPosLogin/components/SelectDevice/index.less +167 -0
  59. package/lib/plus/webPosLogin/components/SelectStore/index.d.ts +24 -0
  60. package/lib/plus/webPosLogin/components/SelectStore/index.js +123 -0
  61. package/lib/plus/webPosLogin/components/SelectStore/index.less +157 -0
  62. package/lib/plus/webPosLogin/components/UserFooter/index.d.ts +28 -0
  63. package/lib/plus/webPosLogin/components/UserFooter/index.js +91 -0
  64. package/lib/plus/webPosLogin/components/UserFooter/index.less +70 -0
  65. package/lib/plus/webPosLogin/index.d.ts +12 -0
  66. package/lib/plus/webPosLogin/index.js +56 -0
  67. package/lib/plus/webPosLogin/locales.d.ts +49 -0
  68. package/lib/plus/webPosLogin/locales.js +77 -0
  69. package/lib/plus/webPosLogin/service.d.ts +44 -0
  70. package/lib/plus/webPosLogin/service.js +94 -0
  71. package/lib/plus/webPosLogin/types.d.ts +286 -0
  72. package/lib/plus/webPosLogin/types.js +17 -0
  73. package/lib/pro/Login2.0/Login2.js +19 -9
  74. package/lib/pro/Login2.0/index.less +0 -12
  75. package/lowcode/web-pos-login/meta.ts +71 -0
  76. package/package.json +4 -4
package/es/index.d.ts CHANGED
@@ -69,3 +69,4 @@ export { default as ContactInfoModal } from './plus/contactInfoModal';
69
69
  export { Login2, Register2, AuthModal } from './pro/Login2.0';
70
70
  export { default as WalletEditor } from './plus/walletEditor';
71
71
  export { default as WalletPassGallery } from './plus/walletPassGallery';
72
+ export { default as WebPosLogin } from './plus/webPosLogin';
package/es/index.js CHANGED
@@ -71,4 +71,5 @@ export { default as ContactInfo } from "./plus/contactInfo";
71
71
  export { default as ContactInfoModal } from "./plus/contactInfoModal";
72
72
  export { Login2, Register2, AuthModal } from "./pro/Login2.0";
73
73
  export { default as WalletEditor } from "./plus/walletEditor";
74
- export { default as WalletPassGallery } from "./plus/walletPassGallery";
74
+ export { default as WalletPassGallery } from "./plus/walletPassGallery";
75
+ export { default as WebPosLogin } from "./plus/webPosLogin";
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { LoginStep } from './types';
3
+ export interface WebPosLoginProps {
4
+ className?: string;
5
+ style?: React.CSSProperties;
6
+ step?: LoginStep;
7
+ backgroundImage?: string;
8
+ [key: string]: any;
9
+ }
10
+ declare const WebPosLogin: (props: WebPosLoginProps) => JSX.Element;
11
+ export default WebPosLogin;
@@ -0,0 +1,551 @@
1
+ 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); }
2
+ 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; }
3
+ 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; }
4
+ 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; }
5
+ 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; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
+ 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); }
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 } from 'react';
17
+ import { PisellToast } from '@pisell/materials';
18
+ import { locales } from '@pisell/utils';
19
+ import WebPosLoginCpt from "./WebPosLoginCpt";
20
+ import useEngineContext from "../../hooks/useEngineContext";
21
+ import { dissociateDevice, getDeviceList, getTenant, getTenantDetail, selectDevice } from "./service";
22
+ import { request } from "../../utils";
23
+ var useSearchParams = function useSearchParams() {
24
+ return new URLSearchParams(window.location.search);
25
+ };
26
+ var WebPosLogin = function WebPosLogin(props) {
27
+ var _context$appHelper, _context$engine;
28
+ var context = useEngineContext();
29
+ var _context$appHelper$ut = (_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.utils,
30
+ _context$appHelper$ut2 = _context$appHelper$ut.getApp,
31
+ getApp = _context$appHelper$ut2 === void 0 ? function () {
32
+ return {};
33
+ } : _context$appHelper$ut2,
34
+ reloadAfterLogin = _context$appHelper$ut.reloadAfterLogin;
35
+ var backgroundImage = props.backgroundImage,
36
+ _props$step = props.step,
37
+ propsStep = _props$step === void 0 ? 'login' : _props$step,
38
+ config = props.config;
39
+ var _useState = useState(function () {
40
+ var _app$storage;
41
+ var app = getApp();
42
+ var storeList = app === null || app === void 0 || (_app$storage = app.storage) === null || _app$storage === void 0 ? void 0 : _app$storage.getStorage('storeList');
43
+ if (!storeList) {
44
+ return [];
45
+ }
46
+ return JSON.parse(storeList);
47
+ }),
48
+ _useState2 = _slicedToArray(_useState, 2),
49
+ storeList = _useState2[0],
50
+ setStoreList = _useState2[1];
51
+ // 优先取url 参数中的step,否则取props.step
52
+ var urlStep = useSearchParams().get('step');
53
+ // 当前步骤
54
+ var _useState3 = useState(function () {
55
+ if (urlStep && urlStep !== 'undefined') {
56
+ return urlStep;
57
+ }
58
+ return props.step || 'login';
59
+ }),
60
+ _useState4 = _slicedToArray(_useState3, 2),
61
+ step = _useState4[0],
62
+ setStep = _useState4[1];
63
+
64
+ // 当前用户信息
65
+ var _useState5 = useState(function () {
66
+ var _app$storage2;
67
+ var app = getApp();
68
+ var userInfo = (app === null || app === void 0 || (_app$storage2 = app.storage) === null || _app$storage2 === void 0 ? void 0 : _app$storage2.getStorage('userInfo')) || '{}';
69
+ var userInfoObj = JSON.parse(userInfo);
70
+ return {
71
+ name: (userInfoObj === null || userInfoObj === void 0 ? void 0 : userInfoObj.name) || '',
72
+ avatar: (userInfoObj === null || userInfoObj === void 0 ? void 0 : userInfoObj.avatar) || ''
73
+ };
74
+ }),
75
+ _useState6 = _slicedToArray(_useState5, 2),
76
+ userInfo = _useState6[0],
77
+ setUserInfo = _useState6[1];
78
+
79
+ // 当前选中的店铺
80
+ var _useState7 = useState(function () {
81
+ var _app$storage3;
82
+ var app = getApp();
83
+ var selectedStore = (app === null || app === void 0 || (_app$storage3 = app.storage) === null || _app$storage3 === void 0 ? void 0 : _app$storage3.getStorage('selectedStore')) || '{}';
84
+ return JSON.parse(selectedStore);
85
+ }),
86
+ _useState8 = _slicedToArray(_useState7, 2),
87
+ selectedStore = _useState8[0],
88
+ setSelectedStore = _useState8[1];
89
+
90
+ // 设备列表
91
+ var _useState9 = useState(function () {
92
+ var _app$storage4;
93
+ var app = getApp();
94
+ var deviceList = (app === null || app === void 0 || (_app$storage4 = app.storage) === null || _app$storage4 === void 0 ? void 0 : _app$storage4.getStorage('deviceList')) || '[]';
95
+ return JSON.parse(deviceList);
96
+ }),
97
+ _useState10 = _slicedToArray(_useState9, 2),
98
+ deviceList = _useState10[0],
99
+ setDeviceList = _useState10[1];
100
+
101
+ // 上次使用的店铺ID
102
+ var _useState11 = useState(function () {
103
+ var _app$storage5, _JSON$parse;
104
+ var app = getApp();
105
+ var lastUsedStore = (app === null || app === void 0 || (_app$storage5 = app.storage) === null || _app$storage5 === void 0 ? void 0 : _app$storage5.getStorage('selectedStore')) || '{}';
106
+ var lastUsedStoreId = ((_JSON$parse = JSON.parse(lastUsedStore)) === null || _JSON$parse === void 0 ? void 0 : _JSON$parse.id) || 0;
107
+ return parseInt(lastUsedStoreId);
108
+ }),
109
+ _useState12 = _slicedToArray(_useState11, 2),
110
+ lastUsedStoreId = _useState12[0],
111
+ setLastUsedStoreId = _useState12[1];
112
+
113
+ // 上次使用的设备ID
114
+ var _useState13 = useState(function () {
115
+ var _app$storage6, _JSON$parse2;
116
+ var app = getApp();
117
+ var lastUsedDevice = (app === null || app === void 0 || (_app$storage6 = app.storage) === null || _app$storage6 === void 0 ? void 0 : _app$storage6.getStorage('lastUsedDevice')) || '{}';
118
+ var lastUsedDeviceId = ((_JSON$parse2 = JSON.parse(lastUsedDevice)) === null || _JSON$parse2 === void 0 ? void 0 : _JSON$parse2.id) || 0;
119
+ return parseInt(lastUsedDeviceId);
120
+ }),
121
+ _useState14 = _slicedToArray(_useState13, 2),
122
+ lastUsedDeviceId = _useState14[0],
123
+ setLastUsedDeviceId = _useState14[1];
124
+
125
+ // 是否显示返回按钮
126
+ var _useState15 = useState(true),
127
+ _useState16 = _slicedToArray(_useState15, 2),
128
+ isShowGoBack = _useState16[0],
129
+ setIsShowGoBack = _useState16[1];
130
+ request.setRequest(context.appHelper.utils.request);
131
+
132
+ /**
133
+ * 登录成功
134
+ * @param res 登录信息
135
+ */
136
+ var onLoginSuccess = /*#__PURE__*/function () {
137
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(res) {
138
+ var _app$getPlugin, _app$storage7, _res$account, _res$account2, _app$storage8;
139
+ var app, tenant, lastUsedStore;
140
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
141
+ while (1) switch (_context.prev = _context.next) {
142
+ case 0:
143
+ app = getApp();
144
+ if (res) {
145
+ _context.next = 3;
146
+ break;
147
+ }
148
+ return _context.abrupt("return");
149
+ case 3:
150
+ // 保存登录信息,如果用户选择了店铺需要更新token
151
+ app === null || app === void 0 || (_app$getPlugin = app.getPlugin('token')) === null || _app$getPlugin === void 0 || _app$getPlugin.set(res === null || res === void 0 ? void 0 : res.authorization);
152
+ app === null || app === void 0 || (_app$storage7 = app.storage) === null || _app$storage7 === void 0 || _app$storage7.setStorage('account', JSON.stringify(_objectSpread(_objectSpread({}, res === null || res === void 0 ? void 0 : res.account), res)));
153
+ setUserInfo({
154
+ name: (res === null || res === void 0 || (_res$account = res.account) === null || _res$account === void 0 ? void 0 : _res$account.name) || '',
155
+ avatar: (res === null || res === void 0 || (_res$account2 = res.account) === null || _res$account2 === void 0 ? void 0 : _res$account2.avatar) || ''
156
+ });
157
+ _context.next = 8;
158
+ return getTenant();
159
+ case 8:
160
+ tenant = _context.sent;
161
+ app === null || app === void 0 || (_app$storage8 = app.storage) === null || _app$storage8 === void 0 || _app$storage8.setStorage('storeList', JSON.stringify(tenant || {}));
162
+
163
+ // 上次使用的店铺
164
+ lastUsedStore = tenant === null || tenant === void 0 ? void 0 : tenant.find(function (item) {
165
+ return item.id == lastUsedStoreId;
166
+ }); // 如果只有一个店铺,直接选择该店铺并进入下一步,否则进入选择店铺页面
167
+ if (!((tenant === null || tenant === void 0 ? void 0 : tenant.length) === 1)) {
168
+ _context.next = 16;
169
+ break;
170
+ }
171
+ _context.next = 14;
172
+ return handleStoreSelect(tenant[0], false);
173
+ case 14:
174
+ _context.next = 22;
175
+ break;
176
+ case 16:
177
+ if (!lastUsedStore) {
178
+ _context.next = 21;
179
+ break;
180
+ }
181
+ _context.next = 19;
182
+ return handleStoreSelect(lastUsedStore, false);
183
+ case 19:
184
+ _context.next = 22;
185
+ break;
186
+ case 21:
187
+ setStep('store');
188
+ case 22:
189
+ setStoreList(tenant);
190
+ case 23:
191
+ case "end":
192
+ return _context.stop();
193
+ }
194
+ }, _callee);
195
+ }));
196
+ return function onLoginSuccess(_x) {
197
+ return _ref.apply(this, arguments);
198
+ };
199
+ }();
200
+
201
+ /**
202
+ * 返回
203
+ */
204
+ var onBack = function onBack() {
205
+ if (step === 'store') {
206
+ setStep('login');
207
+ } else if (step === 'device') {
208
+ setStep('store');
209
+ }
210
+ };
211
+
212
+ /**
213
+ * 选择店铺
214
+ * @param shopInfo 店铺信息
215
+ */
216
+ var handleStoreSelect = /*#__PURE__*/function () {
217
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(shopInfo) {
218
+ var _shopInfo$tenant, _app$logger;
219
+ var isShowGoBack,
220
+ app,
221
+ _res$mypisell_data,
222
+ _app$getPlugin2,
223
+ _res$mypisell_data2,
224
+ _app$logger2,
225
+ res,
226
+ _app$getPlugin3,
227
+ _app$logger3,
228
+ _args2 = arguments;
229
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
230
+ while (1) switch (_context2.prev = _context2.next) {
231
+ case 0:
232
+ isShowGoBack = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : true;
233
+ app = getApp();
234
+ app.storage.setStorage('tenant_domain', shopInfo === null || shopInfo === void 0 || (_shopInfo$tenant = shopInfo.tenant) === null || _shopInfo$tenant === void 0 ? void 0 : _shopInfo$tenant.default_domain);
235
+ app.storage.setStorage('selectedStore', JSON.stringify(shopInfo));
236
+ setLastUsedStoreId(shopInfo.id);
237
+ setSelectedStore(shopInfo);
238
+ app === null || app === void 0 || (_app$logger = app.logger) === null || _app$logger === void 0 || _app$logger.addLog({
239
+ type: 'info',
240
+ title: '选择店铺页-点击店铺',
241
+ metadata: shopInfo || {}
242
+ });
243
+ _context2.prev = 7;
244
+ _context2.next = 10;
245
+ return getTenantDetail();
246
+ case 10:
247
+ res = _context2.sent;
248
+ if (res) {
249
+ _context2.next = 13;
250
+ break;
251
+ }
252
+ return _context2.abrupt("return");
253
+ case 13:
254
+ if (res !== null && res !== void 0 && (_res$mypisell_data = res.mypisell_data) !== null && _res$mypisell_data !== void 0 && _res$mypisell_data.account_token) {
255
+ _context2.next = 16;
256
+ break;
257
+ }
258
+ PisellToast({
259
+ content: locales.getText('webpos-login-store-data-missing')
260
+ });
261
+ return _context2.abrupt("return");
262
+ case 16:
263
+ 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');
264
+ if (res.nocobase_tenant_token) {
265
+ app === null || app === void 0 || (_app$getPlugin3 = app.getPlugin('token')) === null || _app$getPlugin3 === void 0 || _app$getPlugin3.set(res.nocobase_tenant_token, 'nocobaseToken');
266
+ }
267
+ _context2.next = 20;
268
+ return getDeviceListFunction();
269
+ case 20:
270
+ setIsShowGoBack(isShowGoBack);
271
+ // 保存店铺信息
272
+ // app?.storage.setStorage("shopInfo", JSON.stringify(res || {}));
273
+ app === null || app === void 0 || (_app$logger2 = app.logger) === null || _app$logger2 === void 0 || _app$logger2.addLog({
274
+ type: 'info',
275
+ title: '选择店铺页-选择店铺成功',
276
+ metadata: res || {}
277
+ });
278
+ _context2.next = 27;
279
+ break;
280
+ case 24:
281
+ _context2.prev = 24;
282
+ _context2.t0 = _context2["catch"](7);
283
+ app === null || app === void 0 || (_app$logger3 = app.logger) === null || _app$logger3 === void 0 || _app$logger3.addLog({
284
+ type: 'error',
285
+ title: '登录页-选择店铺失败',
286
+ metadata: _context2.t0 || {}
287
+ });
288
+ case 27:
289
+ case "end":
290
+ return _context2.stop();
291
+ }
292
+ }, _callee2, null, [[7, 24]]);
293
+ }));
294
+ return function handleStoreSelect(_x2) {
295
+ return _ref2.apply(this, arguments);
296
+ };
297
+ }();
298
+ var getDeviceListFunction = /*#__PURE__*/function () {
299
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
300
+ var app, type, res, _app$logger4, _app$logger5;
301
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
302
+ while (1) switch (_context3.prev = _context3.next) {
303
+ case 0:
304
+ app = getApp();
305
+ type = 'terminal';
306
+ _context3.next = 4;
307
+ return getDeviceList({
308
+ type: type,
309
+ with: ['client']
310
+ });
311
+ case 4:
312
+ res = _context3.sent;
313
+ if (res) {
314
+ _context3.next = 7;
315
+ break;
316
+ }
317
+ return _context3.abrupt("return");
318
+ case 7:
319
+ if ((res === null || res === void 0 ? void 0 : res.length) > 0) {
320
+ // const boundCloudDevice = JSON.parse(
321
+ // app.storage.getStorage('boundCloudDevice') || '{}'
322
+ // );
323
+ // const available = boundCloudDevice?.number
324
+ // ? !!res?.find((item) => item?.number === boundCloudDevice?.number)
325
+ // : false;
326
+ // 如果云端有设备信息,保存设备信息,并进入选择设备页面
327
+ app === null || app === void 0 || app.storage.setStorage('deviceList', JSON.stringify(res || []));
328
+ setDeviceList(res);
329
+
330
+ // if (available) {
331
+ // app.storage.setStorage('isLogin', true);
332
+ // app.history.reloadTo('/');
333
+ // } else {
334
+ // setStep('device');
335
+ // }
336
+ setStep('device');
337
+ app === null || app === void 0 || (_app$logger4 = app.logger) === null || _app$logger4 === void 0 || _app$logger4.addLog({
338
+ type: 'info',
339
+ title: '选择店铺页-获取设备列表成功-有云端设备',
340
+ metadata: res || {}
341
+ });
342
+ } else {
343
+ app.storage.setStorage('isLogin', true);
344
+ // 如果云端没有设备信息,直接进入打印机列表
345
+ reloadAfterLogin === null || reloadAfterLogin === void 0 || reloadAfterLogin();
346
+ // app?.history?.reloadTo('/');
347
+ app === null || app === void 0 || (_app$logger5 = app.logger) === null || _app$logger5 === void 0 || _app$logger5.addLog({
348
+ type: 'info',
349
+ title: '选择店铺页-获取设备列表成功-没有云端设备',
350
+ metadata: res || {}
351
+ });
352
+ }
353
+ case 8:
354
+ case "end":
355
+ return _context3.stop();
356
+ }
357
+ }, _callee3);
358
+ }));
359
+ return function getDeviceListFunction() {
360
+ return _ref3.apply(this, arguments);
361
+ };
362
+ }();
363
+
364
+ /**
365
+ * 解除设备绑定
366
+ */
367
+ var handleDissociateDevice = /*#__PURE__*/function () {
368
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
369
+ var _app$storage9, _boundCloudDevice$cli;
370
+ var app, boundCloudDevice, _boundCloudDevice$cli2, res, _app$logger6, _app$logger7;
371
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
372
+ while (1) switch (_context4.prev = _context4.next) {
373
+ case 0:
374
+ app = getApp();
375
+ boundCloudDevice = JSON.parse((app === null || app === void 0 || (_app$storage9 = app.storage) === null || _app$storage9 === void 0 ? void 0 : _app$storage9.getStorage('boundCloudDevice')) || '{}');
376
+ if (!(boundCloudDevice !== null && boundCloudDevice !== void 0 && boundCloudDevice.number && boundCloudDevice !== null && boundCloudDevice !== void 0 && (_boundCloudDevice$cli = boundCloudDevice.client) !== null && _boundCloudDevice$cli !== void 0 && _boundCloudDevice$cli.number)) {
377
+ _context4.next = 13;
378
+ break;
379
+ }
380
+ _context4.next = 5;
381
+ return dissociateDevice({
382
+ number: boundCloudDevice === null || boundCloudDevice === void 0 || (_boundCloudDevice$cli2 = boundCloudDevice.client) === null || _boundCloudDevice$cli2 === void 0 ? void 0 : _boundCloudDevice$cli2.number,
383
+ dissociateDeviceNumber: boundCloudDevice === null || boundCloudDevice === void 0 ? void 0 : boundCloudDevice.number
384
+ });
385
+ case 5:
386
+ res = _context4.sent;
387
+ if (res) {
388
+ _context4.next = 11;
389
+ break;
390
+ }
391
+ app === null || app === void 0 || (_app$logger6 = app.logger) === null || _app$logger6 === void 0 || _app$logger6.addLog({
392
+ type: 'error',
393
+ title: '选择设备页-解除设备绑定失败'
394
+ });
395
+ return _context4.abrupt("return", false);
396
+ case 11:
397
+ app === null || app === void 0 || (_app$logger7 = app.logger) === null || _app$logger7 === void 0 || _app$logger7.addLog({
398
+ type: 'info',
399
+ title: '选择设备页-解除设备绑定成功',
400
+ metadata: res || {}
401
+ });
402
+ return _context4.abrupt("return", true);
403
+ case 13:
404
+ return _context4.abrupt("return", true);
405
+ case 14:
406
+ case "end":
407
+ return _context4.stop();
408
+ }
409
+ }, _callee4);
410
+ }));
411
+ return function handleDissociateDevice() {
412
+ return _ref4.apply(this, arguments);
413
+ };
414
+ }();
415
+
416
+ /**
417
+ * 选择设备
418
+ * @param device 设备信息
419
+ */
420
+ var handleDeviceSelect = /*#__PURE__*/function () {
421
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(device) {
422
+ var _app$locales, _app$logger11;
423
+ var app, deviceNumber, language, _device, _deviceOrigin, _app$logger8, _app$logger9, _app$logger10, dissociateRes, res;
424
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
425
+ while (1) switch (_context5.prev = _context5.next) {
426
+ case 0:
427
+ app = getApp();
428
+ app.storage.setStorage('lastUsedDevice', JSON.stringify(device));
429
+ setLastUsedDeviceId(device.id);
430
+ deviceNumber = device === null || device === void 0 ? void 0 : device.number;
431
+ language = (app === null || app === void 0 || (_app$locales = app.locales) === null || _app$locales === void 0 ? void 0 : _app$locales.getLocale()) || 'en';
432
+ _device = null;
433
+ _context5.prev = 6;
434
+ _context5.next = 9;
435
+ return app.plugins.get('device').getDeviceInfo({
436
+ language: language
437
+ });
438
+ case 9:
439
+ _deviceOrigin = _context5.sent;
440
+ _device = (_deviceOrigin === null || _deviceOrigin === void 0 ? void 0 : _deviceOrigin.data) || null;
441
+ app === null || app === void 0 || app.storage.setStorage('localDevice', JSON.stringify(_device || {}));
442
+ _context5.next = 17;
443
+ break;
444
+ case 14:
445
+ _context5.prev = 14;
446
+ _context5.t0 = _context5["catch"](6);
447
+ app === null || app === void 0 || (_app$logger8 = app.logger) === null || _app$logger8 === void 0 || _app$logger8.addLog({
448
+ type: 'error',
449
+ title: '选择设备页-获取本机设备信息获取失败'
450
+ });
451
+ case 17:
452
+ if (_device) {
453
+ _context5.next = 22;
454
+ break;
455
+ }
456
+ app === null || app === void 0 || (_app$logger9 = app.logger) === null || _app$logger9 === void 0 || _app$logger9.addLog({
457
+ type: 'error',
458
+ title: '选择设备页-绑定设备失败-本机设备信息获取失败'
459
+ });
460
+ return _context5.abrupt("return");
461
+ case 22:
462
+ app === null || app === void 0 || (_app$logger10 = app.logger) === null || _app$logger10 === void 0 || _app$logger10.addLog({
463
+ type: 'info',
464
+ title: '选择设备页-绑定设备-本机设备信息获取成功',
465
+ metadata: _device || {}
466
+ });
467
+ case 23:
468
+ _context5.next = 25;
469
+ return handleDissociateDevice();
470
+ case 25:
471
+ dissociateRes = _context5.sent;
472
+ if (dissociateRes) {
473
+ _context5.next = 28;
474
+ break;
475
+ }
476
+ return _context5.abrupt("return");
477
+ case 28:
478
+ _context5.next = 30;
479
+ return selectDevice(_objectSpread({
480
+ deviceNumber: deviceNumber
481
+ }, _device || {}));
482
+ case 30:
483
+ res = _context5.sent;
484
+ if (res) {
485
+ _context5.next = 33;
486
+ break;
487
+ }
488
+ return _context5.abrupt("return");
489
+ case 33:
490
+ app.storage.setStorage('loginStatus', 'success');
491
+ app.storage.setStorage('isLogin', true);
492
+ reloadAfterLogin === null || reloadAfterLogin === void 0 || reloadAfterLogin();
493
+
494
+ // 保存设备信息
495
+ app === null || app === void 0 || app.storage.setStorage('boundCloudDevice', JSON.stringify(res || {}));
496
+ app.pubsub.publish('dataManager', {
497
+ type: 'get',
498
+ key: 'DEVICE_NUMBER',
499
+ metadata: {
500
+ msg: 'webpo主动推送'
501
+ }
502
+ });
503
+ app === null || app === void 0 || (_app$logger11 = app.logger) === null || _app$logger11 === void 0 || _app$logger11.addLog({
504
+ type: 'info',
505
+ title: '选择设备页-绑定设备成功',
506
+ metadata: res || {}
507
+ });
508
+ case 39:
509
+ case "end":
510
+ return _context5.stop();
511
+ }
512
+ }, _callee5, null, [[6, 14]]);
513
+ }));
514
+ return function handleDeviceSelect(_x3) {
515
+ return _ref5.apply(this, arguments);
516
+ };
517
+ }();
518
+ var handleChangeAccount = function handleChangeAccount() {
519
+ setStep('login');
520
+ };
521
+ var handleChangeStore = function handleChangeStore() {
522
+ setStep('store');
523
+ };
524
+ return /*#__PURE__*/React.createElement(WebPosLoginCpt, {
525
+ loginConfig: config,
526
+ backgroundImage: backgroundImage,
527
+ brandConfig: {
528
+ carouselItems: [{
529
+ type: 'image',
530
+ url: 'https://static.pisellcdn.com/defaultLogo.png'
531
+ }]
532
+ },
533
+ step: step,
534
+ showBackButton: isShowGoBack,
535
+ storeList: storeList,
536
+ deviceList: deviceList,
537
+ userInfo: userInfo,
538
+ selectedStore: selectedStore,
539
+ lastUsedStoreId: lastUsedStoreId,
540
+ lastUsedDeviceId: lastUsedDeviceId,
541
+ locale: (context === null || context === void 0 || (_context$engine = context.engine) === null || _context$engine === void 0 || (_context$engine = _context$engine.props) === null || _context$engine === void 0 ? void 0 : _context$engine.locale) || 'en',
542
+ loading: false,
543
+ onStoreSelect: handleStoreSelect,
544
+ onDeviceSelect: handleDeviceSelect,
545
+ onChangeAccount: handleChangeAccount,
546
+ onChangeStore: handleChangeStore,
547
+ onBack: onBack,
548
+ onLoginSuccess: onLoginSuccess
549
+ });
550
+ };
551
+ export default WebPosLogin;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { WebPosLoginCptProps } from './types';
3
+ import './WebPosLoginCpt.less';
4
+ /**
5
+ * WebPosLoginCpt 主组件
6
+ * @description WebPOS 登录流程组件,包含登录、店铺选择、设备选择三个步骤
7
+ */
8
+ declare const WebPosLoginCpt: React.FC<WebPosLoginCptProps>;
9
+ export default WebPosLoginCpt;