@uxda/appkit 1.2.8 → 1.2.12

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 (66) hide show
  1. package/.eslintrc.mjs +7 -7
  2. package/README.md +187 -187
  3. package/babel.config.js +12 -12
  4. package/dist/appkit.css +289 -71
  5. package/dist/index.js +862 -341
  6. package/dist/styles.css +1 -0
  7. package/package.json +78 -78
  8. package/project.config.json +15 -15
  9. package/project.tt.json +13 -13
  10. package/rollup.config.mjs +54 -54
  11. package/src/Appkit.ts +65 -65
  12. package/src/balance/api/endpoints.ts +125 -122
  13. package/src/balance/api/index.ts +82 -82
  14. package/src/balance/components/AccountView.vue +754 -649
  15. package/src/balance/components/BalanceCard.vue +209 -209
  16. package/src/balance/components/BalanceReminder.vue +83 -83
  17. package/src/balance/components/ConsumptionFilter.vue +218 -218
  18. package/src/balance/components/ConsumptionRules.vue +68 -68
  19. package/src/balance/components/DateFilter.vue +235 -235
  20. package/src/balance/components/SecondBalance.vue +71 -71
  21. package/src/balance/components/Tip.vue +46 -0
  22. package/src/balance/components/index.ts +9 -9
  23. package/src/balance/types.ts +90 -88
  24. package/src/components/dd-area/index.vue +222 -222
  25. package/src/components/dd-icon/doc.md +21 -21
  26. package/src/components/dd-icon/index.vue +23 -23
  27. package/src/components/dd-selector/index.vue +124 -124
  28. package/src/components/ocr-id/index.vue +110 -110
  29. package/src/components/ocr-id/types.d.ts +12 -12
  30. package/src/global.ts +6 -6
  31. package/src/index.ts +88 -86
  32. package/src/main.scss +1 -1
  33. package/src/payment/api/config.ts +7 -7
  34. package/src/payment/api/endpoints.ts +103 -78
  35. package/src/payment/api/index.ts +71 -71
  36. package/src/payment/components/AmountPicker.vue +93 -93
  37. package/src/payment/components/RechargeResult.vue +66 -54
  38. package/src/payment/components/RechargeView.vue +154 -154
  39. package/src/payment/components/RightsPicker.vue +106 -0
  40. package/src/payment/components/TradeView.vue +298 -0
  41. package/src/payment/components/UserAgreement.vue +141 -141
  42. package/src/payment/components/index.ts +22 -19
  43. package/src/payment/index.ts +5 -5
  44. package/src/payment/services/index.ts +16 -16
  45. package/src/payment/services/invoke-recharge.ts +25 -25
  46. package/src/payment/services/request-payment.ts +58 -31
  47. package/src/payment/types.ts +28 -23
  48. package/src/register/components/SelfRegistration.vue +227 -227
  49. package/src/register/components/index.ts +2 -2
  50. package/src/shared/components/AppDrawer.vue +58 -58
  51. package/src/shared/components/EmptyView.vue +33 -33
  52. package/src/shared/components/PageHeader.vue +79 -79
  53. package/src/shared/components/index.ts +6 -6
  54. package/src/shared/composables/index.ts +2 -2
  55. package/src/shared/composables/useSafeArea.ts +43 -43
  56. package/src/shared/composables/useTabbar.ts +24 -24
  57. package/src/shared/http/Http.ts +126 -126
  58. package/src/shared/http/index.ts +1 -1
  59. package/src/shared/http/types.ts +157 -157
  60. package/src/shared/index.ts +3 -3
  61. package/src/shared/weixin/payment.ts +38 -38
  62. package/src/styles/fonts.scss +2 -2
  63. package/src/styles/vars.scss +3 -3
  64. package/tsconfig.json +30 -30
  65. package/types/global.d.ts +21 -21
  66. package/types/vue.d.ts +10 -10
@@ -1,122 +1,125 @@
1
- import { HttpEndpoints } from "../../shared/http";
2
- import { 账户流水筛选项, ConsumptionType } from "../types";
3
-
4
- type OnlyApp = {
5
- app: string;
6
- };
7
-
8
- type AndApp<T> = OnlyApp & T;
9
-
10
- /**
11
- * 流水交易类型映射
12
- */
13
- const typeMappings: Record<string, ConsumptionType> = {
14
- CZ: "充值",
15
- JF: "缴费",
16
- FE: "返额",
17
- ZJ: "增加",
18
- KJ: "扣减",
19
- XH: "消耗",
20
- TH: "退回",
21
- };
22
-
23
- /**
24
- * 映射还能反过来
25
- */
26
- const typeMappingsReversed = Object.fromEntries(
27
- Object.entries(typeMappings).map(([x, y]) => [y, x])
28
- );
29
-
30
- const positionMappings = {
31
- common: "云豆",
32
- rights: "小云豆",
33
- gift: "权益",
34
- };
35
-
36
- const positionMappingsReversed = Object.fromEntries(
37
- Object.entries(positionMappings).map(([x, y]) => [y, x])
38
- );
39
-
40
- const directionMappings = {
41
- 0: "收入",
42
- 1: "支出",
43
- };
44
-
45
- const directionMappingsReversed = Object.fromEntries(
46
- Object.entries(directionMappings).map(([x, y]) => [y, x])
47
- );
48
-
49
- const endpointsList: HttpEndpoints = {
50
- 获取余额明细: {
51
- path: "/ac-app/account/info/detail/app", // /app
52
- translate: (data: OnlyApp) => ({
53
- appCode: data.app,
54
- }),
55
- transform(result: any) {
56
- return {
57
- total: result.commonAccount,
58
- privileges: result.rightsAccountBalList.map((r: any) => ({
59
- title: r.rightsName,
60
- count: r.rightsAccount,
61
- unit: r.rightsUnit,
62
- })),
63
- };
64
- },
65
- },
66
- 获取账户流水: {
67
- path: "/ac-app/account/record/detail/mobile",
68
- translate: (data: AndApp<账户流水筛选项>) => {
69
- return {
70
- appCode: data.app,
71
- accountType: positionMappingsReversed[data.账户类型] || "",
72
- inOrOut: directionMappingsReversed[data.收入还是支出] || "",
73
- changeType: typeMappingsReversed[data.交易类型] || "",
74
- operateTimeStart: data.dateFrom || "",
75
- operateTimeEnd: data.dateTo || "",
76
- rightsCode: data.权益类目,
77
- pageNum: data.page,
78
- pageSize: 10,
79
- };
80
- },
81
- transform(response: any) {
82
- const data = response.list.map((d: any) => ({
83
- 账户类型: positionMappings[d.accountType],
84
- 交易类型: typeMappings[d.changeType],
85
- 收入还是支出: directionMappings[d.inOrOut],
86
- amount: d.changeValue,
87
- title: d.rightsName,
88
- time: Date.parse(d.operateTime), // 后台返回的是日期字符串,这里格式化成 timestamp
89
- description: d.remark,
90
- }));
91
- return data;
92
- },
93
- },
94
- 获取权益类目: {
95
- path: "/ac-app/rights/item/list",
96
- translate: (data: OnlyApp) => ({
97
- appCode: data.app,
98
- }),
99
- // translate (data: ConsumptionFiltering) {
100
- // // return { appCode: data.appCode }
101
- // },
102
- transform: (data: any[]) =>
103
- data.map((d) => ({
104
- name: d.rightsName,
105
- code: d.rightsCode,
106
- })),
107
- },
108
- };
109
-
110
- const endpoints = Object.fromEntries(
111
- Object.entries(endpointsList).map(([name, def]) => [name, def.path])
112
- );
113
-
114
- const translates = Object.fromEntries(
115
- Object.entries(endpointsList).map(([, def]) => [def.path, def.translate])
116
- );
117
-
118
- const transforms = Object.fromEntries(
119
- Object.entries(endpointsList).map(([, def]) => [def.path, def.transform])
120
- );
121
-
122
- export { endpoints, translates, transforms };
1
+ import { HttpEndpoints } from "../../shared/http";
2
+ import { 账户流水筛选项, ConsumptionType } from "../types";
3
+
4
+ type OnlyApp = {
5
+ app: string;
6
+ };
7
+
8
+ type AndApp<T> = OnlyApp & T;
9
+
10
+ /**
11
+ * 流水交易类型映射
12
+ */
13
+ const typeMappings: Record<string, ConsumptionType> = {
14
+ CZ: "充值",
15
+ JF: "缴费",
16
+ FE: "返额",
17
+ ZJ: "增加",
18
+ KJ: "扣减",
19
+ XH: "消耗",
20
+ TH: "退回",
21
+ ZS: "赠送",
22
+ HG: "换购"
23
+ };
24
+
25
+ /**
26
+ * 映射还能反过来
27
+ */
28
+ const typeMappingsReversed = Object.fromEntries(
29
+ Object.entries(typeMappings).map(([x, y]) => [y, x])
30
+ );
31
+
32
+ const positionMappings = {
33
+ common: "云豆",
34
+ rights: "小云豆",
35
+ gift: "权益",
36
+ };
37
+
38
+ const positionMappingsReversed = Object.fromEntries(
39
+ Object.entries(positionMappings).map(([x, y]) => [y, x])
40
+ );
41
+
42
+ const directionMappings = {
43
+ 0: "收入",
44
+ 1: "支出",
45
+ };
46
+
47
+ const directionMappingsReversed = Object.fromEntries(
48
+ Object.entries(directionMappings).map(([x, y]) => [y, x])
49
+ );
50
+
51
+ const endpointsList: HttpEndpoints = {
52
+ 获取余额明细: {
53
+ path: "/ac-app/account/info/detail/app", // /app
54
+ translate: (data: OnlyApp) => ({
55
+ appCode: data.app,
56
+ }),
57
+ transform(result: any) {
58
+ return {
59
+ total: result.commonAccount,
60
+ privileges: result.rightsAccountBalList.map((r: any) => ({
61
+ title: r.rightsName,
62
+ count: r.rightsAccount,
63
+ unit: r.rightsUnit,
64
+ appCode: r.appCode
65
+ })),
66
+ };
67
+ },
68
+ },
69
+ 获取账户流水: {
70
+ path: "/ac-app/account/record/detail/mobile",
71
+ translate: (data: AndApp<账户流水筛选项>) => {
72
+ return {
73
+ appCode: data.app,
74
+ accountType: positionMappingsReversed[data.账户类型] || "",
75
+ inOrOut: directionMappingsReversed[data.收入还是支出] || "",
76
+ changeType: typeMappingsReversed[data.交易类型] || "",
77
+ operateTimeStart: data.dateFrom || "",
78
+ operateTimeEnd: data.dateTo || "",
79
+ rightsCode: data.权益类目,
80
+ pageNum: data.page,
81
+ pageSize: 10,
82
+ };
83
+ },
84
+ transform(response: any) {
85
+ const data = response.list.map((d: any) => ({
86
+ 账户类型: positionMappings[d.accountType],
87
+ 交易类型: typeMappings[d.changeType],
88
+ 收入还是支出: directionMappings[d.inOrOut],
89
+ amount: d.changeValue,
90
+ title: d.rightsName,
91
+ time: Date.parse(d.operateTime), // 后台返回的是日期字符串,这里格式化成 timestamp
92
+ description: d.remark,
93
+ }));
94
+ return data;
95
+ },
96
+ },
97
+ 获取权益类目: {
98
+ path: "/ac-app/rights/item/list",
99
+ translate: (data: OnlyApp) => ({
100
+ appCode: data.app,
101
+ }),
102
+ // translate (data: ConsumptionFiltering) {
103
+ // // return { appCode: data.appCode }
104
+ // },
105
+ transform: (data: any[]) =>
106
+ data.map((d) => ({
107
+ name: d.rightsName,
108
+ code: d.rightsCode,
109
+ })),
110
+ }
111
+ };
112
+
113
+ const endpoints = Object.fromEntries(
114
+ Object.entries(endpointsList).map(([name, def]) => [name, def.path])
115
+ );
116
+
117
+ const translates = Object.fromEntries(
118
+ Object.entries(endpointsList).map(([, def]) => [def.path, def.translate])
119
+ );
120
+
121
+ const transforms = Object.fromEntries(
122
+ Object.entries(endpointsList).map(([, def]) => [def.path, def.transform])
123
+ );
124
+
125
+ export { endpoints, translates, transforms };
@@ -1,82 +1,82 @@
1
- import Taro from '@tarojs/taro'
2
- import { HttpRequestConfig, PagingData, PagingParams, ResponseRaw, createHttp } from '../../shared'
3
- import { translates, transforms } from './endpoints'
4
- import { useAppKitOptions } from '../../Appkit'
5
-
6
- /**
7
- * 小程序端 Http
8
- * 使用 Taro.request 实现
9
- */
10
- const vendor = {
11
- async request<T>(config: HttpRequestConfig) {
12
- return new Promise<ResponseRaw<T>>((resolve, reject) => {
13
- Taro.request({
14
- url: config.url,
15
- method: config.method,
16
- header: config.headers,
17
- data: config.data,
18
- })
19
- .then(({ data }) => {
20
- resolve({
21
- status: +data.code,
22
- message: data.msg,
23
- data: data.result as T,
24
- })
25
- })
26
- .catch((e: any) => {
27
- reject(e)
28
- })
29
- })
30
- },
31
- }
32
-
33
- function useHttp() {
34
- const appkitOptions = useAppKitOptions()
35
- const headers = {
36
- Token: appkitOptions.tempToken() || appkitOptions.token(),
37
- Appcode: appkitOptions.app(),
38
- cookie: `tid=${appkitOptions.tenant()}`,
39
- gray: appkitOptions.gray ? appkitOptions.gray() : '0',
40
- }
41
- /**
42
- * 传入配置获取 Http instanse
43
- */
44
- const $http = createHttp({
45
- vendor,
46
- baseUrl: appkitOptions.baseUrl(),
47
- headers,
48
- interceptors: [
49
- (raw) => {
50
- if (raw.status == 401) {
51
- appkitOptions[401]()
52
- return true
53
- }
54
- return false
55
- },
56
- (raw) => {
57
- if (raw.status > 500) {
58
- return true
59
- }
60
- return false
61
- },
62
- ],
63
- paging: {
64
- translate: (params: PagingParams) => ({
65
- pageNum: params.page,
66
- pageSize: params.pageSize,
67
- }),
68
- transform(data: any): PagingData {
69
- return {
70
- totalPages: data.pages,
71
- }
72
- },
73
- },
74
- translates,
75
- transforms,
76
- })
77
- return $http
78
- }
79
-
80
- export { useHttp }
81
-
82
- export * from './endpoints'
1
+ import Taro from '@tarojs/taro'
2
+ import { HttpRequestConfig, PagingData, PagingParams, ResponseRaw, createHttp } from '../../shared'
3
+ import { translates, transforms } from './endpoints'
4
+ import { useAppKitOptions } from '../../Appkit'
5
+
6
+ /**
7
+ * 小程序端 Http
8
+ * 使用 Taro.request 实现
9
+ */
10
+ const vendor = {
11
+ async request<T>(config: HttpRequestConfig) {
12
+ return new Promise<ResponseRaw<T>>((resolve, reject) => {
13
+ Taro.request({
14
+ url: config.url,
15
+ method: config.method,
16
+ header: config.headers,
17
+ data: config.data,
18
+ })
19
+ .then(({ data }) => {
20
+ resolve({
21
+ status: +data.code,
22
+ message: data.msg,
23
+ data: data.result as T,
24
+ })
25
+ })
26
+ .catch((e: any) => {
27
+ reject(e)
28
+ })
29
+ })
30
+ },
31
+ }
32
+
33
+ function useHttp() {
34
+ const appkitOptions = useAppKitOptions()
35
+ const headers = {
36
+ Token: appkitOptions.tempToken() || appkitOptions.token(),
37
+ Appcode: appkitOptions.app(),
38
+ cookie: `tid=${appkitOptions.tenant()}`,
39
+ gray: appkitOptions.gray ? appkitOptions.gray() : '0',
40
+ }
41
+ /**
42
+ * 传入配置获取 Http instanse
43
+ */
44
+ const $http = createHttp({
45
+ vendor,
46
+ baseUrl: appkitOptions.baseUrl(),
47
+ headers,
48
+ interceptors: [
49
+ (raw) => {
50
+ if (raw.status == 401) {
51
+ appkitOptions[401]()
52
+ return true
53
+ }
54
+ return false
55
+ },
56
+ (raw) => {
57
+ if (raw.status > 500) {
58
+ return true
59
+ }
60
+ return false
61
+ },
62
+ ],
63
+ paging: {
64
+ translate: (params: PagingParams) => ({
65
+ pageNum: params.page,
66
+ pageSize: params.pageSize,
67
+ }),
68
+ transform(data: any): PagingData {
69
+ return {
70
+ totalPages: data.pages,
71
+ }
72
+ },
73
+ },
74
+ translates,
75
+ transforms,
76
+ })
77
+ return $http
78
+ }
79
+
80
+ export { useHttp }
81
+
82
+ export * from './endpoints'