@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.
Files changed (267) hide show
  1. package/build/lowcode/assets-daily.json +11 -11
  2. package/build/lowcode/assets-dev.json +2 -2
  3. package/build/lowcode/assets-prod.json +11 -11
  4. package/build/lowcode/index.js +1 -1
  5. package/build/lowcode/meta.js +1 -1
  6. package/build/lowcode/preview.js +8 -8
  7. package/build/lowcode/render/default/view.css +1 -1
  8. package/build/lowcode/render/default/view.js +16 -9
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +15 -8
  11. package/es/components/booking/addons/index.d.ts +1 -1
  12. package/es/components/booking/addons/model.d.ts +1 -2
  13. package/es/components/booking/forms/forms.d.ts +1 -1
  14. package/es/components/booking/forms/index.d.ts +1 -1
  15. package/es/components/booking/forms/model.d.ts +1 -2
  16. package/es/components/booking/index.d.ts +1 -1
  17. package/es/components/booking/info/index.d.ts +1 -1
  18. package/es/components/booking/info/model.d.ts +1 -2
  19. package/es/components/booking/model.d.ts +1 -2
  20. package/es/components/booking/notes/index.d.ts +1 -1
  21. package/es/components/booking/notes/model.d.ts +1 -2
  22. package/es/components/booking/payments/index.d.ts +1 -1
  23. package/es/components/booking/payments/model.d.ts +1 -2
  24. package/es/components/eftpos/const.d.ts +38 -0
  25. package/es/components/eftpos/const.js +79 -0
  26. package/es/components/eftpos/device.d.ts +8 -0
  27. package/es/components/eftpos/device.js +30 -0
  28. package/es/components/eftpos/form/index.d.ts +16 -0
  29. package/es/components/eftpos/form/index.js +113 -0
  30. package/es/components/eftpos/index.d.ts +37 -0
  31. package/es/components/eftpos/index.js +274 -0
  32. package/es/components/eftpos/index.less +153 -0
  33. package/es/components/eftpos/locales.d.ts +75 -0
  34. package/es/components/eftpos/locales.js +98 -0
  35. package/es/components/eftpos/pos.d.ts +9 -0
  36. package/es/components/eftpos/pos.js +33 -0
  37. package/es/components/eftpos/surcharge/index.css +17 -0
  38. package/es/components/eftpos/surcharge/index.d.ts +8 -0
  39. package/es/components/eftpos/surcharge/index.js +111 -0
  40. package/es/components/eftpos/table.d.ts +17 -0
  41. package/es/components/eftpos/table.js +236 -0
  42. package/es/components/eftposPay/amount.d.ts +14 -0
  43. package/es/components/eftposPay/amount.js +253 -0
  44. package/es/components/eftposPay/component/alert/index.d.ts +6 -0
  45. package/es/components/eftposPay/component/alert/index.js +11 -0
  46. package/es/components/eftposPay/component/alert/index.less +29 -0
  47. package/es/components/eftposPay/component/alert/warn.d.ts +3 -0
  48. package/es/components/eftposPay/component/alert/warn.js +45 -0
  49. package/es/components/eftposPay/component/fail/failCustom.d.ts +4 -0
  50. package/es/components/eftposPay/component/fail/failCustom.js +95 -0
  51. package/es/components/eftposPay/component/fail/index.d.ts +4 -0
  52. package/es/components/eftposPay/component/fail/index.js +105 -0
  53. package/es/components/eftposPay/component/fail/network.d.ts +4 -0
  54. package/es/components/eftposPay/component/fail/network.js +48 -0
  55. package/es/components/eftposPay/component/fail/unknow.d.ts +4 -0
  56. package/es/components/eftposPay/component/fail/unknow.js +43 -0
  57. package/es/components/eftposPay/component/header/index.d.ts +9 -0
  58. package/es/components/eftposPay/component/header/index.js +66 -0
  59. package/es/components/eftposPay/component/header/index.less +44 -0
  60. package/es/components/eftposPay/component/header/titlebar.d.ts +13 -0
  61. package/es/components/eftposPay/component/header/titlebar.js +39 -0
  62. package/es/components/eftposPay/component/header/titlebar.less +17 -0
  63. package/es/components/eftposPay/component/manual/index.d.ts +5 -0
  64. package/es/components/eftposPay/component/manual/index.js +91 -0
  65. package/es/components/eftposPay/component/manual/index.less +96 -0
  66. package/es/components/eftposPay/component/signature/index.d.ts +4 -0
  67. package/es/components/eftposPay/component/signature/index.js +63 -0
  68. package/es/components/eftposPay/component/step/index.d.ts +12 -0
  69. package/es/components/eftposPay/component/step/index.js +31 -0
  70. package/es/components/eftposPay/component/step/step.d.ts +9 -0
  71. package/es/components/eftposPay/component/step/step.js +23 -0
  72. package/es/components/eftposPay/const.d.ts +131 -0
  73. package/es/components/eftposPay/const.js +48 -0
  74. package/es/components/eftposPay/device.d.ts +14 -0
  75. package/es/components/eftposPay/device.js +124 -0
  76. package/es/components/eftposPay/device.less +61 -0
  77. package/es/components/eftposPay/eftpos/config.d.ts +11 -0
  78. package/es/components/eftposPay/eftpos/config.js +178 -0
  79. package/es/components/eftposPay/eftpos/const.d.ts +10 -0
  80. package/es/components/eftposPay/eftpos/const.js +139 -0
  81. package/es/components/eftposPay/eftpos/index.d.ts +7 -0
  82. package/es/components/eftposPay/eftpos/index.js +35 -0
  83. package/es/components/eftposPay/helper.d.ts +3 -0
  84. package/es/components/eftposPay/helper.js +35 -0
  85. package/es/components/eftposPay/hooks.d.ts +4 -0
  86. package/es/components/eftposPay/hooks.js +153 -0
  87. package/es/components/eftposPay/index.d.ts +7 -0
  88. package/es/components/eftposPay/index.js +188 -0
  89. package/es/components/eftposPay/index.less +273 -0
  90. package/es/components/eftposPay/locales.d.ts +264 -0
  91. package/es/components/eftposPay/locales.js +384 -0
  92. package/es/components/eftposPay/manufacturer.d.ts +6 -0
  93. package/es/components/eftposPay/manufacturer.js +32 -0
  94. package/es/components/eftposPay/pay.d.ts +10 -0
  95. package/es/components/eftposPay/pay.js +108 -0
  96. package/es/components/eftposPay/payo/config.d.ts +11 -0
  97. package/es/components/eftposPay/payo/config.js +357 -0
  98. package/es/components/eftposPay/payo/const.d.ts +6 -0
  99. package/es/components/eftposPay/payo/const.js +93 -0
  100. package/es/components/eftposPay/payo/hooks.d.ts +5 -0
  101. package/es/components/eftposPay/payo/hooks.js +84 -0
  102. package/es/components/eftposPay/payo/index.d.ts +7 -0
  103. package/es/components/eftposPay/payo/index.js +35 -0
  104. package/es/components/eftposPay/store/index.d.ts +239 -0
  105. package/es/components/eftposPay/store/index.js +304 -0
  106. package/es/components/eftposPay/store/useThunkReducer.d.ts +9 -0
  107. package/es/components/eftposPay/store/useThunkReducer.js +31 -0
  108. package/es/components/eftposPay/windcave/action.d.ts +8 -0
  109. package/es/components/eftposPay/windcave/action.js +104 -0
  110. package/es/components/eftposPay/windcave/const.d.ts +104 -0
  111. package/es/components/eftposPay/windcave/const.js +253 -0
  112. package/es/components/eftposPay/windcave/helper.d.ts +9 -0
  113. package/es/components/eftposPay/windcave/helper.js +314 -0
  114. package/es/components/eftposPay/windcave/hook.d.ts +14 -0
  115. package/es/components/eftposPay/windcave/hook.js +144 -0
  116. package/es/components/eftposPay/windcave/index.d.ts +8 -0
  117. package/es/components/eftposPay/windcave/index.js +49 -0
  118. package/es/components/eftposPay/windcave/pos.d.ts +8 -0
  119. package/es/components/eftposPay/windcave/pos.js +180 -0
  120. package/es/components/eftposPay/windcave/pwd.d.ts +8 -0
  121. package/es/components/eftposPay/windcave/pwd.js +124 -0
  122. package/es/components/eftposPay/windcave/receipet.d.ts +6 -0
  123. package/es/components/eftposPay/windcave/receipet.js +67 -0
  124. package/es/components/eftposPay/windcave/receiptAction.d.ts +11 -0
  125. package/es/components/eftposPay/windcave/receiptAction.js +326 -0
  126. package/es/components/eftposPay/windcave/timer.d.ts +17 -0
  127. package/es/components/eftposPay/windcave/timer.js +181 -0
  128. package/es/components/eftposPay/windcave/wait.d.ts +12 -0
  129. package/es/components/eftposPay/windcave/wait.js +139 -0
  130. package/es/components/eftposPay/windcave/windcave.d.ts +6 -0
  131. package/es/components/eftposPay/windcave/windcave.js +283 -0
  132. package/es/components/schedules/index.d.ts +1 -1
  133. package/es/components/schedules/model.d.ts +1 -2
  134. package/es/hooks/usePrefix.d.ts +1 -0
  135. package/es/hooks/usePrefix.js +10 -0
  136. package/es/index.d.ts +2 -0
  137. package/es/index.js +3 -1
  138. package/lib/components/booking/addons/index.d.ts +1 -1
  139. package/lib/components/booking/addons/model.d.ts +1 -2
  140. package/lib/components/booking/forms/forms.d.ts +1 -1
  141. package/lib/components/booking/forms/index.d.ts +1 -1
  142. package/lib/components/booking/forms/model.d.ts +1 -2
  143. package/lib/components/booking/index.d.ts +1 -1
  144. package/lib/components/booking/info/index.d.ts +1 -1
  145. package/lib/components/booking/info/model.d.ts +1 -2
  146. package/lib/components/booking/model.d.ts +1 -2
  147. package/lib/components/booking/notes/index.d.ts +1 -1
  148. package/lib/components/booking/notes/model.d.ts +1 -2
  149. package/lib/components/booking/payments/index.d.ts +1 -1
  150. package/lib/components/booking/payments/model.d.ts +1 -2
  151. package/lib/components/eftpos/const.d.ts +38 -0
  152. package/lib/components/eftpos/const.js +108 -0
  153. package/lib/components/eftpos/device.d.ts +8 -0
  154. package/lib/components/eftpos/device.js +55 -0
  155. package/lib/components/eftpos/form/index.d.ts +16 -0
  156. package/lib/components/eftpos/form/index.js +124 -0
  157. package/lib/components/eftpos/index.d.ts +37 -0
  158. package/lib/components/eftpos/index.js +279 -0
  159. package/lib/components/eftpos/index.less +153 -0
  160. package/lib/components/eftpos/locales.d.ts +75 -0
  161. package/lib/components/eftpos/locales.js +116 -0
  162. package/lib/components/eftpos/pos.d.ts +9 -0
  163. package/lib/components/eftpos/pos.js +55 -0
  164. package/lib/components/eftpos/surcharge/index.css +17 -0
  165. package/lib/components/eftpos/surcharge/index.d.ts +8 -0
  166. package/lib/components/eftpos/surcharge/index.js +125 -0
  167. package/lib/components/eftpos/table.d.ts +17 -0
  168. package/lib/components/eftpos/table.js +235 -0
  169. package/lib/components/eftposPay/amount.d.ts +14 -0
  170. package/lib/components/eftposPay/amount.js +239 -0
  171. package/lib/components/eftposPay/component/alert/index.d.ts +6 -0
  172. package/lib/components/eftposPay/component/alert/index.js +38 -0
  173. package/lib/components/eftposPay/component/alert/index.less +29 -0
  174. package/lib/components/eftposPay/component/alert/warn.d.ts +3 -0
  175. package/lib/components/eftposPay/component/alert/warn.js +80 -0
  176. package/lib/components/eftposPay/component/fail/failCustom.d.ts +4 -0
  177. package/lib/components/eftposPay/component/fail/failCustom.js +117 -0
  178. package/lib/components/eftposPay/component/fail/index.d.ts +4 -0
  179. package/lib/components/eftposPay/component/fail/index.js +121 -0
  180. package/lib/components/eftposPay/component/fail/network.d.ts +4 -0
  181. package/lib/components/eftposPay/component/fail/network.js +65 -0
  182. package/lib/components/eftposPay/component/fail/unknow.d.ts +4 -0
  183. package/lib/components/eftposPay/component/fail/unknow.js +72 -0
  184. package/lib/components/eftposPay/component/header/index.d.ts +9 -0
  185. package/lib/components/eftposPay/component/header/index.js +92 -0
  186. package/lib/components/eftposPay/component/header/index.less +44 -0
  187. package/lib/components/eftposPay/component/header/titlebar.d.ts +13 -0
  188. package/lib/components/eftposPay/component/header/titlebar.js +55 -0
  189. package/lib/components/eftposPay/component/header/titlebar.less +17 -0
  190. package/lib/components/eftposPay/component/manual/index.d.ts +5 -0
  191. package/lib/components/eftposPay/component/manual/index.js +101 -0
  192. package/lib/components/eftposPay/component/manual/index.less +96 -0
  193. package/lib/components/eftposPay/component/signature/index.d.ts +4 -0
  194. package/lib/components/eftposPay/component/signature/index.js +80 -0
  195. package/lib/components/eftposPay/component/step/index.d.ts +12 -0
  196. package/lib/components/eftposPay/component/step/index.js +71 -0
  197. package/lib/components/eftposPay/component/step/step.d.ts +9 -0
  198. package/lib/components/eftposPay/component/step/step.js +59 -0
  199. package/lib/components/eftposPay/const.d.ts +131 -0
  200. package/lib/components/eftposPay/const.js +86 -0
  201. package/lib/components/eftposPay/device.d.ts +14 -0
  202. package/lib/components/eftposPay/device.js +127 -0
  203. package/lib/components/eftposPay/device.less +61 -0
  204. package/lib/components/eftposPay/eftpos/config.d.ts +11 -0
  205. package/lib/components/eftposPay/eftpos/config.js +199 -0
  206. package/lib/components/eftposPay/eftpos/const.d.ts +10 -0
  207. package/lib/components/eftposPay/eftpos/const.js +165 -0
  208. package/lib/components/eftposPay/eftpos/index.d.ts +7 -0
  209. package/lib/components/eftposPay/eftpos/index.js +66 -0
  210. package/lib/components/eftposPay/helper.d.ts +3 -0
  211. package/lib/components/eftposPay/helper.js +62 -0
  212. package/lib/components/eftposPay/hooks.d.ts +4 -0
  213. package/lib/components/eftposPay/hooks.js +237 -0
  214. package/lib/components/eftposPay/index.d.ts +7 -0
  215. package/lib/components/eftposPay/index.js +189 -0
  216. package/lib/components/eftposPay/index.less +273 -0
  217. package/lib/components/eftposPay/locales.d.ts +264 -0
  218. package/lib/components/eftposPay/locales.js +304 -0
  219. package/lib/components/eftposPay/manufacturer.d.ts +6 -0
  220. package/lib/components/eftposPay/manufacturer.js +77 -0
  221. package/lib/components/eftposPay/pay.d.ts +10 -0
  222. package/lib/components/eftposPay/pay.js +120 -0
  223. package/lib/components/eftposPay/payo/config.d.ts +11 -0
  224. package/lib/components/eftposPay/payo/config.js +377 -0
  225. package/lib/components/eftposPay/payo/const.d.ts +6 -0
  226. package/lib/components/eftposPay/payo/const.js +112 -0
  227. package/lib/components/eftposPay/payo/hooks.d.ts +5 -0
  228. package/lib/components/eftposPay/payo/hooks.js +80 -0
  229. package/lib/components/eftposPay/payo/index.d.ts +7 -0
  230. package/lib/components/eftposPay/payo/index.js +63 -0
  231. package/lib/components/eftposPay/store/index.d.ts +239 -0
  232. package/lib/components/eftposPay/store/index.js +371 -0
  233. package/lib/components/eftposPay/store/useThunkReducer.d.ts +9 -0
  234. package/lib/components/eftposPay/store/useThunkReducer.js +53 -0
  235. package/lib/components/eftposPay/windcave/action.d.ts +8 -0
  236. package/lib/components/eftposPay/windcave/action.js +143 -0
  237. package/lib/components/eftposPay/windcave/const.d.ts +104 -0
  238. package/lib/components/eftposPay/windcave/const.js +300 -0
  239. package/lib/components/eftposPay/windcave/helper.d.ts +9 -0
  240. package/lib/components/eftposPay/windcave/helper.js +378 -0
  241. package/lib/components/eftposPay/windcave/hook.d.ts +14 -0
  242. package/lib/components/eftposPay/windcave/hook.js +139 -0
  243. package/lib/components/eftposPay/windcave/index.d.ts +8 -0
  244. package/lib/components/eftposPay/windcave/index.js +78 -0
  245. package/lib/components/eftposPay/windcave/pos.d.ts +8 -0
  246. package/lib/components/eftposPay/windcave/pos.js +197 -0
  247. package/lib/components/eftposPay/windcave/pwd.d.ts +8 -0
  248. package/lib/components/eftposPay/windcave/pwd.js +143 -0
  249. package/lib/components/eftposPay/windcave/receipet.d.ts +6 -0
  250. package/lib/components/eftposPay/windcave/receipet.js +93 -0
  251. package/lib/components/eftposPay/windcave/receiptAction.d.ts +11 -0
  252. package/lib/components/eftposPay/windcave/receiptAction.js +386 -0
  253. package/lib/components/eftposPay/windcave/timer.d.ts +17 -0
  254. package/lib/components/eftposPay/windcave/timer.js +126 -0
  255. package/lib/components/eftposPay/windcave/wait.d.ts +12 -0
  256. package/lib/components/eftposPay/windcave/wait.js +163 -0
  257. package/lib/components/eftposPay/windcave/windcave.d.ts +6 -0
  258. package/lib/components/eftposPay/windcave/windcave.js +283 -0
  259. package/lib/components/schedules/index.d.ts +1 -1
  260. package/lib/components/schedules/model.d.ts +1 -2
  261. package/lib/hooks/usePrefix.d.ts +1 -0
  262. package/lib/hooks/usePrefix.js +44 -0
  263. package/lib/index.d.ts +2 -0
  264. package/lib/index.js +6 -0
  265. package/lowcode/eftpos/meta.ts +187 -0
  266. package/lowcode/eftpos-pay/meta.ts +122 -0
  267. package/package.json +4 -3
@@ -0,0 +1,314 @@
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
+ /* eslint-disable @typescript-eslint/no-unused-expressions */
8
+ import { locales } from '@pisell/utils';
9
+ import React, { useCallback, useEffect, useRef } from 'react';
10
+ import { StatusEnum, PayStatus } from "../const";
11
+ import { useContextData, useDispatch, updateComponent, updateState, updateStatus, updateCustom, updateKey } from "../store";
12
+ import { StepStatusEnum, getStepMapping, StemTypeEnum } from "./const";
13
+ import XhrTimer from "./timer";
14
+ var Max4004 = 1;
15
+ export var useFail = function useFail() {
16
+ var dispatch = useDispatch();
17
+ var _useContextData = useContextData(),
18
+ custom = _useContextData.custom,
19
+ mode = _useContextData.mode;
20
+ var ref = useRef((custom === null || custom === void 0 ? void 0 : custom.retry) || 0);
21
+ useEffect(function () {
22
+ ref.current = (custom === null || custom === void 0 ? void 0 : custom.retry) || 0;
23
+ }, [custom === null || custom === void 0 ? void 0 : custom.retry]);
24
+ return useCallback(function (res) {
25
+ var isMark = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
26
+ if (!res || !res.code) {
27
+ dispatch(updateCustom({
28
+ errorStatus: 'unknow' // unknow know
29
+ }));
30
+
31
+ dispatch(updateComponent('UnknowFail'));
32
+ return;
33
+ }
34
+ var code = "".concat(res.code);
35
+ if ("".concat(res.code) === PayStatus.Unknown) {
36
+ dispatch(updateCustom({
37
+ failCustom: {
38
+ isPosNetworkError: false,
39
+ status: 'fail',
40
+ fail: locales.getText('page.eftpos-pay.text.transaction.fail'),
41
+ warn: null,
42
+ title: locales.getText('page.eftpos-pay.text.failed')(mode)
43
+ }
44
+ }));
45
+ dispatch(updateComponent('FailCustom'));
46
+ return;
47
+ }
48
+ console.log(code, ref.current, Max4004);
49
+ if (code === PayStatus.NoPay) {
50
+ if (ref.current > Max4004) {
51
+ dispatch(updateCustom({
52
+ retry: 0,
53
+ failCustom: {
54
+ isPosNetworkError: false,
55
+ status: 'fail',
56
+ fail: locales.getText('page.eftpos-pay.text.transaction.fail'),
57
+ warn: null,
58
+ titl: locales.getText('page.eftpos-pay.text.failed')(mode)
59
+ }
60
+ }));
61
+ dispatch(updateComponent('FailCustom'));
62
+ return;
63
+ }
64
+ ref.current += 1;
65
+ dispatch(updateCustom({
66
+ retry: ref.current,
67
+ number: undefined,
68
+ isPay: false,
69
+ list: []
70
+ }));
71
+ dispatch(updateKey(Date.now()));
72
+ return;
73
+ }
74
+ if (code === PayStatus.Timeout || code === PayStatus.PayTimeout) {
75
+ if (isMark) {
76
+ dispatch(updateState({
77
+ manual: {
78
+ title: locales.getText('page.eftpos-pay.text.timedout.title'),
79
+ text: locales.getText('page.eftpos-pay.text.timedout.text')(mode)
80
+ }
81
+ }));
82
+ dispatch(updateComponent('Manual'));
83
+ return;
84
+ }
85
+ dispatch(updateCustom({
86
+ failCustom: {
87
+ isPosNetworkError: false,
88
+ status: 'fail',
89
+ fail: code === PayStatus.Timeout ? locales.getText('page.eftpos-pay.text.transaction.pay.fail.timeout') : locales.getText('page.eftpos-pay.text.transaction.fail.timeout'),
90
+ title: locales.getText('page.eftpos-pay.text.failed')(mode),
91
+ warn: null
92
+ }
93
+ }));
94
+ dispatch(updateComponent('FailCustom'));
95
+ return;
96
+ }
97
+ if (code === PayStatus.PayOtherEftposFailed) {
98
+ dispatch(updateCustom({
99
+ failCustom: {
100
+ isPosNetworkError: false,
101
+ status: 'fail',
102
+ fail: locales.getText('page.eftpos-pay.text.transaction.fail.terminal'),
103
+ title: locales.getText('page.eftpos-pay.text.transaction.fail.terminal.title'),
104
+ warn: null
105
+ }
106
+ }));
107
+ dispatch(updateComponent('FailCustom'));
108
+ return;
109
+ }
110
+ if (code === PayStatus.PayCardErrorFailed) {
111
+ dispatch(updateCustom({
112
+ failCustom: {
113
+ isPosNetworkError: true,
114
+ status: 'fail',
115
+ fail: locales.getText('page.eftpos-pay.text.transaction.fail.cancel'),
116
+ title: locales.getText('page.eftpos-pay.text.transaction.fail.cancel.title'),
117
+ warn: null
118
+ }
119
+ }));
120
+ dispatch(updateComponent('FailCustom'));
121
+ return;
122
+ }
123
+ if (code === PayStatus.NoNetWork || code === PayStatus.SocketError) {
124
+ dispatch(updateCustom({
125
+ failCustom: {
126
+ isPosNetworkError: true,
127
+ status: 'warn',
128
+ fail: null,
129
+ title: locales.getText('page.eftpos-pay.text.interrupted'),
130
+ 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))
131
+ }
132
+ }));
133
+ dispatch(updateComponent('FailCustom'));
134
+ return;
135
+ }
136
+ dispatch(updateCustom({
137
+ errorStatus: 'unknow' // unknow know
138
+ }));
139
+
140
+ dispatch(updateComponent('UnknowFail'));
141
+ }, [dispatch]);
142
+ };
143
+ export var useValidate = function useValidate(check, num, onChange) {
144
+ var unloadRef = useRef(false);
145
+ var dispatch = useDispatch();
146
+ var fail = useFail();
147
+ var failRef = useRef(fail);
148
+ var ref = useRef();
149
+ var _useContextData2 = useContextData(),
150
+ custom = _useContextData2.custom,
151
+ mode = _useContextData2.mode;
152
+ var stepRef = useRef(custom === null || custom === void 0 ? void 0 : custom.step);
153
+ var listRef = useRef(custom === null || custom === void 0 ? void 0 : custom.list);
154
+ var numberRef = useRef(custom === null || custom === void 0 ? void 0 : custom.number);
155
+ var payRef = useRef(custom === null || custom === void 0 ? void 0 : custom.pay);
156
+ var netRef = useRef(custom === null || custom === void 0 ? void 0 : custom.net);
157
+ var watchRef = useRef();
158
+ useEffect(function () {
159
+ listRef.current = custom === null || custom === void 0 ? void 0 : custom.list;
160
+ }, [custom === null || custom === void 0 ? void 0 : custom.list]);
161
+ useEffect(function () {
162
+ stepRef.current = custom === null || custom === void 0 ? void 0 : custom.step;
163
+ }, [custom === null || custom === void 0 ? void 0 : custom.step]);
164
+ useEffect(function () {
165
+ numberRef.current = custom === null || custom === void 0 ? void 0 : custom.number;
166
+ }, [custom === null || custom === void 0 ? void 0 : custom.number]);
167
+ useEffect(function () {
168
+ console.log('custom?.net = ', custom);
169
+ netRef.current = custom === null || custom === void 0 ? void 0 : custom.net;
170
+ }, [custom === null || custom === void 0 ? void 0 : custom.net]);
171
+ useEffect(function () {
172
+ payRef.current = custom === null || custom === void 0 ? void 0 : custom.pay;
173
+ }, [custom === null || custom === void 0 ? void 0 : custom.pay]);
174
+ var run = useCallback(function (timeout) {
175
+ var _ref$current2, _ref$current3;
176
+ if (unloadRef.current) {
177
+ var _ref$current;
178
+ (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.close();
179
+ return;
180
+ }
181
+ if (!watchRef.current) {
182
+ return;
183
+ }
184
+ if (!netRef.current) {
185
+ return;
186
+ }
187
+ (_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.close();
188
+ ref.current = new XhrTimer({
189
+ xhr: check,
190
+ timeout: typeof timeout === 'number' ? timeout : num,
191
+ callback: watchRef.current
192
+ });
193
+ (_ref$current3 = ref.current) === null || _ref$current3 === void 0 ? void 0 : _ref$current3.run({
194
+ number: numberRef.current
195
+ })
196
+ // eslint-disable-next-line consistent-return
197
+ .then(function (res) {
198
+ if (unloadRef.current) {
199
+ return;
200
+ }
201
+ if (!netRef.current) {
202
+ return;
203
+ }
204
+ if (!res || Number(res.code) !== 200) {
205
+ // eslint-disable-next-line consistent-return
206
+ return Promise.reject(res);
207
+ }
208
+ }).catch(function (res) {
209
+ var _failRef$current;
210
+ if (unloadRef.current) {
211
+ return;
212
+ }
213
+ if (!netRef.current) {
214
+ return;
215
+ }
216
+ if (res && res.code === -1) {
217
+ return;
218
+ }
219
+ (_failRef$current = failRef.current) === null || _failRef$current === void 0 ? void 0 : _failRef$current.call(failRef, res, stepRef.current >= 3);
220
+ });
221
+ }, [check, num]);
222
+ useEffect(function () {
223
+ watchRef.current = function (res) {
224
+ if (unloadRef.current) {
225
+ var _ref$current4;
226
+ (_ref$current4 = ref.current) === null || _ref$current4 === void 0 ? void 0 : _ref$current4.close();
227
+ return;
228
+ }
229
+ if (!res || !res.data || !res.data.txn_status_id) {
230
+ var _ref$current5;
231
+ (_ref$current5 = ref.current) === null || _ref$current5 === void 0 ? void 0 : _ref$current5.close();
232
+ }
233
+ var _ref = [Number(res.data.txn_status_id), Number(res.data.status_id), Number(res.data.complete)],
234
+ txn_status_id = _ref[0],
235
+ status_id = _ref[1],
236
+ complete = _ref[2];
237
+ if (txn_status_id === StepStatusEnum.Wait && status_id === 6 && complete === 1) {
238
+ var _ref$current6;
239
+ (_ref$current6 = ref.current) === null || _ref$current6 === void 0 ? void 0 : _ref$current6.close();
240
+ if (stepRef.current !== txn_status_id && listRef.current.every(function (_ref2) {
241
+ var index = _ref2.index;
242
+ return txn_status_id !== index;
243
+ })) {
244
+ var _payRef$current;
245
+ var current = listRef.current.map(function (item) {
246
+ if (Number(item === null || item === void 0 ? void 0 : item.index) < Number(stepRef.current)) {
247
+ return _objectSpread(_objectSpread({}, item), {}, {
248
+ status: 'resolve'
249
+ });
250
+ }
251
+ return item;
252
+ });
253
+ var nextStep = getStepMapping(txn_status_id, {
254
+ money: (_payRef$current = payRef.current) === null || _payRef$current === void 0 ? void 0 : _payRef$current.totalUnit,
255
+ mode: mode
256
+ });
257
+ current.push(nextStep);
258
+ dispatch(updateCustom({
259
+ list: current,
260
+ step: txn_status_id
261
+ }));
262
+ }
263
+ onChange(res.data);
264
+ return;
265
+ }
266
+ if (stepRef.current !== txn_status_id && listRef.current.every(function (_ref3) {
267
+ var index = _ref3.index;
268
+ return txn_status_id !== index;
269
+ })) {
270
+ var _ref$current7, _payRef$current2;
271
+ console.log('self.flag stepRef.current, txn_status_id ', stepRef.current, txn_status_id);
272
+ stepRef.current = txn_status_id;
273
+ (_ref$current7 = ref.current) === null || _ref$current7 === void 0 ? void 0 : _ref$current7.close();
274
+ var _current = listRef.current.map(function (item) {
275
+ if (Number(item === null || item === void 0 ? void 0 : item.index) < Number(stepRef.current)) {
276
+ return _objectSpread(_objectSpread({}, item), {}, {
277
+ status: 'resolve'
278
+ });
279
+ }
280
+ return item;
281
+ });
282
+ var _nextStep = getStepMapping(txn_status_id, {
283
+ money: (_payRef$current2 = payRef.current) === null || _payRef$current2 === void 0 ? void 0 : _payRef$current2.totalUnit,
284
+ mode: mode
285
+ });
286
+ if (_nextStep) {
287
+ _current.push(_nextStep);
288
+ if (_nextStep.type === StemTypeEnum.Passive) {
289
+ dispatch(updateStatus(StatusEnum.Question));
290
+ }
291
+ if (_nextStep.index === StepStatusEnum.Receipt) {
292
+ dispatch(updateState({
293
+ title: locales.getText('page.eftpos-pay.text.waiting.signature') // 等待签名
294
+ }));
295
+ }
296
+ }
297
+
298
+ dispatch(updateCustom({
299
+ list: _current,
300
+ step: txn_status_id
301
+ }));
302
+ txn_status_id === StepStatusEnum.Receipt ? run(-1) : run();
303
+ }
304
+ };
305
+ }, [dispatch, onChange, run]);
306
+ useEffect(function () {
307
+ return function () {
308
+ var _ref$current8;
309
+ (_ref$current8 = ref.current) === null || _ref$current8 === void 0 ? void 0 : _ref$current8.close();
310
+ unloadRef.current = true;
311
+ };
312
+ }, []);
313
+ return [run, ref];
314
+ };
@@ -0,0 +1,14 @@
1
+ import { PayStatus } from '../const';
2
+ export declare const useValidate: (timeout: number, changeStatus?: ((status: PayStatus) => void) | undefined) => readonly [(params: {
3
+ check: (...agrn: unknown[]) => Promise<any>;
4
+ number: number;
5
+ txn_status_id: string;
6
+ time?: number | undefined;
7
+ __start__?: string | undefined;
8
+ checkCondition(...agrn: unknown[]): boolean;
9
+ }) => Promise<{
10
+ [key: string]: unknown;
11
+ }>, () => void];
12
+ export declare const useSuccess: (index: number) => (res: {
13
+ [key: string]: unknown;
14
+ }, hasBackup?: boolean) => void;
@@ -0,0 +1,144 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
3
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
5
+ /* eslint-disable @typescript-eslint/no-loop-func */
6
+ /* eslint-disable @typescript-eslint/no-unused-expressions */
7
+ /* eslint-disable no-await-in-loop */
8
+ import { useCallback, useEffect, useRef } from 'react';
9
+ import { sleep } from "../helper";
10
+ import { useFail } from "../hooks";
11
+ import { useDispatch, updateStep } from "../store";
12
+ export var useValidate = function useValidate(timeout, changeStatus) {
13
+ var controllerRef = useRef();
14
+ var ref = useRef(true);
15
+ var TimeoutRef = useRef();
16
+ var checkApi = useCallback( /*#__PURE__*/function () {
17
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
18
+ var check, number, txn_status_id, time, __start__, checkCondition, res, start, diff;
19
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
20
+ while (1) switch (_context.prev = _context.next) {
21
+ case 0:
22
+ check = _ref.check, number = _ref.number, txn_status_id = _ref.txn_status_id, time = _ref.time, __start__ = _ref.__start__, checkCondition = _ref.checkCondition;
23
+ time = time || 5000;
24
+ controllerRef.current = new AbortController();
25
+ res = {
26
+ txn_status_id: __start__ || '0'
27
+ };
28
+ case 4:
29
+ if (!(ref.current && checkCondition(res))) {
30
+ _context.next = 17;
31
+ break;
32
+ }
33
+ console.log(res.txn_status_id, txn_status_id);
34
+ start = Date.now();
35
+ _context.next = 9;
36
+ return check({
37
+ number: number,
38
+ txn_status_id: res.txn_status_id
39
+ }, {
40
+ signal: controllerRef.current.signal
41
+ }).then(function (r) {
42
+ changeStatus === null || changeStatus === void 0 ? void 0 : changeStatus(r);
43
+ console.log('原始数据 res = ', r);
44
+ if (r && r.data) {
45
+ return r.data;
46
+ }
47
+ return r;
48
+ }).catch(function (err) {
49
+ console.log(res);
50
+ res = err;
51
+ });
52
+ case 9:
53
+ res = _context.sent;
54
+ diff = Date.now() - start;
55
+ console.log('diff', "".concat(res && res.txn_status_id) !== '8' && "".concat(res && res.status_id) !== '6', res);
56
+ if (!(diff < time)) {
57
+ _context.next = 15;
58
+ break;
59
+ }
60
+ _context.next = 15;
61
+ return sleep(time - diff);
62
+ case 15:
63
+ _context.next = 4;
64
+ break;
65
+ case 17:
66
+ console.log(' res 结束当前 流程 == ', res);
67
+ if (!(!res || checkCondition(res))) {
68
+ _context.next = 21;
69
+ break;
70
+ }
71
+ console.log('失败');
72
+ return _context.abrupt("return", Promise.reject(res));
73
+ case 21:
74
+ return _context.abrupt("return", res);
75
+ case 22:
76
+ case "end":
77
+ return _context.stop();
78
+ }
79
+ }, _callee);
80
+ }));
81
+ return function (_x) {
82
+ return _ref2.apply(this, arguments);
83
+ };
84
+ }(), [changeStatus]);
85
+ var close = useCallback(function () {
86
+ var _controllerRef$curren;
87
+ ref.current = false;
88
+ (_controllerRef$curren = controllerRef.current) === null || _controllerRef$curren === void 0 ? void 0 : _controllerRef$curren.abort();
89
+ }, []);
90
+ var run = function run(params) {
91
+ TimeoutRef.current && clearTimeout(TimeoutRef.current);
92
+ TimeoutRef.current = setTimeout(function () {
93
+ close();
94
+ }, timeout);
95
+ return checkApi(params);
96
+ };
97
+ useEffect(function () {
98
+ return function () {
99
+ clearTimeout(TimeoutRef.current);
100
+ close();
101
+ };
102
+ }, [close]);
103
+ return [run, close];
104
+ };
105
+ export var useSuccess = function useSuccess(index) {
106
+ var fail = useFail(index);
107
+ var dispatch = useDispatch();
108
+ return useCallback(function (res, hasBackup) {
109
+ if (hasBackup) {
110
+ return;
111
+ }
112
+ if (!res) {
113
+ console.log('success fail 报错 1 ', res);
114
+ fail(res);
115
+ return;
116
+ }
117
+ var _ref3 = [Number(res.txn_status_id)],
118
+ txn_status_id = _ref3[0];
119
+ console.log('success txn_status_id = ', txn_status_id);
120
+ if (txn_status_id < 5) {
121
+ dispatch(updateStep({
122
+ step: 0
123
+ }));
124
+ } else if (txn_status_id >= 5 && txn_status_id < 7) {
125
+ // 前往 输入密码界面步骤
126
+ dispatch(updateStep({
127
+ step: 1
128
+ }));
129
+ } else if (txn_status_id === 7) {
130
+ // 已经签字 前往签字确认步骤
131
+ dispatch(updateStep({
132
+ step: 2
133
+ }));
134
+ } else if (txn_status_id === 8) {
135
+ if (res.status_id === '6' || res.status_id === 6) {
136
+ dispatch(updateStep({
137
+ step: 5
138
+ }));
139
+ } else {
140
+ fail(res);
141
+ }
142
+ }
143
+ }, [fail, dispatch]);
144
+ };
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ declare const _default: ({ api, onChange, children, hasBackup, }: {
3
+ api: any;
4
+ onChange: any;
5
+ children: React.ReactNode;
6
+ hasBackup: boolean;
7
+ }) => React.JSX.Element;
8
+ export default _default;
@@ -0,0 +1,49 @@
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 consistent-return */
5
+ /* eslint-disable react/no-array-index-key */
6
+ /* eslint-disable array-callback-return */
7
+ import React from 'react';
8
+ import { StatusEnum } from "../const";
9
+ import { useContextData } from "../store";
10
+ import Action from "./action";
11
+ import POS from "./pos";
12
+ import Pwd from "./pwd";
13
+ import Receipet, { ReceipetAgain } from "./receipet";
14
+ import Wait from "./wait";
15
+ export default (function (_ref) {
16
+ var api = _ref.api,
17
+ onChange = _ref.onChange,
18
+ children = _ref.children,
19
+ hasBackup = _ref.hasBackup;
20
+ var _useContextData = useContextData(),
21
+ step = _useContextData.step,
22
+ steps = _useContextData.steps,
23
+ data = _objectWithoutProperties(_useContextData, _excluded);
24
+ console.log('hasBackup = ', hasBackup);
25
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
26
+ className: "pisell-lowcode__eft-pay-body"
27
+ }, steps.map(function (item, idx) {
28
+ var Comm;
29
+ if (idx === 0) Comm = POS;
30
+ if (idx === 1) Comm = Pwd;
31
+ if (idx === 2) Comm = Receipet;
32
+ if (idx === 3) Comm = ReceipetAgain;
33
+ if (idx === 4) Comm = Wait;
34
+ if (!Comm) {
35
+ throw new Error('no comm');
36
+ }
37
+ if (step >= idx) {
38
+ return /*#__PURE__*/React.createElement(Comm, {
39
+ key: "".concat(data.key, "-").concat(item.key, "-").concat(idx),
40
+ api: api,
41
+ hasBackup: hasBackup,
42
+ onChange: onChange
43
+ });
44
+ }
45
+ }), children), data.status !== StatusEnum.Success ? /*#__PURE__*/React.createElement(Action, {
46
+ index: step,
47
+ api: api
48
+ }) : null);
49
+ });
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ declare const POS: ({ api, hasBackup, }: {
3
+ api: {
4
+ [key: string]: (...agrn: unknown[]) => Promise<unknown>;
5
+ };
6
+ hasBackup: boolean;
7
+ }) => React.JSX.Element;
8
+ export default POS;