@pisell/private-materials 3.0.197 → 3.0.199
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 +7 -7
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +10 -10
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +11 -11
- package/es/components/booking/components/customSelect/index.d.ts +0 -1
- package/es/components/booking/components/customSelect/index.js +2 -6
- package/es/components/booking/components/footer/amount.js +22 -45
- package/es/components/booking/components/footer/index.js +40 -84
- package/es/components/booking/components/footer/utils.js +32 -218
- package/es/components/booking/info/addServiceVariant/index.js +1 -8
- package/es/components/booking/info/clientVariant/vertical/SelectDrawer.d.ts +0 -1
- package/es/components/booking/info/clientVariant/vertical/SelectDrawer.js +13 -14
- package/es/components/booking/info/clientVariant/vertical/index.js +4 -33
- package/es/components/booking/info/main.js +8 -20
- package/es/components/booking/info/model.js +0 -3
- package/es/components/booking/info/pet/index.js +5 -54
- package/es/components/booking/info/service/addService/index.js +20 -127
- package/es/components/booking/info/service/addService/index.less +3 -13
- package/es/components/booking/info/service/addService/utils.d.ts +2 -11
- package/es/components/booking/info/service/addService/utils.js +24 -49
- package/es/components/booking/info/service/editService/index.js +41 -232
- package/es/components/booking/info/service/editService/index.less +13 -18
- package/es/components/booking/info/utils.d.ts +0 -9
- package/es/components/booking/info/utils.js +0 -13
- package/es/components/booking/locales.d.ts +0 -60
- package/es/components/booking/locales.js +3 -75
- package/es/components/booking/model.d.ts +1 -4
- package/es/components/booking/model.js +2 -4
- package/es/components/booking/utils.d.ts +3 -12
- package/es/components/booking/utils.js +22 -126
- package/es/components/eftpos/form/index.js +12 -6
- package/es/components/eftpos/group/index.d.ts +1 -2
- package/es/components/eftpos/group/index.js +1 -2
- package/es/components/eftpos/index.js +2 -2
- package/es/components/eftpos/receipt/index.d.ts +24 -0
- package/es/components/eftpos/receipt/index.js +96 -0
- package/es/components/eftposPay/helper.d.ts +1 -0
- package/es/components/eftposPay/helper.js +14 -0
- package/es/components/eftposPay/hooks.d.ts +1 -1
- package/es/components/eftposPay/tyro/index.js +51 -20
- package/es/index.d.ts +0 -1
- package/es/index.js +1 -2
- package/lib/components/booking/components/customSelect/index.d.ts +0 -1
- package/lib/components/booking/components/customSelect/index.js +2 -6
- package/lib/components/booking/components/footer/amount.js +8 -26
- package/lib/components/booking/components/footer/index.js +4 -25
- package/lib/components/booking/components/footer/utils.js +31 -144
- package/lib/components/booking/info/addServiceVariant/index.js +0 -5
- package/lib/components/booking/info/clientVariant/vertical/SelectDrawer.d.ts +0 -1
- package/lib/components/booking/info/clientVariant/vertical/SelectDrawer.js +7 -8
- package/lib/components/booking/info/clientVariant/vertical/index.js +10 -36
- package/lib/components/booking/info/main.js +4 -11
- package/lib/components/booking/info/model.js +0 -3
- package/lib/components/booking/info/pet/index.js +25 -61
- package/lib/components/booking/info/service/addService/index.js +28 -95
- package/lib/components/booking/info/service/addService/index.less +3 -13
- package/lib/components/booking/info/service/addService/utils.d.ts +2 -11
- package/lib/components/booking/info/service/addService/utils.js +10 -31
- package/lib/components/booking/info/service/editService/index.js +122 -271
- package/lib/components/booking/info/service/editService/index.less +13 -18
- package/lib/components/booking/info/utils.d.ts +0 -9
- package/lib/components/booking/info/utils.js +0 -6
- package/lib/components/booking/locales.d.ts +0 -60
- package/lib/components/booking/locales.js +3 -63
- package/lib/components/booking/model.d.ts +1 -4
- package/lib/components/booking/model.js +2 -4
- package/lib/components/booking/utils.d.ts +3 -12
- package/lib/components/booking/utils.js +15 -79
- package/lib/components/eftpos/form/index.js +12 -6
- package/lib/components/eftpos/group/index.d.ts +1 -2
- package/lib/components/eftpos/group/index.js +0 -1
- package/lib/components/eftpos/index.js +2 -2
- package/lib/components/eftpos/receipt/index.d.ts +24 -0
- package/lib/components/eftpos/receipt/index.js +88 -0
- package/lib/components/eftposPay/helper.d.ts +1 -0
- package/lib/components/eftposPay/helper.js +21 -0
- package/lib/components/eftposPay/hooks.d.ts +1 -1
- package/lib/components/eftposPay/tyro/index.js +36 -7
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -3
- package/package.json +3 -3
- package/es/components/booking/components/footer/AppointmentProductModal/index.d.ts +0 -3
- package/es/components/booking/components/footer/AppointmentProductModal/index.js +0 -37
- package/es/components/booking/components/footer/AppointmentProductModal/index.less +0 -0
- package/es/components/booking/info/dateRange/index.d.ts +0 -5
- package/es/components/booking/info/dateRange/index.js +0 -98
- package/es/components/booking/info/dateRange/index.less +0 -21
- package/es/components/booking/info/pet/ChangePetModal/index.d.ts +0 -4
- package/es/components/booking/info/pet/ChangePetModal/index.js +0 -118
- package/es/components/booking/info/pet/ChangePetModal/index.less +0 -4
- package/es/components/booking/info/service2/Lists.d.ts +0 -3
- package/es/components/booking/info/service2/Lists.js +0 -158
- package/es/components/booking/info/service2/hooks/useSelectPet.d.ts +0 -6
- package/es/components/booking/info/service2/hooks/useSelectPet.js +0 -54
- package/es/components/booking/info/service2/index.d.ts +0 -3
- package/es/components/booking/info/service2/index.js +0 -58
- package/es/components/booking/info/service2/status.d.ts +0 -31
- package/es/components/booking/info/service2/status.js +0 -78
- package/es/components/booking/info/service2/utils.d.ts +0 -145
- package/es/components/booking/info/service2/utils.js +0 -436
- package/es/components/booking/materiels/holder/index.d.ts +0 -7
- package/es/components/booking/materiels/holder/index.js +0 -51
- package/es/components/shoppingCart/Provider.d.ts +0 -3
- package/es/components/shoppingCart/Provider.js +0 -86
- package/es/components/shoppingCart/components/Cart/Product.d.ts +0 -4
- package/es/components/shoppingCart/components/Cart/Product.js +0 -96
- package/es/components/shoppingCart/components/Cart/index.d.ts +0 -4
- package/es/components/shoppingCart/components/Cart/index.js +0 -72
- package/es/components/shoppingCart/components/Cart/index.less +0 -68
- package/es/components/shoppingCart/components/Empty/index.d.ts +0 -4
- package/es/components/shoppingCart/components/Empty/index.js +0 -14
- package/es/components/shoppingCart/components/Empty/index.less +0 -19
- package/es/components/shoppingCart/components/Render/index.d.ts +0 -4
- package/es/components/shoppingCart/components/Render/index.js +0 -68
- package/es/components/shoppingCart/components/Render/index.less +0 -2
- package/es/components/shoppingCart/components/SelectHolderModal/index.d.ts +0 -4
- package/es/components/shoppingCart/components/SelectHolderModal/index.js +0 -124
- package/es/components/shoppingCart/components/SelectHolderModal/index.less +0 -32
- package/es/components/shoppingCart/hooks/useAddService.d.ts +0 -3
- package/es/components/shoppingCart/hooks/useAddService.js +0 -23
- package/es/components/shoppingCart/hooks/useClearCart.d.ts +0 -3
- package/es/components/shoppingCart/hooks/useClearCart.js +0 -54
- package/es/components/shoppingCart/hooks/useContext.d.ts +0 -1
- package/es/components/shoppingCart/hooks/useContext.js +0 -5
- package/es/components/shoppingCart/index.d.ts +0 -4
- package/es/components/shoppingCart/index.js +0 -24
- package/es/components/shoppingCart/locales.d.ts +0 -33
- package/es/components/shoppingCart/locales.js +0 -38
- package/es/components/shoppingCart/mock.d.ts +0 -40
- package/es/components/shoppingCart/mock.js +0 -40
- package/es/components/shoppingCart/status.d.ts +0 -2
- package/es/components/shoppingCart/status.js +0 -22
- package/es/components/shoppingCart/type.d.ts +0 -39
- package/es/components/shoppingCart/type.js +0 -1
- package/es/components/shoppingCart/utils.d.ts +0 -63
- package/es/components/shoppingCart/utils.js +0 -119
- package/lib/components/booking/components/footer/AppointmentProductModal/index.d.ts +0 -3
- package/lib/components/booking/components/footer/AppointmentProductModal/index.js +0 -59
- package/lib/components/booking/components/footer/AppointmentProductModal/index.less +0 -0
- package/lib/components/booking/info/dateRange/index.d.ts +0 -5
- package/lib/components/booking/info/dateRange/index.js +0 -111
- package/lib/components/booking/info/dateRange/index.less +0 -21
- package/lib/components/booking/info/pet/ChangePetModal/index.d.ts +0 -4
- package/lib/components/booking/info/pet/ChangePetModal/index.js +0 -110
- package/lib/components/booking/info/pet/ChangePetModal/index.less +0 -4
- package/lib/components/booking/info/service2/Lists.d.ts +0 -3
- package/lib/components/booking/info/service2/Lists.js +0 -113
- package/lib/components/booking/info/service2/hooks/useSelectPet.d.ts +0 -6
- package/lib/components/booking/info/service2/hooks/useSelectPet.js +0 -50
- package/lib/components/booking/info/service2/index.d.ts +0 -3
- package/lib/components/booking/info/service2/index.js +0 -75
- package/lib/components/booking/info/service2/status.d.ts +0 -31
- package/lib/components/booking/info/service2/status.js +0 -81
- package/lib/components/booking/info/service2/utils.d.ts +0 -145
- package/lib/components/booking/info/service2/utils.js +0 -320
- package/lib/components/booking/materiels/holder/index.d.ts +0 -7
- package/lib/components/booking/materiels/holder/index.js +0 -65
- package/lib/components/shoppingCart/Provider.d.ts +0 -3
- package/lib/components/shoppingCart/Provider.js +0 -110
- package/lib/components/shoppingCart/components/Cart/Product.d.ts +0 -4
- package/lib/components/shoppingCart/components/Cart/Product.js +0 -89
- package/lib/components/shoppingCart/components/Cart/index.d.ts +0 -4
- package/lib/components/shoppingCart/components/Cart/index.js +0 -77
- package/lib/components/shoppingCart/components/Cart/index.less +0 -68
- package/lib/components/shoppingCart/components/Empty/index.d.ts +0 -4
- package/lib/components/shoppingCart/components/Empty/index.js +0 -43
- package/lib/components/shoppingCart/components/Empty/index.less +0 -19
- package/lib/components/shoppingCart/components/Render/index.d.ts +0 -4
- package/lib/components/shoppingCart/components/Render/index.js +0 -79
- package/lib/components/shoppingCart/components/Render/index.less +0 -2
- package/lib/components/shoppingCart/components/SelectHolderModal/index.d.ts +0 -4
- package/lib/components/shoppingCart/components/SelectHolderModal/index.js +0 -116
- package/lib/components/shoppingCart/components/SelectHolderModal/index.less +0 -32
- package/lib/components/shoppingCart/hooks/useAddService.d.ts +0 -3
- package/lib/components/shoppingCart/hooks/useAddService.js +0 -55
- package/lib/components/shoppingCart/hooks/useClearCart.d.ts +0 -3
- package/lib/components/shoppingCart/hooks/useClearCart.js +0 -71
- package/lib/components/shoppingCart/hooks/useContext.d.ts +0 -1
- package/lib/components/shoppingCart/hooks/useContext.js +0 -31
- package/lib/components/shoppingCart/index.d.ts +0 -4
- package/lib/components/shoppingCart/index.js +0 -60
- package/lib/components/shoppingCart/locales.d.ts +0 -33
- package/lib/components/shoppingCart/locales.js +0 -56
- package/lib/components/shoppingCart/mock.d.ts +0 -40
- package/lib/components/shoppingCart/mock.js +0 -76
- package/lib/components/shoppingCart/status.d.ts +0 -2
- package/lib/components/shoppingCart/status.js +0 -60
- package/lib/components/shoppingCart/type.d.ts +0 -39
- package/lib/components/shoppingCart/type.js +0 -17
- package/lib/components/shoppingCart/utils.d.ts +0 -63
- package/lib/components/shoppingCart/utils.js +0 -92
- package/lowcode/shopping-cart/meta.ts +0 -98
|
@@ -1,436 +0,0 @@
|
|
|
1
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
|
-
import { getNoResource } from "../../mock";
|
|
8
|
-
import { getErrorList } from "../../utils";
|
|
9
|
-
import { locales } from "@pisell/utils";
|
|
10
|
-
import dayjs from 'dayjs';
|
|
11
|
-
import { appointmentTypes, openingTime } from "./status";
|
|
12
|
-
import localeTexts from "../../locales";
|
|
13
|
-
locales.init(localeTexts, localStorage.getItem('umi_locale') || 'en');
|
|
14
|
-
export var formatActiveKey = function formatActiveKey(lists, platform) {
|
|
15
|
-
if (!(lists !== null && lists !== void 0 && lists.length)) return [];
|
|
16
|
-
|
|
17
|
-
// 管理端默认打开最后一个holder
|
|
18
|
-
if (platform === 'shop') {
|
|
19
|
-
var _lists2;
|
|
20
|
-
return [(_lists2 = lists[lists.length - 1]) === null || _lists2 === void 0 ? void 0 : _lists2.key];
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// 其他端默认打开所有
|
|
24
|
-
return lists === null || lists === void 0 ? void 0 : lists.map(function (cart) {
|
|
25
|
-
return cart === null || cart === void 0 ? void 0 : cart.key;
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* @title: 获取资源名称
|
|
31
|
-
* @description:
|
|
32
|
-
* @param {any} id
|
|
33
|
-
* @param {any} state
|
|
34
|
-
* @return {*}
|
|
35
|
-
* @Author: WangHan
|
|
36
|
-
* @Date: 2024-11-29 18:02
|
|
37
|
-
*/
|
|
38
|
-
export var getResourceItem = function getResourceItem(id, state) {
|
|
39
|
-
var _state$service$resour;
|
|
40
|
-
if (id === 0) {
|
|
41
|
-
return getNoResource();
|
|
42
|
-
}
|
|
43
|
-
return (_state$service$resour = state.service.resources) === null || _state$service$resour === void 0 ? void 0 : _state$service$resour.find(function (d) {
|
|
44
|
-
return d.form_record_id === id;
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
|
-
var errorTypes = {
|
|
48
|
-
product: locales.getText('pisell2.text.status.service-error-1'),
|
|
49
|
-
time: locales.getText('pisell2.text.status.service-error-2'),
|
|
50
|
-
maxLimit: locales.getText('pisell2.text.status.service-error-3'),
|
|
51
|
-
limit: locales.getText('pisell2.text.status.service-error-3')
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* @title: 错误提示
|
|
56
|
-
* @description:
|
|
57
|
-
* @param {any} service
|
|
58
|
-
* @param {any} resourceItem
|
|
59
|
-
* @return {*}
|
|
60
|
-
* @Author: WangHan
|
|
61
|
-
* @Date: 2024-11-29 18:41
|
|
62
|
-
*/
|
|
63
|
-
export var getErrorMessage = function getErrorMessage(service, resourceItem, isDay) {
|
|
64
|
-
var errorList = getErrorList(resourceItem, service, isDay);
|
|
65
|
-
var errorMessage = '';
|
|
66
|
-
if (!service.id) {
|
|
67
|
-
return errorList[0].label;
|
|
68
|
-
}
|
|
69
|
-
if (errorList.length) {
|
|
70
|
-
if (errorList.length > 1) {
|
|
71
|
-
errorMessage = "".concat(errorList.length, " ").concat(locales.getText('pisell2.text.warnings'));
|
|
72
|
-
} else {
|
|
73
|
-
errorMessage = (resourceItem === null || resourceItem === void 0 ? void 0 : resourceItem.labelText) + ' ' + errorTypes[errorList[0].type];
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return errorMessage;
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* @title: 格式化主体列表
|
|
81
|
-
* @description:
|
|
82
|
-
* @param {any} lists
|
|
83
|
-
* @param {boolean} isOpenGroup
|
|
84
|
-
* @return {*}
|
|
85
|
-
* @Author: WangHan
|
|
86
|
-
* @Date: 2024-12-04 11:27
|
|
87
|
-
*/
|
|
88
|
-
export var formatHolderLists = function formatHolderLists(lists) {
|
|
89
|
-
var isOpenGroup = true;
|
|
90
|
-
var _lists = lists === null || lists === void 0 ? void 0 : lists.map(function (item) {
|
|
91
|
-
return _objectSpread(_objectSpread({}, item), {}, {
|
|
92
|
-
id: (item === null || item === void 0 ? void 0 : item.id) || (item === null || item === void 0 ? void 0 : item.form_record_id),
|
|
93
|
-
key: (item === null || item === void 0 ? void 0 : item.id) || (item === null || item === void 0 ? void 0 : item.form_record_id),
|
|
94
|
-
label: locales.getText('pisell2.text.cart.of')(item === null || item === void 0 ? void 0 : item.main_field)
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
// 开启了分组并且是管理端,则增加open items分组
|
|
99
|
-
if (isOpenGroup) {
|
|
100
|
-
var defaults = [{
|
|
101
|
-
key: 0,
|
|
102
|
-
id: 0,
|
|
103
|
-
label: locales.getText('pisell2.text.open.items'),
|
|
104
|
-
main_field: locales.getText('pisell2.text.open.items')
|
|
105
|
-
}];
|
|
106
|
-
return defaults.concat(_lists);
|
|
107
|
-
}
|
|
108
|
-
return _lists;
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* @title: pets数据加 open items
|
|
113
|
-
* @description:
|
|
114
|
-
* @param {any} state
|
|
115
|
-
* @return {*}
|
|
116
|
-
* @Author: WangHan
|
|
117
|
-
* @Date: 2024-12-03 11:40
|
|
118
|
-
*/
|
|
119
|
-
var getHolderLists = function getHolderLists(state) {
|
|
120
|
-
var _state$bookingConfig, _state$bookingConfig$, _state$bookingConfig$2, _state$bookingConfig$3, _state$pet, _state$pet$value;
|
|
121
|
-
var form_id = (state === null || state === void 0 ? void 0 : (_state$bookingConfig = state.bookingConfig) === null || _state$bookingConfig === void 0 ? void 0 : (_state$bookingConfig$ = _state$bookingConfig.config) === null || _state$bookingConfig$ === void 0 ? void 0 : (_state$bookingConfig$2 = _state$bookingConfig$.basic) === null || _state$bookingConfig$2 === void 0 ? void 0 : (_state$bookingConfig$3 = _state$bookingConfig$2.appointment_subject) === null || _state$bookingConfig$3 === void 0 ? void 0 : _state$bookingConfig$3.form_id) || 0;
|
|
122
|
-
var petLists = (state === null || state === void 0 ? void 0 : (_state$pet = state.pet) === null || _state$pet === void 0 ? void 0 : (_state$pet$value = _state$pet.value) === null || _state$pet$value === void 0 ? void 0 : _state$pet$value[form_id]) || [];
|
|
123
|
-
var _lists = formatHolderLists(petLists);
|
|
124
|
-
return _lists;
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* @title: 获取pet名称
|
|
129
|
-
* @description:
|
|
130
|
-
* @param {any} state
|
|
131
|
-
* @param {number} id
|
|
132
|
-
* @return {*}
|
|
133
|
-
* @Author: WangHan
|
|
134
|
-
* @Date: 2024-12-03 11:42
|
|
135
|
-
*/
|
|
136
|
-
var getHolderName = function getHolderName(state, id) {
|
|
137
|
-
var holderLists = getHolderLists(state);
|
|
138
|
-
if (!holderLists.length || !id) return '';
|
|
139
|
-
var resource = holderLists.find(function (d) {
|
|
140
|
-
return (d === null || d === void 0 ? void 0 : d.id) === id;
|
|
141
|
-
});
|
|
142
|
-
return resource === null || resource === void 0 ? void 0 : resource.main_field;
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* @title: 是否是预约商品
|
|
147
|
-
* @description:
|
|
148
|
-
* @return {*}
|
|
149
|
-
* @Author: WangHan
|
|
150
|
-
* @Date: 2024-12-06 11:24
|
|
151
|
-
*/
|
|
152
|
-
export var isAppointment = function isAppointment(item, state) {
|
|
153
|
-
return appointmentTypes.includes(item === null || item === void 0 ? void 0 : item.extension_type) && isDayBooking(state);
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* @title: 格式化商品数据
|
|
158
|
-
* @description:
|
|
159
|
-
* @param {any} lists
|
|
160
|
-
* @return {*}
|
|
161
|
-
* @Author: WangHan
|
|
162
|
-
* @Date: 2024-11-29 17:36
|
|
163
|
-
*/
|
|
164
|
-
export var formatProducts = function formatProducts(lists, state) {
|
|
165
|
-
if (!(lists !== null && lists !== void 0 && lists.length)) return [];
|
|
166
|
-
try {
|
|
167
|
-
return lists.map(function (item) {
|
|
168
|
-
var _item$_extend, _item$_extend3, _item$_extend3$other, _item$_extend4, _item$_extend4$other, _resourceItem, _item$_extend5;
|
|
169
|
-
var _isAppointment = isAppointment(item, state);
|
|
170
|
-
var clientTitle = getHolderName(state, item === null || item === void 0 ? void 0 : (_item$_extend = item._extend) === null || _item$_extend === void 0 ? void 0 : _item$_extend.holder_id);
|
|
171
|
-
var resourceItem = {};
|
|
172
|
-
var errorMessage = '';
|
|
173
|
-
if (_isAppointment) {
|
|
174
|
-
var _item$_extend2;
|
|
175
|
-
resourceItem = getResourceItem(item === null || item === void 0 ? void 0 : (_item$_extend2 = item._extend) === null || _item$_extend2 === void 0 ? void 0 : _item$_extend2.resource, state);
|
|
176
|
-
errorMessage = getErrorMessage(item, resourceItem, isDayBooking(state));
|
|
177
|
-
}
|
|
178
|
-
return _objectSpread(_objectSpread({}, item), {}, {
|
|
179
|
-
note: (item === null || item === void 0 ? void 0 : item.note) || '',
|
|
180
|
-
locale: state.locale,
|
|
181
|
-
symbol: state.amountSymbol,
|
|
182
|
-
total: item === null || item === void 0 ? void 0 : item._extend.total,
|
|
183
|
-
price: item === null || item === void 0 ? void 0 : item._extend.price,
|
|
184
|
-
origin_total: item === null || item === void 0 ? void 0 : item._extend.origin_total,
|
|
185
|
-
num: item === null || item === void 0 ? void 0 : item._extend.quantity,
|
|
186
|
-
bundle: item === null || item === void 0 ? void 0 : (_item$_extend3 = item._extend) === null || _item$_extend3 === void 0 ? void 0 : (_item$_extend3$other = _item$_extend3.other) === null || _item$_extend3$other === void 0 ? void 0 : _item$_extend3$other.bundle,
|
|
187
|
-
options: item === null || item === void 0 ? void 0 : (_item$_extend4 = item._extend) === null || _item$_extend4 === void 0 ? void 0 : (_item$_extend4$other = _item$_extend4.other) === null || _item$_extend4$other === void 0 ? void 0 : _item$_extend4$other.option,
|
|
188
|
-
_showAction: false,
|
|
189
|
-
_actionText: locales.getText("page.booking.text.add-time"),
|
|
190
|
-
_errorMessage: errorMessage,
|
|
191
|
-
_extend: _objectSpread(_objectSpread({}, (item === null || item === void 0 ? void 0 : item._extend) || {}), {}, {
|
|
192
|
-
date: !_isAppointment ? null : state === null || state === void 0 ? void 0 : state.date,
|
|
193
|
-
relation_form_name: !_isAppointment ? '' : ((_resourceItem = resourceItem) === null || _resourceItem === void 0 ? void 0 : _resourceItem.labelText) || item.relation_form_name,
|
|
194
|
-
holder_title: clientTitle,
|
|
195
|
-
resource: !_isAppointment ? null : item === null || item === void 0 ? void 0 : (_item$_extend5 = item._extend) === null || _item$_extend5 === void 0 ? void 0 : _item$_extend5.resource,
|
|
196
|
-
relation_details: []
|
|
197
|
-
})
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
} catch (error) {}
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* @title: 禁用日期
|
|
205
|
-
* @description:
|
|
206
|
-
* @param {any} current
|
|
207
|
-
* @param {string} position
|
|
208
|
-
* @param {any} startDate
|
|
209
|
-
* @return {*}
|
|
210
|
-
* @Author: WangHan
|
|
211
|
-
* @Date: 2024-12-03 17:51
|
|
212
|
-
*/
|
|
213
|
-
export var disabledDate = function disabledDate(current, position, currentDate) {
|
|
214
|
-
if (!dayjs(currentDate).isValid()) return;
|
|
215
|
-
if (position === 'start') {
|
|
216
|
-
return false;
|
|
217
|
-
}
|
|
218
|
-
if (position === 'end' && current.endOf('day') && currentDate) {
|
|
219
|
-
console.log(currentDate, current, position, 'currentDate');
|
|
220
|
-
|
|
221
|
-
// 结束日期最大 = 开始日期 + 8个月
|
|
222
|
-
var endDisabled = currentDate.add(8, 'months').format('YYYY-MM-DD');
|
|
223
|
-
return dayjs(endDisabled) < current.startOf('day') || current.startOf('day') <= currentDate;
|
|
224
|
-
}
|
|
225
|
-
return current && current <= currentDate;
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* @title: 是否是跨日预约
|
|
230
|
-
* @description:
|
|
231
|
-
* @param {any} state
|
|
232
|
-
* @return {*}
|
|
233
|
-
* @Author: WangHan
|
|
234
|
-
* @Date: 2024-12-04 09:49
|
|
235
|
-
*/
|
|
236
|
-
export var isDayBooking = function isDayBooking(state) {
|
|
237
|
-
return (state === null || state === void 0 ? void 0 : state.renderType) === 'dayBooking';
|
|
238
|
-
};
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* @title: 是否是terminal上的跨日预约
|
|
242
|
-
* @description:
|
|
243
|
-
* @param {any} state
|
|
244
|
-
* @return {*}
|
|
245
|
-
* @Author: WangHan
|
|
246
|
-
* @Date: 2024-12-04 15:31
|
|
247
|
-
*/
|
|
248
|
-
export var isTerminalDayBooking = function isTerminalDayBooking(state) {
|
|
249
|
-
return state.isTerminalDayBookingPage;
|
|
250
|
-
};
|
|
251
|
-
export var formatDayDate = function formatDayDate(_extend) {
|
|
252
|
-
// 默认选择的日期
|
|
253
|
-
var startDate = dayjs(_extend === null || _extend === void 0 ? void 0 : _extend.start_date).startOf('day');
|
|
254
|
-
var endDate = dayjs(_extend === null || _extend === void 0 ? void 0 : _extend.end_date).startOf('day');
|
|
255
|
-
return _objectSpread(_objectSpread({}, _extend), {}, {
|
|
256
|
-
start_date: startDate,
|
|
257
|
-
end_date: endDate
|
|
258
|
-
});
|
|
259
|
-
};
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
* @title: 根据营业日时间格式化时间
|
|
263
|
-
* @description:
|
|
264
|
-
* @param {any} state
|
|
265
|
-
* @return {*}
|
|
266
|
-
* @Author: WangHan
|
|
267
|
-
* @Date: 2024-12-04 12:07
|
|
268
|
-
*/
|
|
269
|
-
export var formatDayTime = function formatDayTime(_ref) {
|
|
270
|
-
var startDate = _ref.startDate,
|
|
271
|
-
endDate = _ref.endDate;
|
|
272
|
-
// 营业日时间
|
|
273
|
-
var shopOpeningTime = localStorage.getItem('shopOpeningHours') || '00:00';
|
|
274
|
-
|
|
275
|
-
// 默认选择的日期
|
|
276
|
-
var start_date = dayjs(startDate).format('YYYY-MM-DD');
|
|
277
|
-
var end_date = dayjs(endDate).format('YYYY-MM-DD');
|
|
278
|
-
|
|
279
|
-
// 更新后的日期
|
|
280
|
-
var result = {
|
|
281
|
-
startDateTime: dayjs("".concat(start_date, "T").concat(shopOpeningTime, ":00")),
|
|
282
|
-
// 结束日期根据营业日时间减去一分钟
|
|
283
|
-
endDateTime: dayjs("".concat(end_date, "T").concat(shopOpeningTime, ":00")).subtract(1, 'minute')
|
|
284
|
-
};
|
|
285
|
-
return result;
|
|
286
|
-
};
|
|
287
|
-
export var formatDateTime = function formatDateTime(start_date, end_date) {
|
|
288
|
-
var _openingTime = openingTime();
|
|
289
|
-
|
|
290
|
-
// 开始时间 + 营业日时间
|
|
291
|
-
var startDate = "".concat(start_date, " ").concat(_openingTime);
|
|
292
|
-
var endDate = "".concat(end_date, " ").concat(_openingTime);
|
|
293
|
-
var date = {
|
|
294
|
-
value: dayjs(startDate),
|
|
295
|
-
end_date: dayjs(endDate).subtract(1, 'minute')
|
|
296
|
-
};
|
|
297
|
-
return date;
|
|
298
|
-
};
|
|
299
|
-
|
|
300
|
-
/**
|
|
301
|
-
* @title: 初始化日期
|
|
302
|
-
* @description:
|
|
303
|
-
* @return {*}
|
|
304
|
-
* @Author: WangHan
|
|
305
|
-
* @Date: 2024-12-06 17:24
|
|
306
|
-
*/
|
|
307
|
-
export var initDate = function initDate() {
|
|
308
|
-
var startDate = dayjs().format('YYYY-MM-DD');
|
|
309
|
-
var endDate = dayjs().add(1, 'days').format('YYYY-MM-DD');
|
|
310
|
-
var date = formatDateTime(startDate, endDate);
|
|
311
|
-
return date;
|
|
312
|
-
};
|
|
313
|
-
|
|
314
|
-
/**
|
|
315
|
-
* @title: 是否有预约商品
|
|
316
|
-
* @description:
|
|
317
|
-
* @return {*}
|
|
318
|
-
* @Author: WangHan
|
|
319
|
-
* @Date: 2024-12-12 15:47
|
|
320
|
-
*/
|
|
321
|
-
export var isHasDayAppointmentProduct = function isHasDayAppointmentProduct(state) {
|
|
322
|
-
var _state$bookingConfig2, _state$bookingConfig3, _state$bookingConfig4, _state$bookingConfig5, _state$service, _state$pet2, _state$pet2$value;
|
|
323
|
-
var form_id = (state === null || state === void 0 ? void 0 : (_state$bookingConfig2 = state.bookingConfig) === null || _state$bookingConfig2 === void 0 ? void 0 : (_state$bookingConfig3 = _state$bookingConfig2.config) === null || _state$bookingConfig3 === void 0 ? void 0 : (_state$bookingConfig4 = _state$bookingConfig3.basic) === null || _state$bookingConfig4 === void 0 ? void 0 : (_state$bookingConfig5 = _state$bookingConfig4.appointment_subject) === null || _state$bookingConfig5 === void 0 ? void 0 : _state$bookingConfig5.form_id) || 0;
|
|
324
|
-
var services = ((_state$service = state.service) === null || _state$service === void 0 ? void 0 : _state$service.value) || [];
|
|
325
|
-
var pets = ((_state$pet2 = state.pet) === null || _state$pet2 === void 0 ? void 0 : (_state$pet2$value = _state$pet2.value) === null || _state$pet2$value === void 0 ? void 0 : _state$pet2$value[form_id]) || [];
|
|
326
|
-
|
|
327
|
-
// 没有任何一个预约商品则提示
|
|
328
|
-
var appointmentServices = services.filter(function (d) {
|
|
329
|
-
return appointmentTypes.includes(d.extension_type);
|
|
330
|
-
});
|
|
331
|
-
if (!appointmentServices.length) return true;
|
|
332
|
-
var _pets = pets === null || pets === void 0 ? void 0 : pets.map(function (d) {
|
|
333
|
-
var holderProducts = services.filter(function (d) {
|
|
334
|
-
var _d$_extend;
|
|
335
|
-
return ((_d$_extend = d._extend) === null || _d$_extend === void 0 ? void 0 : _d$_extend.holder_id) == d.form_record_id;
|
|
336
|
-
});
|
|
337
|
-
return _objectSpread(_objectSpread({}, d), {}, {
|
|
338
|
-
// 如果该购物车中没选择任何商品,则不需要验证,所以直接用1来填充
|
|
339
|
-
// services: !holderProducts?.length ? [1] : holderProducts?.filter((d: any) => appointmentTypes.includes(d.extension_type))
|
|
340
|
-
services: services.filter(function (item) {
|
|
341
|
-
var _item$_extend6;
|
|
342
|
-
return ((_item$_extend6 = item._extend) === null || _item$_extend6 === void 0 ? void 0 : _item$_extend6.holder_id) == d.form_record_id && appointmentTypes.includes(item.extension_type);
|
|
343
|
-
})
|
|
344
|
-
});
|
|
345
|
-
});
|
|
346
|
-
_pets = _pets.filter(function (d) {
|
|
347
|
-
return !d.services.length;
|
|
348
|
-
});
|
|
349
|
-
return _pets.length > 0;
|
|
350
|
-
};
|
|
351
|
-
|
|
352
|
-
/**
|
|
353
|
-
* @title: 过滤出如果是预约商品,则只获取跨日的预约商品
|
|
354
|
-
* @description:
|
|
355
|
-
* @param {any} lists
|
|
356
|
-
* @return {*}
|
|
357
|
-
* @Author: WangHan
|
|
358
|
-
* @Date: 2024-12-13 16:44
|
|
359
|
-
*/
|
|
360
|
-
export var getDayProducts = function getDayProducts(holderId, lists, isTerminal) {
|
|
361
|
-
var _lists = lists || [];
|
|
362
|
-
|
|
363
|
-
// 普通商品列表, terminal进入页面直接获取了商品列表数据,所以选择了表单之后不会再次触发该方法
|
|
364
|
-
if (!holderId && !isTerminal) {
|
|
365
|
-
_lists = _lists.filter(function (item) {
|
|
366
|
-
return !appointmentTypes.includes(item === null || item === void 0 ? void 0 : item.extension_type);
|
|
367
|
-
});
|
|
368
|
-
} else {
|
|
369
|
-
// 普通商品 + 跨日预约商品列表
|
|
370
|
-
_lists = _lists.filter(function (item) {
|
|
371
|
-
var _item$duration;
|
|
372
|
-
return !appointmentTypes.includes(item === null || item === void 0 ? void 0 : item.extension_type) || appointmentTypes.includes(item === null || item === void 0 ? void 0 : item.extension_type) && ((_item$duration = item.duration) === null || _item$duration === void 0 ? void 0 : _item$duration.type) === 'days';
|
|
373
|
-
});
|
|
374
|
-
}
|
|
375
|
-
return _lists;
|
|
376
|
-
};
|
|
377
|
-
|
|
378
|
-
/**
|
|
379
|
-
* @title: 判断是否打开删除宠物弹窗
|
|
380
|
-
* @description:
|
|
381
|
-
* @param {any} state
|
|
382
|
-
* @param {any} newVal
|
|
383
|
-
* @return {*}
|
|
384
|
-
* @Author: WangHan
|
|
385
|
-
* @Date: 2024-12-16 16:12
|
|
386
|
-
*/
|
|
387
|
-
export var isOpenDeletePet = function isOpenDeletePet(state, newVal) {
|
|
388
|
-
var _state$bookingConfig6, _state$bookingConfig7, _state$bookingConfig8, _state$bookingConfig9, _state$pet3, _state$pet3$value, _state$service3;
|
|
389
|
-
var form_id = (state === null || state === void 0 ? void 0 : (_state$bookingConfig6 = state.bookingConfig) === null || _state$bookingConfig6 === void 0 ? void 0 : (_state$bookingConfig7 = _state$bookingConfig6.config) === null || _state$bookingConfig7 === void 0 ? void 0 : (_state$bookingConfig8 = _state$bookingConfig7.basic) === null || _state$bookingConfig8 === void 0 ? void 0 : (_state$bookingConfig9 = _state$bookingConfig8.appointment_subject) === null || _state$bookingConfig9 === void 0 ? void 0 : _state$bookingConfig9.form_id) || 0;
|
|
390
|
-
var oldPets = (state === null || state === void 0 ? void 0 : (_state$pet3 = state.pet) === null || _state$pet3 === void 0 ? void 0 : (_state$pet3$value = _state$pet3.value) === null || _state$pet3$value === void 0 ? void 0 : _state$pet3$value[form_id]) || [];
|
|
391
|
-
var newPets = (newVal === null || newVal === void 0 ? void 0 : newVal[form_id]) || [];
|
|
392
|
-
|
|
393
|
-
// 被删除的表单
|
|
394
|
-
var deletePets = oldPets.filter(function (item) {
|
|
395
|
-
return !newPets.some(function (newItem) {
|
|
396
|
-
return newItem.form_record_id === item.form_record_id;
|
|
397
|
-
});
|
|
398
|
-
});
|
|
399
|
-
|
|
400
|
-
// 被删除的表单中是否有预约商品
|
|
401
|
-
var servicePets = deletePets.map(function (item) {
|
|
402
|
-
var _state$service2, _state$service2$value;
|
|
403
|
-
return _objectSpread(_objectSpread({}, item), {}, {
|
|
404
|
-
services: (_state$service2 = state.service) === null || _state$service2 === void 0 ? void 0 : (_state$service2$value = _state$service2.value) === null || _state$service2$value === void 0 ? void 0 : _state$service2$value.filter(function (d) {
|
|
405
|
-
var _d$_extend2;
|
|
406
|
-
return ((_d$_extend2 = d._extend) === null || _d$_extend2 === void 0 ? void 0 : _d$_extend2.holder_id) == item.form_record_id;
|
|
407
|
-
})
|
|
408
|
-
});
|
|
409
|
-
});
|
|
410
|
-
|
|
411
|
-
// 查找被删除的表单中是否有对应的商品数据
|
|
412
|
-
var lists = servicePets.filter(function (item) {
|
|
413
|
-
var _item$services;
|
|
414
|
-
return ((_item$services = item.services) === null || _item$services === void 0 ? void 0 : _item$services.length) > 0;
|
|
415
|
-
});
|
|
416
|
-
console.log(deletePets, (_state$service3 = state.service) === null || _state$service3 === void 0 ? void 0 : _state$service3.value, lists, 'wh98888888');
|
|
417
|
-
return {
|
|
418
|
-
ids: lists.map(function (item) {
|
|
419
|
-
return item.form_record_id;
|
|
420
|
-
}),
|
|
421
|
-
lists: lists
|
|
422
|
-
};
|
|
423
|
-
};
|
|
424
|
-
|
|
425
|
-
/**
|
|
426
|
-
* @title: 当前选中的表单id
|
|
427
|
-
* @description:
|
|
428
|
-
* @param {any} state
|
|
429
|
-
* @return {*}
|
|
430
|
-
* @Author: WangHan
|
|
431
|
-
* @Date: 2024-12-17 14:40
|
|
432
|
-
*/
|
|
433
|
-
export var holderId = function holderId(state) {
|
|
434
|
-
var _state$activeCartId;
|
|
435
|
-
return Number((state === null || state === void 0 ? void 0 : (_state$activeCartId = state.activeCartId) === null || _state$activeCartId === void 0 ? void 0 : _state$activeCartId[0]) || 0);
|
|
436
|
-
};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
var _excluded = ["selectProps"];
|
|
2
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
3
|
-
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; }
|
|
4
|
-
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; }
|
|
5
|
-
import { Select } from 'antd';
|
|
6
|
-
import { Context } from "../../info/model";
|
|
7
|
-
import React, { useCallback, useMemo, useContext } from 'react';
|
|
8
|
-
import useSelectPet from "../../info/service2/hooks/useSelectPet";
|
|
9
|
-
var Holder = function Holder(props) {
|
|
10
|
-
var _state$pet;
|
|
11
|
-
var selectProps = props.selectProps,
|
|
12
|
-
resetProps = _objectWithoutProperties(props, _excluded);
|
|
13
|
-
var _useContext = useContext(Context),
|
|
14
|
-
state = _useContext.state;
|
|
15
|
-
var _useSelectPet = useSelectPet(state),
|
|
16
|
-
holderLists = _useSelectPet.holderLists;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @title: holders数据
|
|
20
|
-
* @description:
|
|
21
|
-
* @param {*} useMemo
|
|
22
|
-
* @return {*}
|
|
23
|
-
* @Author: WangHan
|
|
24
|
-
* @Date: 2024-12-02 22:30
|
|
25
|
-
*/
|
|
26
|
-
var holders = useMemo(function () {
|
|
27
|
-
var lists = holderLists === null || holderLists === void 0 ? void 0 : holderLists.filter(function (d) {
|
|
28
|
-
return (d === null || d === void 0 ? void 0 : d.id) > 0;
|
|
29
|
-
});
|
|
30
|
-
if (!(lists !== null && lists !== void 0 && lists.length)) return [];
|
|
31
|
-
return lists.map(function (d) {
|
|
32
|
-
return {
|
|
33
|
-
value: d === null || d === void 0 ? void 0 : d.id,
|
|
34
|
-
label: d === null || d === void 0 ? void 0 : d.main_field
|
|
35
|
-
};
|
|
36
|
-
});
|
|
37
|
-
}, [state === null || state === void 0 ? void 0 : (_state$pet = state.pet) === null || _state$pet === void 0 ? void 0 : _state$pet.value]);
|
|
38
|
-
var renderOptions = useCallback(function (array) {
|
|
39
|
-
var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'value';
|
|
40
|
-
var label = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'label';
|
|
41
|
-
return array.map(function (d) {
|
|
42
|
-
return /*#__PURE__*/React.createElement(Select.Option, {
|
|
43
|
-
value: d[value],
|
|
44
|
-
key: d[value],
|
|
45
|
-
disabled: d.disabled
|
|
46
|
-
}, d[label]);
|
|
47
|
-
});
|
|
48
|
-
}, []);
|
|
49
|
-
return /*#__PURE__*/React.createElement(Select, _extends({}, selectProps, resetProps), renderOptions(holders));
|
|
50
|
-
};
|
|
51
|
-
export default Holder;
|
|
@@ -1,86 +0,0 @@
|
|
|
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 _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
3
|
-
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."); }
|
|
4
|
-
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); }
|
|
5
|
-
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; }
|
|
6
|
-
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
7
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
8
|
-
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; }
|
|
9
|
-
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; }
|
|
10
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
12
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
13
|
-
import React, { useState, createContext, useEffect } from 'react';
|
|
14
|
-
import { defaultData } from "./status";
|
|
15
|
-
import { formatState } from "./utils";
|
|
16
|
-
export var CartContext = /*#__PURE__*/createContext({});
|
|
17
|
-
export var CartProvider = function CartProvider(_ref) {
|
|
18
|
-
var children = _ref.children,
|
|
19
|
-
props = _ref.props,
|
|
20
|
-
onCard = _ref.onCard,
|
|
21
|
-
onChange = _ref.onChange,
|
|
22
|
-
onAddProduct = _ref.onAddProduct,
|
|
23
|
-
onActiveKey = _ref.onActiveKey;
|
|
24
|
-
var defaultState = _objectSpread(_objectSpread({}, defaultData), props);
|
|
25
|
-
var _useState = useState(defaultState),
|
|
26
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
27
|
-
state = _useState2[0],
|
|
28
|
-
setState = _useState2[1];
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* @title: 更新数据
|
|
32
|
-
* @description:
|
|
33
|
-
* @param {any} newState
|
|
34
|
-
* @return {*}
|
|
35
|
-
* @Author: WangHan
|
|
36
|
-
* @Date: 2024-11-28 14:44
|
|
37
|
-
*/
|
|
38
|
-
var updateState = function updateState(newState) {
|
|
39
|
-
console.log(newState, 'wh_new');
|
|
40
|
-
setState(function (prevState) {
|
|
41
|
-
return _objectSpread(_objectSpread({}, prevState), newState);
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* @title: 更新配置
|
|
47
|
-
* @description:
|
|
48
|
-
* @return {*}
|
|
49
|
-
* @Author: WangHan
|
|
50
|
-
* @Date: 2024-11-28 18:40
|
|
51
|
-
*/
|
|
52
|
-
useEffect(function () {
|
|
53
|
-
// 对象中是否存在开启分组参数,没有则默认true
|
|
54
|
-
var _isOpenGroup = props === null || props === void 0 ? void 0 : props.hasOwnProperty('isOpenGroup');
|
|
55
|
-
var newState = {};
|
|
56
|
-
if (props !== null && props !== void 0 && props.platform) {
|
|
57
|
-
newState['platform'] = props === null || props === void 0 ? void 0 : props.platform;
|
|
58
|
-
}
|
|
59
|
-
if (_isOpenGroup) {
|
|
60
|
-
newState['isOpenGroup'] = props === null || props === void 0 ? void 0 : props.isOpenGroup;
|
|
61
|
-
}
|
|
62
|
-
if (props !== null && props !== void 0 && props.emptyText) {
|
|
63
|
-
newState['emptyText'] = props === null || props === void 0 ? void 0 : props.emptyText;
|
|
64
|
-
}
|
|
65
|
-
if (props !== null && props !== void 0 && props.productParams) {
|
|
66
|
-
newState = _objectSpread(_objectSpread({}, newState), props === null || props === void 0 ? void 0 : props.productParams);
|
|
67
|
-
}
|
|
68
|
-
if (props !== null && props !== void 0 && props.collapseParams) {
|
|
69
|
-
newState['collapseParams'] = props === null || props === void 0 ? void 0 : props.collapseParams;
|
|
70
|
-
}
|
|
71
|
-
var params = _objectSpread(_objectSpread({}, defaultState), newState);
|
|
72
|
-
var result = _objectSpread(_objectSpread({}, params), formatState(params));
|
|
73
|
-
console.log(result, params, 'result');
|
|
74
|
-
setState(result);
|
|
75
|
-
}, [props === null || props === void 0 ? void 0 : props.platform, props === null || props === void 0 ? void 0 : props.isOpenGroup, props === null || props === void 0 ? void 0 : props.emptyText, props === null || props === void 0 ? void 0 : props.productParams, props === null || props === void 0 ? void 0 : props.collapseParams]);
|
|
76
|
-
return /*#__PURE__*/React.createElement(CartContext.Provider, {
|
|
77
|
-
value: {
|
|
78
|
-
state: state,
|
|
79
|
-
updateState: updateState,
|
|
80
|
-
onCard: onCard,
|
|
81
|
-
onChange: onChange,
|
|
82
|
-
onAddProduct: onAddProduct,
|
|
83
|
-
onActiveKey: onActiveKey
|
|
84
|
-
}
|
|
85
|
-
}, children);
|
|
86
|
-
};
|