@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,326 @@
|
|
|
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
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
+
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."); }
|
|
9
|
+
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); }
|
|
10
|
+
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; }
|
|
11
|
+
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; } }
|
|
12
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
+
/* eslint-disable no-nested-ternary */
|
|
14
|
+
import { locales } from '@pisell/utils';
|
|
15
|
+
import { Button } from 'antd';
|
|
16
|
+
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
17
|
+
import { StatusEnum } from "../const";
|
|
18
|
+
import { useContextData, useDispatch, updateState, updateCustom, updateStatus, updateComponent } from "../store";
|
|
19
|
+
import { StemTypeEnum, StepStatusEnum, getStepMapping } from "./const";
|
|
20
|
+
export var ReceiptAction = function ReceiptAction(_ref) {
|
|
21
|
+
var api = _ref.api,
|
|
22
|
+
onChange = _ref.onChange;
|
|
23
|
+
var dispatch = useDispatch();
|
|
24
|
+
var _useContextData = useContextData(),
|
|
25
|
+
custom = _useContextData.custom,
|
|
26
|
+
mode = _useContextData.mode;
|
|
27
|
+
var ref = useRef(custom === null || custom === void 0 ? void 0 : custom.number);
|
|
28
|
+
var listRef = useRef(custom === null || custom === void 0 ? void 0 : custom.list);
|
|
29
|
+
var _useState = useState((custom === null || custom === void 0 ? void 0 : custom.receiptLoading) || false),
|
|
30
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
31
|
+
receiptLoading = _useState2[0],
|
|
32
|
+
setReceiptLoading = _useState2[1];
|
|
33
|
+
var unloadRef = useRef(false);
|
|
34
|
+
useEffect(function () {
|
|
35
|
+
dispatch(updateCustom({
|
|
36
|
+
receiptLoading: receiptLoading
|
|
37
|
+
}));
|
|
38
|
+
}, [receiptLoading]);
|
|
39
|
+
var receiptPage = useMemo(function () {
|
|
40
|
+
return (custom === null || custom === void 0 ? void 0 : custom.step) !== StepStatusEnum.Receipt ? '' : (custom === null || custom === void 0 ? void 0 : custom.receiptPage) || 'receipt';
|
|
41
|
+
}, [custom === null || custom === void 0 ? void 0 : custom.step, custom === null || custom === void 0 ? void 0 : custom.receiptPage]);
|
|
42
|
+
useEffect(function () {
|
|
43
|
+
listRef.current = custom === null || custom === void 0 ? void 0 : custom.list;
|
|
44
|
+
}, [custom === null || custom === void 0 ? void 0 : custom.list]);
|
|
45
|
+
useEffect(function () {
|
|
46
|
+
ref.current = custom === null || custom === void 0 ? void 0 : custom.number;
|
|
47
|
+
}, [custom === null || custom === void 0 ? void 0 : custom.number]);
|
|
48
|
+
var onAccept = function onAccept() {
|
|
49
|
+
// 确认签名
|
|
50
|
+
dispatch(updateStatus(StatusEnum.Loading));
|
|
51
|
+
dispatch(updateCustom({
|
|
52
|
+
list: listRef.current.map(function (item) {
|
|
53
|
+
return item.index === 7 ? _objectSpread(_objectSpread({}, item), {}, {
|
|
54
|
+
status: 'resolve'
|
|
55
|
+
}) : item;
|
|
56
|
+
})
|
|
57
|
+
}));
|
|
58
|
+
dispatch(updateState({
|
|
59
|
+
title: locales.getText('page.eftpos-pay.text.processing')
|
|
60
|
+
}));
|
|
61
|
+
setReceiptLoading(true);
|
|
62
|
+
api.update({
|
|
63
|
+
type: 'YES',
|
|
64
|
+
number: custom === null || custom === void 0 ? void 0 : custom.number
|
|
65
|
+
}).then(function (res) {
|
|
66
|
+
if (unloadRef.current) {
|
|
67
|
+
return res;
|
|
68
|
+
}
|
|
69
|
+
if (res && (res.code === 200 || res.code === '200')) {
|
|
70
|
+
setReceiptLoading(false);
|
|
71
|
+
var current = listRef.current.map(function (item) {
|
|
72
|
+
if (Number(item === null || item === void 0 ? void 0 : item.index) < StepStatusEnum.Wait) {
|
|
73
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
74
|
+
status: 'resolve'
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
return item;
|
|
78
|
+
});
|
|
79
|
+
var nextStep = getStepMapping(StepStatusEnum.Wait, {
|
|
80
|
+
mode: mode
|
|
81
|
+
});
|
|
82
|
+
if (nextStep) {
|
|
83
|
+
current.push(nextStep);
|
|
84
|
+
if (nextStep.type === StemTypeEnum.Passive) {
|
|
85
|
+
dispatch(updateStatus(StatusEnum.Question));
|
|
86
|
+
}
|
|
87
|
+
dispatch(updateState({
|
|
88
|
+
title: nextStep.index < StepStatusEnum.Receipt ? locales.getText('page.eftpos-pay.text.loading')(mode) : nextStep.index === StepStatusEnum.Receipt ? locales.getText('page.eftpos-pay.text.waiting.signature') // 等待签名
|
|
89
|
+
: locales.getText('page.eftpos-pay.text.loading')(mode)
|
|
90
|
+
}));
|
|
91
|
+
}
|
|
92
|
+
dispatch(updateCustom({
|
|
93
|
+
step: StepStatusEnum.Wait,
|
|
94
|
+
list: current,
|
|
95
|
+
isDeclineReceipt: false
|
|
96
|
+
}));
|
|
97
|
+
onChange(true);
|
|
98
|
+
return res;
|
|
99
|
+
}
|
|
100
|
+
return Promise.reject(res);
|
|
101
|
+
}).catch(function () {
|
|
102
|
+
if (unloadRef.current) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
dispatch(updateCustom({
|
|
106
|
+
list: listRef.current.map(function (item) {
|
|
107
|
+
return item.index === StepStatusEnum.Receipt ? _objectSpread(_objectSpread({}, item), {}, {
|
|
108
|
+
status: 'pedding'
|
|
109
|
+
}) : item;
|
|
110
|
+
}),
|
|
111
|
+
isDeclineReceipt: false
|
|
112
|
+
}));
|
|
113
|
+
dispatch(updateState({
|
|
114
|
+
title: locales.getText('page.eftpos-pay.text.waiting.signature') // 等待签名
|
|
115
|
+
}));
|
|
116
|
+
|
|
117
|
+
dispatch(updateStatus(StatusEnum.Question));
|
|
118
|
+
setReceiptLoading(false);
|
|
119
|
+
onChange(false);
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
var onBack = function onBack() {
|
|
123
|
+
dispatch(updateState({
|
|
124
|
+
title: locales.getText('page.eftpos-pay.text.waiting.signature'),
|
|
125
|
+
// ''), // 等待签名
|
|
126
|
+
status: StatusEnum.Question
|
|
127
|
+
}));
|
|
128
|
+
dispatch(updateCustom({
|
|
129
|
+
receiptPage: 'receipt'
|
|
130
|
+
}));
|
|
131
|
+
};
|
|
132
|
+
var onConfirm = function onConfirm() {
|
|
133
|
+
// 取消签名
|
|
134
|
+
dispatch(updateState({
|
|
135
|
+
title: locales.getText('page.eftpos-pay.text.processing'),
|
|
136
|
+
status: StatusEnum.Loading
|
|
137
|
+
}));
|
|
138
|
+
dispatch(updateCustom({
|
|
139
|
+
list: listRef.current.map(function (item) {
|
|
140
|
+
return item.index === StepStatusEnum.Receipt ? _objectSpread(_objectSpread({}, item), {}, {
|
|
141
|
+
status: 'reject'
|
|
142
|
+
}) : item;
|
|
143
|
+
}),
|
|
144
|
+
receiptPage: 'receipt'
|
|
145
|
+
}));
|
|
146
|
+
setReceiptLoading(true);
|
|
147
|
+
api.update({
|
|
148
|
+
type: 'NO',
|
|
149
|
+
number: custom === null || custom === void 0 ? void 0 : custom.number
|
|
150
|
+
}).then(function (res) {
|
|
151
|
+
if (unloadRef.current) {
|
|
152
|
+
return res;
|
|
153
|
+
}
|
|
154
|
+
setReceiptLoading(false);
|
|
155
|
+
if (res && (res.code === 200 || res.code === '200')) {
|
|
156
|
+
// 取消接口
|
|
157
|
+
var current = listRef.current.map(function (item) {
|
|
158
|
+
if (Number(item === null || item === void 0 ? void 0 : item.index) === StepStatusEnum.Receipt) {
|
|
159
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
160
|
+
resolve: item.reject,
|
|
161
|
+
status: 'resolve'
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
if (Number(item === null || item === void 0 ? void 0 : item.index) < StepStatusEnum.Wait) {
|
|
165
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
166
|
+
status: 'resolve'
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
return item;
|
|
170
|
+
});
|
|
171
|
+
var nextStep = getStepMapping(StepStatusEnum.Wait, {
|
|
172
|
+
mode: mode
|
|
173
|
+
});
|
|
174
|
+
if (nextStep) {
|
|
175
|
+
nextStep.pedding = locales.getText('page.eftpos-pay.text.waiting.decline.signature');
|
|
176
|
+
if (nextStep.type === StemTypeEnum.Passive) {
|
|
177
|
+
dispatch(updateStatus(StatusEnum.Question));
|
|
178
|
+
}
|
|
179
|
+
dispatch(updateState({
|
|
180
|
+
title: nextStep.index < StepStatusEnum.Receipt ? locales.getText('page.eftpos-pay.text.loading')(mode) : nextStep.index === StepStatusEnum.Receipt ? locales.getText('page.eftpos-pay.text.waiting.signature') // 等待签名
|
|
181
|
+
: locales.getText('page.eftpos-pay.text.loading')(mode)
|
|
182
|
+
}));
|
|
183
|
+
current.push(nextStep);
|
|
184
|
+
}
|
|
185
|
+
dispatch(updateCustom({
|
|
186
|
+
step: StepStatusEnum.Wait,
|
|
187
|
+
list: current,
|
|
188
|
+
isDeclineReceipt: true
|
|
189
|
+
}));
|
|
190
|
+
onChange(true);
|
|
191
|
+
return res;
|
|
192
|
+
}
|
|
193
|
+
return Promise.reject(res);
|
|
194
|
+
}).catch(function () {
|
|
195
|
+
if (unloadRef.current) {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
onChange(false);
|
|
199
|
+
setReceiptLoading(false);
|
|
200
|
+
dispatch(updateCustom({
|
|
201
|
+
list: listRef.current.map(function (item) {
|
|
202
|
+
return item.index === StepStatusEnum.Receipt ? _objectSpread(_objectSpread({}, item), {}, {
|
|
203
|
+
status: 'pedding'
|
|
204
|
+
}) : item;
|
|
205
|
+
}),
|
|
206
|
+
isDeclineReceipt: false
|
|
207
|
+
}));
|
|
208
|
+
dispatch(updateState({
|
|
209
|
+
title: locales.getText('page.eftpos-pay.text.waiting.signature') // 等待签名
|
|
210
|
+
}));
|
|
211
|
+
|
|
212
|
+
dispatch(updateStatus(StatusEnum.Question));
|
|
213
|
+
setReceiptLoading(false);
|
|
214
|
+
});
|
|
215
|
+
};
|
|
216
|
+
var onDecline = function onDecline() {
|
|
217
|
+
dispatch(updateState({
|
|
218
|
+
title: locales.getText('page.eftpos-pay.text.signature.title'),
|
|
219
|
+
// 'page.eftpos-pay.text.waiting.signature'), // 等待签名
|
|
220
|
+
status: StatusEnum.Warn
|
|
221
|
+
}));
|
|
222
|
+
dispatch(updateState({
|
|
223
|
+
custom: _objectSpread(_objectSpread({}, custom), {}, {
|
|
224
|
+
receiptPage: 'again'
|
|
225
|
+
})
|
|
226
|
+
}));
|
|
227
|
+
};
|
|
228
|
+
useEffect(function () {
|
|
229
|
+
return function () {
|
|
230
|
+
unloadRef.current = true;
|
|
231
|
+
};
|
|
232
|
+
}, []);
|
|
233
|
+
if (receiptLoading) {
|
|
234
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
235
|
+
className: "pisell-lowcode__eft-pay-step-item-btns"
|
|
236
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
237
|
+
block: true,
|
|
238
|
+
className: "pisell-lowcode__eft-pay-step-item-btn",
|
|
239
|
+
disabled: true
|
|
240
|
+
}, locales.getText('page.eftpos-pay.text.leave')));
|
|
241
|
+
}
|
|
242
|
+
if (receiptPage === 'receipt') {
|
|
243
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
244
|
+
className: "pisell-lowcode__eft-pay-step-item-btns"
|
|
245
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
246
|
+
block: true,
|
|
247
|
+
className: "pisell-lowcode__eft-pay-step-item-btn",
|
|
248
|
+
onClick: onDecline
|
|
249
|
+
}, locales.getText('page.eftpos-pay.text.decline')), /*#__PURE__*/React.createElement(Button, {
|
|
250
|
+
block: true,
|
|
251
|
+
type: "primary",
|
|
252
|
+
className: "pisell-lowcode__eft-pay-step-item-btn",
|
|
253
|
+
onClick: onAccept
|
|
254
|
+
}, locales.getText('page.eftpos-pay.text.accept')));
|
|
255
|
+
}
|
|
256
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
257
|
+
className: "pisell-lowcode__eft-pay-step-item-btns"
|
|
258
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
259
|
+
block: true,
|
|
260
|
+
className: "pisell-lowcode__eft-pay-step-item-btn",
|
|
261
|
+
onClick: onBack
|
|
262
|
+
}, locales.getText('page.eftpos-pay.text.back')), /*#__PURE__*/React.createElement(Button, {
|
|
263
|
+
block: true,
|
|
264
|
+
className: "pisell-lowcode__eft-pay-step-item-btn",
|
|
265
|
+
type: "primary",
|
|
266
|
+
onClick: onConfirm,
|
|
267
|
+
disabled: receiptLoading
|
|
268
|
+
}, locales.getText('page.eftpos-pay.text.confirm.decline')));
|
|
269
|
+
};
|
|
270
|
+
var Action = function Action(_ref2) {
|
|
271
|
+
var index = _ref2.index,
|
|
272
|
+
onCancel = _ref2.onCancel,
|
|
273
|
+
disabled = _ref2.disabled;
|
|
274
|
+
var dispatch = useDispatch();
|
|
275
|
+
var _useContextData2 = useContextData(),
|
|
276
|
+
custom = _useContextData2.custom,
|
|
277
|
+
mode = _useContextData2.mode;
|
|
278
|
+
var onManually = function onManually() {
|
|
279
|
+
dispatch(updateState({
|
|
280
|
+
manual: {
|
|
281
|
+
title: locales.getText('page.eftpos-pay.text.request.title')(mode),
|
|
282
|
+
text: locales.getText('page.eftpos-pay.text.request.text')(mode)
|
|
283
|
+
}
|
|
284
|
+
}));
|
|
285
|
+
dispatch(updateComponent('Manual', true));
|
|
286
|
+
};
|
|
287
|
+
if (index < StepStatusEnum.Account) {
|
|
288
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
289
|
+
className: "pisell-lowcode__eft-pay-step-item-btns"
|
|
290
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
291
|
+
block: true,
|
|
292
|
+
className: "pisell-lowcode__eft-pay-step-item-btn",
|
|
293
|
+
onClick: onCancel,
|
|
294
|
+
disabled: disabled
|
|
295
|
+
}, locales.getText('page.eftpos-pay.text.cancel')));
|
|
296
|
+
}
|
|
297
|
+
if (index >= StepStatusEnum.Account && index < StepStatusEnum.Receipt) {
|
|
298
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
299
|
+
className: "pisell-lowcode__eft-pay-step-item-btns"
|
|
300
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
301
|
+
block: true,
|
|
302
|
+
className: "pisell-lowcode__eft-pay-step-item-btn",
|
|
303
|
+
disabled: true
|
|
304
|
+
}, locales.getText('page.eftpos-pay.text.leave')));
|
|
305
|
+
}
|
|
306
|
+
if (index === StepStatusEnum.Receipt) {
|
|
307
|
+
return null;
|
|
308
|
+
}
|
|
309
|
+
if (custom !== null && custom !== void 0 && custom.isDeclineReceipt) {
|
|
310
|
+
/*#__PURE__*/React.createElement("div", {
|
|
311
|
+
className: "pisell-lowcode__eft-pay-step-item-btns"
|
|
312
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
313
|
+
block: true,
|
|
314
|
+
className: "pisell-lowcode__eft-pay-step-item-btn",
|
|
315
|
+
disabled: true
|
|
316
|
+
}, locales.getText('page.eftpos-pay.text.leave')));
|
|
317
|
+
}
|
|
318
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
319
|
+
className: "pisell-lowcode__eft-pay-step-item-btns"
|
|
320
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
321
|
+
block: true,
|
|
322
|
+
className: "pisell-lowcode__eft-pay-step-item-btn",
|
|
323
|
+
onClick: onManually
|
|
324
|
+
}, locales.getText('page.eftpos-pay.text.manual.marking')));
|
|
325
|
+
};
|
|
326
|
+
export default Action;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export default class XhrTimer {
|
|
2
|
+
clearTimeout: number;
|
|
3
|
+
isTimeoutClose: boolean;
|
|
4
|
+
timeout: number;
|
|
5
|
+
callback: (...agrn: unknown[]) => unknown;
|
|
6
|
+
flag: boolean;
|
|
7
|
+
run: any;
|
|
8
|
+
abortController: AbortController;
|
|
9
|
+
num: string;
|
|
10
|
+
constructor({ xhr, timeout, callback, max, }: {
|
|
11
|
+
xhr: (...agrn: unknown[]) => Promise<unknown>;
|
|
12
|
+
timeout: number;
|
|
13
|
+
callback: (...agrn: unknown[]) => unknown;
|
|
14
|
+
max?: number;
|
|
15
|
+
});
|
|
16
|
+
close(): void;
|
|
17
|
+
}
|
|
@@ -0,0 +1,181 @@
|
|
|
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 _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; }
|
|
5
|
+
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); } }
|
|
6
|
+
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); }); }; }
|
|
7
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
8
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
9
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
10
|
+
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; }
|
|
11
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
12
|
+
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); }
|
|
13
|
+
import { PayStatus } from "../const";
|
|
14
|
+
import { sleep, getUuid } from "../helper";
|
|
15
|
+
var MaxTime = 5000;
|
|
16
|
+
var XhrTimer = /*#__PURE__*/function () {
|
|
17
|
+
function XhrTimer(_ref) {
|
|
18
|
+
var xhr = _ref.xhr,
|
|
19
|
+
timeout = _ref.timeout,
|
|
20
|
+
callback = _ref.callback,
|
|
21
|
+
_ref$max = _ref.max,
|
|
22
|
+
max = _ref$max === void 0 ? MaxTime : _ref$max;
|
|
23
|
+
_classCallCheck(this, XhrTimer);
|
|
24
|
+
_defineProperty(this, "clearTimeout", 0);
|
|
25
|
+
_defineProperty(this, "isTimeoutClose", false);
|
|
26
|
+
_defineProperty(this, "timeout", void 0);
|
|
27
|
+
_defineProperty(this, "callback", void 0);
|
|
28
|
+
_defineProperty(this, "flag", true);
|
|
29
|
+
_defineProperty(this, "run", void 0);
|
|
30
|
+
_defineProperty(this, "abortController", void 0);
|
|
31
|
+
_defineProperty(this, "num", void 0);
|
|
32
|
+
this.timeout = timeout;
|
|
33
|
+
this.callback = callback;
|
|
34
|
+
this.num = getUuid();
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
36
|
+
var self = this;
|
|
37
|
+
var xhrApi = new Proxy(xhr, {
|
|
38
|
+
apply: function apply(target, ctx, agrns) {
|
|
39
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
40
|
+
var laster, result, currentTime, diff;
|
|
41
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
42
|
+
while (1) switch (_context.prev = _context.next) {
|
|
43
|
+
case 0:
|
|
44
|
+
laster = Date.now();
|
|
45
|
+
_context.next = 3;
|
|
46
|
+
return Promise.resolve(undefined);
|
|
47
|
+
case 3:
|
|
48
|
+
result = _context.sent;
|
|
49
|
+
case 4:
|
|
50
|
+
if (!self.flag) {
|
|
51
|
+
_context.next = 19;
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
laster = Date.now();
|
|
55
|
+
if (!self.flag) {
|
|
56
|
+
_context.next = 12;
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
self.abortController = new AbortController();
|
|
60
|
+
if (!agrns[1]) {
|
|
61
|
+
agrns[1] = {
|
|
62
|
+
signal: self.abortController.signal
|
|
63
|
+
};
|
|
64
|
+
} else {
|
|
65
|
+
agrns[1].signal = self.abortController.signal;
|
|
66
|
+
}
|
|
67
|
+
_context.next = 11;
|
|
68
|
+
return Reflect.apply(target, ctx, agrns).then(function (res) {
|
|
69
|
+
if (res && "".concat(res.code) === PayStatus.Success) {
|
|
70
|
+
self.callback(res);
|
|
71
|
+
}
|
|
72
|
+
return res;
|
|
73
|
+
}).catch(function (err) {
|
|
74
|
+
console.log('外部取消', self.flag, !self.isTimeoutClose, self.num);
|
|
75
|
+
if (!self.flag && !self.isTimeoutClose) {
|
|
76
|
+
// 用户关闭
|
|
77
|
+
return Promise.resolve({
|
|
78
|
+
code: -1
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
console.log(err);
|
|
82
|
+
self.flag = false;
|
|
83
|
+
return Promise.resolve(err);
|
|
84
|
+
});
|
|
85
|
+
case 11:
|
|
86
|
+
result = _context.sent;
|
|
87
|
+
case 12:
|
|
88
|
+
currentTime = Date.now();
|
|
89
|
+
diff = currentTime - laster;
|
|
90
|
+
if (!(self.flag && diff < max)) {
|
|
91
|
+
_context.next = 17;
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
_context.next = 17;
|
|
95
|
+
return sleep(max - diff);
|
|
96
|
+
case 17:
|
|
97
|
+
_context.next = 4;
|
|
98
|
+
break;
|
|
99
|
+
case 19:
|
|
100
|
+
return _context.abrupt("return", result);
|
|
101
|
+
case 20:
|
|
102
|
+
case "end":
|
|
103
|
+
return _context.stop();
|
|
104
|
+
}
|
|
105
|
+
}, _callee);
|
|
106
|
+
}))();
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
this.run = new Proxy(xhrApi, {
|
|
110
|
+
apply: function apply(target, ctx, agrns) {
|
|
111
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
112
|
+
var result, _ref2, code;
|
|
113
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
114
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
115
|
+
case 0:
|
|
116
|
+
self.flag = true;
|
|
117
|
+
self.isTimeoutClose = false;
|
|
118
|
+
if (self.clearTimeout) {
|
|
119
|
+
clearTimeout(self.clearTimeout);
|
|
120
|
+
}
|
|
121
|
+
if (self.timeout > 4) {
|
|
122
|
+
self.clearTimeout = setTimeout(function () {
|
|
123
|
+
if (self.flag) {
|
|
124
|
+
self.flag = false;
|
|
125
|
+
self.isTimeoutClose = true;
|
|
126
|
+
}
|
|
127
|
+
}, self.timeout);
|
|
128
|
+
}
|
|
129
|
+
_context2.next = 6;
|
|
130
|
+
return Reflect.apply(target, ctx, agrns);
|
|
131
|
+
case 6:
|
|
132
|
+
result = _context2.sent;
|
|
133
|
+
clearTimeout(self.clearTimeout);
|
|
134
|
+
if (!self.isTimeoutClose) {
|
|
135
|
+
_context2.next = 15;
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
if (result) {
|
|
139
|
+
_context2.next = 11;
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
return _context2.abrupt("return", {
|
|
143
|
+
code: PayStatus.Timeout
|
|
144
|
+
});
|
|
145
|
+
case 11:
|
|
146
|
+
_ref2 = result, code = _ref2.code;
|
|
147
|
+
if (!("".concat(code) === "200")) {
|
|
148
|
+
_context2.next = 14;
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
return _context2.abrupt("return", _objectSpread(_objectSpread({}, result), {}, {
|
|
152
|
+
code: PayStatus.Timeout
|
|
153
|
+
}));
|
|
154
|
+
case 14:
|
|
155
|
+
return _context2.abrupt("return", result);
|
|
156
|
+
case 15:
|
|
157
|
+
return _context2.abrupt("return", result);
|
|
158
|
+
case 16:
|
|
159
|
+
case "end":
|
|
160
|
+
return _context2.stop();
|
|
161
|
+
}
|
|
162
|
+
}, _callee2);
|
|
163
|
+
}))();
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
_createClass(XhrTimer, [{
|
|
168
|
+
key: "close",
|
|
169
|
+
value: function close() {
|
|
170
|
+
var _this$abortController;
|
|
171
|
+
console.log('外部关闭', this.flag, this.num);
|
|
172
|
+
this.flag = false;
|
|
173
|
+
(_this$abortController = this.abortController) === null || _this$abortController === void 0 ? void 0 : _this$abortController.abort();
|
|
174
|
+
if (this.clearTimeout) {
|
|
175
|
+
clearTimeout(this.clearTimeout);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}]);
|
|
179
|
+
return XhrTimer;
|
|
180
|
+
}();
|
|
181
|
+
export { XhrTimer as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StatusEnum } from '../const';
|
|
3
|
+
declare const Wait: ({ api, onChange, hasBackup, }: {
|
|
4
|
+
api: {
|
|
5
|
+
[key: string]: (...agrn: unknown[]) => Promise<unknown>;
|
|
6
|
+
};
|
|
7
|
+
onChange: (status: `${StatusEnum.Success}` | `${StatusEnum.Fail}`, params?: {
|
|
8
|
+
[keys: string]: unknown;
|
|
9
|
+
} | undefined) => void;
|
|
10
|
+
hasBackup: boolean;
|
|
11
|
+
}) => React.JSX.Element;
|
|
12
|
+
export default Wait;
|