@uxda/appkit 4.2.79 → 4.2.81

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/dist/index.js CHANGED
@@ -104,7 +104,7 @@ const getSdkConfig = (appCode, url) => {
104
104
  return new Promise((resolve, reject) => {
105
105
  const $http = useHttp$2();
106
106
  $http.get("/wecom/config/getConfig", {
107
- appCode: appCode || "loankitMp",
107
+ appCode: appCode || "cloudkitProMp",
108
108
  callbackUrl: url || encodeURIComponent(location.href.split("#")[0])
109
109
  }).then((response) => {
110
110
  resolve(response);
@@ -504,6 +504,35 @@ function useLogger(options) {
504
504
  };
505
505
  }
506
506
 
507
+ function useWxAuth() {
508
+ function toWxAuth(source, redirectUri) {
509
+ const $http = useHttp$2();
510
+ $http.get("/cas/auth/render/", {
511
+ source,
512
+ redirectUri
513
+ }).then((res) => {
514
+ location.replace(res);
515
+ });
516
+ }
517
+ async function toCallbackLogin({ code, state, source }, cb) {
518
+ const $http = useHttp$2();
519
+ const res = await $http.post(
520
+ `/cas/auth/callbackLogin/${source}`,
521
+ { code, state, source },
522
+ {
523
+ "Content-Type": "application/x-www-form-urlencoded"
524
+ }
525
+ );
526
+ if (res) {
527
+ cb && cb(res);
528
+ }
529
+ }
530
+ return {
531
+ toWxAuth,
532
+ toCallbackLogin
533
+ };
534
+ }
535
+
507
536
  const _hoisted_1$E = {
508
537
  key: 0,
509
538
  class: "page-title"
@@ -924,6 +953,13 @@ const vendor$3 = {
924
953
  header,
925
954
  data: config.data
926
955
  }).then(({ data }) => {
956
+ const endTime = (/* @__PURE__ */ new Date()).getTime();
957
+ logger$3.info({
958
+ send: JSON.stringify({ url: config.url, data: config.data }),
959
+ receive: JSON.stringify(data),
960
+ traceId: header.traceId,
961
+ duration: endTime - startTime
962
+ });
927
963
  if (data.success) {
928
964
  resolve({
929
965
  status: +data.code,
@@ -936,13 +972,6 @@ const vendor$3 = {
936
972
  icon: "none"
937
973
  });
938
974
  }
939
- const endTime = (/* @__PURE__ */ new Date()).getTime();
940
- logger$3.info({
941
- send: JSON.stringify({ url: config.url, data: config.data }),
942
- receive: JSON.stringify(data),
943
- traceId: header.traceId,
944
- duration: endTime - startTime
945
- });
946
975
  }).catch((e) => {
947
976
  reject(e);
948
977
  });
@@ -1414,11 +1443,12 @@ const get = (url, data) => {
1414
1443
  method: HttpMethod.get
1415
1444
  });
1416
1445
  };
1417
- const post = (url, data) => {
1446
+ const post = (url, data, headers) => {
1418
1447
  return request({
1419
1448
  url,
1420
1449
  data,
1421
- method: HttpMethod.post
1450
+ method: HttpMethod.post,
1451
+ headers
1422
1452
  });
1423
1453
  };
1424
1454
  const defaultClientConfig = {
@@ -1544,6 +1574,13 @@ const vendor$2 = {
1544
1574
  header,
1545
1575
  data: config.data
1546
1576
  }).then(({ data }) => {
1577
+ const endTime = (/* @__PURE__ */ new Date()).getTime();
1578
+ logger$2.info({
1579
+ send: JSON.stringify({ url: config.url, data: config.data }),
1580
+ receive: JSON.stringify(data),
1581
+ traceId: header.traceId,
1582
+ duration: endTime - startTime
1583
+ });
1547
1584
  if (data.success) {
1548
1585
  resolve({
1549
1586
  status: +data.code,
@@ -1556,13 +1593,6 @@ const vendor$2 = {
1556
1593
  icon: "none"
1557
1594
  });
1558
1595
  }
1559
- const endTime = (/* @__PURE__ */ new Date()).getTime();
1560
- logger$2.info({
1561
- send: JSON.stringify({ url: config.url, data: config.data }),
1562
- receive: JSON.stringify(data),
1563
- traceId: header.traceId,
1564
- duration: endTime - startTime
1565
- });
1566
1596
  }).catch((e) => {
1567
1597
  reject(e);
1568
1598
  });
@@ -1804,7 +1834,7 @@ var script$D = /* @__PURE__ */ defineComponent({
1804
1834
  }
1805
1835
  requestBrandWCPay({
1806
1836
  amount: amounts.value[state.selected].amount,
1807
- app: "loankitMp",
1837
+ app: "cloudkitProMp",
1808
1838
  tenant: props.tenant,
1809
1839
  accountAuthFlag: false,
1810
1840
  channelCode: "centergzh",
@@ -2187,7 +2217,7 @@ var script$z = /* @__PURE__ */ defineComponent({
2187
2217
  requestBrandWCPayByBean({
2188
2218
  caseConfigId: amounts.value[state.selected].id,
2189
2219
  amount: amounts.value[state.selected].paymentAmount,
2190
- app: "loankitMp",
2220
+ app: "cloudkitProMp",
2191
2221
  tenant: props.tenant,
2192
2222
  accountAuthFlag: false,
2193
2223
  channelCode: "centergzh",
@@ -4916,6 +4946,13 @@ const vendor$1 = {
4916
4946
  header,
4917
4947
  data: config.data
4918
4948
  }).then(({ data }) => {
4949
+ const endTime = (/* @__PURE__ */ new Date()).getTime();
4950
+ logger$1.info({
4951
+ send: JSON.stringify({ url: config.url, data: config.data }),
4952
+ receive: JSON.stringify(data),
4953
+ traceId: header.traceId,
4954
+ duration: endTime - startTime
4955
+ });
4919
4956
  if (data.success) {
4920
4957
  resolve({
4921
4958
  status: +data.code,
@@ -4928,13 +4965,6 @@ const vendor$1 = {
4928
4965
  icon: "none"
4929
4966
  });
4930
4967
  }
4931
- const endTime = (/* @__PURE__ */ new Date()).getTime();
4932
- logger$1.info({
4933
- send: JSON.stringify({ url: config.url, data: config.data }),
4934
- receive: JSON.stringify(data),
4935
- traceId: header.traceId,
4936
- duration: endTime - startTime
4937
- });
4938
4968
  }).catch((e) => {
4939
4969
  reject(e);
4940
4970
  });
@@ -5958,6 +5988,13 @@ const vendor = {
5958
5988
  header,
5959
5989
  data: config.data
5960
5990
  }).then(({ data }) => {
5991
+ const endTime = (/* @__PURE__ */ new Date()).getTime();
5992
+ logger.info({
5993
+ send: JSON.stringify({ url: config.url, data: config.data }),
5994
+ receive: JSON.stringify(data),
5995
+ traceId: header.traceId,
5996
+ duration: endTime - startTime
5997
+ });
5961
5998
  if (data.success) {
5962
5999
  resolve({
5963
6000
  status: +data.code,
@@ -5970,13 +6007,6 @@ const vendor = {
5970
6007
  icon: "none"
5971
6008
  });
5972
6009
  }
5973
- const endTime = (/* @__PURE__ */ new Date()).getTime();
5974
- logger.info({
5975
- send: JSON.stringify({ url: config.url, data: config.data }),
5976
- receive: JSON.stringify(data),
5977
- traceId: header.traceId,
5978
- duration: endTime - startTime
5979
- });
5980
6010
  }).catch((e) => {
5981
6011
  reject(e);
5982
6012
  });
@@ -9304,4 +9334,4 @@ const AppKit = {
9304
9334
  }
9305
9335
  };
9306
9336
 
9307
- export { script$s as AccountView, script$L as AmountPicker, script$J as AppDrawer, script$I as AppVerify, script$y as BalanceCard, script$r as BalanceReminder, script$q as DateRange, script$G as DeviceVersion, script$o as ListFilter, script$4 as LoginSetting, script$h as NoticeBanner, script$g as NoticeEntry, script$e as NoticeList, script$E as OcrBusinessLicense, script$F as OcrIcon, script$K as PageHeader, script$n as PromoterCard, script$B as RechargeResult, script$D as RechargeView, script$j as SelfRegistration, script as SharePoster, script$z as TradeView, script$C as UserAgreement, script$2 as UserAuth, script$a as UserBinding, script$9 as UserBindingSuccess, script$d as UserEntry, script$6 as UserFeedback, script$5 as UserFeedbackEntry, script$7 as UserHeadCrop, script$b as UserInfo, script$3 as UserResourceEmpty, components, createHttp, AppKit as default, defaultCryptoConfig, generateUniqueId, getSdkConfig, jssdkServices, requestPayment$2 as requestPayment, requestWxH5Pay, services$1 as services, useAppKit, useCountdown, useCrypto, useEncode, useLogger, useSafeArea, useTabbar, useUpload, useValidator };
9337
+ export { script$s as AccountView, script$L as AmountPicker, script$J as AppDrawer, script$I as AppVerify, script$y as BalanceCard, script$r as BalanceReminder, script$q as DateRange, script$G as DeviceVersion, script$o as ListFilter, script$4 as LoginSetting, script$h as NoticeBanner, script$g as NoticeEntry, script$e as NoticeList, script$E as OcrBusinessLicense, script$F as OcrIcon, script$K as PageHeader, script$n as PromoterCard, script$B as RechargeResult, script$D as RechargeView, script$j as SelfRegistration, script as SharePoster, script$z as TradeView, script$C as UserAgreement, script$2 as UserAuth, script$a as UserBinding, script$9 as UserBindingSuccess, script$d as UserEntry, script$6 as UserFeedback, script$5 as UserFeedbackEntry, script$7 as UserHeadCrop, script$b as UserInfo, script$3 as UserResourceEmpty, components, createHttp, AppKit as default, defaultCryptoConfig, generateUniqueId, getSdkConfig, jssdkServices, requestPayment$2 as requestPayment, requestWxH5Pay, services$1 as services, useAppKit, useCountdown, useCrypto, useEncode, useLogger, useSafeArea, useTabbar, useUpload, useValidator, useWxAuth };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxda/appkit",
3
- "version": "4.2.79",
3
+ "version": "4.2.81",
4
4
  "description": "小程序应用开发包",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.ts",
@@ -25,6 +25,15 @@ const vendor = {
25
25
  data: config.data,
26
26
  })
27
27
  .then(({ data }) => {
28
+ // 记录阿里日志
29
+ const endTime = new Date().getTime()
30
+ logger.info({
31
+ send: JSON.stringify({ url: config.url, data: config.data }),
32
+ receive: JSON.stringify(data),
33
+ traceId: header.traceId,
34
+ duration: endTime - startTime,
35
+ })
36
+
28
37
  if (data.success) {
29
38
  resolve({
30
39
  status: +data.code,
@@ -37,15 +46,6 @@ const vendor = {
37
46
  icon: 'none',
38
47
  })
39
48
  }
40
-
41
- // 记录阿里日志
42
- const endTime = new Date().getTime()
43
- logger.info({
44
- send: JSON.stringify({ url: config.url, data: config.data }),
45
- receive: JSON.stringify(data),
46
- traceId: header.traceId,
47
- duration: endTime - startTime,
48
- })
49
49
  })
50
50
  .catch((e: any) => {
51
51
  reject(e)
package/src/index.ts CHANGED
@@ -71,6 +71,7 @@ const AppKit = {
71
71
  appKitOptions.baseUrl = options.baseUrl
72
72
  appKitOptions[401] = options[401]
73
73
  appKitOptions.gray = options.gray
74
+
74
75
  nutComponents.forEach((component) => {
75
76
  app.use(component)
76
77
  })
@@ -25,6 +25,15 @@ const vendor = {
25
25
  data: config.data,
26
26
  })
27
27
  .then(({ data }) => {
28
+ // 记录阿里日志
29
+ const endTime = new Date().getTime()
30
+ logger.info({
31
+ send: JSON.stringify({ url: config.url, data: config.data }),
32
+ receive: JSON.stringify(data),
33
+ traceId: header.traceId,
34
+ duration: endTime - startTime,
35
+ })
36
+
28
37
  if (data.success) {
29
38
  resolve({
30
39
  status: +data.code,
@@ -37,15 +46,6 @@ const vendor = {
37
46
  icon: 'none',
38
47
  })
39
48
  }
40
-
41
- // 记录阿里日志
42
- const endTime = new Date().getTime()
43
- logger.info({
44
- send: JSON.stringify({ url: config.url, data: config.data }),
45
- receive: JSON.stringify(data),
46
- traceId: header.traceId,
47
- duration: endTime - startTime,
48
- })
49
49
  })
50
50
  .catch((e: any) => {
51
51
  reject(e)
@@ -25,6 +25,15 @@ const vendor = {
25
25
  data: config.data,
26
26
  })
27
27
  .then(({ data }) => {
28
+ // 记录阿里日志
29
+ const endTime = new Date().getTime()
30
+ logger.info({
31
+ send: JSON.stringify({ url: config.url, data: config.data }),
32
+ receive: JSON.stringify(data),
33
+ traceId: header.traceId,
34
+ duration: endTime - startTime,
35
+ })
36
+
28
37
  if (data.success) {
29
38
  resolve({
30
39
  status: +data.code,
@@ -37,15 +46,6 @@ const vendor = {
37
46
  icon: 'none',
38
47
  })
39
48
  }
40
-
41
- // 记录阿里日志
42
- const endTime = new Date().getTime()
43
- logger.info({
44
- send: JSON.stringify({ url: config.url, data: config.data }),
45
- receive: JSON.stringify(data),
46
- traceId: header.traceId,
47
- duration: endTime - startTime,
48
- })
49
49
  })
50
50
  .catch((e: any) => {
51
51
  reject(e)
@@ -67,6 +67,7 @@ function useHttp(defaultHeader?: DefaultHeaderType) {
67
67
  cookie: `tid=${defaultHeader?.Tenant || appkitOptions.tenant()}`,
68
68
  gray: appkitOptions.gray ? appkitOptions.gray() : '0',
69
69
  }
70
+
70
71
  /**
71
72
  * 传入配置获取 Http instanse
72
73
  */
@@ -105,7 +105,7 @@ const onPayClick = () => {
105
105
  }
106
106
  requestBrandWCPay({
107
107
  amount: amounts.value[state.selected].amount,
108
- app: 'loankitMp',
108
+ app: 'cloudkitProMp',
109
109
  tenant: props.tenant,
110
110
  accountAuthFlag: false,
111
111
  channelCode: 'centergzh',
@@ -176,7 +176,7 @@ const onPayClick = () => {
176
176
  requestBrandWCPayByBean({
177
177
  caseConfigId: amounts.value[state.selected].id,
178
178
  amount: amounts.value[state.selected].paymentAmount,
179
- app: 'loankitMp',
179
+ app: 'cloudkitProMp',
180
180
  tenant: props.tenant,
181
181
  accountAuthFlag: false,
182
182
  channelCode: 'centergzh',
@@ -6,3 +6,4 @@ export * from './useEncode'
6
6
  export * from './useUpload'
7
7
  export * from './useCrypto'
8
8
  export * from './useLogger'
9
+ export * from './useWxAuth'
@@ -0,0 +1,48 @@
1
+ /**
2
+ * @description: H5微信授权相关
3
+ */
4
+
5
+ import { useHttp } from '../../payment/api'
6
+
7
+ export function useWxAuth() {
8
+ /**
9
+ * 跳转微信授权页面,授权完成后,返回授权码code与state
10
+ * @param source 设备码
11
+ * @param redirectUri 重定向地址
12
+ */
13
+ function toWxAuth(source, redirectUri) {
14
+ const $http = useHttp()
15
+ $http
16
+ .get('/cas/auth/render/', {
17
+ source,
18
+ redirectUri,
19
+ })
20
+ .then((res: any) => {
21
+ location.replace(res)
22
+ })
23
+ }
24
+
25
+ /**
26
+ * 授权回调后,登录cas获取用户信息
27
+ * @param source
28
+ * @param state
29
+ */
30
+ async function toCallbackLogin({ code, state, source }, cb) {
31
+ const $http = useHttp()
32
+ const res = await $http.post(
33
+ `/cas/auth/callbackLogin/${source}`,
34
+ { code, state, source },
35
+ {
36
+ 'Content-Type': 'application/x-www-form-urlencoded',
37
+ }
38
+ )
39
+ if (res) {
40
+ cb && cb(res)
41
+ }
42
+ }
43
+
44
+ return {
45
+ toWxAuth,
46
+ toCallbackLogin,
47
+ }
48
+ }
@@ -8,6 +8,7 @@ import {
8
8
  ResponseRaw,
9
9
  Paging,
10
10
  HttpTranslate,
11
+ RequestHeaders,
11
12
  } from './types'
12
13
  /**
13
14
  * Useage:
@@ -96,11 +97,16 @@ const get: HttpInstance['get'] = <T = ResponseData>(url: string, data?: RequestD
96
97
  })
97
98
  }
98
99
 
99
- const post: HttpInstance['post'] = <T = ResponseData>(url: string, data: RequestData) => {
100
+ const post: HttpInstance['post'] = <T = ResponseData>(
101
+ url: string,
102
+ data: RequestData,
103
+ headers?: RequestHeaders
104
+ ) => {
100
105
  return request<T>({
101
106
  url,
102
107
  data,
103
108
  method: HttpMethod.post,
109
+ headers,
104
110
  })
105
111
  }
106
112
 
@@ -3,21 +3,21 @@
3
3
  * createHttp() 使用的配置
4
4
  */
5
5
  export type HttpClientConfig = {
6
- vendor?: HttpVendor,
7
- baseUrl: string,
6
+ vendor?: HttpVendor
7
+ baseUrl: string
8
8
  /**
9
9
  * 向 HTTP header 加入的数据
10
10
  * 通常含有 JWT token 以及其他参数
11
11
  */
12
- headers?: HeaderParams,
13
- paging?: Paging,
12
+ headers?: HeaderParams
13
+ paging?: Paging
14
14
  /**
15
15
  * 拦截器组
16
16
  * 请求返回异常时进行一定的操作
17
17
  */
18
- interceptors?: HttpInterceptor[],
19
- translates?: HttpTranslates,
20
- transforms?: HttpTransforms,
18
+ interceptors?: HttpInterceptor[]
19
+ translates?: HttpTranslates
20
+ transforms?: HttpTransforms
21
21
  }
22
22
 
23
23
  /**
@@ -25,7 +25,7 @@ export type HttpClientConfig = {
25
25
  * Axios/Taro.request
26
26
  */
27
27
  export type HttpVendor = {
28
- request <T = ResponseData>(config: HttpRequestConfig): Promise<ResponseRaw<T>>
28
+ request<T = ResponseData>(config: HttpRequestConfig): Promise<ResponseRaw<T>>
29
29
  }
30
30
 
31
31
  export type HttpInterceptor = (raw: ResponseRaw) => boolean
@@ -35,11 +35,11 @@ export type HttpInterceptor = (raw: ResponseRaw) => boolean
35
35
  * 沿用 Axios 的部分配置
36
36
  */
37
37
  export type HttpRequestConfig<D = RequestData> = {
38
- url: string,
39
- method?: HttpMethod,
40
- baseUrl?: string,
41
- headers?: HeaderData,
42
- data?: D,
38
+ url: string
39
+ method?: HttpMethod
40
+ baseUrl?: string
41
+ headers?: HeaderData
42
+ data?: D
43
43
  }
44
44
 
45
45
  /**
@@ -47,12 +47,14 @@ export type HttpRequestConfig<D = RequestData> = {
47
47
  */
48
48
  export type RequestData = Record<string, any>
49
49
 
50
+ export type RequestHeaders = Record<string, any>
51
+
50
52
  /**
51
53
  * 接口请求返回的标准格式
52
54
  */
53
55
  export type ResponseRaw<T = ResponseData> = {
54
- status: number,
55
- message: string,
56
+ status: number
57
+ message: string
56
58
  data: T
57
59
  }
58
60
 
@@ -63,8 +65,8 @@ export type ResponseData = Record<string, any> | any[]
63
65
 
64
66
  export type HttpInstance = {
65
67
  request<T = ResponseData>(config: HttpRequestConfig): Promise<T>
66
- get<T = ResponseData>(url: string, data?: RequestData): Promise<T>,
67
- post<T = ResponseData>(url: string, data?: RequestData): Promise<T>,
68
+ get<T = ResponseData>(url: string, data?: RequestData): Promise<T>
69
+ post<T = ResponseData>(url: string, data?: RequestData, headers?: RequestHeaders): Promise<T>
68
70
  }
69
71
 
70
72
  /**
@@ -88,7 +90,7 @@ export enum HttpMethod {
88
90
 
89
91
  export enum HttpError {
90
92
  auth = 'auth',
91
- server = 'server'
93
+ server = 'server',
92
94
  }
93
95
 
94
96
  export type HeaderData = Record<string, string>
@@ -107,9 +109,9 @@ export type HttpTransform = (data: ResponseData) => ResponseData
107
109
  * 接口设置
108
110
  */
109
111
  export type HttpEndpoint = {
110
- path: string,
111
- translate?: HttpTranslate,
112
- transform?: HttpTransform,
112
+ path: string
113
+ translate?: HttpTranslate
114
+ transform?: HttpTransform
113
115
  }
114
116
 
115
117
  /**
@@ -126,33 +128,33 @@ export type PagingParams = {
126
128
  /**
127
129
  * 页数
128
130
  */
129
- page: number,
131
+ page: number
130
132
  /**
131
133
  * 页数据条数
132
134
  */
133
- pageSize: number,
135
+ pageSize: number
134
136
  }
135
137
 
136
138
  export type PagingData = {
137
139
  /**
138
140
  * 页总数
139
141
  */
140
- totalPages: number,
142
+ totalPages: number
141
143
  }
142
144
 
143
145
  /**
144
146
  * Wrapped with Paging Data
145
147
  */
146
148
  export type WithPaging<T = ResponseData> = {
147
- [K in keyof PagingData]: PagingData[K];
149
+ [K in keyof PagingData]: PagingData[K]
148
150
  } & {
149
- data: T;
151
+ data: T
150
152
  }
151
153
 
152
154
  /**
153
155
  * 分页设置
154
156
  */
155
157
  export type Paging = {
156
- translate (params: PagingParams): any,
157
- transform (resonse: any): PagingData,
158
- }
158
+ translate(params: PagingParams): any
159
+ transform(resonse: any): PagingData
160
+ }
@@ -29,7 +29,7 @@ const getSdkConfig = (appCode?: string, url?: string): Promise<JssdkConfig> => {
29
29
 
30
30
  $http
31
31
  .get('/wecom/config/getConfig', {
32
- appCode: appCode || 'loankitMp',
32
+ appCode: appCode || 'cloudkitProMp',
33
33
  callbackUrl: url || encodeURIComponent(location.href.split('#')[0]),
34
34
  })
35
35
  .then((response: JssdkConfig) => {
@@ -25,6 +25,15 @@ const vendor = {
25
25
  data: config.data,
26
26
  })
27
27
  .then(({ data }) => {
28
+ // 记录阿里日志
29
+ const endTime = new Date().getTime()
30
+ logger.info({
31
+ send: JSON.stringify({ url: config.url, data: config.data }),
32
+ receive: JSON.stringify(data),
33
+ traceId: header.traceId,
34
+ duration: endTime - startTime,
35
+ })
36
+
28
37
  if (data.success) {
29
38
  resolve({
30
39
  status: +data.code,
@@ -37,15 +46,6 @@ const vendor = {
37
46
  icon: 'none',
38
47
  })
39
48
  }
40
-
41
- // 记录阿里日志
42
- const endTime = new Date().getTime()
43
- logger.info({
44
- send: JSON.stringify({ url: config.url, data: config.data }),
45
- receive: JSON.stringify(data),
46
- traceId: header.traceId,
47
- duration: endTime - startTime,
48
- })
49
49
  })
50
50
  .catch((e: any) => {
51
51
  reject(e)