@pisell/private-materials 3.0.95 → 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,139 @@
|
|
|
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 _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
11
|
+
amount: '0',
|
|
12
|
+
symbol: '',
|
|
13
|
+
mode: ModeEnum.Pay
|
|
14
|
+
},
|
|
15
|
+
amount = _ref.amount,
|
|
16
|
+
symbol = _ref.symbol,
|
|
17
|
+
mode = _ref.mode;
|
|
18
|
+
return [{
|
|
19
|
+
title: locales.getText('page.eftpos-pay.text.loading')(mode),
|
|
20
|
+
key: Date.now(),
|
|
21
|
+
text: locales.getText('page.eftpos-pay.text.wait')(symbol + amount, mode),
|
|
22
|
+
// 'Asked EFTPOS to accept payment for Purchase $100...',
|
|
23
|
+
warn: '',
|
|
24
|
+
tip: 'processing...',
|
|
25
|
+
status: 'loading'
|
|
26
|
+
}, {
|
|
27
|
+
title: locales.getText('page.eftpos-pay.text.loading')(mode),
|
|
28
|
+
key: Date.now(),
|
|
29
|
+
text: locales.getText('page.eftpos-pay.text.surcharge'),
|
|
30
|
+
warn: '',
|
|
31
|
+
tip: 'processing...',
|
|
32
|
+
status: 'loading'
|
|
33
|
+
}, {
|
|
34
|
+
title: locales.getText('page.eftpos-pay.text.loading')(mode),
|
|
35
|
+
key: Date.now(),
|
|
36
|
+
text: locales.getText('page.eftpos-pay.text.account'),
|
|
37
|
+
warn: '',
|
|
38
|
+
tip: 'processing...',
|
|
39
|
+
status: 'loading'
|
|
40
|
+
}, {
|
|
41
|
+
title: locales.getText('page.eftpos-pay.text.loading')(mode),
|
|
42
|
+
key: Date.now(),
|
|
43
|
+
text: locales.getText('page.eftpos-pay.text.pin'),
|
|
44
|
+
warn: '',
|
|
45
|
+
tip: 'processing...',
|
|
46
|
+
status: 'loading'
|
|
47
|
+
}, {
|
|
48
|
+
title: locales.getText('page.eftpos-pay.text.loading')(mode),
|
|
49
|
+
key: Date.now(),
|
|
50
|
+
text: locales.getText('page.eftpos-pay.text.receipt'),
|
|
51
|
+
warn: '',
|
|
52
|
+
tip: 'processing...',
|
|
53
|
+
status: 'loading'
|
|
54
|
+
}, {
|
|
55
|
+
title: locales.getText('page.eftpos-pay.text.loading')(mode),
|
|
56
|
+
key: Date.now(),
|
|
57
|
+
text: locales.getText('page.eftpos-pay.text.receipt.again.title'),
|
|
58
|
+
warn: locales.getText('page.eftpos-pay.text.receipt.again.text'),
|
|
59
|
+
tip: '',
|
|
60
|
+
status: 'warn'
|
|
61
|
+
}, {
|
|
62
|
+
title: locales.getText('page.eftpos-pay.text.loading')(mode),
|
|
63
|
+
key: Date.now(),
|
|
64
|
+
text: 'Waiting for the appvoval...',
|
|
65
|
+
success: 'Approade',
|
|
66
|
+
warn: '',
|
|
67
|
+
tip: 'processing...',
|
|
68
|
+
status: 'loading'
|
|
69
|
+
}];
|
|
70
|
+
};
|
|
71
|
+
var getInitState = function getInitState(params) {
|
|
72
|
+
return _objectSpread({
|
|
73
|
+
mode: (params === null || params === void 0 ? void 0 : params.mode) || ModeEnum.Pay,
|
|
74
|
+
eftpos: EftposEnum.Eftpos,
|
|
75
|
+
key: Date.now(),
|
|
76
|
+
warn: '',
|
|
77
|
+
step: 0,
|
|
78
|
+
type: PayRouteEnum.Step,
|
|
79
|
+
title: locales.getText('page.eftpos-pay.text.loading')((params === null || params === void 0 ? void 0 : params.mode) || ModeEnum.Pay),
|
|
80
|
+
component: '',
|
|
81
|
+
status: StatusEnum.Loading,
|
|
82
|
+
steps: getStep(params),
|
|
83
|
+
custom: params,
|
|
84
|
+
render: true
|
|
85
|
+
}, params.device ? {
|
|
86
|
+
device: params.device
|
|
87
|
+
} : {});
|
|
88
|
+
};
|
|
89
|
+
export default getInitState;
|
|
90
|
+
export function getAmonunt(store) {
|
|
91
|
+
var device = store.device,
|
|
92
|
+
custom = store.custom;
|
|
93
|
+
if (!device || !custom) {
|
|
94
|
+
throw Error('device or custom is not defined');
|
|
95
|
+
}
|
|
96
|
+
var name = custom.name;
|
|
97
|
+
var symbol = custom.symbol;
|
|
98
|
+
// const format = custom.format as string;
|
|
99
|
+
var money = custom.amount;
|
|
100
|
+
var pay = custom.pay;
|
|
101
|
+
var setting = device.setting;
|
|
102
|
+
if (pay) {
|
|
103
|
+
return {
|
|
104
|
+
name: name,
|
|
105
|
+
symbol: symbol,
|
|
106
|
+
// format,
|
|
107
|
+
money: money,
|
|
108
|
+
amount: Number(pay.amount),
|
|
109
|
+
surRate: Number(pay.surRate),
|
|
110
|
+
surMoney: Number(pay.surMoney),
|
|
111
|
+
surcharge: (setting === null || setting === void 0 ? void 0 : setting.surcharge) || false
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
if (!setting) {
|
|
115
|
+
return {
|
|
116
|
+
name: name,
|
|
117
|
+
symbol: symbol,
|
|
118
|
+
// format,
|
|
119
|
+
money: money,
|
|
120
|
+
amount: money,
|
|
121
|
+
surRate: 0,
|
|
122
|
+
surMoney: 0,
|
|
123
|
+
surcharge: false
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
var surRate = setting.constant_rate || 0;
|
|
127
|
+
var surMoney = setting.constant_money || 0;
|
|
128
|
+
var surcharge = setting.surcharge;
|
|
129
|
+
return {
|
|
130
|
+
name: name,
|
|
131
|
+
symbol: symbol,
|
|
132
|
+
// format,
|
|
133
|
+
money: money,
|
|
134
|
+
amount: money,
|
|
135
|
+
surRate: surcharge ? surRate : 0,
|
|
136
|
+
surMoney: surcharge ? surMoney : 0,
|
|
137
|
+
surcharge: surcharge
|
|
138
|
+
};
|
|
139
|
+
}
|
|
@@ -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 react/no-array-index-key */
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { StatusEnum } from "../const";
|
|
7
|
+
import { useContextData } from "../store";
|
|
8
|
+
import { POS, Surcharge, Card, Pwd, Receipet, ReceipetAgain, Wait, Action } from "./config";
|
|
9
|
+
export default (function (_ref) {
|
|
10
|
+
var api = _ref.api,
|
|
11
|
+
onChange = _ref.onChange,
|
|
12
|
+
children = _ref.children;
|
|
13
|
+
var _useContextData = useContextData(),
|
|
14
|
+
step = _useContextData.step,
|
|
15
|
+
steps = _useContextData.steps,
|
|
16
|
+
data = _objectWithoutProperties(_useContextData, _excluded);
|
|
17
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, steps.map(function (item, idx) {
|
|
18
|
+
var Comm;
|
|
19
|
+
if (idx === 0) Comm = POS;
|
|
20
|
+
if (idx === 1) Comm = Surcharge;
|
|
21
|
+
if (idx === 2) Comm = Card;
|
|
22
|
+
if (idx === 3) Comm = Pwd;
|
|
23
|
+
if (idx === 4) Comm = Receipet;
|
|
24
|
+
if (idx === 5) Comm = ReceipetAgain;
|
|
25
|
+
if (idx === 6) Comm = Wait;
|
|
26
|
+
if (!Comm) {
|
|
27
|
+
throw new Error('no comm');
|
|
28
|
+
}
|
|
29
|
+
return /*#__PURE__*/React.createElement(Comm, {
|
|
30
|
+
key: "".concat(data.key, "-").concat(item.key, "-").concat(idx)
|
|
31
|
+
});
|
|
32
|
+
}), children, data.status !== StatusEnum.Success ? /*#__PURE__*/React.createElement(Action, {
|
|
33
|
+
index: step
|
|
34
|
+
}) : null);
|
|
35
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
/* eslint-disable no-bitwise */
|
|
3
|
+
export function getUuid() {
|
|
4
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
5
|
+
var r = Math.random() * 16 | 0;
|
|
6
|
+
var v = c === 'x' ? r : r & 0x3 | 0x8;
|
|
7
|
+
return v.toString(16);
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
export var sleep = function sleep(time) {
|
|
11
|
+
return new Promise(function (resove) {
|
|
12
|
+
setTimeout(function () {
|
|
13
|
+
resove(undefined);
|
|
14
|
+
}, time);
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
export function cloneDeep(source) {
|
|
18
|
+
var hash = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new WeakMap();
|
|
19
|
+
if (_typeof(source) !== 'object' || source === null) {
|
|
20
|
+
return source;
|
|
21
|
+
}
|
|
22
|
+
if (hash.has(source)) {
|
|
23
|
+
return hash.get(source);
|
|
24
|
+
}
|
|
25
|
+
var target = Array.isArray(source) ? [] : {};
|
|
26
|
+
Reflect.ownKeys(source).forEach(function (key) {
|
|
27
|
+
var val = source[key];
|
|
28
|
+
if (_typeof(val) === 'object' && val != null) {
|
|
29
|
+
target[key] = cloneDeep(val, hash);
|
|
30
|
+
} else {
|
|
31
|
+
target[key] = val;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
return target;
|
|
35
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
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 React, { useCallback, useEffect, useRef } from 'react';
|
|
9
|
+
import { PayStatus } from "./const";
|
|
10
|
+
import { useContextData, useDispatch, updateComponent, updateSteps, updateState, updateCustom, updateCustomStemItem, updateKey } from "./store";
|
|
11
|
+
var Max4004 = 1;
|
|
12
|
+
export var useFail = function useFail(index) {
|
|
13
|
+
var isMark = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
14
|
+
var _useContextData = useContextData(),
|
|
15
|
+
steps = _useContextData.steps,
|
|
16
|
+
custom = _useContextData.custom,
|
|
17
|
+
mode = _useContextData.mode;
|
|
18
|
+
var dispatch = useDispatch();
|
|
19
|
+
var ref = useRef((custom === null || custom === void 0 ? void 0 : custom.retry) || 0);
|
|
20
|
+
useEffect(function () {
|
|
21
|
+
ref.current = (custom === null || custom === void 0 ? void 0 : custom.retry) || 0;
|
|
22
|
+
}, [custom === null || custom === void 0 ? void 0 : custom.retry]);
|
|
23
|
+
return useCallback(function (res) {
|
|
24
|
+
if (!res || !res.code) {
|
|
25
|
+
dispatch(updateCustom({
|
|
26
|
+
errorStatus: 'unknow' // unknow know
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
dispatch(updateComponent('UnknowFail'));
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
var code = "".concat(res.code);
|
|
33
|
+
dispatch(updateCustomStemItem({
|
|
34
|
+
step: index
|
|
35
|
+
}));
|
|
36
|
+
if (code === PayStatus.Unknown) {
|
|
37
|
+
steps[index].title = locales.getText('page.eftpos-pay.text.failed')(mode);
|
|
38
|
+
steps[index].fail = locales.getText('page.eftpos-pay.text.transaction.fail');
|
|
39
|
+
steps[index].status = 'fail';
|
|
40
|
+
dispatch(updateSteps(steps));
|
|
41
|
+
dispatch(updateComponent('Fail'));
|
|
42
|
+
dispatch(updateCustom({
|
|
43
|
+
errorStatus: 'know' // unknow know
|
|
44
|
+
}));
|
|
45
|
+
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (code === PayStatus.Timeout || code === PayStatus.PayTimeout) {
|
|
49
|
+
if (isMark) {
|
|
50
|
+
steps[index].status = 'fail';
|
|
51
|
+
dispatch(updateSteps(steps));
|
|
52
|
+
dispatch(updateState({
|
|
53
|
+
manual: {
|
|
54
|
+
title: locales.getText('page.eftpos-pay.text.timedout.title'),
|
|
55
|
+
text: locales.getText('page.eftpos-pay.text.timedout.text')(mode)
|
|
56
|
+
}
|
|
57
|
+
}));
|
|
58
|
+
dispatch(updateCustom({
|
|
59
|
+
errorStatus: 'know' // unknow know
|
|
60
|
+
}));
|
|
61
|
+
|
|
62
|
+
dispatch(updateComponent('Manual'));
|
|
63
|
+
dispatch(updateCustom({
|
|
64
|
+
errorStatus: 'know' // unknow know
|
|
65
|
+
}));
|
|
66
|
+
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
steps[index].fail = code === PayStatus.Timeout ? locales.getText('page.eftpos-pay.text.transaction.pay.fail.timeout') : locales.getText('page.eftpos-pay.text.transaction.fail.timeout');
|
|
70
|
+
steps[index].title = locales.getText('page.eftpos-pay.text.failed')(mode);
|
|
71
|
+
steps[index].status = 'fail';
|
|
72
|
+
dispatch(updateSteps(steps));
|
|
73
|
+
dispatch(updateComponent('Fail'));
|
|
74
|
+
dispatch(updateCustom({
|
|
75
|
+
errorStatus: 'know' // unknow know
|
|
76
|
+
}));
|
|
77
|
+
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (code === PayStatus.NoPay) {
|
|
81
|
+
if (ref.current > Max4004) {
|
|
82
|
+
dispatch(updateCustom({
|
|
83
|
+
retry: ref.current,
|
|
84
|
+
number: undefined
|
|
85
|
+
}));
|
|
86
|
+
steps[index].title = locales.getText('page.eftpos-pay.text.failed')(mode);
|
|
87
|
+
steps[index].fail = locales.getText('page.eftpos-pay.text.transaction.fail');
|
|
88
|
+
steps[index].status = 'fail';
|
|
89
|
+
dispatch(updateSteps(steps));
|
|
90
|
+
dispatch(updateComponent('Fail'));
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
ref.current += 1;
|
|
94
|
+
dispatch(updateCustom({
|
|
95
|
+
retry: ref.current,
|
|
96
|
+
number: undefined
|
|
97
|
+
}));
|
|
98
|
+
dispatch(updateKey(Date.now()));
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (code === PayStatus.PayOtherEftposFailed) {
|
|
102
|
+
steps[index].title = locales.getText('page.eftpos-pay.text.transaction.fail.terminal.title');
|
|
103
|
+
// steps[index].title = locales.getText('page.eftpos-pay.text.failed')(mode)
|
|
104
|
+
steps[index].fail = locales.getText('page.eftpos-pay.text.transaction.fail.terminal');
|
|
105
|
+
steps[index].status = 'fail';
|
|
106
|
+
dispatch(updateSteps(steps));
|
|
107
|
+
dispatch(updateComponent('Fail'));
|
|
108
|
+
dispatch(updateCustom({
|
|
109
|
+
errorStatus: 'know' // unknow know
|
|
110
|
+
}));
|
|
111
|
+
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if (code === PayStatus.PayCardErrorFailed) {
|
|
115
|
+
steps[index].title = locales.getText('page.eftpos-pay.text.transaction.fail.cancel.title');
|
|
116
|
+
steps[index].fail = locales.getText('page.eftpos-pay.text.transaction.fail.cancel');
|
|
117
|
+
steps[index].status = 'fail';
|
|
118
|
+
dispatch(updateSteps(steps));
|
|
119
|
+
dispatch(updateComponent('Fail'));
|
|
120
|
+
dispatch(updateCustom({
|
|
121
|
+
errorStatus: 'know' // unknow know
|
|
122
|
+
}));
|
|
123
|
+
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (code === PayStatus.NoNetWork || code === PayStatus.SocketError) {
|
|
127
|
+
steps[index].title = locales.getText('page.eftpos-pay.text.interrupted');
|
|
128
|
+
steps[index].warn = /*#__PURE__*/React.createElement(React.Fragment, null, locales.getText('page.eftpos-pay.text.transaction.eftpos.fail.title'), /*#__PURE__*/React.createElement("br", null), locales.getText('page.eftpos-pay.text.transaction.eftpos.fail.power'), ". ", /*#__PURE__*/React.createElement("br", null), locales.getText('page.eftpos-pay.text.transaction.eftpos.fail.device'), /*#__PURE__*/React.createElement("br", null), locales.getText('page.eftpos-pay.text.transaction.eftpos.fail.network'), /*#__PURE__*/React.createElement("br", null), locales.getText('page.eftpos-pay.text.transaction.eftpos.fail.if')(mode));
|
|
129
|
+
steps[index].status = 'warn';
|
|
130
|
+
steps[index].custom = steps[index].custom ? _objectSpread(_objectSpread({}, steps[index].custom), {}, {
|
|
131
|
+
isPosNetworkError: true
|
|
132
|
+
}) : {
|
|
133
|
+
isPosNetworkError: true
|
|
134
|
+
};
|
|
135
|
+
dispatch(updateSteps(steps));
|
|
136
|
+
dispatch(updateComponent('Fail'));
|
|
137
|
+
dispatch(updateCustom({
|
|
138
|
+
errorStatus: 'know' // unknow know
|
|
139
|
+
}));
|
|
140
|
+
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
steps[index].title = locales.getText('page.eftpos-pay.text.failed')(mode);
|
|
144
|
+
steps[index].status = 'fail';
|
|
145
|
+
steps[index].fail = locales.getText('page.eftpos-pay.text.transaction.fail');
|
|
146
|
+
dispatch(updateSteps(steps));
|
|
147
|
+
dispatch(updateCustom({
|
|
148
|
+
errorStatus: 'unknow' // unknow know
|
|
149
|
+
}));
|
|
150
|
+
|
|
151
|
+
dispatch(updateComponent('UnknowFail'));
|
|
152
|
+
}, [dispatch, index, steps, isMark]);
|
|
153
|
+
};
|
|
@@ -0,0 +1,188 @@
|
|
|
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"];
|
|
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 react/destructuring-assignment */
|
|
17
|
+
import { locales } from '@pisell/utils';
|
|
18
|
+
import React, { useEffect, useState, useMemo, useRef } from 'react';
|
|
19
|
+
import { useNetwork } from 'ahooks';
|
|
20
|
+
import useEngineContext from "../../hooks/useEngineContext";
|
|
21
|
+
import Amount from "./amount";
|
|
22
|
+
import { RouteEnum, ModeEnum } from "./const";
|
|
23
|
+
import Device from "./device";
|
|
24
|
+
import localeTexts from "./locales";
|
|
25
|
+
import { getInitState } from "./manufacturer";
|
|
26
|
+
import Pay from "./pay";
|
|
27
|
+
import { Provider, useContextData } from "./store";
|
|
28
|
+
import "./index.less";
|
|
29
|
+
locales.init(localeTexts, localStorage.getItem('umi_locale') || 'en');
|
|
30
|
+
var App = function App(_ref) {
|
|
31
|
+
var _context$appHelper;
|
|
32
|
+
var action = _ref.action,
|
|
33
|
+
getApi = _ref.getApi,
|
|
34
|
+
terminal = _ref.terminal,
|
|
35
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
36
|
+
var data = useContextData();
|
|
37
|
+
var ref = useRef(false);
|
|
38
|
+
var _useState = useState(action),
|
|
39
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
40
|
+
current = _useState2[0],
|
|
41
|
+
setCurrent = _useState2[1];
|
|
42
|
+
var statusRef = useRef(data.status);
|
|
43
|
+
var actRef = useRef(action);
|
|
44
|
+
var context = useEngineContext();
|
|
45
|
+
var _ref2 = ((_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.utils) || {
|
|
46
|
+
formatAmount: function formatAmount(number, precision, symbol) {
|
|
47
|
+
return "".concat(symbol).concat(number);
|
|
48
|
+
},
|
|
49
|
+
isTerminal: function isTerminal() {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
formatAmount = _ref2.formatAmount,
|
|
54
|
+
isTerminal = _ref2.isTerminal;
|
|
55
|
+
var network = useMemo(function () {
|
|
56
|
+
return typeof terminal.network === 'boolean' ? terminal.network : true;
|
|
57
|
+
}, [terminal === null || terminal === void 0 ? void 0 : terminal.network]);
|
|
58
|
+
var _useNetwork = useNetwork(),
|
|
59
|
+
online = _useNetwork.online;
|
|
60
|
+
var netRef = useRef([network, online]);
|
|
61
|
+
var net = useMemo(function () {
|
|
62
|
+
var networkChange = false,
|
|
63
|
+
onlineChange = false;
|
|
64
|
+
if (netRef.current[0] !== network) {
|
|
65
|
+
netRef.current[0] = network;
|
|
66
|
+
networkChange = true;
|
|
67
|
+
}
|
|
68
|
+
if (netRef.current[1] !== online) {
|
|
69
|
+
netRef.current[1] = online;
|
|
70
|
+
onlineChange = true;
|
|
71
|
+
}
|
|
72
|
+
if (networkChange) {
|
|
73
|
+
return network;
|
|
74
|
+
}
|
|
75
|
+
return online;
|
|
76
|
+
}, [network, online]);
|
|
77
|
+
useEffect(function () {
|
|
78
|
+
statusRef.current = data.status;
|
|
79
|
+
}, [data.status]);
|
|
80
|
+
var isIpad = useMemo(function () {
|
|
81
|
+
return isTerminal && isTerminal();
|
|
82
|
+
}, [isTerminal]);
|
|
83
|
+
var api = useMemo(function () {
|
|
84
|
+
if (typeof getApi === 'function') {
|
|
85
|
+
return getApi();
|
|
86
|
+
}
|
|
87
|
+
return {};
|
|
88
|
+
}, [getApi]);
|
|
89
|
+
|
|
90
|
+
// 切换
|
|
91
|
+
var onChange = function onChange(status, params) {
|
|
92
|
+
if (status === 'page' && typeof params === 'string') {
|
|
93
|
+
if (['amount', 'deviceList', 'pay'].includes(params)) {
|
|
94
|
+
setCurrent(params);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
console.log('状态切换 = ', status, params);
|
|
98
|
+
props.onChangeStatus(status, params);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
// 成功失败
|
|
102
|
+
var onClose = function onClose() {
|
|
103
|
+
onChange('fail');
|
|
104
|
+
};
|
|
105
|
+
if (current === RouteEnum.DeviceList) {
|
|
106
|
+
return /*#__PURE__*/React.createElement(Device, {
|
|
107
|
+
api: api,
|
|
108
|
+
onChange: onChange,
|
|
109
|
+
onClose: onClose,
|
|
110
|
+
isIpad: isIpad,
|
|
111
|
+
className: isIpad ? 'pisell-lowcode__eft-pay-terminal' : '',
|
|
112
|
+
net: net
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
if (current === RouteEnum.Amount) {
|
|
116
|
+
return /*#__PURE__*/React.createElement(Amount, {
|
|
117
|
+
onChange: onChange,
|
|
118
|
+
onClose: onClose,
|
|
119
|
+
formatAmount: formatAmount,
|
|
120
|
+
isIpad: isIpad,
|
|
121
|
+
className: isIpad ? 'pisell-lowcode__eft-pay-terminal' : '',
|
|
122
|
+
net: net
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
return /*#__PURE__*/React.createElement(Pay, {
|
|
126
|
+
api: api,
|
|
127
|
+
onChange: onChange,
|
|
128
|
+
className: isIpad ? 'pisell-lowcode__eft-pay-terminal' : '',
|
|
129
|
+
terminal: terminal,
|
|
130
|
+
net: net
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
export default (function (props) {
|
|
134
|
+
var _context$appHelper2, _store$getState, _store$getState$call, _store$getState$call$;
|
|
135
|
+
var context = useEngineContext();
|
|
136
|
+
var _ref3 = ((_context$appHelper2 = context.appHelper) === null || _context$appHelper2 === void 0 ? void 0 : _context$appHelper2.utils) || {
|
|
137
|
+
store: {}
|
|
138
|
+
},
|
|
139
|
+
store = _ref3.store;
|
|
140
|
+
var mode = useMemo(function () {
|
|
141
|
+
if (props.mode) {
|
|
142
|
+
return props.mode;
|
|
143
|
+
}
|
|
144
|
+
return ModeEnum.Pay;
|
|
145
|
+
}, [props.mode]);
|
|
146
|
+
var action = useMemo(function () {
|
|
147
|
+
if (mode === ModeEnum.Pay) {
|
|
148
|
+
return RouteEnum.DeviceList;
|
|
149
|
+
}
|
|
150
|
+
if (mode === ModeEnum.Refund) {
|
|
151
|
+
return RouteEnum.DeviceList;
|
|
152
|
+
}
|
|
153
|
+
if (mode === ModeEnum.Query) {
|
|
154
|
+
return RouteEnum.Pay;
|
|
155
|
+
}
|
|
156
|
+
throw Error('未知模式');
|
|
157
|
+
}, [mode]);
|
|
158
|
+
var symbol = (store === null || store === void 0 ? void 0 : (_store$getState = store.getState) === null || _store$getState === void 0 ? void 0 : (_store$getState$call = _store$getState.call(store)) === null || _store$getState$call === void 0 ? void 0 : (_store$getState$call$ = _store$getState$call.global) === null || _store$getState$call$ === void 0 ? void 0 : _store$getState$call$.symbol) || '$';
|
|
159
|
+
var onChangeStatus = function onChangeStatus(status, params) {
|
|
160
|
+
props.onChangeStatus(status, params);
|
|
161
|
+
};
|
|
162
|
+
var state = useMemo(function () {
|
|
163
|
+
var current = props.params && props.params.symbol ? props.params.symbol : symbol;
|
|
164
|
+
console.log('current 单位 = ', props.params.symbol, symbol);
|
|
165
|
+
return getInitState(props.type, props.params ? _objectSpread(_objectSpread({
|
|
166
|
+
mode: mode
|
|
167
|
+
}, props.params), {}, {
|
|
168
|
+
symbol: current
|
|
169
|
+
}) : {
|
|
170
|
+
mode: mode,
|
|
171
|
+
symbol: current
|
|
172
|
+
});
|
|
173
|
+
}, [mode, props.params, props.type, symbol]);
|
|
174
|
+
|
|
175
|
+
// useEffect(() => {
|
|
176
|
+
// document.body.id = 'body';
|
|
177
|
+
// }, []);
|
|
178
|
+
|
|
179
|
+
return /*#__PURE__*/React.createElement(Provider, {
|
|
180
|
+
state: state
|
|
181
|
+
}, /*#__PURE__*/React.createElement(App, {
|
|
182
|
+
getApi: props.getApi,
|
|
183
|
+
params: props.params,
|
|
184
|
+
onChangeStatus: onChangeStatus,
|
|
185
|
+
terminal: props.terminal,
|
|
186
|
+
action: action
|
|
187
|
+
}));
|
|
188
|
+
});
|