@pisell/private-materials 3.0.134 → 3.0.135

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.
@@ -1,13 +1,14 @@
1
1
  import React from 'react';
2
2
  import { PayProps, PosProps } from './const';
3
3
  import './device.less';
4
- declare const _default: ({ api, onChange, onClose, className, isIpad, net, }: {
4
+ declare const _default: ({ api, onChange, onClose, className, device_number, isIpad, net, }: {
5
5
  api: PayProps['api'];
6
6
  className?: string | undefined;
7
- onChange?: ((status: "page" | "success" | "fail", params?: string | {
7
+ onChange?: ((status: "fail" | "success" | "page", params?: string | {
8
8
  [keys: string]: unknown;
9
9
  } | undefined) => void) | undefined;
10
10
  onClose: () => void;
11
+ device_number?: string | number | undefined;
11
12
  isIpad: boolean;
12
13
  net: boolean;
13
14
  }) => React.JSX.Element;
@@ -18,6 +18,7 @@ export default (function (_ref) {
18
18
  onClose = _ref.onClose,
19
19
  _ref$className = _ref.className,
20
20
  className = _ref$className === void 0 ? '' : _ref$className,
21
+ device_number = _ref.device_number,
21
22
  isIpad = _ref.isIpad,
22
23
  net = _ref.net;
23
24
  var _useContextData = useContextData(),
@@ -63,6 +64,30 @@ export default (function (_ref) {
63
64
  }).then(function (res) {
64
65
  setLoading(false);
65
66
  if (res && Array.isArray(res.list) && res.list.length > 0) {
67
+ if (device_number) {
68
+ var hostDeviceList = res.list.filter(function (item) {
69
+ var _item$setting, _item$setting$devices;
70
+ return item === null || item === void 0 ? void 0 : (_item$setting = item.setting) === null || _item$setting === void 0 ? void 0 : (_item$setting$devices = _item$setting.devices) === null || _item$setting$devices === void 0 ? void 0 : _item$setting$devices.some(function (i) {
71
+ return i.number === device_number;
72
+ });
73
+ });
74
+ if (hostDeviceList.length >= 1) {
75
+ setDataStaus(true);
76
+ setList(hostDeviceList);
77
+ if (hostDeviceList.length === 1) {
78
+ dispatch(updateDevice({
79
+ device: hostDeviceList[0]
80
+ }));
81
+ if (typeof api.selectDevice === 'function') {
82
+ api.selectDevice(hostDeviceList[0]);
83
+ }
84
+ if (typeof onChange === 'function') {
85
+ onChange('page', mode === ModeEnum.Pay ? 'amount' : 'pay');
86
+ }
87
+ }
88
+ return;
89
+ }
90
+ }
66
91
  setDataStaus(true);
67
92
  setList(res.list);
68
93
  if (res.list.length === 1) {
@@ -1,5 +1,5 @@
1
1
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
- var _excluded = ["action", "getApi", "terminal"];
2
+ var _excluded = ["action", "getApi", "device_number", "terminal"];
3
3
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
4
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
5
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; }
@@ -31,6 +31,7 @@ var App = function App(_ref) {
31
31
  var _context$appHelper;
32
32
  var action = _ref.action,
33
33
  getApi = _ref.getApi,
34
+ device_number = _ref.device_number,
34
35
  terminal = _ref.terminal,
35
36
  props = _objectWithoutProperties(_ref, _excluded);
36
37
  var data = useContextData();
@@ -109,7 +110,8 @@ var App = function App(_ref) {
109
110
  onClose: onClose,
110
111
  isIpad: isIpad,
111
112
  className: isIpad ? 'pisell-lowcode__eft-pay-terminal' : '',
112
- net: net
113
+ net: net,
114
+ device_number: device_number
113
115
  });
114
116
  }
115
117
  if (current === RouteEnum.Amount) {
@@ -132,7 +134,7 @@ var App = function App(_ref) {
132
134
  });
133
135
  };
134
136
  export default (function (props) {
135
- var _context$appHelper2, _store$getState, _store$getState$call, _store$getState$call$;
137
+ var _context$appHelper2, _store$getState, _store$getState$call, _store$getState$call$, _props$params, _props$params2;
136
138
  var context = useEngineContext();
137
139
  var _ref3 = ((_context$appHelper2 = context.appHelper) === null || _context$appHelper2 === void 0 ? void 0 : _context$appHelper2.utils) || {
138
140
  store: {}
@@ -175,6 +177,7 @@ export default (function (props) {
175
177
  useEffect(function () {
176
178
  document.body.id = 'body';
177
179
  }, []);
180
+ console.log('props?.params?.device_number = ', props === null || props === void 0 ? void 0 : (_props$params = props.params) === null || _props$params === void 0 ? void 0 : _props$params.device_number);
178
181
  return /*#__PURE__*/React.createElement(Provider, {
179
182
  state: state
180
183
  }, /*#__PURE__*/React.createElement(App, {
@@ -182,6 +185,7 @@ export default (function (props) {
182
185
  params: props.params,
183
186
  onChangeStatus: onChangeStatus,
184
187
  terminal: props.terminal,
185
- action: action
188
+ action: action,
189
+ device_number: props === null || props === void 0 ? void 0 : (_props$params2 = props.params) === null || _props$params2 === void 0 ? void 0 : _props$params2.device_number
186
190
  }));
187
191
  });
@@ -1,13 +1,14 @@
1
1
  import React from 'react';
2
2
  import { PayProps, PosProps } from './const';
3
3
  import './device.less';
4
- declare const _default: ({ api, onChange, onClose, className, isIpad, net, }: {
4
+ declare const _default: ({ api, onChange, onClose, className, device_number, isIpad, net, }: {
5
5
  api: PayProps['api'];
6
6
  className?: string | undefined;
7
- onChange?: ((status: "page" | "success" | "fail", params?: string | {
7
+ onChange?: ((status: "fail" | "success" | "page", params?: string | {
8
8
  [keys: string]: unknown;
9
9
  } | undefined) => void) | undefined;
10
10
  onClose: () => void;
11
+ device_number?: string | number | undefined;
11
12
  isIpad: boolean;
12
13
  net: boolean;
13
14
  }) => React.JSX.Element;
@@ -45,6 +45,7 @@ var device_default = ({
45
45
  onChange,
46
46
  onClose,
47
47
  className = "",
48
+ device_number,
48
49
  isIpad,
49
50
  net
50
51
  }) => {
@@ -74,6 +75,30 @@ var device_default = ({
74
75
  (res) => {
75
76
  setLoading(false);
76
77
  if (res && Array.isArray(res.list) && res.list.length > 0) {
78
+ if (device_number) {
79
+ const hostDeviceList = res.list.filter(
80
+ (item) => {
81
+ var _a, _b;
82
+ return (_b = (_a = item == null ? void 0 : item.setting) == null ? void 0 : _a.devices) == null ? void 0 : _b.some(
83
+ (i) => i.number === device_number
84
+ );
85
+ }
86
+ );
87
+ if (hostDeviceList.length >= 1) {
88
+ setDataStaus(true);
89
+ setList(hostDeviceList);
90
+ if (hostDeviceList.length === 1) {
91
+ dispatch((0, import_store.updateDevice)({ device: hostDeviceList[0] }));
92
+ if (typeof api.selectDevice === "function") {
93
+ api.selectDevice(hostDeviceList[0]);
94
+ }
95
+ if (typeof onChange === "function") {
96
+ onChange("page", mode === import_const.ModeEnum.Pay ? "amount" : "pay");
97
+ }
98
+ }
99
+ return;
100
+ }
101
+ }
77
102
  setDataStaus(true);
78
103
  setList(res.list);
79
104
  if (res.list.length === 1) {
@@ -48,6 +48,7 @@ import_utils.locales.init(import_locales.default, localStorage.getItem("umi_loca
48
48
  var App = ({
49
49
  action,
50
50
  getApi,
51
+ device_number,
51
52
  terminal,
52
53
  ...props
53
54
  }) => {
@@ -114,7 +115,8 @@ var App = ({
114
115
  onClose,
115
116
  isIpad,
116
117
  className: isIpad ? "pisell-lowcode__eft-pay-terminal" : "",
117
- net
118
+ net,
119
+ device_number
118
120
  }
119
121
  );
120
122
  }
@@ -144,7 +146,7 @@ var App = ({
144
146
  );
145
147
  };
146
148
  var eftposPay_default = (props) => {
147
- var _a, _b, _c, _d;
149
+ var _a, _b, _c, _d, _e, _f;
148
150
  const context = (0, import_useEngineContext.default)();
149
151
  const { store } = ((_a = context.appHelper) == null ? void 0 : _a.utils) || { store: {} };
150
152
  const mode = (0, import_react.useMemo)(() => {
@@ -180,6 +182,7 @@ var eftposPay_default = (props) => {
180
182
  (0, import_react.useEffect)(() => {
181
183
  document.body.id = "body";
182
184
  }, []);
185
+ console.log("props?.params?.device_number = ", (_e = props == null ? void 0 : props.params) == null ? void 0 : _e.device_number);
183
186
  return /* @__PURE__ */ import_react.default.createElement(import_store.Provider, { state }, /* @__PURE__ */ import_react.default.createElement(
184
187
  App,
185
188
  {
@@ -187,7 +190,8 @@ var eftposPay_default = (props) => {
187
190
  params: props.params,
188
191
  onChangeStatus,
189
192
  terminal: props.terminal,
190
- action
193
+ action,
194
+ device_number: (_f = props == null ? void 0 : props.params) == null ? void 0 : _f.device_number
191
195
  }
192
196
  ));
193
197
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/private-materials",
3
- "version": "3.0.134",
3
+ "version": "3.0.135",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",