@pisell/private-materials 6.3.15 → 6.3.17
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 +150 -150
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +7 -7
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +8 -8
- package/es/components/appointmentBooking/components/Guest/components/InformationOptionsModal/index.d.ts +1 -0
- package/es/components/booking/addons/model.d.ts +10 -1
- package/es/components/booking/components/TabProduct/tabs/index.js +5 -1
- package/es/components/booking/components/browserSelect/index.js +1 -1
- package/es/components/booking/components/formItemChildrenWrap/index.d.ts +1 -0
- package/es/components/booking/forms/model.d.ts +10 -1
- package/es/components/booking/forms/model.js +5 -5
- package/es/components/booking/forms/sendModal/useSendModal.d.ts +1 -1
- package/es/components/booking/info/clientVariant/hooks/useIsLowSpeedNetwork.d.ts +1 -0
- package/es/components/booking/info/model.d.ts +10 -1
- package/es/components/booking/info/service/addService/utils.d.ts +1 -1
- package/es/components/booking/info/service/like/index.d.ts +1 -0
- package/es/components/booking/info/service/like/index.js +1 -1
- package/es/components/booking/info/service2/utils.d.ts +1 -1
- package/es/components/booking/info2/service/addService/utils.d.ts +1 -1
- package/es/components/booking/model.d.ts +9 -1
- package/es/components/booking/notes/NoteBlock/NoteItem/index.js +1 -1
- package/es/components/booking/notes/NoteBlock/index.js +11 -11
- package/es/components/booking/notes/model.d.ts +10 -1
- package/es/components/booking/notes/model.js +5 -5
- package/es/components/booking/payments/model.d.ts +10 -1
- package/es/components/booking/payments/model.js +5 -5
- package/es/components/eftpos/deviceList/index.d.ts +1 -0
- package/es/components/eftpos/group/index.d.ts +1 -0
- package/es/components/eftpos/icon/apiKey.d.ts +1 -0
- package/es/components/eftpos/icon/device.d.ts +1 -0
- package/es/components/eftpos/receipt/index.d.ts +1 -0
- package/es/components/eftposPay/amount.d.ts +1 -1
- package/es/components/eftposPay/component/alert/warn.d.ts +1 -0
- package/es/components/eftposPay/component/header/titlebar.d.ts +1 -0
- package/es/components/eftposPay/component/step/index.d.ts +1 -0
- package/es/components/eftposPay/component/step/step.d.ts +1 -0
- package/es/components/eftposPay/device.d.ts +1 -1
- package/es/components/eftposPay/hooks.d.ts +2 -2
- package/es/components/eftposPay/store/index.d.ts +3 -3
- package/es/components/eftposPay/tyro/hooks.d.ts +1 -0
- package/es/components/eventBooking/components/ErrorTip/index.d.ts +1 -0
- package/es/components/eventBooking/components/Provider/InformationOptionsModal/index.d.ts +1 -0
- package/es/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/CalenDateWeek/WeekItem/index.d.ts +1 -0
- package/es/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/CalenDateWeek/index.d.ts +1 -0
- package/es/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/Item/DayItem/index.d.ts +1 -0
- package/es/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/Item/index.d.ts +1 -0
- package/es/components/index.d.ts +3 -1
- package/es/components/index.js +3 -1
- package/es/components/listComponent/index.js +5 -5
- package/es/components/pay/toC/PaymentMethods/StripePay/Stripe/components/SetupForm/index.d.ts +1 -0
- package/es/components/pay/toC/PaymentMethods/WalletPass/List/index.d.ts +2 -0
- package/es/components/pay/toC/PaymentMethods/WalletPass/index.js +112 -24
- package/es/components/pay/toC/PaymentMethods/WalletPass/serve.d.ts +38 -2
- package/es/components/pay/toC/PaymentMethods/WalletPass/serve.js +78 -0
- package/es/components/pay/toC/PaymentMethods/WalletPass/utils.d.ts +6 -0
- package/es/components/pay/toC/PaymentMethods/WalletPass/utils.js +9 -0
- package/es/components/pay/toC/model.d.ts +9 -1
- package/es/components/pay/toC/utils.js +1 -1
- package/es/components/pinModal/hooks.d.ts +7 -0
- package/es/components/pinModal/hooks.js +65 -0
- package/es/components/pinModal/index.d.ts +4 -0
- package/es/components/pinModal/index.js +98 -0
- package/es/components/pinModal/index.less +44 -0
- package/es/components/pinModal/locales.d.ts +27 -0
- package/es/components/pinModal/locales.js +26 -0
- package/es/components/pinModal/serve.d.ts +6 -0
- package/es/components/pinModal/serve.js +11 -0
- package/es/components/pinModal/types.d.ts +0 -0
- package/es/components/pinModal/types.js +0 -0
- package/es/components/pinVerifyModal/hooks.d.ts +7 -0
- package/es/components/pinVerifyModal/hooks.js +80 -0
- package/es/components/pinVerifyModal/index.d.ts +5 -0
- package/es/components/pinVerifyModal/index.js +218 -0
- package/es/components/pinVerifyModal/index.less +92 -0
- package/es/components/pinVerifyModal/locales.d.ts +24 -0
- package/es/components/pinVerifyModal/locales.js +23 -0
- package/es/components/pinVerifyModal/types.d.ts +33 -0
- package/es/components/pinVerifyModal/types.js +1 -0
- package/es/components/productExtension/card/index.js +3 -3
- package/es/components/productExtension/fields/Actor/CutOffTime/index.js +1 -1
- package/es/components/productExtension/fields/Forms/index.js +12 -12
- package/es/components/productExtension/fields/SelectProducts/ProductItemPreview/index.js +1 -1
- package/es/components/productExtension/fields/SelectProducts/server.js +2 -2
- package/es/components/productExtension/fields/SelectResourcesTable/server.js +2 -2
- package/es/components/productExtension/server.js +2 -2
- package/es/components/ruleSetting/ruleBorder/index.js +1 -1
- package/es/components/schedules/calendar/index.js +4 -4
- package/es/components/schedules/calendar/serve.js +2 -2
- package/es/components/schedules/components/CurrentDay/index.js +5 -5
- package/es/components/schedules/components/CurrentDay/serve.js +2 -2
- package/es/components/schedules/components/DropdownSort/index.js +1 -1
- package/es/components/schedules/components/ResourceList/index.js +1 -1
- package/es/components/schedules/components/Search/index.js +5 -5
- package/es/components/schedules/model.d.ts +9 -1
- package/es/components/schedules/model.js +5 -5
- package/es/components/schedules/openHours/index.js +1 -1
- package/es/components/schedules/openHours/serve.js +2 -2
- package/es/components/schedules/products/ProductDetailDrawer/ProductDetail/MaxParticipantsModule/index.js +1 -1
- package/es/components/schedules/products/ProductDetailDrawer/ProductDetail/ResourcesModule/index.js +5 -5
- package/es/components/schedules/products/ProductDetailDrawer/ProductDetail/SchedulesModule/index.js +4 -4
- package/es/components/schedules/products/ProductDetailDrawer/index.js +3 -3
- package/es/components/schedules/products/serve.js +2 -2
- package/es/components/schedules/products/utils.js +5 -5
- package/es/components/schedules/resources/detail/detailContent.js +2 -2
- package/es/components/schedules/resources/detail/index.js +10 -10
- package/es/components/schedules/resources/list/index.js +2 -2
- package/es/components/schedules/resources/relationProduct/index.js +1 -1
- package/es/components/schedules/resources/serve.js +2 -2
- package/es/components/schedules/schedules/ScheduleDetailDrawer/index.js +9 -9
- package/es/components/schedules/utils.d.ts +1 -1
- package/es/components/schedules/utils.js +4 -4
- package/es/components/selectModal/index.js +2 -2
- package/es/components/ticketBooking/components/ticketBooking/index.js +2 -0
- package/es/components/wallet/Detail/index.js +3 -1
- package/es/components/wallet/Detail/model.d.ts +13 -1
- package/es/components/wallet/DiscountCard/model.d.ts +14 -1
- package/es/components/wallet/PointCard/model.d.ts +13 -1
- package/es/components/wallet/RechargeableCard/model.d.ts +29 -1
- package/es/components/wallet/Voucher/model.d.ts +13 -1
- package/es/components/wallet/components/WalletCard.js +8 -3
- package/es/components/wallet/model.d.ts +9 -1
- package/es/components/walletList/index.js +20 -2
- package/es/components/workSpaceList/components/Modal/index.d.ts +1 -0
- package/es/hooks/useComponents.js +1 -1
- package/es/index.d.ts +2 -0
- package/es/index.js +3 -1
- package/es/utils/index.d.ts +1 -1
- package/lib/components/appointmentBooking/components/Guest/components/InformationOptionsModal/index.d.ts +1 -0
- package/lib/components/booking/addons/model.d.ts +10 -1
- package/lib/components/booking/components/formItemChildrenWrap/index.d.ts +1 -0
- package/lib/components/booking/forms/model.d.ts +10 -1
- package/lib/components/booking/forms/sendModal/useSendModal.d.ts +1 -1
- package/lib/components/booking/info/clientVariant/hooks/useIsLowSpeedNetwork.d.ts +1 -0
- package/lib/components/booking/info/model.d.ts +10 -1
- package/lib/components/booking/info/service/addService/utils.d.ts +1 -1
- package/lib/components/booking/info/service/like/index.d.ts +1 -0
- package/lib/components/booking/info/service2/utils.d.ts +1 -1
- package/lib/components/booking/info2/service/addService/utils.d.ts +1 -1
- package/lib/components/booking/model.d.ts +9 -1
- package/lib/components/booking/notes/model.d.ts +10 -1
- package/lib/components/booking/payments/model.d.ts +10 -1
- package/lib/components/eftpos/deviceList/index.d.ts +1 -0
- package/lib/components/eftpos/group/index.d.ts +1 -0
- package/lib/components/eftpos/icon/apiKey.d.ts +1 -0
- package/lib/components/eftpos/icon/device.d.ts +1 -0
- package/lib/components/eftpos/receipt/index.d.ts +1 -0
- package/lib/components/eftposPay/amount.d.ts +1 -1
- package/lib/components/eftposPay/component/alert/warn.d.ts +1 -0
- package/lib/components/eftposPay/component/header/titlebar.d.ts +1 -0
- package/lib/components/eftposPay/component/step/index.d.ts +1 -0
- package/lib/components/eftposPay/component/step/step.d.ts +1 -0
- package/lib/components/eftposPay/device.d.ts +1 -1
- package/lib/components/eftposPay/hooks.d.ts +2 -2
- package/lib/components/eftposPay/store/index.d.ts +3 -3
- package/lib/components/eftposPay/tyro/hooks.d.ts +1 -0
- package/lib/components/eventBooking/components/ErrorTip/index.d.ts +1 -0
- package/lib/components/eventBooking/components/Provider/InformationOptionsModal/index.d.ts +1 -0
- package/lib/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/CalenDateWeek/WeekItem/index.d.ts +1 -0
- package/lib/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/CalenDateWeek/index.d.ts +1 -0
- package/lib/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/Item/DayItem/index.d.ts +1 -0
- package/lib/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/Item/index.d.ts +1 -0
- package/lib/components/index.d.ts +3 -1
- package/lib/components/index.js +6 -0
- package/lib/components/pay/toC/PaymentMethods/StripePay/Stripe/components/SetupForm/index.d.ts +1 -0
- package/lib/components/pay/toC/PaymentMethods/WalletPass/List/index.d.ts +2 -0
- package/lib/components/pay/toC/PaymentMethods/WalletPass/index.js +84 -36
- package/lib/components/pay/toC/PaymentMethods/WalletPass/serve.d.ts +38 -2
- package/lib/components/pay/toC/PaymentMethods/WalletPass/serve.js +18 -0
- package/lib/components/pay/toC/PaymentMethods/WalletPass/utils.d.ts +6 -0
- package/lib/components/pay/toC/PaymentMethods/WalletPass/utils.js +7 -2
- package/lib/components/pay/toC/model.d.ts +9 -1
- package/lib/components/pay/toC/utils.js +1 -1
- package/lib/components/pinModal/hooks.d.ts +7 -0
- package/lib/components/pinModal/hooks.js +85 -0
- package/lib/components/pinModal/index.d.ts +4 -0
- package/lib/components/pinModal/index.js +88 -0
- package/lib/components/pinModal/index.less +44 -0
- package/lib/components/pinModal/locales.d.ts +27 -0
- package/lib/components/pinModal/locales.js +50 -0
- package/lib/components/pinModal/serve.d.ts +6 -0
- package/lib/components/pinModal/serve.js +37 -0
- package/lib/components/pinModal/types.d.ts +0 -0
- package/lib/components/pinModal/types.js +0 -0
- package/lib/components/pinVerifyModal/hooks.d.ts +7 -0
- package/lib/components/pinVerifyModal/hooks.js +93 -0
- package/lib/components/pinVerifyModal/index.d.ts +5 -0
- package/lib/components/pinVerifyModal/index.js +230 -0
- package/lib/components/pinVerifyModal/index.less +92 -0
- package/lib/components/pinVerifyModal/locales.d.ts +24 -0
- package/lib/components/pinVerifyModal/locales.js +47 -0
- package/lib/components/pinVerifyModal/types.d.ts +33 -0
- package/lib/components/pinVerifyModal/types.js +17 -0
- package/lib/components/schedules/model.d.ts +9 -1
- package/lib/components/schedules/utils.d.ts +1 -1
- package/lib/components/schedules/utils.js +1 -1
- package/lib/components/ticketBooking/components/ticketBooking/index.js +1 -0
- package/lib/components/wallet/Detail/index.js +18 -5
- package/lib/components/wallet/Detail/model.d.ts +13 -1
- package/lib/components/wallet/DiscountCard/model.d.ts +14 -1
- package/lib/components/wallet/PointCard/model.d.ts +13 -1
- package/lib/components/wallet/RechargeableCard/model.d.ts +29 -1
- package/lib/components/wallet/Voucher/model.d.ts +13 -1
- package/lib/components/wallet/components/WalletCard.js +3 -1
- package/lib/components/wallet/model.d.ts +9 -1
- package/lib/components/walletList/index.js +19 -2
- package/lib/components/workSpaceList/components/Modal/index.d.ts +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +6 -0
- package/lib/utils/index.d.ts +1 -1
- package/lowcode/pin-modal/meta.ts +37 -0
- package/lowcode/pin-verify-modal/meta.ts +80 -0
- package/package.json +3 -3
@@ -1,9 +1,9 @@
|
|
1
|
-
function _typeof(
|
2
|
-
function ownKeys(
|
3
|
-
function _objectSpread(
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
4
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(
|
6
|
-
function _toPrimitive(
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
7
7
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
8
8
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
9
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); }
|
@@ -11,6 +11,8 @@ export interface WalletPassListProps {
|
|
11
11
|
name: string;
|
12
12
|
};
|
13
13
|
onChangeDebounce?: boolean;
|
14
|
+
loading?: boolean;
|
15
|
+
onLoadingChange?: (loading: boolean) => void;
|
14
16
|
}
|
15
17
|
export declare type WalletPassListRef = {
|
16
18
|
init: (params: MachineCodeListParams, formatList?: (val: WalletPassDataType[]) => WalletPassDataType[]) => void;
|
@@ -22,18 +22,22 @@ import { PisellModal, PisellText, PisellToast } from '@pisell/materials';
|
|
22
22
|
import { locales, uniqueByKey } from '@pisell/utils';
|
23
23
|
import { useMemoizedFn } from 'ahooks';
|
24
24
|
import { InfoCircleOutlined } from '@ant-design/icons';
|
25
|
+
import PinVerifyModal from "../../../../pinVerifyModal";
|
25
26
|
import MultiModeSearch from "./MultiModeSearch";
|
26
27
|
import List from "./List";
|
27
|
-
import { searchMachineCodeList } from "./serve";
|
28
|
-
import { formatMachineCodeServer2CardList } from "./utils";
|
28
|
+
import { searchMachineCodeList, searchWalletCode } from "./serve";
|
29
|
+
import { formatMachineCodeServer2CardList, getIsWalletCode } from "./utils";
|
29
30
|
import { calcWalletPassListAmount, formatWalletPassList2PreparePayments } from "../../utils";
|
30
31
|
import "./index.less";
|
32
|
+
import useEngineContext from "../../../../../hooks/useEngineContext";
|
31
33
|
var Amount = PisellText.Amount;
|
32
34
|
var WalletPass = /*#__PURE__*/forwardRef(function (props, ref) {
|
33
|
-
var _searchSelectData$ids;
|
35
|
+
var _context$appHelper, _context$appHelper$ge, _searchSelectData$ids;
|
34
36
|
var onWalletPassChange = props.onWalletPassChange,
|
35
37
|
walletPass = props.walletPass,
|
36
38
|
walletSetting = props.walletSetting;
|
39
|
+
var context = useEngineContext();
|
40
|
+
var isWalletCode = context === null || context === void 0 || (_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 || (_context$appHelper = _context$appHelper.utils) === null || _context$appHelper === void 0 || (_context$appHelper = _context$appHelper.businessUtils) === null || _context$appHelper === void 0 || (_context$appHelper$ge = _context$appHelper.getAppByModal) === null || _context$appHelper$ge === void 0 ? void 0 : _context$appHelper$ge.call(_context$appHelper, 'wallet');
|
37
41
|
|
38
42
|
/** 当前 walletPass信息 弹窗操作时都在内部进行,点击 redeem时同步到外层 */
|
39
43
|
var _useState = useState(walletPass),
|
@@ -87,7 +91,8 @@ var WalletPass = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
87
91
|
var listRef = useRef(null);
|
88
92
|
|
89
93
|
/** 当前搜索框搜索值 */
|
90
|
-
var searchValRef = useRef(
|
94
|
+
var searchValRef = useRef(null);
|
95
|
+
var pinVerifyModalRef = useRef(null);
|
91
96
|
var _ref = currentWalletPass || {},
|
92
97
|
walletPassSelectCards = _ref.cards,
|
93
98
|
amount = _ref.amount;
|
@@ -207,30 +212,33 @@ var WalletPass = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
207
212
|
* @param val
|
208
213
|
*/
|
209
214
|
var searchList = /*#__PURE__*/function () {
|
210
|
-
var
|
211
|
-
var _order$_order2;
|
212
|
-
var result;
|
215
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref3, isSelectChange) {
|
216
|
+
var code, customer_pin_key, _order$_order2, result;
|
213
217
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
214
218
|
while (1) switch (_context2.prev = _context2.next) {
|
215
219
|
case 0:
|
220
|
+
code = _ref3.code, customer_pin_key = _ref3.customer_pin_key;
|
216
221
|
if (order !== null && order !== void 0 && order.order_id) {
|
217
|
-
_context2.next =
|
222
|
+
_context2.next = 3;
|
218
223
|
break;
|
219
224
|
}
|
220
225
|
return _context2.abrupt("return");
|
221
|
-
case
|
222
|
-
|
226
|
+
case 3:
|
227
|
+
setLoading(true);
|
228
|
+
_context2.prev = 4;
|
229
|
+
_context2.next = 7;
|
223
230
|
return searchMachineCodeList({
|
224
231
|
order_id: order.order_id,
|
225
|
-
code:
|
232
|
+
code: code,
|
226
233
|
prepare_payments: prepare_payments,
|
227
|
-
filter_prepare_wallet_pass: 1,
|
228
|
-
sale_channel: ((_order$_order2 = order._order) === null || _order$_order2 === void 0 ? void 0 : _order$_order2.sale_channel) || 'online-store'
|
234
|
+
// filter_prepare_wallet_pass: 1,
|
235
|
+
sale_channel: ((_order$_order2 = order._order) === null || _order$_order2 === void 0 ? void 0 : _order$_order2.sale_channel) || 'online-store',
|
236
|
+
customer_pin_key: customer_pin_key
|
229
237
|
});
|
230
|
-
case
|
238
|
+
case 7:
|
231
239
|
result = _context2.sent;
|
232
240
|
if (result) {
|
233
|
-
_context2.next =
|
241
|
+
_context2.next = 11;
|
234
242
|
break;
|
235
243
|
}
|
236
244
|
if (!isSelectChange) {
|
@@ -239,7 +247,13 @@ var WalletPass = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
239
247
|
});
|
240
248
|
}
|
241
249
|
return _context2.abrupt("return");
|
242
|
-
case
|
250
|
+
case 11:
|
251
|
+
if (!(isSelectChange && !searchValRef.current)) {
|
252
|
+
_context2.next = 13;
|
253
|
+
break;
|
254
|
+
}
|
255
|
+
return _context2.abrupt("return");
|
256
|
+
case 13:
|
243
257
|
setSearchData(formatMachineCodeServer2CardList([].concat(_toConsumableArray(searchSelectData.details), _toConsumableArray(result)), searchSelectData.ids));
|
244
258
|
if (result.length) {
|
245
259
|
// 如果搜索结果只有一个并且可用,则直接选中
|
@@ -250,22 +264,88 @@ var WalletPass = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
250
264
|
});
|
251
265
|
}
|
252
266
|
setSearchOpen(true);
|
253
|
-
searchValRef.current =
|
267
|
+
searchValRef.current = {
|
268
|
+
code: code,
|
269
|
+
customer_pin_key: customer_pin_key
|
270
|
+
};
|
254
271
|
}
|
255
|
-
case
|
272
|
+
case 15:
|
273
|
+
_context2.prev = 15;
|
274
|
+
setLoading(false);
|
275
|
+
return _context2.finish(15);
|
276
|
+
case 18:
|
256
277
|
case "end":
|
257
278
|
return _context2.stop();
|
258
279
|
}
|
259
|
-
}, _callee2);
|
280
|
+
}, _callee2, null, [[4,, 15, 18]]);
|
260
281
|
}));
|
261
282
|
return function searchList(_x2, _x3) {
|
262
|
-
return
|
283
|
+
return _ref4.apply(this, arguments);
|
284
|
+
};
|
285
|
+
}();
|
286
|
+
var searchWalletCodeFn = /*#__PURE__*/function () {
|
287
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(val) {
|
288
|
+
var _pinVerifyModalRef$cu, result;
|
289
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
290
|
+
while (1) switch (_context3.prev = _context3.next) {
|
291
|
+
case 0:
|
292
|
+
setLoading(true);
|
293
|
+
_context3.prev = 1;
|
294
|
+
_context3.next = 4;
|
295
|
+
return searchWalletCode({
|
296
|
+
code: val,
|
297
|
+
with_customer: 1
|
298
|
+
});
|
299
|
+
case 4:
|
300
|
+
result = _context3.sent;
|
301
|
+
console.log(result, 'result');
|
302
|
+
// 如果搜索不到wallet code则走原始搜索逻辑
|
303
|
+
if (result) {
|
304
|
+
_context3.next = 9;
|
305
|
+
break;
|
306
|
+
}
|
307
|
+
searchList({
|
308
|
+
code: val
|
309
|
+
});
|
310
|
+
return _context3.abrupt("return");
|
311
|
+
case 9:
|
312
|
+
(_pinVerifyModalRef$cu = pinVerifyModalRef.current) === null || _pinVerifyModalRef$cu === void 0 || _pinVerifyModalRef$cu.open({
|
313
|
+
wallet_code: result.code,
|
314
|
+
wallet_detail_id: result.id,
|
315
|
+
failed_count: result.failed_count,
|
316
|
+
check_max_count: result.check_max_count,
|
317
|
+
customer: result.customer
|
318
|
+
});
|
319
|
+
// const pin = await getPin({ wallet_detail_id: result.id });
|
320
|
+
// const pinResult = await verifyPinCode({ wallet_detail_id: result.id, pin: pin.pin });
|
321
|
+
// searchList({ customer_pin_key: pinResult.customer_pin_key });
|
322
|
+
// console.log(pinResult, 'pinResult');
|
323
|
+
case 10:
|
324
|
+
_context3.prev = 10;
|
325
|
+
setLoading(false);
|
326
|
+
return _context3.finish(10);
|
327
|
+
case 13:
|
328
|
+
case "end":
|
329
|
+
return _context3.stop();
|
330
|
+
}
|
331
|
+
}, _callee3, null, [[1,, 10, 13]]);
|
332
|
+
}));
|
333
|
+
return function searchWalletCodeFn(_x4) {
|
334
|
+
return _ref5.apply(this, arguments);
|
263
335
|
};
|
264
336
|
}();
|
265
337
|
var handleSearch = useMemoizedFn(function (val) {
|
266
338
|
if (!val || searchOpen) return;
|
267
339
|
isAutoSelect.current = true;
|
268
|
-
|
340
|
+
|
341
|
+
// 如果是wallet code 并且安装wallet应用 则搜索wallet code
|
342
|
+
if (getIsWalletCode(val) && isWalletCode) {
|
343
|
+
searchWalletCodeFn(val);
|
344
|
+
} else {
|
345
|
+
searchList({
|
346
|
+
code: val
|
347
|
+
});
|
348
|
+
}
|
269
349
|
});
|
270
350
|
useImperativeHandle(ref, function () {
|
271
351
|
return {
|
@@ -274,7 +354,7 @@ var WalletPass = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
274
354
|
});
|
275
355
|
var handleSearchModalClose = function handleSearchModalClose() {
|
276
356
|
setSearchOpen(false);
|
277
|
-
searchValRef.current =
|
357
|
+
searchValRef.current = null;
|
278
358
|
setSearchSelectData({
|
279
359
|
ids: [],
|
280
360
|
details: []
|
@@ -398,7 +478,15 @@ var WalletPass = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
398
478
|
walletSetting: walletSetting,
|
399
479
|
data: searchData,
|
400
480
|
value: searchSelectData.ids,
|
401
|
-
onChange: handleAddChange
|
402
|
-
|
481
|
+
onChange: handleAddChange,
|
482
|
+
loading: loading
|
483
|
+
}))), /*#__PURE__*/React.createElement(PinVerifyModal, {
|
484
|
+
ref: pinVerifyModalRef,
|
485
|
+
onSuccess: function onSuccess(params) {
|
486
|
+
searchList({
|
487
|
+
customer_pin_key: params === null || params === void 0 ? void 0 : params.customer_pin_key
|
488
|
+
});
|
489
|
+
}
|
490
|
+
}));
|
403
491
|
});
|
404
492
|
export default /*#__PURE__*/memo(WalletPass);
|
@@ -84,14 +84,15 @@ export declare const getRecommendMachineCodeList: (order_id: number) => Promise<
|
|
84
84
|
*/
|
85
85
|
export declare const searchMachineCodeList: (params: {
|
86
86
|
order_id: number | string;
|
87
|
-
code
|
87
|
+
code?: string;
|
88
88
|
sale_channel: string;
|
89
89
|
prepare_payments: {
|
90
90
|
voucher_id: number;
|
91
91
|
amount: number;
|
92
92
|
tag: string;
|
93
93
|
}[];
|
94
|
-
filter_prepare_wallet_pass
|
94
|
+
filter_prepare_wallet_pass?: 1 | 0;
|
95
|
+
customer_pin_key?: string;
|
95
96
|
}) => Promise<WalletPassDataType[]>;
|
96
97
|
/**
|
97
98
|
* walletpass支付
|
@@ -110,4 +111,39 @@ export declare const walletPassPay: (params: {
|
|
110
111
|
};
|
111
112
|
}[];
|
112
113
|
}) => Promise<WalletPassDataType[]>;
|
114
|
+
/**
|
115
|
+
* 搜索wallet code
|
116
|
+
*/
|
117
|
+
export declare const searchWalletCode: (params: {
|
118
|
+
code: string;
|
119
|
+
with_customer: 1 | 0;
|
120
|
+
}) => Promise<{
|
121
|
+
code: string;
|
122
|
+
id: number;
|
123
|
+
status: 'enable' | 'disable' | 'expired';
|
124
|
+
expired_at: string;
|
125
|
+
customer: Record<string, any>;
|
126
|
+
check_max_count: number;
|
127
|
+
failed_count: number;
|
128
|
+
}>;
|
129
|
+
/**
|
130
|
+
* 验证pin码
|
131
|
+
*/
|
132
|
+
export declare const verifyPinCode: (params: {
|
133
|
+
wallet_detail_id: number;
|
134
|
+
pin: string;
|
135
|
+
}) => Promise<{
|
136
|
+
status: number;
|
137
|
+
customer_id: number;
|
138
|
+
msg: string;
|
139
|
+
customer_pin_key: string;
|
140
|
+
}>;
|
141
|
+
/**
|
142
|
+
* 获取pin码
|
143
|
+
*/
|
144
|
+
export declare const getPin: (params: {
|
145
|
+
wallet_detail_id: number;
|
146
|
+
}) => Promise<{
|
147
|
+
pin: string;
|
148
|
+
}>;
|
113
149
|
export {};
|
@@ -111,4 +111,82 @@ export var walletPassPay = /*#__PURE__*/function () {
|
|
111
111
|
return function walletPassPay(_x4) {
|
112
112
|
return _ref4.apply(this, arguments);
|
113
113
|
};
|
114
|
+
}();
|
115
|
+
|
116
|
+
/**
|
117
|
+
* 搜索wallet code
|
118
|
+
*/
|
119
|
+
export var searchWalletCode = /*#__PURE__*/function () {
|
120
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(params) {
|
121
|
+
var _yield$request$getReq5, data;
|
122
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
123
|
+
while (1) switch (_context5.prev = _context5.next) {
|
124
|
+
case 0:
|
125
|
+
_context5.next = 2;
|
126
|
+
return request.getRequest().post("/h5/wallet/detail/search", params);
|
127
|
+
case 2:
|
128
|
+
_yield$request$getReq5 = _context5.sent;
|
129
|
+
data = _yield$request$getReq5.data;
|
130
|
+
return _context5.abrupt("return", data);
|
131
|
+
case 5:
|
132
|
+
case "end":
|
133
|
+
return _context5.stop();
|
134
|
+
}
|
135
|
+
}, _callee5);
|
136
|
+
}));
|
137
|
+
return function searchWalletCode(_x5) {
|
138
|
+
return _ref5.apply(this, arguments);
|
139
|
+
};
|
140
|
+
}();
|
141
|
+
|
142
|
+
/**
|
143
|
+
* 验证pin码
|
144
|
+
*/
|
145
|
+
export var verifyPinCode = /*#__PURE__*/function () {
|
146
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(params) {
|
147
|
+
var _yield$request$getReq6, data;
|
148
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
149
|
+
while (1) switch (_context6.prev = _context6.next) {
|
150
|
+
case 0:
|
151
|
+
_context6.next = 2;
|
152
|
+
return request.getRequest().post("/h5/wallet/detail/pin/validate", params);
|
153
|
+
case 2:
|
154
|
+
_yield$request$getReq6 = _context6.sent;
|
155
|
+
data = _yield$request$getReq6.data;
|
156
|
+
return _context6.abrupt("return", data);
|
157
|
+
case 5:
|
158
|
+
case "end":
|
159
|
+
return _context6.stop();
|
160
|
+
}
|
161
|
+
}, _callee6);
|
162
|
+
}));
|
163
|
+
return function verifyPinCode(_x6) {
|
164
|
+
return _ref6.apply(this, arguments);
|
165
|
+
};
|
166
|
+
}();
|
167
|
+
|
168
|
+
/**
|
169
|
+
* 获取pin码
|
170
|
+
*/
|
171
|
+
export var getPin = /*#__PURE__*/function () {
|
172
|
+
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(params) {
|
173
|
+
var _yield$request$getReq7, data;
|
174
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
175
|
+
while (1) switch (_context7.prev = _context7.next) {
|
176
|
+
case 0:
|
177
|
+
_context7.next = 2;
|
178
|
+
return request.getRequest().get("/h5/wallet/detail/pin", params);
|
179
|
+
case 2:
|
180
|
+
_yield$request$getReq7 = _context7.sent;
|
181
|
+
data = _yield$request$getReq7.data;
|
182
|
+
return _context7.abrupt("return", data);
|
183
|
+
case 5:
|
184
|
+
case "end":
|
185
|
+
return _context7.stop();
|
186
|
+
}
|
187
|
+
}, _callee7);
|
188
|
+
}));
|
189
|
+
return function getPin(_x7) {
|
190
|
+
return _ref7.apply(this, arguments);
|
191
|
+
};
|
114
192
|
}();
|
@@ -1,3 +1,9 @@
|
|
1
1
|
import { WalletPassDataType } from './serve';
|
2
2
|
export declare const formatMachineCodeServer2CardList: (data: WalletPassDataType[], selectId?: number[]) => any;
|
3
3
|
export declare const getDataByIds: (arr: any[], ids: number[]) => any[];
|
4
|
+
/**
|
5
|
+
* 判断是否是wallet code
|
6
|
+
* @param val
|
7
|
+
* @returns
|
8
|
+
*/
|
9
|
+
export declare const getIsWalletCode: (val: string) => boolean;
|
@@ -38,4 +38,13 @@ export var getDataByIds = function getDataByIds(arr, ids) {
|
|
38
38
|
return arr.filter(function (item) {
|
39
39
|
return ids.includes(item.id);
|
40
40
|
});
|
41
|
+
};
|
42
|
+
|
43
|
+
/**
|
44
|
+
* 判断是否是wallet code
|
45
|
+
* @param val
|
46
|
+
* @returns
|
47
|
+
*/
|
48
|
+
export var getIsWalletCode = function getIsWalletCode(val) {
|
49
|
+
return val.startsWith('WL') || val.startsWith('2') && val.length === 10;
|
41
50
|
};
|
@@ -1,3 +1,4 @@
|
|
1
|
+
/// <reference types="react" />
|
1
2
|
export interface FormState {
|
2
3
|
platform: 'pc' | 'h5' | '' | undefined;
|
3
4
|
order: any;
|
@@ -28,4 +29,11 @@ export interface PayGroup {
|
|
28
29
|
pay_number?: string;
|
29
30
|
_order: any;
|
30
31
|
}
|
31
|
-
export declare const Provider: any, Context:
|
32
|
+
export declare const Provider: (ComponentUi: any) => any, Context: import("react").Context<{
|
33
|
+
state: FormState;
|
34
|
+
} & {
|
35
|
+
dispatch: (params: {
|
36
|
+
type: string;
|
37
|
+
payload: any;
|
38
|
+
}) => void;
|
39
|
+
}>;
|
@@ -41,7 +41,7 @@ export var formatWalletPassParams = function formatWalletPassParams(payGroup) {
|
|
41
41
|
var payments = (walletPass === null || walletPass === void 0 ? void 0 : walletPass.cards.map(function (item) {
|
42
42
|
return {
|
43
43
|
amount: getAvailableMaxAmount(item),
|
44
|
-
wallet_pass_use_value: item.
|
44
|
+
wallet_pass_use_value: item.recommended_usage_par_value,
|
45
45
|
voucher_id: item.id,
|
46
46
|
tag: item.tag,
|
47
47
|
wallet_pass_usage_unit: item.wallet_pass_usage_unit
|
@@ -0,0 +1,65 @@
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
2
|
+
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."); }
|
3
|
+
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); }
|
4
|
+
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; }
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
7
|
+
import { useState } from 'react';
|
8
|
+
import { useRequest } from 'ahooks';
|
9
|
+
import dayjs from 'dayjs';
|
10
|
+
import { getPinApi, resetPinApi } from "./serve";
|
11
|
+
export var usePin = function usePin() {
|
12
|
+
var _useState = useState(''),
|
13
|
+
_useState2 = _slicedToArray(_useState, 2),
|
14
|
+
pin = _useState2[0],
|
15
|
+
setPin = _useState2[1];
|
16
|
+
var _useState3 = useState(''),
|
17
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
18
|
+
lastUpdateTime = _useState4[0],
|
19
|
+
setLastUpdateTime = _useState4[1];
|
20
|
+
var _getPinRequest = useRequest(getPinApi, {
|
21
|
+
manual: true,
|
22
|
+
loadingDelay: 100,
|
23
|
+
onSuccess: function onSuccess(res) {
|
24
|
+
var code = res.code,
|
25
|
+
data = res.data;
|
26
|
+
if (code === 200 && data !== null && data !== void 0 && data.pin) {
|
27
|
+
setPin(data.pin);
|
28
|
+
setLastUpdateTime(getTime((data === null || data === void 0 ? void 0 : data.generated_at) || ''));
|
29
|
+
}
|
30
|
+
}
|
31
|
+
});
|
32
|
+
var getTime = function getTime(time) {
|
33
|
+
if (!time) return '';
|
34
|
+
return dayjs(time).format('YYYY-MM-DD HH:mm');
|
35
|
+
};
|
36
|
+
var _resetPinRequest = useRequest(resetPinApi, {
|
37
|
+
manual: true,
|
38
|
+
loadingDelay: 100,
|
39
|
+
onSuccess: function onSuccess(res) {
|
40
|
+
var code = res.code,
|
41
|
+
data = res.data;
|
42
|
+
if (code === 200 && data !== null && data !== void 0 && data.pin) {
|
43
|
+
setPin(data.pin);
|
44
|
+
setLastUpdateTime(getTime((data === null || data === void 0 ? void 0 : data.generated_at) || ''));
|
45
|
+
}
|
46
|
+
}
|
47
|
+
});
|
48
|
+
var getPin = function getPin(id) {
|
49
|
+
_getPinRequest.run({
|
50
|
+
wallet_detail_id: id
|
51
|
+
});
|
52
|
+
};
|
53
|
+
var resetPin = function resetPin(id) {
|
54
|
+
_resetPinRequest.run({
|
55
|
+
wallet_detail_id: id
|
56
|
+
});
|
57
|
+
};
|
58
|
+
return {
|
59
|
+
pin: pin,
|
60
|
+
lastUpdateTime: lastUpdateTime,
|
61
|
+
getPin: getPin,
|
62
|
+
resetPin: resetPin,
|
63
|
+
resetPinLoading: _resetPinRequest.loading
|
64
|
+
};
|
65
|
+
};
|
@@ -0,0 +1,98 @@
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
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 e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
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
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
6
|
+
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."); }
|
7
|
+
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); }
|
8
|
+
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; }
|
9
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
10
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
11
|
+
import React, { forwardRef, useImperativeHandle, useRef, useState } from 'react';
|
12
|
+
import { PisellModal } from '@pisell/materials';
|
13
|
+
import { locales } from '@pisell/utils';
|
14
|
+
import useEngineContext from "../../hooks/useEngineContext";
|
15
|
+
import localeTexts from "./locales";
|
16
|
+
import { usePin } from "./hooks";
|
17
|
+
import { request } from "../../utils";
|
18
|
+
import "./index.less";
|
19
|
+
var PinModal = function PinModal(props, ref) {
|
20
|
+
var _context$engine, _context$appHelper;
|
21
|
+
var context = useEngineContext();
|
22
|
+
locales.init(localeTexts, (context === null || context === void 0 || (_context$engine = context.engine) === null || _context$engine === void 0 || (_context$engine = _context$engine.props) === null || _context$engine === void 0 ? void 0 : _context$engine.locale) || 'en');
|
23
|
+
request.setRequest(context === null || context === void 0 || (_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 || (_context$appHelper = _context$appHelper.utils) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.request);
|
24
|
+
var _useState = useState(false),
|
25
|
+
_useState2 = _slicedToArray(_useState, 2),
|
26
|
+
visible = _useState2[0],
|
27
|
+
setVisible = _useState2[1];
|
28
|
+
var _usePin = usePin(),
|
29
|
+
pin = _usePin.pin,
|
30
|
+
lastUpdateTime = _usePin.lastUpdateTime,
|
31
|
+
getPin = _usePin.getPin,
|
32
|
+
resetPin = _usePin.resetPin,
|
33
|
+
resetPinLoading = _usePin.resetPinLoading;
|
34
|
+
var walletDetailIdRef = useRef();
|
35
|
+
var onOpen = function onOpen(wallet_detail_id) {
|
36
|
+
walletDetailIdRef.current = wallet_detail_id;
|
37
|
+
getPin(wallet_detail_id);
|
38
|
+
setVisible(true);
|
39
|
+
};
|
40
|
+
var onHide = function onHide() {
|
41
|
+
walletDetailIdRef.current = undefined;
|
42
|
+
setVisible(false);
|
43
|
+
};
|
44
|
+
var onResetPin = /*#__PURE__*/function () {
|
45
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
46
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
47
|
+
while (1) switch (_context.prev = _context.next) {
|
48
|
+
case 0:
|
49
|
+
if (!(!walletDetailIdRef.current || resetPinLoading)) {
|
50
|
+
_context.next = 2;
|
51
|
+
break;
|
52
|
+
}
|
53
|
+
return _context.abrupt("return");
|
54
|
+
case 2:
|
55
|
+
resetPin(walletDetailIdRef.current);
|
56
|
+
case 3:
|
57
|
+
case "end":
|
58
|
+
return _context.stop();
|
59
|
+
}
|
60
|
+
}, _callee);
|
61
|
+
}));
|
62
|
+
return function onResetPin() {
|
63
|
+
return _ref.apply(this, arguments);
|
64
|
+
};
|
65
|
+
}();
|
66
|
+
useImperativeHandle(ref, function () {
|
67
|
+
return {
|
68
|
+
open: onOpen,
|
69
|
+
hide: onHide
|
70
|
+
};
|
71
|
+
});
|
72
|
+
return /*#__PURE__*/React.createElement(PisellModal, {
|
73
|
+
title: locales.getText('pisell2.pin.modal.title'),
|
74
|
+
open: visible,
|
75
|
+
okText: locales.getText('pisell2.pin.modal.reset.pin'),
|
76
|
+
onOk: onResetPin,
|
77
|
+
cancelText: locales.getText('pisell2.pin.modal.cancel'),
|
78
|
+
onCancel: onHide,
|
79
|
+
okButtonProps: {
|
80
|
+
loading: resetPinLoading
|
81
|
+
},
|
82
|
+
destroyOnClose: true,
|
83
|
+
mobileModalHeight: "auto"
|
84
|
+
}, /*#__PURE__*/React.createElement("div", {
|
85
|
+
className: "pin-modal"
|
86
|
+
}, /*#__PURE__*/React.createElement("div", {
|
87
|
+
className: "pin-modal-content"
|
88
|
+
}, /*#__PURE__*/React.createElement("span", {
|
89
|
+
className: "pin-modal-content-label"
|
90
|
+
}, locales.getText('pisell2.pin.modal.label')), /*#__PURE__*/React.createElement("span", {
|
91
|
+
className: "pin-modal-content-code"
|
92
|
+
}, pin)), /*#__PURE__*/React.createElement("span", {
|
93
|
+
className: "pin-modal-content-desc"
|
94
|
+
}, locales.getText('pisell2.pin.modal.desc')), /*#__PURE__*/React.createElement("span", {
|
95
|
+
className: "pin-modal-content-time"
|
96
|
+
}, locales.getText('pisell2.pin.modal.time'), lastUpdateTime)));
|
97
|
+
};
|
98
|
+
export default /*#__PURE__*/forwardRef(PinModal);
|