@pisell/utils 3.0.3 → 3.0.4

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/es/index.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ export * from './otherUtils';
2
+ export * from './typeUtils';
3
+ export * from './document';
4
+ export * from './date';
5
+ export * from './platform';
6
+ export * from './log';
7
+ export * from './format';
8
+ export * from './escPosPrinter';
9
+ export * from './miniRedux';
10
+ export * from './jsBridge';
11
+ export * from './image';
12
+ export * from './locales';
13
+ export * from './arrayUtils';
14
+ export * from './walletValidity';
15
+ export declare const setPisellUtilsConfig: (config: {
16
+ [key: string]: any;
17
+ }) => void;
18
+ export declare const getPisellUtilsConfig: () => {
19
+ [key: string]: any;
20
+ };
@@ -0,0 +1,118 @@
1
+ declare type LanguageNumber = {
2
+ en: number;
3
+ zh_CN: number;
4
+ zh_HK: number;
5
+ };
6
+ declare type LanguageString = {
7
+ en: string;
8
+ zh_CN: string;
9
+ zh_HK: string;
10
+ } | string;
11
+ /**
12
+ * 打印小票
13
+ */
14
+ declare type WebPrint0 = {
15
+ /**
16
+ * 打印类型
17
+ * 0: 小票
18
+ * 1:ITS备货单/划菜单
19
+ * 2:手环
20
+ */
21
+ type: "0";
22
+ data: {
23
+ /** 订单ID */
24
+ order_id: string;
25
+ };
26
+ /** 打印语言对应的数量 */
27
+ language: LanguageNumber;
28
+ };
29
+ /**
30
+ * 打印ITS备货单/划菜单
31
+ */
32
+ declare type WebPrint1 = {
33
+ /**
34
+ * 打印类型
35
+ * 0: 小票
36
+ * 1:ITS备货单/划菜单
37
+ * 2:手环
38
+ */
39
+ type: "1";
40
+ data: {
41
+ /** 0:备货 1:划单 */
42
+ mode: "0" | "1";
43
+ resource: LanguageString;
44
+ /** 订单备注 */
45
+ order_note: string;
46
+ /** 订单时间或商品下单时间 */
47
+ time: string;
48
+ /** 订单编号 */
49
+ order_number?: string;
50
+ /** 商品 */
51
+ products: {
52
+ /** 商品名称 */
53
+ product_title: LanguageString;
54
+ /** 商品规格 */
55
+ product_option_string: LanguageString;
56
+ /** 商品备注 */
57
+ product_note: string;
58
+ /** 商品数量 */
59
+ product_quantity: number;
60
+ /** 加菜标识 待定 */
61
+ is_append?: boolean;
62
+ /** 退菜标识 待定 */
63
+ is_removed?: boolean;
64
+ }[];
65
+ };
66
+ /** 打印语言对应的数量 */
67
+ language: LanguageNumber;
68
+ };
69
+ declare type WebPrint2 = {
70
+ /**
71
+ * 打印类型
72
+ * 0: 小票
73
+ * 1:ITS备货单/划菜单
74
+ * 2:手环
75
+ */
76
+ type: "2";
77
+ data: {
78
+ /** 0: 普通票 1:成人票 2:免费成人票 */
79
+ type: "0" | "1" | "2";
80
+ /** 发行编码 */
81
+ encoded: string;
82
+ /** 编码 */
83
+ code: string;
84
+ /** 到期时间 */
85
+ expire_date: string;
86
+ areas: {
87
+ /** 区域名字 */
88
+ area_name: string;
89
+ /** 区域代码 */
90
+ area_code: string;
91
+ /** 可用次数 */
92
+ limit_num: number;
93
+ /** 已用次数 */
94
+ used_num: number;
95
+ }[];
96
+ };
97
+ };
98
+ declare type WebPrintParams = WebPrint0 | WebPrint1 | WebPrint2;
99
+ /**
100
+ * webView页面中调用打印机打印
101
+ * 此api暂时只支持native app平台下ios手机
102
+ * @param params
103
+ * @param callback
104
+ */
105
+ export declare function webPrint(params: WebPrintParams, callback: (...arg: any) => void): void;
106
+ declare type DataManagerParams = {
107
+ module: "set" | "get";
108
+ key: string;
109
+ data?: any;
110
+ };
111
+ /**
112
+ * webView页面中调用APP内的数据
113
+ * 此api暂时只支持native app平台下ios手机
114
+ * @param params
115
+ * @param callback
116
+ */
117
+ export declare function dataManager(params: DataManagerParams, callback: (...arg: any) => void, onError: () => void): void;
118
+ export {};
@@ -68,10 +68,10 @@ function getComposedBridge(deviceType) {
68
68
  } catch (error) {
69
69
  console.log("error ".concat(apiName), error);
70
70
  }
71
- if (result.code || result.code === 0) {
72
- // 强转字符串,兼容安卓的number
73
- result.code = "".concat(result.code);
74
- }
71
+ // if (result.code || result.code === 0) {
72
+ // // 强转字符串,兼容安卓的number
73
+ // result.code = `${result.code}`;
74
+ // }
75
75
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
76
76
  args[_key - 1] = arguments[_key];
77
77
  }
@@ -0,0 +1,12 @@
1
+ export declare const locales: {
2
+ init: (_localeMaps: any, _locale: string) => void;
3
+ getText: (id: string) => any;
4
+ locale: string;
5
+ localeMap: any;
6
+ localeMaps: {
7
+ en: {};
8
+ 'zh-CN': {};
9
+ 'zh-HK': {};
10
+ };
11
+ formatLocale: (_locale: string) => string;
12
+ };
@@ -0,0 +1,16 @@
1
+ interface MiniReduxProps<State, Namespace> {
2
+ namespace?: Namespace;
3
+ state?: State;
4
+ reducers?: any;
5
+ effects?: any;
6
+ }
7
+ export declare const miniRedux: <State extends Record<string, any>, Namespace extends string>({ namespace, state, reducers, effects, }: MiniReduxProps<State, Namespace>) => {
8
+ Context: React.Context<{ [K in Namespace]: State; } & {
9
+ dispatch: (params: {
10
+ type: string;
11
+ payload: any;
12
+ }) => void;
13
+ }>;
14
+ Provider: (ComponentUi: any) => any;
15
+ };
16
+ export {};
package/lib/index.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ export * from './otherUtils';
2
+ export * from './typeUtils';
3
+ export * from './document';
4
+ export * from './date';
5
+ export * from './platform';
6
+ export * from './log';
7
+ export * from './format';
8
+ export * from './escPosPrinter';
9
+ export * from './miniRedux';
10
+ export * from './jsBridge';
11
+ export * from './image';
12
+ export * from './locales';
13
+ export * from './arrayUtils';
14
+ export * from './walletValidity';
15
+ export declare const setPisellUtilsConfig: (config: {
16
+ [key: string]: any;
17
+ }) => void;
18
+ export declare const getPisellUtilsConfig: () => {
19
+ [key: string]: any;
20
+ };
@@ -0,0 +1,118 @@
1
+ declare type LanguageNumber = {
2
+ en: number;
3
+ zh_CN: number;
4
+ zh_HK: number;
5
+ };
6
+ declare type LanguageString = {
7
+ en: string;
8
+ zh_CN: string;
9
+ zh_HK: string;
10
+ } | string;
11
+ /**
12
+ * 打印小票
13
+ */
14
+ declare type WebPrint0 = {
15
+ /**
16
+ * 打印类型
17
+ * 0: 小票
18
+ * 1:ITS备货单/划菜单
19
+ * 2:手环
20
+ */
21
+ type: "0";
22
+ data: {
23
+ /** 订单ID */
24
+ order_id: string;
25
+ };
26
+ /** 打印语言对应的数量 */
27
+ language: LanguageNumber;
28
+ };
29
+ /**
30
+ * 打印ITS备货单/划菜单
31
+ */
32
+ declare type WebPrint1 = {
33
+ /**
34
+ * 打印类型
35
+ * 0: 小票
36
+ * 1:ITS备货单/划菜单
37
+ * 2:手环
38
+ */
39
+ type: "1";
40
+ data: {
41
+ /** 0:备货 1:划单 */
42
+ mode: "0" | "1";
43
+ resource: LanguageString;
44
+ /** 订单备注 */
45
+ order_note: string;
46
+ /** 订单时间或商品下单时间 */
47
+ time: string;
48
+ /** 订单编号 */
49
+ order_number?: string;
50
+ /** 商品 */
51
+ products: {
52
+ /** 商品名称 */
53
+ product_title: LanguageString;
54
+ /** 商品规格 */
55
+ product_option_string: LanguageString;
56
+ /** 商品备注 */
57
+ product_note: string;
58
+ /** 商品数量 */
59
+ product_quantity: number;
60
+ /** 加菜标识 待定 */
61
+ is_append?: boolean;
62
+ /** 退菜标识 待定 */
63
+ is_removed?: boolean;
64
+ }[];
65
+ };
66
+ /** 打印语言对应的数量 */
67
+ language: LanguageNumber;
68
+ };
69
+ declare type WebPrint2 = {
70
+ /**
71
+ * 打印类型
72
+ * 0: 小票
73
+ * 1:ITS备货单/划菜单
74
+ * 2:手环
75
+ */
76
+ type: "2";
77
+ data: {
78
+ /** 0: 普通票 1:成人票 2:免费成人票 */
79
+ type: "0" | "1" | "2";
80
+ /** 发行编码 */
81
+ encoded: string;
82
+ /** 编码 */
83
+ code: string;
84
+ /** 到期时间 */
85
+ expire_date: string;
86
+ areas: {
87
+ /** 区域名字 */
88
+ area_name: string;
89
+ /** 区域代码 */
90
+ area_code: string;
91
+ /** 可用次数 */
92
+ limit_num: number;
93
+ /** 已用次数 */
94
+ used_num: number;
95
+ }[];
96
+ };
97
+ };
98
+ declare type WebPrintParams = WebPrint0 | WebPrint1 | WebPrint2;
99
+ /**
100
+ * webView页面中调用打印机打印
101
+ * 此api暂时只支持native app平台下ios手机
102
+ * @param params
103
+ * @param callback
104
+ */
105
+ export declare function webPrint(params: WebPrintParams, callback: (...arg: any) => void): void;
106
+ declare type DataManagerParams = {
107
+ module: "set" | "get";
108
+ key: string;
109
+ data?: any;
110
+ };
111
+ /**
112
+ * webView页面中调用APP内的数据
113
+ * 此api暂时只支持native app平台下ios手机
114
+ * @param params
115
+ * @param callback
116
+ */
117
+ export declare function dataManager(params: DataManagerParams, callback: (...arg: any) => void, onError: () => void): void;
118
+ export {};
@@ -85,9 +85,6 @@ function getComposedBridge(deviceType) {
85
85
  } catch (error) {
86
86
  console.log(`error ${apiName}`, error);
87
87
  }
88
- if (result.code || result.code === 0) {
89
- result.code = `${result.code}`;
90
- }
91
88
  inCb(result, ...args);
92
89
  };
93
90
  if (deviceType === "iphone") {
@@ -0,0 +1,12 @@
1
+ export declare const locales: {
2
+ init: (_localeMaps: any, _locale: string) => void;
3
+ getText: (id: string) => any;
4
+ locale: string;
5
+ localeMap: any;
6
+ localeMaps: {
7
+ en: {};
8
+ 'zh-CN': {};
9
+ 'zh-HK': {};
10
+ };
11
+ formatLocale: (_locale: string) => string;
12
+ };
@@ -0,0 +1,16 @@
1
+ interface MiniReduxProps<State, Namespace> {
2
+ namespace?: Namespace;
3
+ state?: State;
4
+ reducers?: any;
5
+ effects?: any;
6
+ }
7
+ export declare const miniRedux: <State extends Record<string, any>, Namespace extends string>({ namespace, state, reducers, effects, }: MiniReduxProps<State, Namespace>) => {
8
+ Context: React.Context<{ [K in Namespace]: State; } & {
9
+ dispatch: (params: {
10
+ type: string;
11
+ payload: any;
12
+ }) => void;
13
+ }>;
14
+ Provider: (ComponentUi: any) => any;
15
+ };
16
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/utils",
3
- "version": "3.0.3",
3
+ "version": "3.0.4",
4
4
  "sideEffects": false,
5
5
  "main": "./lib/index.js",
6
6
  "module": "./es/index.js",
package/es/format.d.ts DELETED
@@ -1,28 +0,0 @@
1
- /**
2
- * @title: 格式化金额
3
- * @description:
4
- * @param {number} amount 原金额
5
- * @param {number} precision 小数位数
6
- * @param {string} symbol 货币符号
7
- * @return {*}
8
- * @Author: zhiwei.Wang
9
- * @Date: 2023-11-06 16:51
10
- */
11
- export declare const formatAmount: (amount?: number | string, precision?: number, symbol?: string) => string | number;
12
- export declare type FormatOptions = {
13
- /** 小数点后位数 默认是小数点后2位 */
14
- precision?: number;
15
- /** 显示货币符号 指的是 ¥$ 等货币符号等显隐,默认是展示 */
16
- showCurrencySymbol?: boolean;
17
- /** 千分位 指的是长金额的千分位逗号隔开,比如“123, 245, 315” 这种展现形式,默认是关闭 */
18
- useThousandsSeparator?: boolean;
19
- /** 整数位隐藏小数 指的是如果价格为整数,后面的".00" 将被省略以节省页面空间 */
20
- hideDecimalForWholeNumbers?: boolean;
21
- };
22
- /**
23
- * 根据配置格式化金额
24
- * @param amount
25
- * @param symbol
26
- * @param options
27
- */
28
- export declare const formatAmountWithOptions: (amount: string | number | undefined, symbol: string | undefined, options: FormatOptions) => string | number;
package/lib/format.d.ts DELETED
@@ -1,28 +0,0 @@
1
- /**
2
- * @title: 格式化金额
3
- * @description:
4
- * @param {number} amount 原金额
5
- * @param {number} precision 小数位数
6
- * @param {string} symbol 货币符号
7
- * @return {*}
8
- * @Author: zhiwei.Wang
9
- * @Date: 2023-11-06 16:51
10
- */
11
- export declare const formatAmount: (amount?: number | string, precision?: number, symbol?: string) => string | number;
12
- export declare type FormatOptions = {
13
- /** 小数点后位数 默认是小数点后2位 */
14
- precision?: number;
15
- /** 显示货币符号 指的是 ¥$ 等货币符号等显隐,默认是展示 */
16
- showCurrencySymbol?: boolean;
17
- /** 千分位 指的是长金额的千分位逗号隔开,比如“123, 245, 315” 这种展现形式,默认是关闭 */
18
- useThousandsSeparator?: boolean;
19
- /** 整数位隐藏小数 指的是如果价格为整数,后面的".00" 将被省略以节省页面空间 */
20
- hideDecimalForWholeNumbers?: boolean;
21
- };
22
- /**
23
- * 根据配置格式化金额
24
- * @param amount
25
- * @param symbol
26
- * @param options
27
- */
28
- export declare const formatAmountWithOptions: (amount: string | number | undefined, symbol: string | undefined, options: FormatOptions) => string | number;