@pisell/private-materials 3.0.96 → 3.0.97
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/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/index.js +1 -1
- package/build/lowcode/meta.js +1 -1
- package/build/lowcode/preview.js +8 -8
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +16 -9
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +15 -8
- package/es/components/booking/addons/index.d.ts +1 -1
- package/es/components/booking/addons/model.d.ts +1 -2
- package/es/components/booking/forms/forms.d.ts +1 -1
- package/es/components/booking/forms/index.d.ts +1 -1
- package/es/components/booking/forms/model.d.ts +1 -2
- package/es/components/booking/index.d.ts +1 -1
- package/es/components/booking/info/index.d.ts +1 -1
- package/es/components/booking/info/model.d.ts +1 -2
- package/es/components/booking/model.d.ts +1 -2
- package/es/components/booking/notes/index.d.ts +1 -1
- package/es/components/booking/notes/model.d.ts +1 -2
- package/es/components/booking/payments/index.d.ts +1 -1
- package/es/components/booking/payments/model.d.ts +1 -2
- package/es/components/eftpos/const.d.ts +38 -0
- package/es/components/eftpos/const.js +79 -0
- package/es/components/eftpos/device.d.ts +8 -0
- package/es/components/eftpos/device.js +30 -0
- package/es/components/eftpos/form/index.d.ts +16 -0
- package/es/components/eftpos/form/index.js +113 -0
- package/es/components/eftpos/index.d.ts +37 -0
- package/es/components/eftpos/index.js +274 -0
- package/es/components/eftpos/index.less +153 -0
- package/es/components/eftpos/locales.d.ts +75 -0
- package/es/components/eftpos/locales.js +98 -0
- package/es/components/eftpos/pos.d.ts +9 -0
- package/es/components/eftpos/pos.js +33 -0
- package/es/components/eftpos/surcharge/index.css +17 -0
- package/es/components/eftpos/surcharge/index.d.ts +8 -0
- package/es/components/eftpos/surcharge/index.js +111 -0
- package/es/components/eftpos/table.d.ts +17 -0
- package/es/components/eftpos/table.js +236 -0
- package/es/components/eftposPay/amount.d.ts +14 -0
- package/es/components/eftposPay/amount.js +253 -0
- package/es/components/eftposPay/component/alert/index.d.ts +6 -0
- package/es/components/eftposPay/component/alert/index.js +11 -0
- package/es/components/eftposPay/component/alert/index.less +29 -0
- package/es/components/eftposPay/component/alert/warn.d.ts +3 -0
- package/es/components/eftposPay/component/alert/warn.js +45 -0
- package/es/components/eftposPay/component/fail/failCustom.d.ts +4 -0
- package/es/components/eftposPay/component/fail/failCustom.js +95 -0
- package/es/components/eftposPay/component/fail/index.d.ts +4 -0
- package/es/components/eftposPay/component/fail/index.js +105 -0
- package/es/components/eftposPay/component/fail/network.d.ts +4 -0
- package/es/components/eftposPay/component/fail/network.js +48 -0
- package/es/components/eftposPay/component/fail/unknow.d.ts +4 -0
- package/es/components/eftposPay/component/fail/unknow.js +43 -0
- package/es/components/eftposPay/component/header/index.d.ts +9 -0
- package/es/components/eftposPay/component/header/index.js +66 -0
- package/es/components/eftposPay/component/header/index.less +44 -0
- package/es/components/eftposPay/component/header/titlebar.d.ts +13 -0
- package/es/components/eftposPay/component/header/titlebar.js +39 -0
- package/es/components/eftposPay/component/header/titlebar.less +17 -0
- package/es/components/eftposPay/component/manual/index.d.ts +5 -0
- package/es/components/eftposPay/component/manual/index.js +91 -0
- package/es/components/eftposPay/component/manual/index.less +96 -0
- package/es/components/eftposPay/component/signature/index.d.ts +4 -0
- package/es/components/eftposPay/component/signature/index.js +63 -0
- package/es/components/eftposPay/component/step/index.d.ts +12 -0
- package/es/components/eftposPay/component/step/index.js +31 -0
- package/es/components/eftposPay/component/step/step.d.ts +9 -0
- package/es/components/eftposPay/component/step/step.js +23 -0
- package/es/components/eftposPay/const.d.ts +131 -0
- package/es/components/eftposPay/const.js +48 -0
- package/es/components/eftposPay/device.d.ts +14 -0
- package/es/components/eftposPay/device.js +124 -0
- package/es/components/eftposPay/device.less +61 -0
- package/es/components/eftposPay/eftpos/config.d.ts +11 -0
- package/es/components/eftposPay/eftpos/config.js +178 -0
- package/es/components/eftposPay/eftpos/const.d.ts +10 -0
- package/es/components/eftposPay/eftpos/const.js +139 -0
- package/es/components/eftposPay/eftpos/index.d.ts +7 -0
- package/es/components/eftposPay/eftpos/index.js +35 -0
- package/es/components/eftposPay/helper.d.ts +3 -0
- package/es/components/eftposPay/helper.js +35 -0
- package/es/components/eftposPay/hooks.d.ts +4 -0
- package/es/components/eftposPay/hooks.js +153 -0
- package/es/components/eftposPay/index.d.ts +7 -0
- package/es/components/eftposPay/index.js +188 -0
- package/es/components/eftposPay/index.less +273 -0
- package/es/components/eftposPay/locales.d.ts +264 -0
- package/es/components/eftposPay/locales.js +384 -0
- package/es/components/eftposPay/manufacturer.d.ts +6 -0
- package/es/components/eftposPay/manufacturer.js +32 -0
- package/es/components/eftposPay/pay.d.ts +10 -0
- package/es/components/eftposPay/pay.js +108 -0
- package/es/components/eftposPay/payo/config.d.ts +11 -0
- package/es/components/eftposPay/payo/config.js +357 -0
- package/es/components/eftposPay/payo/const.d.ts +6 -0
- package/es/components/eftposPay/payo/const.js +93 -0
- package/es/components/eftposPay/payo/hooks.d.ts +5 -0
- package/es/components/eftposPay/payo/hooks.js +84 -0
- package/es/components/eftposPay/payo/index.d.ts +7 -0
- package/es/components/eftposPay/payo/index.js +35 -0
- package/es/components/eftposPay/store/index.d.ts +239 -0
- package/es/components/eftposPay/store/index.js +304 -0
- package/es/components/eftposPay/store/useThunkReducer.d.ts +9 -0
- package/es/components/eftposPay/store/useThunkReducer.js +31 -0
- package/es/components/eftposPay/windcave/action.d.ts +8 -0
- package/es/components/eftposPay/windcave/action.js +104 -0
- package/es/components/eftposPay/windcave/const.d.ts +104 -0
- package/es/components/eftposPay/windcave/const.js +253 -0
- package/es/components/eftposPay/windcave/helper.d.ts +9 -0
- package/es/components/eftposPay/windcave/helper.js +314 -0
- package/es/components/eftposPay/windcave/hook.d.ts +14 -0
- package/es/components/eftposPay/windcave/hook.js +144 -0
- package/es/components/eftposPay/windcave/index.d.ts +8 -0
- package/es/components/eftposPay/windcave/index.js +49 -0
- package/es/components/eftposPay/windcave/pos.d.ts +8 -0
- package/es/components/eftposPay/windcave/pos.js +180 -0
- package/es/components/eftposPay/windcave/pwd.d.ts +8 -0
- package/es/components/eftposPay/windcave/pwd.js +124 -0
- package/es/components/eftposPay/windcave/receipet.d.ts +6 -0
- package/es/components/eftposPay/windcave/receipet.js +67 -0
- package/es/components/eftposPay/windcave/receiptAction.d.ts +11 -0
- package/es/components/eftposPay/windcave/receiptAction.js +326 -0
- package/es/components/eftposPay/windcave/timer.d.ts +17 -0
- package/es/components/eftposPay/windcave/timer.js +181 -0
- package/es/components/eftposPay/windcave/wait.d.ts +12 -0
- package/es/components/eftposPay/windcave/wait.js +139 -0
- package/es/components/eftposPay/windcave/windcave.d.ts +6 -0
- package/es/components/eftposPay/windcave/windcave.js +283 -0
- package/es/components/schedules/index.d.ts +1 -1
- package/es/components/schedules/model.d.ts +1 -2
- package/es/hooks/usePrefix.d.ts +1 -0
- package/es/hooks/usePrefix.js +10 -0
- package/es/index.d.ts +2 -0
- package/es/index.js +3 -1
- package/lib/components/booking/addons/index.d.ts +1 -1
- package/lib/components/booking/addons/model.d.ts +1 -2
- package/lib/components/booking/forms/forms.d.ts +1 -1
- package/lib/components/booking/forms/index.d.ts +1 -1
- package/lib/components/booking/forms/model.d.ts +1 -2
- package/lib/components/booking/index.d.ts +1 -1
- package/lib/components/booking/info/index.d.ts +1 -1
- package/lib/components/booking/info/model.d.ts +1 -2
- package/lib/components/booking/model.d.ts +1 -2
- package/lib/components/booking/notes/index.d.ts +1 -1
- package/lib/components/booking/notes/model.d.ts +1 -2
- package/lib/components/booking/payments/index.d.ts +1 -1
- package/lib/components/booking/payments/model.d.ts +1 -2
- package/lib/components/eftpos/const.d.ts +38 -0
- package/lib/components/eftpos/const.js +108 -0
- package/lib/components/eftpos/device.d.ts +8 -0
- package/lib/components/eftpos/device.js +55 -0
- package/lib/components/eftpos/form/index.d.ts +16 -0
- package/lib/components/eftpos/form/index.js +124 -0
- package/lib/components/eftpos/index.d.ts +37 -0
- package/lib/components/eftpos/index.js +279 -0
- package/lib/components/eftpos/index.less +153 -0
- package/lib/components/eftpos/locales.d.ts +75 -0
- package/lib/components/eftpos/locales.js +116 -0
- package/lib/components/eftpos/pos.d.ts +9 -0
- package/lib/components/eftpos/pos.js +55 -0
- package/lib/components/eftpos/surcharge/index.css +17 -0
- package/lib/components/eftpos/surcharge/index.d.ts +8 -0
- package/lib/components/eftpos/surcharge/index.js +125 -0
- package/lib/components/eftpos/table.d.ts +17 -0
- package/lib/components/eftpos/table.js +235 -0
- package/lib/components/eftposPay/amount.d.ts +14 -0
- package/lib/components/eftposPay/amount.js +239 -0
- package/lib/components/eftposPay/component/alert/index.d.ts +6 -0
- package/lib/components/eftposPay/component/alert/index.js +38 -0
- package/lib/components/eftposPay/component/alert/index.less +29 -0
- package/lib/components/eftposPay/component/alert/warn.d.ts +3 -0
- package/lib/components/eftposPay/component/alert/warn.js +80 -0
- package/lib/components/eftposPay/component/fail/failCustom.d.ts +4 -0
- package/lib/components/eftposPay/component/fail/failCustom.js +117 -0
- package/lib/components/eftposPay/component/fail/index.d.ts +4 -0
- package/lib/components/eftposPay/component/fail/index.js +121 -0
- package/lib/components/eftposPay/component/fail/network.d.ts +4 -0
- package/lib/components/eftposPay/component/fail/network.js +65 -0
- package/lib/components/eftposPay/component/fail/unknow.d.ts +4 -0
- package/lib/components/eftposPay/component/fail/unknow.js +72 -0
- package/lib/components/eftposPay/component/header/index.d.ts +9 -0
- package/lib/components/eftposPay/component/header/index.js +92 -0
- package/lib/components/eftposPay/component/header/index.less +44 -0
- package/lib/components/eftposPay/component/header/titlebar.d.ts +13 -0
- package/lib/components/eftposPay/component/header/titlebar.js +55 -0
- package/lib/components/eftposPay/component/header/titlebar.less +17 -0
- package/lib/components/eftposPay/component/manual/index.d.ts +5 -0
- package/lib/components/eftposPay/component/manual/index.js +101 -0
- package/lib/components/eftposPay/component/manual/index.less +96 -0
- package/lib/components/eftposPay/component/signature/index.d.ts +4 -0
- package/lib/components/eftposPay/component/signature/index.js +80 -0
- package/lib/components/eftposPay/component/step/index.d.ts +12 -0
- package/lib/components/eftposPay/component/step/index.js +71 -0
- package/lib/components/eftposPay/component/step/step.d.ts +9 -0
- package/lib/components/eftposPay/component/step/step.js +59 -0
- package/lib/components/eftposPay/const.d.ts +131 -0
- package/lib/components/eftposPay/const.js +86 -0
- package/lib/components/eftposPay/device.d.ts +14 -0
- package/lib/components/eftposPay/device.js +127 -0
- package/lib/components/eftposPay/device.less +61 -0
- package/lib/components/eftposPay/eftpos/config.d.ts +11 -0
- package/lib/components/eftposPay/eftpos/config.js +199 -0
- package/lib/components/eftposPay/eftpos/const.d.ts +10 -0
- package/lib/components/eftposPay/eftpos/const.js +165 -0
- package/lib/components/eftposPay/eftpos/index.d.ts +7 -0
- package/lib/components/eftposPay/eftpos/index.js +66 -0
- package/lib/components/eftposPay/helper.d.ts +3 -0
- package/lib/components/eftposPay/helper.js +62 -0
- package/lib/components/eftposPay/hooks.d.ts +4 -0
- package/lib/components/eftposPay/hooks.js +237 -0
- package/lib/components/eftposPay/index.d.ts +7 -0
- package/lib/components/eftposPay/index.js +189 -0
- package/lib/components/eftposPay/index.less +273 -0
- package/lib/components/eftposPay/locales.d.ts +264 -0
- package/lib/components/eftposPay/locales.js +304 -0
- package/lib/components/eftposPay/manufacturer.d.ts +6 -0
- package/lib/components/eftposPay/manufacturer.js +77 -0
- package/lib/components/eftposPay/pay.d.ts +10 -0
- package/lib/components/eftposPay/pay.js +120 -0
- package/lib/components/eftposPay/payo/config.d.ts +11 -0
- package/lib/components/eftposPay/payo/config.js +377 -0
- package/lib/components/eftposPay/payo/const.d.ts +6 -0
- package/lib/components/eftposPay/payo/const.js +112 -0
- package/lib/components/eftposPay/payo/hooks.d.ts +5 -0
- package/lib/components/eftposPay/payo/hooks.js +80 -0
- package/lib/components/eftposPay/payo/index.d.ts +7 -0
- package/lib/components/eftposPay/payo/index.js +63 -0
- package/lib/components/eftposPay/store/index.d.ts +239 -0
- package/lib/components/eftposPay/store/index.js +371 -0
- package/lib/components/eftposPay/store/useThunkReducer.d.ts +9 -0
- package/lib/components/eftposPay/store/useThunkReducer.js +53 -0
- package/lib/components/eftposPay/windcave/action.d.ts +8 -0
- package/lib/components/eftposPay/windcave/action.js +143 -0
- package/lib/components/eftposPay/windcave/const.d.ts +104 -0
- package/lib/components/eftposPay/windcave/const.js +300 -0
- package/lib/components/eftposPay/windcave/helper.d.ts +9 -0
- package/lib/components/eftposPay/windcave/helper.js +378 -0
- package/lib/components/eftposPay/windcave/hook.d.ts +14 -0
- package/lib/components/eftposPay/windcave/hook.js +139 -0
- package/lib/components/eftposPay/windcave/index.d.ts +8 -0
- package/lib/components/eftposPay/windcave/index.js +78 -0
- package/lib/components/eftposPay/windcave/pos.d.ts +8 -0
- package/lib/components/eftposPay/windcave/pos.js +197 -0
- package/lib/components/eftposPay/windcave/pwd.d.ts +8 -0
- package/lib/components/eftposPay/windcave/pwd.js +143 -0
- package/lib/components/eftposPay/windcave/receipet.d.ts +6 -0
- package/lib/components/eftposPay/windcave/receipet.js +93 -0
- package/lib/components/eftposPay/windcave/receiptAction.d.ts +11 -0
- package/lib/components/eftposPay/windcave/receiptAction.js +386 -0
- package/lib/components/eftposPay/windcave/timer.d.ts +17 -0
- package/lib/components/eftposPay/windcave/timer.js +126 -0
- package/lib/components/eftposPay/windcave/wait.d.ts +12 -0
- package/lib/components/eftposPay/windcave/wait.js +163 -0
- package/lib/components/eftposPay/windcave/windcave.d.ts +6 -0
- package/lib/components/eftposPay/windcave/windcave.js +283 -0
- package/lib/components/schedules/index.d.ts +1 -1
- package/lib/components/schedules/model.d.ts +1 -2
- package/lib/hooks/usePrefix.d.ts +1 -0
- package/lib/hooks/usePrefix.js +44 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +6 -0
- package/lowcode/eftpos/meta.ts +187 -0
- package/lowcode/eftpos-pay/meta.ts +122 -0
- package/package.json +4 -3
|
@@ -0,0 +1,357 @@
|
|
|
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 = ["key"];
|
|
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
|
+
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
|
+
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(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
7
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
8
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
9
|
+
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."); }
|
|
10
|
+
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); }
|
|
11
|
+
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; }
|
|
12
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
13
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
15
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
16
|
+
/* eslint-disable no-unused-vars */
|
|
17
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
18
|
+
/* eslint-disable consistent-return */
|
|
19
|
+
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
|
20
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
21
|
+
import { locales } from '@pisell/utils';
|
|
22
|
+
import { Button } from 'antd';
|
|
23
|
+
import React, { useEffect, useRef } from 'react';
|
|
24
|
+
import { Decimal } from 'decimal.js';
|
|
25
|
+
import Step from "../component/step";
|
|
26
|
+
import { PayStatus, StatusEnum, ModeEnum } from "../const";
|
|
27
|
+
import { getUuid } from "../helper";
|
|
28
|
+
import { useFail } from "../hooks";
|
|
29
|
+
import { useContextData, useDispatch, updateNextStep, updateComponent, updateState, updateCurrentCustomStemItem } from "../store";
|
|
30
|
+
import { useValidate } from "./hooks";
|
|
31
|
+
export var POS = function POS(_ref) {
|
|
32
|
+
var _props$custom, _props$custom3;
|
|
33
|
+
var api = _ref.api,
|
|
34
|
+
onChange = _ref.onChange;
|
|
35
|
+
var _useContextData = useContextData(),
|
|
36
|
+
steps = _useContextData.steps,
|
|
37
|
+
eftpos = _useContextData.eftpos,
|
|
38
|
+
device = _useContextData.device,
|
|
39
|
+
custom = _useContextData.custom,
|
|
40
|
+
status = _useContextData.status,
|
|
41
|
+
mode = _useContextData.mode;
|
|
42
|
+
var refundRef = useRef(custom === null || custom === void 0 ? void 0 : custom.refund);
|
|
43
|
+
var statusRef = useRef(status);
|
|
44
|
+
var dispatch = useDispatch();
|
|
45
|
+
var _steps$ = steps[0],
|
|
46
|
+
key = _steps$.key,
|
|
47
|
+
props = _objectWithoutProperties(_steps$, _excluded);
|
|
48
|
+
var modeRef = useRef(mode);
|
|
49
|
+
var ref = useRef(custom === null || custom === void 0 ? void 0 : custom.number);
|
|
50
|
+
var customRef = useRef(custom);
|
|
51
|
+
var deviceRef = useRef(device);
|
|
52
|
+
var stepStatusRef = useRef(props === null || props === void 0 ? void 0 : (_props$custom = props.custom) === null || _props$custom === void 0 ? void 0 : _props$custom.status);
|
|
53
|
+
var fail = useFail(0, true);
|
|
54
|
+
var failRef = useRef(fail);
|
|
55
|
+
var controllerRef = useRef();
|
|
56
|
+
var clearRef = useRef();
|
|
57
|
+
var initRef = useRef(false);
|
|
58
|
+
var unloadRef = useRef(false);
|
|
59
|
+
var netRef = useRef(custom === null || custom === void 0 ? void 0 : custom.net);
|
|
60
|
+
var _useValidate = useValidate(1000 * 60),
|
|
61
|
+
_useValidate2 = _slicedToArray(_useValidate, 1),
|
|
62
|
+
check = _useValidate2[0];
|
|
63
|
+
useEffect(function () {
|
|
64
|
+
customRef.current = custom;
|
|
65
|
+
}, [custom]);
|
|
66
|
+
useEffect(function () {
|
|
67
|
+
deviceRef.current = device;
|
|
68
|
+
}, [device]);
|
|
69
|
+
useEffect(function () {
|
|
70
|
+
modeRef.current = mode;
|
|
71
|
+
}, [mode]);
|
|
72
|
+
useEffect(function () {
|
|
73
|
+
refundRef.current = custom === null || custom === void 0 ? void 0 : custom.refund;
|
|
74
|
+
}, [custom === null || custom === void 0 ? void 0 : custom.refund]);
|
|
75
|
+
useEffect(function () {
|
|
76
|
+
statusRef.current = status;
|
|
77
|
+
}, [status]);
|
|
78
|
+
useEffect(function () {
|
|
79
|
+
netRef.current = custom === null || custom === void 0 ? void 0 : custom.net;
|
|
80
|
+
}, [custom === null || custom === void 0 ? void 0 : custom.net]);
|
|
81
|
+
useEffect(function () {
|
|
82
|
+
var _props$custom2;
|
|
83
|
+
stepStatusRef.current = props === null || props === void 0 ? void 0 : (_props$custom2 = props.custom) === null || _props$custom2 === void 0 ? void 0 : _props$custom2.status;
|
|
84
|
+
}, [props === null || props === void 0 ? void 0 : (_props$custom3 = props.custom) === null || _props$custom3 === void 0 ? void 0 : _props$custom3.status]);
|
|
85
|
+
useEffect(function () {
|
|
86
|
+
failRef.current = fail;
|
|
87
|
+
}, [fail]);
|
|
88
|
+
useEffect(function () {
|
|
89
|
+
if (initRef.current) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
initRef.current = true;
|
|
93
|
+
if (statusRef.current !== StatusEnum.Loading) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (!ref.current) {
|
|
97
|
+
var _ref2 = customRef.current,
|
|
98
|
+
pay = _ref2.pay,
|
|
99
|
+
order_id = _ref2.order_id;
|
|
100
|
+
ref.current = getUuid();
|
|
101
|
+
dispatch(updateState({
|
|
102
|
+
custom: _objectSpread(_objectSpread({}, customRef.current), {}, {
|
|
103
|
+
number: ref.current
|
|
104
|
+
})
|
|
105
|
+
}));
|
|
106
|
+
if (api && api.pay) {
|
|
107
|
+
var _deviceRef$current, _refundRef$current, _deviceRef$current2;
|
|
108
|
+
controllerRef.current = new AbortController();
|
|
109
|
+
var clear;
|
|
110
|
+
var resultPromise = modeRef.current === ModeEnum.Pay ? api.pay({
|
|
111
|
+
order_id: order_id,
|
|
112
|
+
amount: pay.total,
|
|
113
|
+
card_reader_type: eftpos,
|
|
114
|
+
card_reader_id: (_deviceRef$current = deviceRef.current) === null || _deviceRef$current === void 0 ? void 0 : _deviceRef$current.id,
|
|
115
|
+
number: ref.current
|
|
116
|
+
}, {
|
|
117
|
+
signal: controllerRef.current.signal
|
|
118
|
+
}) : api.refund({
|
|
119
|
+
order_id: order_id,
|
|
120
|
+
amount: (_refundRef$current = refundRef.current) === null || _refundRef$current === void 0 ? void 0 : _refundRef$current.total,
|
|
121
|
+
card_reader_type: eftpos,
|
|
122
|
+
card_reader_id: (_deviceRef$current2 = deviceRef.current) === null || _deviceRef$current2 === void 0 ? void 0 : _deviceRef$current2.id,
|
|
123
|
+
number: ref.current
|
|
124
|
+
}, {
|
|
125
|
+
signal: controllerRef.current.signal
|
|
126
|
+
});
|
|
127
|
+
resultPromise.then(function (res) {
|
|
128
|
+
var _customRef$current;
|
|
129
|
+
console.log('netRef.current = ', netRef.current);
|
|
130
|
+
if (unloadRef.current) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
if (!((_customRef$current = customRef.current) !== null && _customRef$current !== void 0 && _customRef$current.net)) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (res && (res.code === 200 || res.code === '200')) {
|
|
137
|
+
dispatch(updateCurrentCustomStemItem({
|
|
138
|
+
status: 'pay'
|
|
139
|
+
}));
|
|
140
|
+
return res;
|
|
141
|
+
}
|
|
142
|
+
if (res && "".concat(res.code) === PayStatus.Timeout) {
|
|
143
|
+
dispatch(updateCurrentCustomStemItem({
|
|
144
|
+
status: 'pay'
|
|
145
|
+
}));
|
|
146
|
+
}
|
|
147
|
+
return Promise.reject(res);
|
|
148
|
+
}).then(function (res) {
|
|
149
|
+
var _customRef$current2;
|
|
150
|
+
console.log('netRef.current = ', netRef.current);
|
|
151
|
+
if (unloadRef.current) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
if (!((_customRef$current2 = customRef.current) !== null && _customRef$current2 !== void 0 && _customRef$current2.net)) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
dispatch(updateNextStep());
|
|
158
|
+
clear = setTimeout(function () {
|
|
159
|
+
if (modeRef.current === ModeEnum.Pay) {
|
|
160
|
+
var _customRef$current3, _res$data;
|
|
161
|
+
var obj = ((_customRef$current3 = customRef.current) === null || _customRef$current3 === void 0 ? void 0 : _customRef$current3.pay) || {};
|
|
162
|
+
var cardReaderSurcharge = (res === null || res === void 0 ? void 0 : (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.card_reader_surcharge) || 0;
|
|
163
|
+
|
|
164
|
+
// 卡手续费
|
|
165
|
+
var surCardDeci = new Decimal(Number(cardReaderSurcharge));
|
|
166
|
+
|
|
167
|
+
// 手续费-固定金额
|
|
168
|
+
var surMoneyDeci = new Decimal(Number((obj === null || obj === void 0 ? void 0 : obj.surMoney) || 0));
|
|
169
|
+
|
|
170
|
+
// 手续费-比例金额
|
|
171
|
+
var surRateMoneyDeci = new Decimal(Number(obj === null || obj === void 0 ? void 0 : obj.surRateMoney));
|
|
172
|
+
|
|
173
|
+
// 手续费-固定金额 + 卡手续费 = 固定金额总额
|
|
174
|
+
var surMoneyTotal = surMoneyDeci.add(surCardDeci);
|
|
175
|
+
|
|
176
|
+
// 手续费-固定金额 + 卡手续费 + 手续费-比例金额 = 总手续费
|
|
177
|
+
var surchargeDeci = surMoneyTotal.add(surRateMoneyDeci);
|
|
178
|
+
onChange('success', _objectSpread(_objectSpread({}, obj), {}, {
|
|
179
|
+
number: ref.current,
|
|
180
|
+
device: deviceRef.current,
|
|
181
|
+
cardReaderSurcharge: cardReaderSurcharge,
|
|
182
|
+
surMoney: surMoneyTotal.toFixed(2, Decimal.ROUND_HALF_UP),
|
|
183
|
+
surcharge: surchargeDeci.toFixed(2, Decimal.ROUND_HALF_UP)
|
|
184
|
+
}));
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
if (modeRef.current === ModeEnum.Refund) {
|
|
188
|
+
var _obj = refundRef.current || {};
|
|
189
|
+
onChange('success', _objectSpread(_objectSpread({}, _obj), {}, {
|
|
190
|
+
number: ref.current,
|
|
191
|
+
device: deviceRef.current
|
|
192
|
+
}));
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
onChange('success', {
|
|
196
|
+
number: ref.current
|
|
197
|
+
});
|
|
198
|
+
}, 1000);
|
|
199
|
+
}, function (res) {
|
|
200
|
+
return Promise.reject(res);
|
|
201
|
+
}).catch(function (res) {
|
|
202
|
+
var _customRef$current4;
|
|
203
|
+
console.log('netRef.current = ', netRef.current);
|
|
204
|
+
if (unloadRef.current) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
if (!((_customRef$current4 = customRef.current) !== null && _customRef$current4 !== void 0 && _customRef$current4.net)) {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
if (res && "".concat(res.code) === PayStatus.Timeout) {
|
|
211
|
+
check(api.check, ref.current).then(function (r) {
|
|
212
|
+
var _customRef$current5;
|
|
213
|
+
console.log(' check :检车2 ,r ', r);
|
|
214
|
+
if (unloadRef.current) {
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
if (!((_customRef$current5 = customRef.current) !== null && _customRef$current5 !== void 0 && _customRef$current5.net)) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
if (r && (r.code === 200 || r.code === '200')) {
|
|
221
|
+
dispatch(updateCurrentCustomStemItem({
|
|
222
|
+
status: 'pay'
|
|
223
|
+
}));
|
|
224
|
+
dispatch(updateNextStep());
|
|
225
|
+
clearRef.current = setTimeout(function () {
|
|
226
|
+
var _res$data2, _customRef$current6;
|
|
227
|
+
var cardReaderSurcharge = (res === null || res === void 0 ? void 0 : (_res$data2 = res.data) === null || _res$data2 === void 0 ? void 0 : _res$data2.card_reader_surcharge) || 0;
|
|
228
|
+
var obj = ((_customRef$current6 = customRef.current) === null || _customRef$current6 === void 0 ? void 0 : _customRef$current6.pay) || {};
|
|
229
|
+
// 卡手续费
|
|
230
|
+
var surCardDeci = new Decimal(Number(cardReaderSurcharge));
|
|
231
|
+
|
|
232
|
+
// 手续费-固定金额
|
|
233
|
+
var surMoneyDeci = new Decimal(Number((obj === null || obj === void 0 ? void 0 : obj.surMoney) || 0));
|
|
234
|
+
|
|
235
|
+
// 手续费-比例金额
|
|
236
|
+
var surRateMoneyDeci = new Decimal(Number(obj === null || obj === void 0 ? void 0 : obj.surRateMoney));
|
|
237
|
+
|
|
238
|
+
// 手续费-固定金额 + 卡手续费 = 固定金额总额
|
|
239
|
+
var surMoneyTotal = surMoneyDeci.add(surCardDeci);
|
|
240
|
+
|
|
241
|
+
// 手续费-固定金额 + 卡手续费 + 手续费-比例金额 = 总手续费
|
|
242
|
+
var surchargeDeci = surMoneyTotal.add(surRateMoneyDeci);
|
|
243
|
+
onChange('success', _objectSpread(_objectSpread({}, obj), {}, {
|
|
244
|
+
number: ref.current,
|
|
245
|
+
device: deviceRef.current,
|
|
246
|
+
cardReaderSurcharge: cardReaderSurcharge,
|
|
247
|
+
surMoney: surMoneyTotal.toFixed(2, Decimal.ROUND_HALF_UP),
|
|
248
|
+
surcharge: surchargeDeci.toFixed(2, Decimal.ROUND_HALF_UP)
|
|
249
|
+
}));
|
|
250
|
+
}, 1000);
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
failRef.current(r);
|
|
254
|
+
}, function (r) {
|
|
255
|
+
var _customRef$current7;
|
|
256
|
+
if (unloadRef.current) {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
if (!((_customRef$current7 = customRef.current) !== null && _customRef$current7 !== void 0 && _customRef$current7.net)) {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
failRef.current(r);
|
|
263
|
+
});
|
|
264
|
+
} else {
|
|
265
|
+
failRef.current(res);
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
} else {
|
|
270
|
+
check(api.check, ref.current).then(function (res) {
|
|
271
|
+
var _customRef$current8;
|
|
272
|
+
console.log(' check 检车 ,r ', res);
|
|
273
|
+
if (unloadRef.current) {
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
if (!((_customRef$current8 = customRef.current) !== null && _customRef$current8 !== void 0 && _customRef$current8.net)) {
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
if (res && (res.code === 200 || res.code === '200')) {
|
|
280
|
+
dispatch(updateCurrentCustomStemItem({
|
|
281
|
+
status: 'pay'
|
|
282
|
+
}));
|
|
283
|
+
dispatch(updateNextStep());
|
|
284
|
+
clearRef.current = setTimeout(function () {
|
|
285
|
+
var _res$data3, _customRef$current9;
|
|
286
|
+
var cardReaderSurcharge = (res === null || res === void 0 ? void 0 : (_res$data3 = res.data) === null || _res$data3 === void 0 ? void 0 : _res$data3.card_reader_surcharge) || 0;
|
|
287
|
+
var obj = ((_customRef$current9 = customRef.current) === null || _customRef$current9 === void 0 ? void 0 : _customRef$current9.pay) || {};
|
|
288
|
+
// 卡手续费
|
|
289
|
+
var surCardDeci = new Decimal(Number(cardReaderSurcharge));
|
|
290
|
+
|
|
291
|
+
// 手续费-固定金额
|
|
292
|
+
var surMoneyDeci = new Decimal(Number((obj === null || obj === void 0 ? void 0 : obj.surMoney) || 0));
|
|
293
|
+
|
|
294
|
+
// 手续费-比例金额
|
|
295
|
+
var surRateMoneyDeci = new Decimal(Number(obj === null || obj === void 0 ? void 0 : obj.surRateMoney));
|
|
296
|
+
|
|
297
|
+
// 手续费-固定金额 + 卡手续费 = 固定金额总额
|
|
298
|
+
var surMoneyTotal = surMoneyDeci.add(surCardDeci);
|
|
299
|
+
|
|
300
|
+
// 手续费-固定金额 + 卡手续费 + 手续费-比例金额 = 总手续费
|
|
301
|
+
var surchargeDeci = surMoneyTotal.add(surRateMoneyDeci);
|
|
302
|
+
onChange('success', _objectSpread(_objectSpread({}, obj), {}, {
|
|
303
|
+
number: ref.current,
|
|
304
|
+
device: deviceRef.current,
|
|
305
|
+
cardReaderSurcharge: cardReaderSurcharge,
|
|
306
|
+
surMoney: surMoneyTotal.toFixed(2, Decimal.ROUND_HALF_UP),
|
|
307
|
+
surcharge: surchargeDeci.toFixed(2, Decimal.ROUND_HALF_UP)
|
|
308
|
+
}));
|
|
309
|
+
}, 1000);
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
failRef.current(res);
|
|
313
|
+
}, function (res) {
|
|
314
|
+
var _customRef$current10;
|
|
315
|
+
if (unloadRef.current) {
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
if (!((_customRef$current10 = customRef.current) !== null && _customRef$current10 !== void 0 && _customRef$current10.net)) {
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
failRef.current(res);
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
}, [api, check, dispatch, eftpos, onChange]);
|
|
325
|
+
useEffect(function () {
|
|
326
|
+
return function () {
|
|
327
|
+
var _controllerRef$curren;
|
|
328
|
+
(_controllerRef$curren = controllerRef.current) === null || _controllerRef$curren === void 0 ? void 0 : _controllerRef$curren.abort();
|
|
329
|
+
unloadRef.current = true;
|
|
330
|
+
if (clearRef.current) {
|
|
331
|
+
clearTimeout(clearRef.current);
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
}, []);
|
|
335
|
+
return /*#__PURE__*/React.createElement(Step, props);
|
|
336
|
+
};
|
|
337
|
+
export var Action = function Action() {
|
|
338
|
+
var dispatch = useDispatch();
|
|
339
|
+
var _useContextData2 = useContextData(),
|
|
340
|
+
mode = _useContextData2.mode;
|
|
341
|
+
var onManually = function onManually() {
|
|
342
|
+
dispatch(updateState({
|
|
343
|
+
manual: {
|
|
344
|
+
title: locales.getText('page.eftpos-pay.text.request.title')(mode),
|
|
345
|
+
text: locales.getText('page.eftpos-pay.text.request.text')(mode)
|
|
346
|
+
}
|
|
347
|
+
}));
|
|
348
|
+
dispatch(updateComponent('Manual', true));
|
|
349
|
+
};
|
|
350
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
351
|
+
className: "pisell-lowcode__eft-pay-step-item-btns"
|
|
352
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
353
|
+
block: true,
|
|
354
|
+
className: "pisell-lowcode__eft-pay-step-item-btn",
|
|
355
|
+
onClick: onManually
|
|
356
|
+
}, locales.getText('page.eftpos-pay.text.manual.marking')));
|
|
357
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Amount, ModeEnum } from '../const';
|
|
2
|
+
import { State } from '../store';
|
|
3
|
+
export declare const getStep: (mode?: ModeEnum) => State['steps'];
|
|
4
|
+
declare const getInitState: (params: any) => State;
|
|
5
|
+
export default getInitState;
|
|
6
|
+
export declare function getAmonunt(store: State): Amount;
|
|
@@ -0,0 +1,93 @@
|
|
|
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
|
+
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; }
|
|
3
|
+
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; }
|
|
4
|
+
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; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
|
+
import { locales } from '@pisell/utils';
|
|
8
|
+
import { EftposEnum, StatusEnum, PayRouteEnum, ModeEnum } from "../const";
|
|
9
|
+
export var getStep = function getStep() {
|
|
10
|
+
var mode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ModeEnum.Pay;
|
|
11
|
+
return [{
|
|
12
|
+
key: Date.now(),
|
|
13
|
+
title: locales.getText('page.eftpos-pay.text.loading')(mode),
|
|
14
|
+
// 'Payment in process...',
|
|
15
|
+
text: locales.getText('page.eftpos-pay.text.waiting.processing'),
|
|
16
|
+
// 'Waiting for the processing...',
|
|
17
|
+
warn: '',
|
|
18
|
+
tip: locales.getText('page.eftpos-pay.text.processing'),
|
|
19
|
+
// 'processing...',
|
|
20
|
+
status: StatusEnum.Loading
|
|
21
|
+
}];
|
|
22
|
+
};
|
|
23
|
+
var getInitState = function getInitState(params) {
|
|
24
|
+
return _objectSpread({
|
|
25
|
+
mode: (params === null || params === void 0 ? void 0 : params.mode) || ModeEnum.Pay,
|
|
26
|
+
eftpos: EftposEnum.Payo,
|
|
27
|
+
key: Date.now(),
|
|
28
|
+
warn: locales.getText('page.eftpos-pay.text.waiting.pay')((params === null || params === void 0 ? void 0 : params.mode) || ModeEnum.Pay),
|
|
29
|
+
// 'If you have confirmed the payment status from the PoS, you can press Manual marking buttonto skip.',
|
|
30
|
+
step: 0,
|
|
31
|
+
type: PayRouteEnum.Step,
|
|
32
|
+
title: locales.getText('page.eftpos-pay.text.loading')((params === null || params === void 0 ? void 0 : params.mode) || ModeEnum.Pay),
|
|
33
|
+
// 'Payment in process...',
|
|
34
|
+
component: '',
|
|
35
|
+
status: StatusEnum.Loading,
|
|
36
|
+
steps: getStep((params === null || params === void 0 ? void 0 : params.mode) || ModeEnum.Pay),
|
|
37
|
+
custom: params,
|
|
38
|
+
render: true
|
|
39
|
+
}, params.device ? {
|
|
40
|
+
device: params.device
|
|
41
|
+
} : {});
|
|
42
|
+
};
|
|
43
|
+
export default getInitState;
|
|
44
|
+
export function getAmonunt(store) {
|
|
45
|
+
var device = store.device,
|
|
46
|
+
custom = store.custom;
|
|
47
|
+
if (!device || !custom) {
|
|
48
|
+
throw Error('device or custom is not defined');
|
|
49
|
+
}
|
|
50
|
+
var name = custom.name;
|
|
51
|
+
var symbol = custom.symbol;
|
|
52
|
+
// const format = custom.format as string;
|
|
53
|
+
var money = custom.amount;
|
|
54
|
+
var pay = custom.pay;
|
|
55
|
+
var setting = device.setting;
|
|
56
|
+
if (pay) {
|
|
57
|
+
return {
|
|
58
|
+
name: name,
|
|
59
|
+
symbol: symbol,
|
|
60
|
+
// format,
|
|
61
|
+
money: money,
|
|
62
|
+
amount: Number(pay.amount),
|
|
63
|
+
surRate: Number(pay.surRate),
|
|
64
|
+
surMoney: Number(pay.surMoney),
|
|
65
|
+
surcharge: (setting === null || setting === void 0 ? void 0 : setting.surcharge) || false
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
if (!setting) {
|
|
69
|
+
return {
|
|
70
|
+
name: name,
|
|
71
|
+
symbol: symbol,
|
|
72
|
+
// format,
|
|
73
|
+
money: money,
|
|
74
|
+
amount: money,
|
|
75
|
+
surRate: 0,
|
|
76
|
+
surMoney: 0,
|
|
77
|
+
surcharge: false
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
var surRate = setting.constant_rate || 0;
|
|
81
|
+
var surMoney = setting.constant_money || 0;
|
|
82
|
+
var surcharge = setting.surcharge;
|
|
83
|
+
return {
|
|
84
|
+
name: name,
|
|
85
|
+
symbol: symbol,
|
|
86
|
+
// format,
|
|
87
|
+
money: money,
|
|
88
|
+
amount: money,
|
|
89
|
+
surRate: surcharge ? surRate : 0,
|
|
90
|
+
surMoney: surcharge ? surMoney : 0,
|
|
91
|
+
surcharge: surcharge
|
|
92
|
+
};
|
|
93
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { PayStatus } from '../const';
|
|
2
|
+
export declare const useValidate: (timeout: number) => readonly [(params_0: (...agrn: unknown[]) => Promise<any>, params_1: number, params_2?: number | undefined) => Promise<{
|
|
3
|
+
[key: string]: unknown;
|
|
4
|
+
code: `${PayStatus}`;
|
|
5
|
+
}>, () => void];
|
|
@@ -0,0 +1,84 @@
|
|
|
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
|
+
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 exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
3
|
+
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); } }
|
|
4
|
+
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); }); }; }
|
|
5
|
+
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
|
6
|
+
/* eslint-disable @typescript-eslint/no-loop-func */
|
|
7
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
8
|
+
import { PayStatus } from "../const";
|
|
9
|
+
import { sleep } from "../helper";
|
|
10
|
+
export var useValidate = function useValidate(timeout) {
|
|
11
|
+
var controllerRef = useRef();
|
|
12
|
+
var ref = useRef(true);
|
|
13
|
+
var TimeoutRef = useRef();
|
|
14
|
+
var checkApi = useCallback( /*#__PURE__*/function () {
|
|
15
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(check, number, time) {
|
|
16
|
+
var res, start, diff;
|
|
17
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
18
|
+
while (1) switch (_context.prev = _context.next) {
|
|
19
|
+
case 0:
|
|
20
|
+
time = time || 5000;
|
|
21
|
+
controllerRef.current = new AbortController();
|
|
22
|
+
res = {
|
|
23
|
+
code: PayStatus.Timeout
|
|
24
|
+
};
|
|
25
|
+
console.log('循环开始前...');
|
|
26
|
+
case 4:
|
|
27
|
+
if (!(ref.current && res && ("".concat(res.code) === PayStatus.Timeout || "".concat(res.code) === PayStatus.PayTimeout))) {
|
|
28
|
+
_context.next = 16;
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
start = Date.now();
|
|
32
|
+
_context.next = 8;
|
|
33
|
+
return check({
|
|
34
|
+
number: number
|
|
35
|
+
}, {
|
|
36
|
+
signal: controllerRef.current.signal
|
|
37
|
+
}).catch(function (err) {
|
|
38
|
+
return Promise.resolve(err);
|
|
39
|
+
});
|
|
40
|
+
case 8:
|
|
41
|
+
res = _context.sent;
|
|
42
|
+
diff = Date.now() - start;
|
|
43
|
+
console.log(diff, time, time - diff, 'diff', res);
|
|
44
|
+
if (!(diff < time)) {
|
|
45
|
+
_context.next = 14;
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
_context.next = 14;
|
|
49
|
+
return sleep(time - diff);
|
|
50
|
+
case 14:
|
|
51
|
+
_context.next = 4;
|
|
52
|
+
break;
|
|
53
|
+
case 16:
|
|
54
|
+
return _context.abrupt("return", res);
|
|
55
|
+
case 17:
|
|
56
|
+
case "end":
|
|
57
|
+
return _context.stop();
|
|
58
|
+
}
|
|
59
|
+
}, _callee);
|
|
60
|
+
}));
|
|
61
|
+
return function (_x, _x2, _x3) {
|
|
62
|
+
return _ref.apply(this, arguments);
|
|
63
|
+
};
|
|
64
|
+
}(), []);
|
|
65
|
+
var close = useCallback(function () {
|
|
66
|
+
var _controllerRef$curren;
|
|
67
|
+
ref.current = false;
|
|
68
|
+
(_controllerRef$curren = controllerRef.current) === null || _controllerRef$curren === void 0 ? void 0 : _controllerRef$curren.abort();
|
|
69
|
+
}, []);
|
|
70
|
+
var run = function run() {
|
|
71
|
+
TimeoutRef.current && clearTimeout(TimeoutRef.current);
|
|
72
|
+
TimeoutRef.current = setTimeout(function () {
|
|
73
|
+
close();
|
|
74
|
+
}, timeout);
|
|
75
|
+
return checkApi.apply(void 0, arguments);
|
|
76
|
+
};
|
|
77
|
+
useEffect(function () {
|
|
78
|
+
return function () {
|
|
79
|
+
clearTimeout(TimeoutRef.current);
|
|
80
|
+
close();
|
|
81
|
+
};
|
|
82
|
+
}, [close]);
|
|
83
|
+
return [run, close];
|
|
84
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
var _excluded = ["step", "steps"];
|
|
2
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
3
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
4
|
+
/* eslint-disable array-callback-return */
|
|
5
|
+
/* eslint-disable consistent-return */
|
|
6
|
+
/* eslint-disable react/no-array-index-key */
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { StatusEnum } from "../const";
|
|
9
|
+
import { useContextData } from "../store";
|
|
10
|
+
import { POS, Action } from "./config";
|
|
11
|
+
export default (function (_ref) {
|
|
12
|
+
var api = _ref.api,
|
|
13
|
+
onChange = _ref.onChange,
|
|
14
|
+
children = _ref.children;
|
|
15
|
+
var _useContextData = useContextData(),
|
|
16
|
+
step = _useContextData.step,
|
|
17
|
+
steps = _useContextData.steps,
|
|
18
|
+
data = _objectWithoutProperties(_useContextData, _excluded);
|
|
19
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
20
|
+
className: "pisell-lowcode__eft-pay-body "
|
|
21
|
+
}, steps.map(function (item, idx) {
|
|
22
|
+
var Comm;
|
|
23
|
+
if (idx === 0) Comm = POS;
|
|
24
|
+
if (!Comm) {
|
|
25
|
+
throw new Error('no comm');
|
|
26
|
+
}
|
|
27
|
+
if (step >= idx) {
|
|
28
|
+
return /*#__PURE__*/React.createElement(Comm, {
|
|
29
|
+
key: "".concat(data.key, "-").concat(item.key, "-").concat(idx),
|
|
30
|
+
api: api,
|
|
31
|
+
onChange: onChange
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}), children), data.status !== StatusEnum.Success ? /*#__PURE__*/React.createElement(Action, null) : null);
|
|
35
|
+
});
|