@uxda/appkit 1.1.0 → 1.2.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxda/appkit",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "小程序应用开发包",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.ts",
@@ -1,82 +1,84 @@
1
- import { HttpEndpoints } from '../../shared/http'
2
- import { 账户流水筛选项, ConsumptionType } from '../types'
1
+ import { HttpEndpoints } from "../../shared/http";
2
+ import { 账户流水筛选项, ConsumptionType } from "../types";
3
3
 
4
4
  type OnlyApp = {
5
- app: string
6
- }
5
+ app: string;
6
+ };
7
7
 
8
- type AndApp<T> = OnlyApp & T
8
+ type AndApp<T> = OnlyApp & T;
9
9
 
10
10
  /**
11
11
  * 流水交易类型映射
12
12
  */
13
13
  const typeMappings: Record<string, ConsumptionType> = {
14
- 'CZ': '充值',
15
- 'JF': '缴费',
16
- 'FE': '返额',
17
- 'ZJ': '增加',
18
- 'KJ': '扣减',
19
- 'XH': '消耗',
20
- 'TH': '退回',
21
- }
14
+ CZ: "充值",
15
+ JF: "缴费",
16
+ FE: "返额",
17
+ ZJ: "增加",
18
+ KJ: "扣减",
19
+ XH: "消耗",
20
+ TH: "退回",
21
+ };
22
22
 
23
23
  /**
24
24
  * 映射还能反过来
25
25
  */
26
26
  const typeMappingsReversed = Object.fromEntries(
27
27
  Object.entries(typeMappings).map(([x, y]) => [y, x])
28
- )
28
+ );
29
29
 
30
30
  const positionMappings = {
31
- 'common': '云豆',
32
- 'rights': '小云豆',
33
- }
31
+ common: "云豆",
32
+ rights: "小云豆",
33
+ gift: "权益",
34
+ };
34
35
 
35
36
  const positionMappingsReversed = Object.fromEntries(
36
37
  Object.entries(positionMappings).map(([x, y]) => [y, x])
37
- )
38
+ );
38
39
 
39
40
  const directionMappings = {
40
- 0: '收入',
41
- 1: '支出'
42
- }
41
+ 0: "收入",
42
+ 1: "支出",
43
+ };
43
44
 
44
45
  const directionMappingsReversed = Object.fromEntries(
45
46
  Object.entries(directionMappings).map(([x, y]) => [y, x])
46
- )
47
+ );
47
48
 
48
49
  const endpointsList: HttpEndpoints = {
49
50
  获取余额明细: {
50
- path: '/ac-app/account/info/detail/app', // /app
51
+ path: "/ac-app/account/info/detail/app", // /app
51
52
  translate: (data: OnlyApp) => ({
52
- appCode: data.app
53
+ appCode: data.app,
53
54
  }),
54
- transform (result: any) {
55
+ transform(result: any) {
55
56
  return {
56
57
  total: result.commonAccount,
57
58
  privileges: result.rightsAccountBalList.map((r: any) => ({
58
59
  title: r.rightsName,
59
- count: r.rightsAccount
60
- }))
61
- }
62
- }
60
+ count: r.rightsAccount,
61
+ unit: r.rightsUnit,
62
+ })),
63
+ };
64
+ },
63
65
  },
64
66
  获取账户流水: {
65
- path: '/ac-app/account/record/detail/mobile',
67
+ path: "/ac-app/account/record/detail/mobile",
66
68
  translate: (data: AndApp<账户流水筛选项>) => {
67
69
  return {
68
70
  appCode: data.app,
69
- accountType: positionMappingsReversed[data.账户类型] || '',
70
- inOrOut: directionMappingsReversed[data.收入还是支出] || '',
71
- changeType: typeMappingsReversed[data.交易类型] || '',
72
- operateTimeStart: data.dateFrom || '',
73
- operateTimeEnd: data.dateTo || '',
71
+ accountType: positionMappingsReversed[data.账户类型] || "",
72
+ inOrOut: directionMappingsReversed[data.收入还是支出] || "",
73
+ changeType: typeMappingsReversed[data.交易类型] || "",
74
+ operateTimeStart: data.dateFrom || "",
75
+ operateTimeEnd: data.dateTo || "",
74
76
  rightsCode: data.权益类目,
75
77
  pageNum: data.page,
76
78
  pageSize: 10,
77
- }
79
+ };
78
80
  },
79
- transform (response: any) {
81
+ transform(response: any) {
80
82
  const data = response.list.map((d: any) => ({
81
83
  账户类型: positionMappings[d.accountType],
82
84
  交易类型: typeMappings[d.changeType],
@@ -85,39 +87,36 @@ const endpointsList: HttpEndpoints = {
85
87
  title: d.rightsName,
86
88
  time: Date.parse(d.operateTime), // 后台返回的是日期字符串,这里格式化成 timestamp
87
89
  description: d.remark,
88
- }))
89
- return data
90
- }
90
+ }));
91
+ return data;
92
+ },
91
93
  },
92
94
  获取权益类目: {
93
- path: '/ac-app/rights/item/list',
95
+ path: "/ac-app/rights/item/list",
94
96
  translate: (data: OnlyApp) => ({
95
- appCode: data.app
97
+ appCode: data.app,
96
98
  }),
97
99
  // translate (data: ConsumptionFiltering) {
98
100
  // // return { appCode: data.appCode }
99
101
  // },
100
- transform: (data: any[]) => data.map(d => ({
101
- name: d.rightsName,
102
- code: d.rightsCode,
103
- }))
104
- }
105
- }
102
+ transform: (data: any[]) =>
103
+ data.map((d) => ({
104
+ name: d.rightsName,
105
+ code: d.rightsCode,
106
+ })),
107
+ },
108
+ };
106
109
 
107
110
  const endpoints = Object.fromEntries(
108
111
  Object.entries(endpointsList).map(([name, def]) => [name, def.path])
109
- )
112
+ );
110
113
 
111
114
  const translates = Object.fromEntries(
112
115
  Object.entries(endpointsList).map(([, def]) => [def.path, def.translate])
113
- )
116
+ );
114
117
 
115
118
  const transforms = Object.fromEntries(
116
119
  Object.entries(endpointsList).map(([, def]) => [def.path, def.transform])
117
- )
120
+ );
118
121
 
119
- export {
120
- endpoints,
121
- translates,
122
- transforms,
123
- }
122
+ export { endpoints, translates, transforms };