@pisell/private-materials 6.3.100 → 6.3.102

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/build/lowcode/assets-daily.json +11 -11
  2. package/build/lowcode/assets-dev.json +2 -2
  3. package/build/lowcode/assets-prod.json +11 -11
  4. package/build/lowcode/index.js +1 -1
  5. package/build/lowcode/meta.js +1 -1
  6. package/build/lowcode/preview.js +8 -8
  7. package/build/lowcode/render/default/view.css +1 -1
  8. package/build/lowcode/render/default/view.js +9 -9
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +10 -10
  11. package/es/components/booking/info/header/index.js +7 -7
  12. package/es/components/booking/info/header/index.less +5 -5
  13. package/es/components/ecocup/components/AddCustomerModal/index.js +3 -3
  14. package/es/components/ecocup/components/CupInfoCard/index.d.ts +3 -1
  15. package/es/components/ecocup/components/CupInfoCard/index.js +4 -2
  16. package/es/components/ecocup/components/CupStatusModal/hooks.d.ts +32 -1
  17. package/es/components/ecocup/components/CupStatusModal/hooks.js +109 -1
  18. package/es/components/ecocup/components/CupStatusModal/index.js +164 -30
  19. package/es/components/ecocup/components/CupStatusModal/index.less +48 -10
  20. package/es/components/ecocup/components/CustomerAndCupModal/index.js +1 -1
  21. package/es/components/ecocup/components/CustomerCard/index.d.ts +3 -1
  22. package/es/components/ecocup/components/CustomerCard/index.js +9 -6
  23. package/es/components/ecocup/components/PageHeader/index.d.ts +2 -0
  24. package/es/components/ecocup/components/PageHeader/index.js +15 -5
  25. package/es/components/ecocup/components/PageHeader/index.less +16 -4
  26. package/es/components/ecocup/components/SearchBar/index.d.ts +1 -0
  27. package/es/components/ecocup/components/SearchBar/index.js +33 -3
  28. package/es/components/ecocup/components/SettingModal/const.d.ts +6 -0
  29. package/es/components/ecocup/components/SettingModal/const.js +17 -0
  30. package/es/components/ecocup/components/SettingModal/index.d.ts +9 -0
  31. package/es/components/ecocup/components/SettingModal/index.js +253 -0
  32. package/es/components/ecocup/components/SettingModal/index.less +9 -0
  33. package/es/components/ecocup/cupList/const.d.ts +8 -1
  34. package/es/components/ecocup/cupList/const.js +14 -1
  35. package/es/components/ecocup/cupList/hooks/index.d.ts +2 -2
  36. package/es/components/ecocup/cupList/hooks/index.js +2 -2
  37. package/es/components/ecocup/cupList/hooks/useColumns.d.ts +2 -1
  38. package/es/components/ecocup/cupList/hooks/useColumns.js +4 -6
  39. package/es/components/ecocup/cupList/hooks/useCupApi.d.ts +12 -3
  40. package/es/components/ecocup/cupList/hooks/useCupApi.js +148 -8
  41. package/es/components/ecocup/cupList/hooks/useSummary.js +9 -7
  42. package/es/components/ecocup/cupList/index.js +60 -12
  43. package/es/components/ecocup/cupList/index.less +62 -16
  44. package/es/components/ecocup/cupProject/const.js +8 -2
  45. package/es/components/ecocup/cupProject/index.js +10 -1
  46. package/es/components/ecocup/hooks.d.ts +8 -0
  47. package/es/components/ecocup/hooks.js +29 -12
  48. package/es/components/ecocup/locales.d.ts +93 -3
  49. package/es/components/ecocup/locales.js +124 -25
  50. package/es/components/ecocup/utils/download.d.ts +7 -0
  51. package/es/components/ecocup/utils/download.js +34 -0
  52. package/es/components/ecocup/utils/index.d.ts +2 -0
  53. package/es/components/ecocup/utils/index.js +2 -0
  54. package/es/hooks/useLocale.js +8 -1
  55. package/es/pro/Cards/components/SKUCard/index.d.ts +0 -1
  56. package/es/pro/Cards/components/SKUCard/index.js +0 -1
  57. package/es/pro/Cards/components/SKUCard/types.d.ts +2 -2
  58. package/es/pro/Login2.0/Login2.js +8 -8
  59. package/es/pro/Login2.0/locales.d.ts +5 -0
  60. package/es/pro/Login2.0/locales.js +5 -0
  61. package/es/pro/comprehensiveSearch/components/searchSection/index.js +3 -2
  62. package/lib/components/booking/info/header/index.js +7 -7
  63. package/lib/components/booking/info/header/index.less +5 -5
  64. package/lib/components/ecocup/components/AddCustomerModal/index.js +2 -2
  65. package/lib/components/ecocup/components/CupInfoCard/index.d.ts +3 -1
  66. package/lib/components/ecocup/components/CupInfoCard/index.js +2 -2
  67. package/lib/components/ecocup/components/CupStatusModal/hooks.d.ts +32 -1
  68. package/lib/components/ecocup/components/CupStatusModal/hooks.js +62 -2
  69. package/lib/components/ecocup/components/CupStatusModal/index.js +103 -22
  70. package/lib/components/ecocup/components/CupStatusModal/index.less +48 -10
  71. package/lib/components/ecocup/components/CustomerAndCupModal/index.js +1 -1
  72. package/lib/components/ecocup/components/CustomerCard/index.d.ts +3 -1
  73. package/lib/components/ecocup/components/CustomerCard/index.js +13 -3
  74. package/lib/components/ecocup/components/PageHeader/index.d.ts +2 -0
  75. package/lib/components/ecocup/components/PageHeader/index.js +10 -3
  76. package/lib/components/ecocup/components/PageHeader/index.less +16 -4
  77. package/lib/components/ecocup/components/SearchBar/index.d.ts +1 -0
  78. package/lib/components/ecocup/components/SearchBar/index.js +15 -2
  79. package/lib/components/ecocup/components/SettingModal/const.d.ts +6 -0
  80. package/lib/components/ecocup/components/SettingModal/const.js +48 -0
  81. package/lib/components/ecocup/components/SettingModal/index.d.ts +9 -0
  82. package/lib/components/ecocup/components/SettingModal/index.js +199 -0
  83. package/lib/components/ecocup/components/SettingModal/index.less +9 -0
  84. package/lib/components/ecocup/cupList/const.d.ts +8 -1
  85. package/lib/components/ecocup/cupList/const.js +18 -0
  86. package/lib/components/ecocup/cupList/hooks/index.d.ts +2 -2
  87. package/lib/components/ecocup/cupList/hooks/index.js +4 -0
  88. package/lib/components/ecocup/cupList/hooks/useColumns.d.ts +2 -1
  89. package/lib/components/ecocup/cupList/hooks/useColumns.js +2 -4
  90. package/lib/components/ecocup/cupList/hooks/useCupApi.d.ts +12 -3
  91. package/lib/components/ecocup/cupList/hooks/useCupApi.js +123 -8
  92. package/lib/components/ecocup/cupList/hooks/useSummary.js +22 -14
  93. package/lib/components/ecocup/cupList/index.js +70 -16
  94. package/lib/components/ecocup/cupList/index.less +62 -16
  95. package/lib/components/ecocup/cupProject/const.js +8 -1
  96. package/lib/components/ecocup/cupProject/index.js +10 -1
  97. package/lib/components/ecocup/hooks.d.ts +8 -0
  98. package/lib/components/ecocup/hooks.js +18 -4
  99. package/lib/components/ecocup/locales.d.ts +93 -3
  100. package/lib/components/ecocup/locales.js +118 -25
  101. package/lib/components/ecocup/utils/download.d.ts +7 -0
  102. package/lib/components/ecocup/utils/download.js +47 -0
  103. package/lib/components/ecocup/utils/index.d.ts +2 -0
  104. package/lib/components/ecocup/utils/index.js +42 -0
  105. package/lib/hooks/useLocale.js +7 -2
  106. package/lib/pro/Cards/components/SKUCard/index.d.ts +0 -1
  107. package/lib/pro/Cards/components/SKUCard/index.js +0 -1
  108. package/lib/pro/Cards/components/SKUCard/types.d.ts +2 -2
  109. package/lib/pro/Login2.0/Login2.js +8 -8
  110. package/lib/pro/Login2.0/locales.d.ts +5 -0
  111. package/lib/pro/Login2.0/locales.js +5 -0
  112. package/lib/pro/comprehensiveSearch/components/searchSection/index.js +3 -2
  113. package/lowcode/eco-cup-list/meta.ts +1 -1
  114. package/lowcode/eco-customer-list/meta.ts +1 -1
  115. package/package.json +3 -3
@@ -0,0 +1,199 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/components/ecocup/components/SettingModal/index.tsx
30
+ var SettingModal_exports = {};
31
+ __export(SettingModal_exports, {
32
+ default: () => SettingModal_default
33
+ });
34
+ module.exports = __toCommonJS(SettingModal_exports);
35
+ var import_react = __toESM(require("react"));
36
+ var import_materials = require("@pisell/materials");
37
+ var import_utils = require("@pisell/utils");
38
+ var import_antd = require("antd");
39
+ var import_index = require("./index.less");
40
+ var import_hooks = require("../../hooks");
41
+ var import_const = require("./const");
42
+ var SettingModal = (props) => {
43
+ const { visible, onCancel } = props;
44
+ const [form] = import_antd.Form.useForm();
45
+ const { post, get } = (0, import_hooks.useRequest)();
46
+ const [loading, setLoading] = (0, import_react.useState)(false);
47
+ const _onCancel = () => {
48
+ if (loading) return;
49
+ onCancel == null ? void 0 : onCancel();
50
+ form.resetFields();
51
+ };
52
+ const _onOk = async () => {
53
+ if (loading) return;
54
+ try {
55
+ const values = await form.validateFields();
56
+ const result = await postSetting(values);
57
+ if (!result) {
58
+ return;
59
+ }
60
+ _onCancel();
61
+ } catch (error) {
62
+ console.error(error);
63
+ }
64
+ };
65
+ const getSetting = async () => {
66
+ const params = {
67
+ keys: ["eco_cup_customer_rent_config", "eco_cup_rent_expire_config"]
68
+ };
69
+ const res = await get("/shop/metadata/many", params);
70
+ if ((res == null ? void 0 : res.code) == 200) {
71
+ const { data } = res;
72
+ const expireConfig = (data == null ? void 0 : data.eco_cup_rent_expire_config) || {};
73
+ const rentConfig = (data == null ? void 0 : data.eco_cup_customer_rent_config) || [];
74
+ const formValues = {
75
+ expire: (expireConfig == null ? void 0 : expireConfig.expire) || 30
76
+ };
77
+ rentConfig.forEach((item) => {
78
+ if (item == null ? void 0 : item.name) {
79
+ formValues[item.name] = Number(item == null ? void 0 : item.max_rent_count) || void 0;
80
+ }
81
+ });
82
+ form.setFieldsValue(formValues);
83
+ }
84
+ };
85
+ (0, import_react.useEffect)(() => {
86
+ getSetting();
87
+ }, []);
88
+ const postSetting = async (values) => {
89
+ const { expire, ...membershipValues } = values;
90
+ const eco_cup_customer_rent_config = import_const.formItemsConfig.map((config) => ({
91
+ name: config.name,
92
+ max_rent_count: membershipValues[config.name]
93
+ }));
94
+ const params = {
95
+ eco_cup_customer_rent_config,
96
+ eco_cup_rent_expire_config: {
97
+ expire,
98
+ unit: "day"
99
+ }
100
+ };
101
+ try {
102
+ setLoading(true);
103
+ const res = await post("/shop/metadata/many", params);
104
+ if ((res == null ? void 0 : res.code) == 200) {
105
+ (0, import_materials.PisellToast)({
106
+ content: import_utils.locales.getText(
107
+ "pisell2.text.ecocup.setting.success"
108
+ )
109
+ });
110
+ return true;
111
+ }
112
+ return false;
113
+ } catch (error) {
114
+ console.error("提交设置失败:", error);
115
+ return false;
116
+ } finally {
117
+ setLoading(false);
118
+ }
119
+ };
120
+ return /* @__PURE__ */ import_react.default.createElement(
121
+ import_materials.PisellModal,
122
+ {
123
+ open: visible,
124
+ headerDivider: true,
125
+ title: import_utils.locales.getText("pisell2.text.cup-project.footer.button.setting"),
126
+ onCancel: _onCancel,
127
+ onOk: _onOk,
128
+ okText: import_utils.locales.getText("pisell2.text.ecocup.button.confirm"),
129
+ cancelText: import_utils.locales.getText("pisell2.text.ecocup.button.cancel"),
130
+ width: 680,
131
+ centered: true,
132
+ destroyOnClose: true,
133
+ wrapClassName: "pisell2-ecocup-add-customer-modal",
134
+ okButtonProps: { loading }
135
+ },
136
+ /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell2-ecocup-add-customer-modal-content" }, /* @__PURE__ */ import_react.default.createElement(import_antd.Form, { form, size: "large" }, import_const.formItemsConfig.map((config) => /* @__PURE__ */ import_react.default.createElement(
137
+ import_materials.FormItemInputNumber,
138
+ {
139
+ key: config.name,
140
+ renderMode: "edit",
141
+ name: config.name,
142
+ label: import_utils.locales.getText(config.labelKey),
143
+ placeholder: import_utils.locales.getText(config.placeholderKey),
144
+ maxobj: {
145
+ enabled: true,
146
+ max: 9999,
147
+ message: import_utils.locales.getText(
148
+ "pisell2.text.ecocup.setting.max-rent-count-max"
149
+ )
150
+ },
151
+ minobj: {
152
+ enabled: true,
153
+ min: 0,
154
+ message: import_utils.locales.getText(
155
+ "pisell2.text.ecocup.setting.max-rent-count-min"
156
+ )
157
+ },
158
+ requiredobj: {
159
+ required: true,
160
+ message: import_utils.locales.getText(config.requiredMessageKey)
161
+ }
162
+ }
163
+ )), /* @__PURE__ */ import_react.default.createElement(
164
+ import_materials.FormItemInputNumber,
165
+ {
166
+ renderMode: "edit",
167
+ name: "expire",
168
+ label: import_utils.locales.getText(
169
+ "pisell2.text.ecocup.setting.expire-time"
170
+ ),
171
+ placeholder: import_utils.locales.getText(
172
+ "pisell2.text.ecocup.setting.expire-time-placeholder"
173
+ ),
174
+ maxobj: {
175
+ enabled: true,
176
+ max: 365,
177
+ message: import_utils.locales.getText(
178
+ "pisell2.text.ecocup.setting.expire-time-max"
179
+ )
180
+ },
181
+ minobj: {
182
+ enabled: true,
183
+ min: 0,
184
+ message: import_utils.locales.getText(
185
+ "pisell2.text.ecocup.setting.expire-time-min"
186
+ )
187
+ },
188
+ suffix: import_utils.locales.getText("pisell2.text.ecocup.setting.days"),
189
+ requiredobj: {
190
+ required: true,
191
+ message: import_utils.locales.getText(
192
+ "pisell2.text.ecocup.setting.expire-time-required"
193
+ )
194
+ }
195
+ }
196
+ )))
197
+ );
198
+ };
199
+ var SettingModal_default = SettingModal;
@@ -0,0 +1,9 @@
1
+ .pisell2-ecocup-add-customer-modal-content {
2
+ padding: 24px 0;
3
+
4
+ .pisell2-ecocup-add-customer-modal-content-name-wrap {
5
+ display: flex;
6
+ flex-direction: row;
7
+ gap: 16px;
8
+ }
9
+ }
@@ -130,4 +130,11 @@ declare const FILTER: (locales: any, isNormalShop: boolean, ecoShopLists?: any,
130
130
  };
131
131
  })[];
132
132
  };
133
- export { STATUS_TEXT_MAP, STATUS_COLOR_MAP, SORT_SETTINGS, COLUMN_SETTING, FILTER, };
133
+ declare const HEADER_RIGHT_OPTIONS: {
134
+ languageKey: string;
135
+ key: string;
136
+ size: string;
137
+ icon: string;
138
+ type: string;
139
+ }[];
140
+ export { STATUS_TEXT_MAP, STATUS_COLOR_MAP, SORT_SETTINGS, COLUMN_SETTING, FILTER, HEADER_RIGHT_OPTIONS };
@@ -21,6 +21,7 @@ var const_exports = {};
21
21
  __export(const_exports, {
22
22
  COLUMN_SETTING: () => COLUMN_SETTING,
23
23
  FILTER: () => FILTER,
24
+ HEADER_RIGHT_OPTIONS: () => HEADER_RIGHT_OPTIONS,
24
25
  SORT_SETTINGS: () => SORT_SETTINGS,
25
26
  STATUS_COLOR_MAP: () => STATUS_COLOR_MAP,
26
27
  STATUS_TEXT_MAP: () => STATUS_TEXT_MAP
@@ -316,10 +317,27 @@ var FILTER = (locales, isNormalShop, ecoShopLists, isPartner, currentPagination)
316
317
  ]
317
318
  };
318
319
  };
320
+ var HEADER_RIGHT_OPTIONS = [
321
+ {
322
+ languageKey: "pisell2.text.ecocup.share.title",
323
+ key: "share",
324
+ size: "large",
325
+ icon: "pisell2-share-06",
326
+ type: "default"
327
+ },
328
+ {
329
+ languageKey: "pisell2.text.ecocup.export.title",
330
+ key: "export",
331
+ size: "large",
332
+ icon: "pisell2-download-01",
333
+ type: "default"
334
+ }
335
+ ];
319
336
  // Annotate the CommonJS export names for ESM import in node:
320
337
  0 && (module.exports = {
321
338
  COLUMN_SETTING,
322
339
  FILTER,
340
+ HEADER_RIGHT_OPTIONS,
323
341
  SORT_SETTINGS,
324
342
  STATUS_COLOR_MAP,
325
343
  STATUS_TEXT_MAP
@@ -1,4 +1,4 @@
1
1
  import { useColumns } from './useColumns';
2
2
  import { useSummary } from './useSummary';
3
- import { useCupListsApi, useStatisticsApi, useEcoShopListsApi } from './useCupApi';
4
- export { useColumns, useSummary, useCupListsApi, useStatisticsApi, useEcoShopListsApi, };
3
+ import { useCupListsApi, useStatisticsApi, useEcoShopListsApi, useExportApi, useShareApi } from './useCupApi';
4
+ export { useColumns, useSummary, useCupListsApi, useStatisticsApi, useEcoShopListsApi, useExportApi, useShareApi };
@@ -22,6 +22,8 @@ __export(hooks_exports, {
22
22
  useColumns: () => import_useColumns.useColumns,
23
23
  useCupListsApi: () => import_useCupApi.useCupListsApi,
24
24
  useEcoShopListsApi: () => import_useCupApi.useEcoShopListsApi,
25
+ useExportApi: () => import_useCupApi.useExportApi,
26
+ useShareApi: () => import_useCupApi.useShareApi,
25
27
  useStatisticsApi: () => import_useCupApi.useStatisticsApi,
26
28
  useSummary: () => import_useSummary.useSummary
27
29
  });
@@ -34,6 +36,8 @@ var import_useCupApi = require("./useCupApi");
34
36
  useColumns,
35
37
  useCupListsApi,
36
38
  useEcoShopListsApi,
39
+ useExportApi,
40
+ useShareApi,
37
41
  useStatisticsApi,
38
42
  useSummary
39
43
  });
@@ -3,6 +3,7 @@ import '../index.less';
3
3
  interface IProps {
4
4
  onClickAction: (type: string, record: any) => void;
5
5
  locales: any;
6
+ isEcoShare?: boolean;
6
7
  }
7
8
  export declare const useColumns: (props: IProps) => ({
8
9
  title: any;
@@ -35,7 +36,7 @@ export declare const useColumns: (props: IProps) => ({
35
36
  title: any;
36
37
  dataIndex: string;
37
38
  key: string;
38
- hidden: boolean;
39
+ hidden: boolean | undefined;
39
40
  width: number;
40
41
  render: (text: string, record: any) => React.JSX.Element | null;
41
42
  align?: undefined;
@@ -41,10 +41,8 @@ var import_hooks = require("../../hooks");
41
41
  var import__ = require("../index.less");
42
42
  var prefixCls = "ecocup-cup-list";
43
43
  var useColumns = (props) => {
44
- const { onClickAction, locales } = props;
45
- const { isNormalShop } = (0, import_hooks.useGetGoalShopInfo)();
44
+ const { onClickAction, locales, isEcoShare } = props;
46
45
  const isApp = (0, import_hooks.useIsApp)();
47
- const hiddenColumn = isApp ? false : isNormalShop;
48
46
  const getRelativeTime = (text) => {
49
47
  if (!text) return "";
50
48
  const diff = (0, import_dayjs.default)().diff((0, import_dayjs.default)(text), "day");
@@ -172,7 +170,7 @@ var useColumns = (props) => {
172
170
  title: locales.getText("pisell2.text.ecocup.table.actions"),
173
171
  dataIndex: "actions",
174
172
  key: "actions",
175
- hidden: isApp,
173
+ hidden: isApp || isEcoShare,
176
174
  width: 180,
177
175
  render: (text, record) => {
178
176
  const _status = (record == null ? void 0 : record.status) || "";
@@ -16,17 +16,26 @@ interface GetStatisticsParams {
16
16
  type?: 'eco' | 'normal';
17
17
  partner_shop_id?: number;
18
18
  }
19
- export declare const useCupListsApi: () => {
19
+ interface IProps {
20
+ isEcoShare?: boolean;
21
+ }
22
+ export declare const useCupListsApi: (props: IProps) => {
20
23
  loading: boolean;
21
24
  data: any;
22
25
  run: (params: GetCupListsParams) => Promise<void>;
23
26
  };
24
- export declare const useStatisticsApi: () => {
27
+ export declare const useStatisticsApi: (props: IProps) => {
25
28
  data: any;
26
29
  getStatics: (params: GetStatisticsParams) => Promise<void>;
27
30
  };
28
- export declare const useEcoShopListsApi: () => {
31
+ export declare const useEcoShopListsApi: (props: IProps) => {
29
32
  data: any;
30
33
  getEcoShopLists: (params?: any) => Promise<void>;
31
34
  };
35
+ export declare const useShareApi: () => {
36
+ postShareApi: () => Promise<void>;
37
+ };
38
+ export declare const useExportApi: () => {
39
+ postExportApi: (params?: any) => Promise<void>;
40
+ };
32
41
  export {};
@@ -1,6 +1,8 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
4
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
7
  var __export = (target, all) => {
6
8
  for (var name in all)
@@ -14,6 +16,14 @@ var __copyProps = (to, from, except, desc) => {
14
16
  }
15
17
  return to;
16
18
  };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
17
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
28
 
19
29
  // src/components/ecocup/cupList/hooks/useCupApi.ts
@@ -21,17 +31,30 @@ var useCupApi_exports = {};
21
31
  __export(useCupApi_exports, {
22
32
  useCupListsApi: () => useCupListsApi,
23
33
  useEcoShopListsApi: () => useEcoShopListsApi,
34
+ useExportApi: () => useExportApi,
35
+ useShareApi: () => useShareApi,
24
36
  useStatisticsApi: () => useStatisticsApi
25
37
  });
26
38
  module.exports = __toCommonJS(useCupApi_exports);
27
39
  var import_react = require("react");
40
+ var import_materials = require("@pisell/materials");
41
+ var import_utils = require("@pisell/utils");
42
+ var import_useEngineContext = __toESM(require("../../../../hooks/useEngineContext"));
28
43
  var import_hooks = require("../../hooks");
29
- var useCupListsApi = () => {
44
+ var getApiConfig = (isEcoShare) => {
45
+ if (!isEcoShare) return {};
46
+ return {
47
+ isShopApi: true
48
+ };
49
+ };
50
+ var useCupListsApi = (props) => {
51
+ const { isEcoShare } = props;
30
52
  const [loading, setLoading] = (0, import_react.useState)(false);
31
53
  const [data, setData] = (0, import_react.useState)({});
32
54
  const { get } = (0, import_hooks.useRequest)();
33
55
  const { isNormalShop } = (0, import_hooks.useGetGoalShopInfo)();
34
56
  const isApp = (0, import_hooks.useIsApp)();
57
+ const apiConfig = getApiConfig(isEcoShare);
35
58
  const getCupLists = (0, import_react.useCallback)(async (params) => {
36
59
  try {
37
60
  const api = isApp ? "/h5/wallet/eco" : "/shop/wallet/eco";
@@ -39,11 +62,20 @@ var useCupListsApi = () => {
39
62
  setLoading(true);
40
63
  let _params = {
41
64
  type: isPartner ? "partner" : "eco",
42
- with: ["customer:id,display_name", "rentShop:id,name", "returnShop:id,name", "currentShop:id,name"],
65
+ with: [
66
+ "customer:id,display_name",
67
+ "rentShop:id,name",
68
+ "returnShop:id,name",
69
+ "currentShop:id,name"
70
+ ],
43
71
  ...params
44
72
  };
45
73
  if (isPartner) {
46
- _params.with = ["customer:id,display_name", "rentShop:id,name", "returnShop:id,name"];
74
+ _params.with = [
75
+ "customer:id,display_name",
76
+ "rentShop:id,name",
77
+ "returnShop:id,name"
78
+ ];
47
79
  }
48
80
  if (isApp) {
49
81
  _params = {
@@ -51,7 +83,7 @@ var useCupListsApi = () => {
51
83
  skip: params == null ? void 0 : params.skip
52
84
  };
53
85
  }
54
- const res = await get(api, _params);
86
+ const res = await get(api, _params, apiConfig);
55
87
  setData((res == null ? void 0 : res.data) || {});
56
88
  setLoading(false);
57
89
  } catch (error) {
@@ -64,10 +96,12 @@ var useCupListsApi = () => {
64
96
  run: getCupLists
65
97
  };
66
98
  };
67
- var useStatisticsApi = () => {
99
+ var useStatisticsApi = (props) => {
100
+ const { isEcoShare } = props;
68
101
  const [data, setData] = (0, import_react.useState)({});
69
102
  const { get } = (0, import_hooks.useRequest)();
70
103
  const { isNormalShop } = (0, import_hooks.useGetGoalShopInfo)();
104
+ const apiConfig = getApiConfig(isEcoShare);
71
105
  const getStatics = (0, import_react.useCallback)(async (params) => {
72
106
  try {
73
107
  const isPartner = isNormalShop || (params == null ? void 0 : params.partner_shop_id);
@@ -75,7 +109,7 @@ var useStatisticsApi = () => {
75
109
  type: isPartner ? "partner" : "eco",
76
110
  ...params
77
111
  };
78
- const res = await get("/shop/wallet/eco/statistics", _params);
112
+ const res = await get("/shop/wallet/eco/statistics", _params, apiConfig);
79
113
  setData((res == null ? void 0 : res.data) || {});
80
114
  } catch (error) {
81
115
  }
@@ -85,16 +119,18 @@ var useStatisticsApi = () => {
85
119
  getStatics
86
120
  };
87
121
  };
88
- var useEcoShopListsApi = () => {
122
+ var useEcoShopListsApi = (props) => {
123
+ const { isEcoShare } = props;
89
124
  const [data, setData] = (0, import_react.useState)([]);
90
125
  const { get } = (0, import_hooks.useRequest)();
126
+ const apiConfig = getApiConfig(isEcoShare);
91
127
  const getEcoShopLists = (0, import_react.useCallback)(async (params) => {
92
128
  try {
93
129
  const _params = {
94
130
  skip: 1,
95
131
  num: 100
96
132
  };
97
- const res = await get("/shop/wallet/eco/shops", _params);
133
+ const res = await get("/shop/wallet/eco/shops", _params, apiConfig);
98
134
  setData((res == null ? void 0 : res.data) || []);
99
135
  } catch (error) {
100
136
  }
@@ -104,9 +140,88 @@ var useEcoShopListsApi = () => {
104
140
  getEcoShopLists
105
141
  };
106
142
  };
143
+ var useShareApi = () => {
144
+ var _a;
145
+ const { post } = (0, import_hooks.useRequest)();
146
+ const app = (0, import_hooks.useGetApp)();
147
+ const context = (0, import_useEngineContext.default)();
148
+ const coreData = (0, import_react.useMemo)(() => {
149
+ var _a2, _b, _c, _d, _e, _f;
150
+ return (_f = (_e = (_d = (_c = (_b = (_a2 = app == null ? void 0 : app()) == null ? void 0 : _a2.data) == null ? void 0 : _b.store) == null ? void 0 : _c.getStore) == null ? void 0 : _d.call(_c)) == null ? void 0 : _e.getDataByModel) == null ? void 0 : _f.call(_e, "tenantCore", "core");
151
+ }, [app]);
152
+ const postShareApi = (0, import_react.useCallback)(async () => {
153
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
154
+ try {
155
+ const token = (_d = (_c = (_b = (_a2 = app()) == null ? void 0 : _a2.data) == null ? void 0 : _b.storage) == null ? void 0 : _c.getStorage) == null ? void 0 : _d.call(_c, "token");
156
+ const { copyToClipboard } = ((_f = (_e = context == null ? void 0 : context.appHelper) == null ? void 0 : _e.utils) == null ? void 0 : _f.businessUtils) || {};
157
+ if (!token) return;
158
+ const params = {
159
+ // 有效期,7天,转成秒
160
+ ttl: 7 * 24 * 60 * 60,
161
+ data: {
162
+ login_token: token
163
+ }
164
+ };
165
+ const res = await post("/tenant/core/stash-token", params, {
166
+ isPisell2: true
167
+ });
168
+ if (((_g = res == null ? void 0 : res.data) == null ? void 0 : _g.token) && ((_h = coreData == null ? void 0 : coreData.tenant) == null ? void 0 : _h.default_domain)) {
169
+ const path = `https://${(_i = coreData == null ? void 0 : coreData.tenant) == null ? void 0 : _i.default_domain}/admin/ecocup/cup-list`;
170
+ const url = `${path}?source=ecoShare&key=${(_j = res == null ? void 0 : res.data) == null ? void 0 : _j.token}`;
171
+ copyToClipboard && copyToClipboard(url);
172
+ (0, import_materials.PisellToast)({
173
+ content: import_utils.locales.getText("pisell2.text.ecocup.toast.success-copy-link")
174
+ });
175
+ }
176
+ } catch (error) {
177
+ console.log("分享失败", error);
178
+ }
179
+ }, [(_a = coreData == null ? void 0 : coreData.tenant) == null ? void 0 : _a.default_domain]);
180
+ return {
181
+ postShareApi
182
+ };
183
+ };
184
+ var useExportApi = () => {
185
+ const { post } = (0, import_hooks.useRequest)();
186
+ const shopId = (0, import_hooks.useGetShopId)();
187
+ const context = (0, import_useEngineContext.default)();
188
+ const postExportApi = (0, import_react.useCallback)(async (params) => {
189
+ var _a, _b;
190
+ try {
191
+ const { downloadFile } = ((_a = context == null ? void 0 : context.appHelper) == null ? void 0 : _a.utils) || {};
192
+ const { isPartner, listParams } = params;
193
+ const _params = {
194
+ type: isPartner ? "partner" : "eco",
195
+ business_shop_id: !isPartner ? shopId : listParams == null ? void 0 : listParams.partner_shop_id,
196
+ operated_at_start: listParams == null ? void 0 : listParams.operated_at_start,
197
+ operated_at_end: listParams == null ? void 0 : listParams.operated_at_end
198
+ };
199
+ const res = await post("/shop/wallet/eco/export-url", _params);
200
+ if ((_b = res == null ? void 0 : res.data) == null ? void 0 : _b.export_url) {
201
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[-:T.]/g, "").slice(0, 14);
202
+ const filename = `shop-eco-cups-${timestamp}.csv`;
203
+ downloadFile && downloadFile(res.data.export_url, filename);
204
+ (0, import_materials.PisellToast)({
205
+ content: import_utils.locales.getText("pisell2.text.ecocup.export.success")
206
+ });
207
+ return;
208
+ }
209
+ (0, import_materials.PisellToast)({
210
+ content: import_utils.locales.getText("pisell2.text.ecocup.export.fail")
211
+ });
212
+ } catch (error) {
213
+ console.log("导出失败", error);
214
+ }
215
+ }, []);
216
+ return {
217
+ postExportApi
218
+ };
219
+ };
107
220
  // Annotate the CommonJS export names for ESM import in node:
108
221
  0 && (module.exports = {
109
222
  useCupListsApi,
110
223
  useEcoShopListsApi,
224
+ useExportApi,
225
+ useShareApi,
111
226
  useStatisticsApi
112
227
  });
@@ -39,33 +39,41 @@ var prefixCls = "ecocup-cup-list";
39
39
  var useSummary = (locales, staticsData, isPartner) => {
40
40
  const summaryData = (0, import_react.useMemo)(() => {
41
41
  return [
42
- {
43
- key: "available-to-rent",
44
- title: locales.getText("pisell2.text.ecocup.available-to-rent"),
45
- value: (staticsData == null ? void 0 : staticsData.in_stock_count) || 0
46
- },
47
42
  {
48
43
  key: "cup-rent",
49
44
  title: isPartner ? locales.getText("pisell2.text.ecocup.cup-rent") : locales.getText("pisell2.text.ecocup.eco.cup-rent"),
50
- value: (staticsData == null ? void 0 : staticsData.rent_count) || 0
45
+ value: (staticsData == null ? void 0 : staticsData.rent_count) || 0,
46
+ type: "primary"
51
47
  },
52
48
  {
53
49
  key: "cup-returned",
54
50
  title: isPartner ? locales.getText("pisell2.text.ecocup.cup-returned") : locales.getText("pisell2.text.ecocup.eco.cup-returned"),
55
- value: (staticsData == null ? void 0 : staticsData.return_count) || 0
51
+ value: (staticsData == null ? void 0 : staticsData.return_count) || 0,
52
+ type: "primary"
53
+ },
54
+ {
55
+ key: "available-to-rent",
56
+ title: locales.getText("pisell2.text.ecocup.available-to-rent"),
57
+ value: (staticsData == null ? void 0 : staticsData.in_stock_count) || 0
56
58
  }
57
59
  ];
58
60
  }, [staticsData, isPartner]);
59
61
  return (0, import_react.useMemo)(() => {
60
62
  return () => /* @__PURE__ */ import_react.default.createElement(import_materials.Row, { gutter: 8, className: `${prefixCls}-summary` }, summaryData.map((item) => {
61
- return /* @__PURE__ */ import_react.default.createElement(import_materials.Col, { span: 8, key: item.key }, /* @__PURE__ */ import_react.default.createElement(import_materials.Card, { className: `${prefixCls}-summary-card` }, /* @__PURE__ */ import_react.default.createElement(
62
- import_materials.Statistic,
63
+ return /* @__PURE__ */ import_react.default.createElement(import_materials.Col, { span: 8, key: item.key }, /* @__PURE__ */ import_react.default.createElement(
64
+ import_materials.Card,
63
65
  {
64
- title: item.title,
65
- value: item.value,
66
- className: `${prefixCls}-summary-card-statistic`
67
- }
68
- )));
66
+ className: `${prefixCls}-summary-card ${(item == null ? void 0 : item.type) === "primary" ? `${prefixCls}-summary-primary` : ""}`
67
+ },
68
+ /* @__PURE__ */ import_react.default.createElement(
69
+ import_materials.Statistic,
70
+ {
71
+ title: item.title,
72
+ value: item.value,
73
+ className: `${prefixCls}-summary-card-statistic`
74
+ }
75
+ )
76
+ ));
69
77
  }));
70
78
  }, [summaryData]);
71
79
  };