@uxda/appkit 4.1.24 → 4.1.26
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 +212 -50
- package/package.json +1 -1
- package/src/Appkit.ts +0 -6
- package/src/balance/api/index.ts +29 -5
- package/src/index.ts +0 -4
- package/src/notice/api/index.ts +29 -5
- package/src/payment/api/index.ts +37 -8
- package/src/payment/components/RechargeView.vue +14 -11
- package/src/shared/composables/index.ts +1 -0
- package/src/shared/composables/useLogger.ts +123 -0
- package/src/user/api/index.ts +29 -5
package/dist/index.js
CHANGED
|
@@ -316,6 +316,113 @@ function useCrypto(config) {
|
|
|
316
316
|
};
|
|
317
317
|
}
|
|
318
318
|
|
|
319
|
+
const globalData = {};
|
|
320
|
+
|
|
321
|
+
const appKitOptions = {
|
|
322
|
+
app: () => "",
|
|
323
|
+
tenant: () => "",
|
|
324
|
+
token: () => "",
|
|
325
|
+
tempToken: () => "",
|
|
326
|
+
baseUrl: () => "",
|
|
327
|
+
401() {
|
|
328
|
+
},
|
|
329
|
+
gray: () => ""
|
|
330
|
+
};
|
|
331
|
+
const useAppKitOptions = () => {
|
|
332
|
+
if (!globalData.$appKitOptions) {
|
|
333
|
+
globalData.$appKitOptions = appKitOptions;
|
|
334
|
+
}
|
|
335
|
+
return globalData.$appKitOptions;
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
const defaultLogOptions = {
|
|
339
|
+
projectName: "ddyk-dev",
|
|
340
|
+
logStore: "ddjf-internet-web",
|
|
341
|
+
topic: "appkit",
|
|
342
|
+
enable: true
|
|
343
|
+
};
|
|
344
|
+
function generateUniqueId(pre) {
|
|
345
|
+
return `${pre ? pre + "-" : ""}${Date.now().toString(16)}-${Math.random().toString(36).substr(2)}`;
|
|
346
|
+
}
|
|
347
|
+
function useLogger(options) {
|
|
348
|
+
const appkitOptions = useAppKitOptions();
|
|
349
|
+
const url = appkitOptions.baseUrl();
|
|
350
|
+
if (url.includes("ytech.ddjf.com")) {
|
|
351
|
+
defaultLogOptions.projectName = "ddyk-prod";
|
|
352
|
+
}
|
|
353
|
+
if (options) {
|
|
354
|
+
options = Object.assign(defaultLogOptions, options);
|
|
355
|
+
} else {
|
|
356
|
+
options = defaultLogOptions;
|
|
357
|
+
}
|
|
358
|
+
const projectName = options.projectName;
|
|
359
|
+
const logStore = options.logStore;
|
|
360
|
+
const topic = options.topic || "";
|
|
361
|
+
const APIVersion = "0.6.0";
|
|
362
|
+
const baseUrl = `https://${projectName}.cn-shenzhen.log.aliyuncs.com/logstores/${logStore}/track?APIVersion=${APIVersion}`;
|
|
363
|
+
const alislsURL = topic ? `${baseUrl}&__topic__=${topic}` : baseUrl;
|
|
364
|
+
const enable = options.enable === void 0 ? true : options.enable;
|
|
365
|
+
const { miniProgram } = Taro.getAccountInfoSync();
|
|
366
|
+
const systemInfo = JSON.stringify({
|
|
367
|
+
...Taro.getSystemInfoSync(),
|
|
368
|
+
appVersion: miniProgram.version
|
|
369
|
+
}) || "\u672A\u77E5";
|
|
370
|
+
function send(params) {
|
|
371
|
+
if (!enable) return;
|
|
372
|
+
params.systemInfo = systemInfo;
|
|
373
|
+
const token = appkitOptions.tempToken() || appkitOptions.token();
|
|
374
|
+
if (token) {
|
|
375
|
+
params.userInfo = token;
|
|
376
|
+
}
|
|
377
|
+
if (params.msg && !params.send) {
|
|
378
|
+
params.send = params.msg;
|
|
379
|
+
}
|
|
380
|
+
if (params.send) {
|
|
381
|
+
params.send = params.send.slice(0, 1024);
|
|
382
|
+
}
|
|
383
|
+
if (params.receive) {
|
|
384
|
+
params.receive = params.receive.slice(0, 1024);
|
|
385
|
+
}
|
|
386
|
+
if (params.duration) {
|
|
387
|
+
params.duration = params.duration;
|
|
388
|
+
}
|
|
389
|
+
const pages = Taro.getCurrentPages();
|
|
390
|
+
const currentPage = pages?.[pages.length - 1];
|
|
391
|
+
const lastPage = pages?.[pages.length - 2];
|
|
392
|
+
params.pages = JSON.stringify({
|
|
393
|
+
current: currentPage?.$taroPath,
|
|
394
|
+
last: lastPage?.$taroPath
|
|
395
|
+
}).slice(0, 1024);
|
|
396
|
+
console.log(params);
|
|
397
|
+
const tmpStr = Object.keys(params).map((key) => `${key}=${encodeURIComponent(params[key])}`).join("&");
|
|
398
|
+
const url2 = `${alislsURL}&${tmpStr}`;
|
|
399
|
+
Taro.request({ url: url2 });
|
|
400
|
+
}
|
|
401
|
+
function info(params) {
|
|
402
|
+
if (!enable) return;
|
|
403
|
+
send({
|
|
404
|
+
send: params.send ?? "",
|
|
405
|
+
receive: params.receive ?? "",
|
|
406
|
+
duration: params.duration ?? "",
|
|
407
|
+
traceId: params.traceId,
|
|
408
|
+
level: "info"
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
function error(params) {
|
|
412
|
+
if (!enable) return;
|
|
413
|
+
send({
|
|
414
|
+
send: params.send ?? "",
|
|
415
|
+
receive: params.receive ?? "",
|
|
416
|
+
traceId: params.traceId,
|
|
417
|
+
level: "error"
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
return {
|
|
421
|
+
info,
|
|
422
|
+
error
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
|
|
319
426
|
const _hoisted_1$A = {
|
|
320
427
|
key: 0,
|
|
321
428
|
class: "page-title"
|
|
@@ -714,39 +821,39 @@ const transforms$3 = Object.fromEntries(
|
|
|
714
821
|
Object.entries(endpointsList$3).map(([, def]) => [def.path, def.transform])
|
|
715
822
|
);
|
|
716
823
|
|
|
717
|
-
const
|
|
718
|
-
|
|
719
|
-
const appKitOptions = {
|
|
720
|
-
app: () => "",
|
|
721
|
-
tenant: () => "",
|
|
722
|
-
token: () => "",
|
|
723
|
-
tempToken: () => "",
|
|
724
|
-
tempAppcode: () => "",
|
|
725
|
-
baseUrl: () => "",
|
|
726
|
-
401() {
|
|
727
|
-
},
|
|
728
|
-
gray: () => ""
|
|
729
|
-
};
|
|
730
|
-
const useAppKitOptions = () => {
|
|
731
|
-
if (!globalData.$appKitOptions) {
|
|
732
|
-
globalData.$appKitOptions = appKitOptions;
|
|
733
|
-
}
|
|
734
|
-
return globalData.$appKitOptions;
|
|
735
|
-
};
|
|
736
|
-
|
|
824
|
+
const logger$3 = useLogger();
|
|
737
825
|
const vendor$3 = {
|
|
738
826
|
async request(config) {
|
|
739
827
|
return new Promise((resolve, reject) => {
|
|
828
|
+
const header = {
|
|
829
|
+
...config.headers,
|
|
830
|
+
traceId: generateUniqueId("appkit")
|
|
831
|
+
};
|
|
832
|
+
const startTime = (/* @__PURE__ */ new Date()).getTime();
|
|
740
833
|
Taro.request({
|
|
741
834
|
url: config.url,
|
|
742
835
|
method: config.method,
|
|
743
|
-
header
|
|
836
|
+
header,
|
|
744
837
|
data: config.data
|
|
745
838
|
}).then(({ data }) => {
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
839
|
+
if (data.success) {
|
|
840
|
+
resolve({
|
|
841
|
+
status: +data.code,
|
|
842
|
+
message: data.msg,
|
|
843
|
+
data: data.result
|
|
844
|
+
});
|
|
845
|
+
} else if (data.code !== "401") {
|
|
846
|
+
Taro.showToast({
|
|
847
|
+
title: data.msg,
|
|
848
|
+
icon: "none"
|
|
849
|
+
});
|
|
850
|
+
}
|
|
851
|
+
const endTime = (/* @__PURE__ */ new Date()).getTime();
|
|
852
|
+
logger$3.info({
|
|
853
|
+
send: JSON.stringify({ url: config.url, data: config.data }),
|
|
854
|
+
receive: JSON.stringify(data),
|
|
855
|
+
traceId: header.traceId,
|
|
856
|
+
duration: endTime - startTime
|
|
750
857
|
});
|
|
751
858
|
}).catch((e) => {
|
|
752
859
|
reject(e);
|
|
@@ -1245,19 +1352,39 @@ const transforms$2 = Object.fromEntries(
|
|
|
1245
1352
|
Object.entries(endpointsList$2).map(([, def]) => [def.path, def.transform])
|
|
1246
1353
|
);
|
|
1247
1354
|
|
|
1355
|
+
const logger$2 = useLogger();
|
|
1248
1356
|
const vendor$2 = {
|
|
1249
1357
|
async request(config) {
|
|
1250
1358
|
return new Promise((resolve, reject) => {
|
|
1359
|
+
const header = {
|
|
1360
|
+
...config.headers,
|
|
1361
|
+
traceId: generateUniqueId("appkit")
|
|
1362
|
+
};
|
|
1363
|
+
const startTime = (/* @__PURE__ */ new Date()).getTime();
|
|
1251
1364
|
Taro.request({
|
|
1252
1365
|
url: config.url,
|
|
1253
1366
|
method: config.method,
|
|
1254
|
-
header
|
|
1367
|
+
header,
|
|
1255
1368
|
data: config.data
|
|
1256
1369
|
}).then(({ data }) => {
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1370
|
+
if (data.success) {
|
|
1371
|
+
resolve({
|
|
1372
|
+
status: +data.code,
|
|
1373
|
+
message: data.msg,
|
|
1374
|
+
data: data.result
|
|
1375
|
+
});
|
|
1376
|
+
} else if (data.code !== "401") {
|
|
1377
|
+
Taro.showToast({
|
|
1378
|
+
title: data.msg,
|
|
1379
|
+
icon: "none"
|
|
1380
|
+
});
|
|
1381
|
+
}
|
|
1382
|
+
const endTime = (/* @__PURE__ */ new Date()).getTime();
|
|
1383
|
+
logger$2.info({
|
|
1384
|
+
send: JSON.stringify({ url: config.url, data: config.data }),
|
|
1385
|
+
receive: JSON.stringify(data),
|
|
1386
|
+
traceId: header.traceId,
|
|
1387
|
+
duration: endTime - startTime
|
|
1261
1388
|
});
|
|
1262
1389
|
}).catch((e) => {
|
|
1263
1390
|
reject(e);
|
|
@@ -1265,12 +1392,12 @@ const vendor$2 = {
|
|
|
1265
1392
|
});
|
|
1266
1393
|
}
|
|
1267
1394
|
};
|
|
1268
|
-
function useHttp$2() {
|
|
1395
|
+
function useHttp$2(defaultHeader) {
|
|
1269
1396
|
const appkitOptions = useAppKitOptions();
|
|
1270
1397
|
const headers = {
|
|
1271
1398
|
Token: appkitOptions.tempToken() || appkitOptions.token(),
|
|
1272
|
-
Appcode:
|
|
1273
|
-
cookie: `tid=${appkitOptions.tenant()}`,
|
|
1399
|
+
Appcode: defaultHeader?.Appcode || appkitOptions.app(),
|
|
1400
|
+
cookie: `tid=${defaultHeader?.Tenant || appkitOptions.tenant()}`,
|
|
1274
1401
|
gray: appkitOptions.gray ? appkitOptions.gray() : "0"
|
|
1275
1402
|
};
|
|
1276
1403
|
const $http = createHttp({
|
|
@@ -1401,10 +1528,9 @@ var script$A = /* @__PURE__ */ defineComponent({
|
|
|
1401
1528
|
state.selected = selected;
|
|
1402
1529
|
};
|
|
1403
1530
|
onMounted(() => {
|
|
1404
|
-
const $http = useHttp$2();
|
|
1531
|
+
const $http = useHttp$2({ Appcode: props.app !== "cloudkitPro" ? props.app : "", Tenant: props.tenant });
|
|
1405
1532
|
$http.get(endpoints.\u83B7\u53D6\u5145\u503C\u91D1\u989D\u5217\u8868, {
|
|
1406
1533
|
app: props.app,
|
|
1407
|
-
// stage: 'aiApproveRecharge', // 支付场景
|
|
1408
1534
|
tenant: props.tenant
|
|
1409
1535
|
}).then((response) => {
|
|
1410
1536
|
amounts.value = response;
|
|
@@ -4202,19 +4328,39 @@ const transforms$1 = Object.fromEntries(
|
|
|
4202
4328
|
Object.entries(endpointsList$1).map(([, def]) => [def.path, def.transform])
|
|
4203
4329
|
);
|
|
4204
4330
|
|
|
4331
|
+
const logger$1 = useLogger();
|
|
4205
4332
|
const vendor$1 = {
|
|
4206
4333
|
async request(config) {
|
|
4207
4334
|
return new Promise((resolve, reject) => {
|
|
4335
|
+
const header = {
|
|
4336
|
+
...config.headers,
|
|
4337
|
+
traceId: generateUniqueId("appkit")
|
|
4338
|
+
};
|
|
4339
|
+
const startTime = (/* @__PURE__ */ new Date()).getTime();
|
|
4208
4340
|
Taro.request({
|
|
4209
4341
|
url: config.url,
|
|
4210
4342
|
method: config.method,
|
|
4211
|
-
header
|
|
4343
|
+
header,
|
|
4212
4344
|
data: config.data
|
|
4213
4345
|
}).then(({ data }) => {
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
|
|
4346
|
+
if (data.success) {
|
|
4347
|
+
resolve({
|
|
4348
|
+
status: +data.code,
|
|
4349
|
+
message: data.msg,
|
|
4350
|
+
data: data.result
|
|
4351
|
+
});
|
|
4352
|
+
} else if (data.code !== "401") {
|
|
4353
|
+
Taro.showToast({
|
|
4354
|
+
title: data.msg,
|
|
4355
|
+
icon: "none"
|
|
4356
|
+
});
|
|
4357
|
+
}
|
|
4358
|
+
const endTime = (/* @__PURE__ */ new Date()).getTime();
|
|
4359
|
+
logger$1.info({
|
|
4360
|
+
send: JSON.stringify({ url: config.url, data: config.data }),
|
|
4361
|
+
receive: JSON.stringify(data),
|
|
4362
|
+
traceId: header.traceId,
|
|
4363
|
+
duration: endTime - startTime
|
|
4218
4364
|
});
|
|
4219
4365
|
}).catch((e) => {
|
|
4220
4366
|
reject(e);
|
|
@@ -5206,19 +5352,39 @@ const transforms = Object.fromEntries(
|
|
|
5206
5352
|
Object.entries(endpointsList).map(([, def]) => [def.path, def.transform])
|
|
5207
5353
|
);
|
|
5208
5354
|
|
|
5355
|
+
const logger = useLogger();
|
|
5209
5356
|
const vendor = {
|
|
5210
5357
|
async request(config) {
|
|
5211
5358
|
return new Promise((resolve, reject) => {
|
|
5359
|
+
const header = {
|
|
5360
|
+
...config.headers,
|
|
5361
|
+
traceId: generateUniqueId("appkit")
|
|
5362
|
+
};
|
|
5363
|
+
const startTime = (/* @__PURE__ */ new Date()).getTime();
|
|
5212
5364
|
Taro.request({
|
|
5213
5365
|
url: config.url,
|
|
5214
5366
|
method: config.method,
|
|
5215
|
-
header
|
|
5367
|
+
header,
|
|
5216
5368
|
data: config.data
|
|
5217
5369
|
}).then(({ data }) => {
|
|
5218
|
-
|
|
5219
|
-
|
|
5220
|
-
|
|
5221
|
-
|
|
5370
|
+
if (data.success) {
|
|
5371
|
+
resolve({
|
|
5372
|
+
status: +data.code,
|
|
5373
|
+
message: data.msg,
|
|
5374
|
+
data: data.result
|
|
5375
|
+
});
|
|
5376
|
+
} else if (data.code !== "401") {
|
|
5377
|
+
Taro.showToast({
|
|
5378
|
+
title: data.msg,
|
|
5379
|
+
icon: "none"
|
|
5380
|
+
});
|
|
5381
|
+
}
|
|
5382
|
+
const endTime = (/* @__PURE__ */ new Date()).getTime();
|
|
5383
|
+
logger.info({
|
|
5384
|
+
send: JSON.stringify({ url: config.url, data: config.data }),
|
|
5385
|
+
receive: JSON.stringify(data),
|
|
5386
|
+
traceId: header.traceId,
|
|
5387
|
+
duration: endTime - startTime
|
|
5222
5388
|
});
|
|
5223
5389
|
}).catch((e) => {
|
|
5224
5390
|
reject(e);
|
|
@@ -7740,10 +7906,6 @@ const $app = {
|
|
|
7740
7906
|
const appKitOptions = useAppKitOptions();
|
|
7741
7907
|
appKitOptions.tempToken = token;
|
|
7742
7908
|
},
|
|
7743
|
-
setTempAppcode: (appcode) => {
|
|
7744
|
-
const appKitOptions = useAppKitOptions();
|
|
7745
|
-
appKitOptions.tempAppcode = appcode;
|
|
7746
|
-
},
|
|
7747
7909
|
requestPayment: (options) => {
|
|
7748
7910
|
},
|
|
7749
7911
|
invokeRecharge: (options) => {
|
|
@@ -7770,4 +7932,4 @@ const AppKit = {
|
|
|
7770
7932
|
}
|
|
7771
7933
|
};
|
|
7772
7934
|
|
|
7773
|
-
export { script$p as AccountView, script$I as AmountPicker, script$G as AppDrawer, script$F as AppVerify, script$v as BalanceCard, script$o as BalanceReminder, script$n as DateRange, script$D as DeviceVersion, script$l as ListFilter, script$1 as LoginSetting, script$e as NoticeBanner, script$d as NoticeEntry, script$b as NoticeList, script$B as OcrBusinessLicense, script$C as OcrIcon, script$H as PageHeader, script$y as RechargeResult, script$A as RechargeView, script$g as SelfRegistration, script$w as TradeView, script$z as UserAgreement, script$7 as UserBinding, script$6 as UserBindingSuccess, script$a as UserEntry, script$3 as UserFeedback, script$2 as UserFeedbackEntry, script$4 as UserHeadCrop, script$8 as UserInfo, script as UserResourceEmpty, components, createHttp, AppKit as default, defaultCryptoConfig, requestPayment$2 as requestPayment, services$1 as services, useAppKit, useCountdown, useCrypto, useEncode, useSafeArea, useTabbar, useUpload, useValidator };
|
|
7935
|
+
export { script$p as AccountView, script$I as AmountPicker, script$G as AppDrawer, script$F as AppVerify, script$v as BalanceCard, script$o as BalanceReminder, script$n as DateRange, script$D as DeviceVersion, script$l as ListFilter, script$1 as LoginSetting, script$e as NoticeBanner, script$d as NoticeEntry, script$b as NoticeList, script$B as OcrBusinessLicense, script$C as OcrIcon, script$H as PageHeader, script$y as RechargeResult, script$A as RechargeView, script$g as SelfRegistration, script$w as TradeView, script$z as UserAgreement, script$7 as UserBinding, script$6 as UserBindingSuccess, script$a as UserEntry, script$3 as UserFeedback, script$2 as UserFeedbackEntry, script$4 as UserHeadCrop, script$8 as UserInfo, script as UserResourceEmpty, components, createHttp, AppKit as default, defaultCryptoConfig, generateUniqueId, requestPayment$2 as requestPayment, services$1 as services, useAppKit, useCountdown, useCrypto, useEncode, useLogger, useSafeArea, useTabbar, useUpload, useValidator };
|
package/package.json
CHANGED
package/src/Appkit.ts
CHANGED
|
@@ -27,10 +27,6 @@ export type AppKitOptions = {
|
|
|
27
27
|
* 临时 appcode 获取方法
|
|
28
28
|
* 由使用场景提供
|
|
29
29
|
*/
|
|
30
|
-
tempAppcode: () => string
|
|
31
|
-
/**
|
|
32
|
-
* 调用 API 时使用的 base url
|
|
33
|
-
*/
|
|
34
30
|
baseUrl(): string
|
|
35
31
|
|
|
36
32
|
401(): void
|
|
@@ -43,7 +39,6 @@ export type AppKitOptions = {
|
|
|
43
39
|
export type DollarApp = {
|
|
44
40
|
setToken: (token: () => string) => void
|
|
45
41
|
setTempToken: (token: () => string) => void
|
|
46
|
-
setTempAppcode: (appcode: () => string) => void
|
|
47
42
|
requestPayment: (options: PaymentParams) => void
|
|
48
43
|
invokeRecharge: (options: RechargeParams) => void
|
|
49
44
|
}
|
|
@@ -56,7 +51,6 @@ const appKitOptions: AppKitOptions = {
|
|
|
56
51
|
tenant: () => '',
|
|
57
52
|
token: () => '',
|
|
58
53
|
tempToken: () => '',
|
|
59
|
-
tempAppcode: () => '',
|
|
60
54
|
baseUrl: () => '',
|
|
61
55
|
401() {},
|
|
62
56
|
gray: () => '',
|
package/src/balance/api/index.ts
CHANGED
|
@@ -2,7 +2,9 @@ import Taro from '@tarojs/taro'
|
|
|
2
2
|
import { HttpRequestConfig, PagingData, PagingParams, ResponseRaw, createHttp } from '../../shared'
|
|
3
3
|
import { translates, transforms } from './endpoints'
|
|
4
4
|
import { useAppKitOptions } from '../../Appkit'
|
|
5
|
+
import { useLogger, generateUniqueId } from '../../shared/composables/useLogger'
|
|
5
6
|
|
|
7
|
+
const logger = useLogger()
|
|
6
8
|
/**
|
|
7
9
|
* 小程序端 Http
|
|
8
10
|
* 使用 Taro.request 实现
|
|
@@ -10,17 +12,39 @@ import { useAppKitOptions } from '../../Appkit'
|
|
|
10
12
|
const vendor = {
|
|
11
13
|
async request<T>(config: HttpRequestConfig) {
|
|
12
14
|
return new Promise<ResponseRaw<T>>((resolve, reject) => {
|
|
15
|
+
const header = {
|
|
16
|
+
...config.headers,
|
|
17
|
+
traceId: generateUniqueId('appkit'),
|
|
18
|
+
}
|
|
19
|
+
const startTime = new Date().getTime()
|
|
20
|
+
|
|
13
21
|
Taro.request({
|
|
14
22
|
url: config.url,
|
|
15
23
|
method: config.method,
|
|
16
|
-
header
|
|
24
|
+
header,
|
|
17
25
|
data: config.data,
|
|
18
26
|
})
|
|
19
27
|
.then(({ data }) => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
28
|
+
if (data.success) {
|
|
29
|
+
resolve({
|
|
30
|
+
status: +data.code,
|
|
31
|
+
message: data.msg,
|
|
32
|
+
data: data.result as T,
|
|
33
|
+
})
|
|
34
|
+
} else if (data.code !== '401') {
|
|
35
|
+
Taro.showToast({
|
|
36
|
+
title: data.msg,
|
|
37
|
+
icon: 'none',
|
|
38
|
+
})
|
|
39
|
+
}
|
|
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,
|
|
24
48
|
})
|
|
25
49
|
})
|
|
26
50
|
.catch((e: any) => {
|
package/src/index.ts
CHANGED
|
@@ -48,10 +48,6 @@ const $app: DollarApp = {
|
|
|
48
48
|
const appKitOptions = useAppKitOptions()
|
|
49
49
|
appKitOptions.tempToken = token
|
|
50
50
|
},
|
|
51
|
-
setTempAppcode: (appcode: () => string) => {
|
|
52
|
-
const appKitOptions = useAppKitOptions()
|
|
53
|
-
appKitOptions.tempAppcode = appcode
|
|
54
|
-
},
|
|
55
51
|
requestPayment: (options: PaymentParams) => {},
|
|
56
52
|
invokeRecharge: (options: RechargeParams) => {},
|
|
57
53
|
}
|
package/src/notice/api/index.ts
CHANGED
|
@@ -2,7 +2,9 @@ import Taro from '@tarojs/taro'
|
|
|
2
2
|
import { HttpRequestConfig, PagingData, PagingParams, ResponseRaw, createHttp } from '../../shared'
|
|
3
3
|
import { translates, transforms } from './endpoints'
|
|
4
4
|
import { useAppKitOptions } from '../../Appkit'
|
|
5
|
+
import { useLogger, generateUniqueId } from '../../shared/composables/useLogger'
|
|
5
6
|
|
|
7
|
+
const logger = useLogger()
|
|
6
8
|
/**
|
|
7
9
|
* 小程序端 Http
|
|
8
10
|
* 使用 Taro.request 实现
|
|
@@ -10,17 +12,39 @@ import { useAppKitOptions } from '../../Appkit'
|
|
|
10
12
|
const vendor = {
|
|
11
13
|
async request<T>(config: HttpRequestConfig) {
|
|
12
14
|
return new Promise<ResponseRaw<T>>((resolve, reject) => {
|
|
15
|
+
const header = {
|
|
16
|
+
...config.headers,
|
|
17
|
+
traceId: generateUniqueId('appkit'),
|
|
18
|
+
}
|
|
19
|
+
const startTime = new Date().getTime()
|
|
20
|
+
|
|
13
21
|
Taro.request({
|
|
14
22
|
url: config.url,
|
|
15
23
|
method: config.method,
|
|
16
|
-
header
|
|
24
|
+
header,
|
|
17
25
|
data: config.data,
|
|
18
26
|
})
|
|
19
27
|
.then(({ data }) => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
28
|
+
if (data.success) {
|
|
29
|
+
resolve({
|
|
30
|
+
status: +data.code,
|
|
31
|
+
message: data.msg,
|
|
32
|
+
data: data.result as T,
|
|
33
|
+
})
|
|
34
|
+
} else if (data.code !== '401') {
|
|
35
|
+
Taro.showToast({
|
|
36
|
+
title: data.msg,
|
|
37
|
+
icon: 'none',
|
|
38
|
+
})
|
|
39
|
+
}
|
|
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,
|
|
24
48
|
})
|
|
25
49
|
})
|
|
26
50
|
.catch((e: any) => {
|
package/src/payment/api/index.ts
CHANGED
|
@@ -2,7 +2,9 @@ import Taro from '@tarojs/taro'
|
|
|
2
2
|
import { HttpRequestConfig, ResponseRaw, createHttp } from '../../shared'
|
|
3
3
|
import { translates, transforms } from './endpoints'
|
|
4
4
|
import { useAppKitOptions } from '../../Appkit'
|
|
5
|
+
import { useLogger, generateUniqueId } from '../../shared/composables/useLogger'
|
|
5
6
|
|
|
7
|
+
const logger = useLogger()
|
|
6
8
|
/**
|
|
7
9
|
* 小程序端 Http
|
|
8
10
|
* 使用 Taro.request 实现
|
|
@@ -10,17 +12,39 @@ import { useAppKitOptions } from '../../Appkit'
|
|
|
10
12
|
const vendor = {
|
|
11
13
|
async request<T>(config: HttpRequestConfig) {
|
|
12
14
|
return new Promise<ResponseRaw<T>>((resolve, reject) => {
|
|
15
|
+
const header = {
|
|
16
|
+
...config.headers,
|
|
17
|
+
traceId: generateUniqueId('appkit'),
|
|
18
|
+
}
|
|
19
|
+
const startTime = new Date().getTime()
|
|
20
|
+
|
|
13
21
|
Taro.request({
|
|
14
22
|
url: config.url,
|
|
15
23
|
method: config.method,
|
|
16
|
-
header
|
|
24
|
+
header,
|
|
17
25
|
data: config.data,
|
|
18
26
|
})
|
|
19
27
|
.then(({ data }) => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
28
|
+
if (data.success) {
|
|
29
|
+
resolve({
|
|
30
|
+
status: +data.code,
|
|
31
|
+
message: data.msg,
|
|
32
|
+
data: data.result as T,
|
|
33
|
+
})
|
|
34
|
+
} else if (data.code !== '401') {
|
|
35
|
+
Taro.showToast({
|
|
36
|
+
title: data.msg,
|
|
37
|
+
icon: 'none',
|
|
38
|
+
})
|
|
39
|
+
}
|
|
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,
|
|
24
48
|
})
|
|
25
49
|
})
|
|
26
50
|
.catch((e: any) => {
|
|
@@ -30,12 +54,17 @@ const vendor = {
|
|
|
30
54
|
},
|
|
31
55
|
}
|
|
32
56
|
|
|
33
|
-
|
|
57
|
+
interface DefaultHeaderType {
|
|
58
|
+
Token?: string
|
|
59
|
+
Appcode?: string
|
|
60
|
+
Tenant?: string
|
|
61
|
+
}
|
|
62
|
+
function useHttp(defaultHeader?: DefaultHeaderType) {
|
|
34
63
|
const appkitOptions = useAppKitOptions()
|
|
35
64
|
const headers = {
|
|
36
65
|
Token: appkitOptions.tempToken() || appkitOptions.token(),
|
|
37
|
-
Appcode:
|
|
38
|
-
cookie: `tid=${appkitOptions.tenant()}`,
|
|
66
|
+
Appcode: defaultHeader?.Appcode || appkitOptions.app(),
|
|
67
|
+
cookie: `tid=${defaultHeader?.Tenant || appkitOptions.tenant()}`,
|
|
39
68
|
gray: appkitOptions.gray ? appkitOptions.gray() : '0',
|
|
40
69
|
}
|
|
41
70
|
/**
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<view class="view recharge-view">
|
|
3
3
|
<view class="flex-grow">
|
|
4
|
-
<amount-picker :items="amounts"
|
|
5
|
-
:selected="state.selected"
|
|
6
|
-
@change="onAmountSelect" />
|
|
4
|
+
<amount-picker :items="amounts" :selected="state.selected" @change="onAmountSelect" />
|
|
7
5
|
</view>
|
|
8
6
|
<view class="amount-footer">
|
|
9
7
|
<view class="agreement">
|
|
10
|
-
<nut-checkbox v-model="state.agreed">我已阅读并同意<a class="link inline"
|
|
8
|
+
<nut-checkbox v-model="state.agreed">我已阅读并同意<a class="link inline"
|
|
9
|
+
@click="onAgreementLinkClick">《大道云平台云豆充值服务协议》</a></nut-checkbox>
|
|
11
10
|
</view>
|
|
12
|
-
<nut-button block
|
|
13
|
-
shape="square"
|
|
14
|
-
:loading="state.buttonLoading"
|
|
15
|
-
@click="onPayClick"
|
|
11
|
+
<nut-button block shape="square" :loading="state.buttonLoading" @click="onPayClick"
|
|
16
12
|
class="recharge-button">立即充值</nut-button>
|
|
17
13
|
</view>
|
|
18
14
|
</view>
|
|
@@ -72,10 +68,10 @@ const onAmountSelect = (selected: number) => {
|
|
|
72
68
|
}
|
|
73
69
|
|
|
74
70
|
onMounted(() => {
|
|
75
|
-
const $http = useHttp()
|
|
71
|
+
const $http = useHttp({ Appcode: props.app !== 'cloudkitPro' ? props.app : '', Tenant: props.tenant })
|
|
72
|
+
|
|
76
73
|
$http.get<any[]>(endpoints.获取充值金额列表, {
|
|
77
74
|
app: props.app,
|
|
78
|
-
// stage: 'aiApproveRecharge', // 支付场景
|
|
79
75
|
tenant: props.tenant
|
|
80
76
|
}).then(response => {
|
|
81
77
|
amounts.value = response
|
|
@@ -92,7 +88,7 @@ const onPayClick = () => {
|
|
|
92
88
|
}
|
|
93
89
|
state.buttonLoading = true
|
|
94
90
|
wx.login({
|
|
95
|
-
success
|
|
91
|
+
success({ code }: { code: string }) {
|
|
96
92
|
requestPayment({
|
|
97
93
|
amount: amounts.value[state.selected].amount,
|
|
98
94
|
app: props.app, // 'crm',
|
|
@@ -114,12 +110,15 @@ const onPayClick = () => {
|
|
|
114
110
|
height: 100%;
|
|
115
111
|
display: flex;
|
|
116
112
|
flex-direction: column;
|
|
113
|
+
|
|
117
114
|
.flex-grow {
|
|
118
115
|
flex-grow: 1;
|
|
119
116
|
}
|
|
117
|
+
|
|
120
118
|
.amount-footer {
|
|
121
119
|
padding: 10px;
|
|
122
120
|
padding-bottom: 20px;
|
|
121
|
+
|
|
123
122
|
.agreement {
|
|
124
123
|
font-size: 12px;
|
|
125
124
|
display: flex;
|
|
@@ -127,6 +126,7 @@ const onPayClick = () => {
|
|
|
127
126
|
align-items: cebter;
|
|
128
127
|
height: 40px;
|
|
129
128
|
}
|
|
129
|
+
|
|
130
130
|
.recharge-button {
|
|
131
131
|
background: linear-gradient(90deg, #FFEBC1 0%, #FFD7A7 52.29%, #FFB875 100%);
|
|
132
132
|
color: #353535;
|
|
@@ -134,14 +134,17 @@ const onPayClick = () => {
|
|
|
134
134
|
border: 0;
|
|
135
135
|
border-radius: 8px;
|
|
136
136
|
}
|
|
137
|
+
|
|
137
138
|
.nut-checkbox {
|
|
138
139
|
line-height: 40px;
|
|
139
140
|
}
|
|
141
|
+
|
|
140
142
|
.nut-checkbox__label {
|
|
141
143
|
margin-left: 8px;
|
|
142
144
|
flex: flex;
|
|
143
145
|
font-size: 12px;
|
|
144
146
|
}
|
|
147
|
+
|
|
145
148
|
.link {
|
|
146
149
|
display: inline;
|
|
147
150
|
color: #FD6701;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 记录阿里日志
|
|
3
|
+
* 生产: https://sls.console.aliyun.com/lognext/project/ddyk-prod/logsearch/ddjf-internet-web
|
|
4
|
+
*/
|
|
5
|
+
import { useAppKitOptions } from '../../Appkit'
|
|
6
|
+
import Taro from '@tarojs/taro'
|
|
7
|
+
|
|
8
|
+
interface LogType {
|
|
9
|
+
projectName?: string
|
|
10
|
+
logStore?: string
|
|
11
|
+
topic?: string
|
|
12
|
+
APIVersion?: string
|
|
13
|
+
baseUrl?: string
|
|
14
|
+
alislsURL?: string
|
|
15
|
+
systemInfo?: string
|
|
16
|
+
enable?: boolean
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const defaultLogOptions: LogType = {
|
|
20
|
+
projectName: 'ddyk-dev',
|
|
21
|
+
logStore: 'ddjf-internet-web',
|
|
22
|
+
topic: 'appkit',
|
|
23
|
+
enable: true,
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// 使用时间戳生成唯一标识
|
|
27
|
+
export function generateUniqueId(pre?: string) {
|
|
28
|
+
return `${pre ? pre + '-' : ''}${Date.now().toString(16)}-${Math.random().toString(36).substr(2)}`
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function useLogger(options?: LogType) {
|
|
32
|
+
const appkitOptions = useAppKitOptions()
|
|
33
|
+
const url = appkitOptions.baseUrl()
|
|
34
|
+
|
|
35
|
+
if (url.includes('ytech.ddjf.com')) {
|
|
36
|
+
defaultLogOptions.projectName = 'ddyk-prod'
|
|
37
|
+
}
|
|
38
|
+
if (options) {
|
|
39
|
+
options = Object.assign(defaultLogOptions, options)
|
|
40
|
+
} else {
|
|
41
|
+
options = defaultLogOptions
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const projectName = options.projectName
|
|
45
|
+
const logStore = options.logStore
|
|
46
|
+
const topic = options.topic || ''
|
|
47
|
+
const APIVersion = '0.6.0'
|
|
48
|
+
const baseUrl = `https://${projectName}.cn-shenzhen.log.aliyuncs.com/logstores/${logStore}/track?APIVersion=${APIVersion}`
|
|
49
|
+
const alislsURL = topic ? `${baseUrl}&__topic__=${topic}` : baseUrl
|
|
50
|
+
const enable = options.enable === undefined ? true : options.enable
|
|
51
|
+
|
|
52
|
+
const { miniProgram } = Taro.getAccountInfoSync()
|
|
53
|
+
const systemInfo =
|
|
54
|
+
JSON.stringify({
|
|
55
|
+
...Taro.getSystemInfoSync(),
|
|
56
|
+
appVersion: miniProgram.version,
|
|
57
|
+
}) || '未知'
|
|
58
|
+
|
|
59
|
+
function send(params: Record<string, any>) {
|
|
60
|
+
if (!enable) return
|
|
61
|
+
|
|
62
|
+
params.systemInfo = systemInfo
|
|
63
|
+
const token = appkitOptions.tempToken() || appkitOptions.token()
|
|
64
|
+
if (token) {
|
|
65
|
+
params.userInfo = token
|
|
66
|
+
}
|
|
67
|
+
if (params.msg && !params.send) {
|
|
68
|
+
params.send = params.msg
|
|
69
|
+
}
|
|
70
|
+
if (params.send) {
|
|
71
|
+
params.send = params.send.slice(0, 1024)
|
|
72
|
+
}
|
|
73
|
+
if (params.receive) {
|
|
74
|
+
params.receive = params.receive.slice(0, 1024)
|
|
75
|
+
}
|
|
76
|
+
if (params.duration) {
|
|
77
|
+
params.duration = params.duration
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// 记录页面栈信息
|
|
81
|
+
const pages = Taro.getCurrentPages()
|
|
82
|
+
const currentPage = pages?.[pages.length - 1]
|
|
83
|
+
const lastPage = pages?.[pages.length - 2]
|
|
84
|
+
params.pages = JSON.stringify({
|
|
85
|
+
current: currentPage?.$taroPath,
|
|
86
|
+
last: lastPage?.$taroPath,
|
|
87
|
+
}).slice(0, 1024)
|
|
88
|
+
|
|
89
|
+
console.log(params)
|
|
90
|
+
|
|
91
|
+
const tmpStr = Object.keys(params)
|
|
92
|
+
.map((key) => `${key}=${encodeURIComponent(params[key])}`)
|
|
93
|
+
.join('&')
|
|
94
|
+
const url = `${alislsURL}&${tmpStr}`
|
|
95
|
+
Taro.request({ url })
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function info(params: any) {
|
|
99
|
+
if (!enable) return
|
|
100
|
+
send({
|
|
101
|
+
send: params.send ?? '',
|
|
102
|
+
receive: params.receive ?? '',
|
|
103
|
+
duration: params.duration ?? '',
|
|
104
|
+
traceId: params.traceId as string,
|
|
105
|
+
level: 'info',
|
|
106
|
+
})
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function error(params: any) {
|
|
110
|
+
if (!enable) return
|
|
111
|
+
send({
|
|
112
|
+
send: params.send ?? '',
|
|
113
|
+
receive: params.receive ?? '',
|
|
114
|
+
traceId: params.traceId as string,
|
|
115
|
+
level: 'error',
|
|
116
|
+
})
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return {
|
|
120
|
+
info,
|
|
121
|
+
error,
|
|
122
|
+
}
|
|
123
|
+
}
|
package/src/user/api/index.ts
CHANGED
|
@@ -2,7 +2,9 @@ import Taro from '@tarojs/taro'
|
|
|
2
2
|
import { HttpRequestConfig, PagingData, PagingParams, ResponseRaw, createHttp } from '../../shared'
|
|
3
3
|
import { translates, transforms } from './endpoints'
|
|
4
4
|
import { useAppKitOptions } from '../../Appkit'
|
|
5
|
+
import { useLogger, generateUniqueId } from '../../shared/composables/useLogger'
|
|
5
6
|
|
|
7
|
+
const logger = useLogger()
|
|
6
8
|
/**
|
|
7
9
|
* 小程序端 Http
|
|
8
10
|
* 使用 Taro.request 实现
|
|
@@ -10,17 +12,39 @@ import { useAppKitOptions } from '../../Appkit'
|
|
|
10
12
|
const vendor = {
|
|
11
13
|
async request<T>(config: HttpRequestConfig) {
|
|
12
14
|
return new Promise<ResponseRaw<T>>((resolve, reject) => {
|
|
15
|
+
const header = {
|
|
16
|
+
...config.headers,
|
|
17
|
+
traceId: generateUniqueId('appkit'),
|
|
18
|
+
}
|
|
19
|
+
const startTime = new Date().getTime()
|
|
20
|
+
|
|
13
21
|
Taro.request({
|
|
14
22
|
url: config.url,
|
|
15
23
|
method: config.method,
|
|
16
|
-
header
|
|
24
|
+
header,
|
|
17
25
|
data: config.data,
|
|
18
26
|
})
|
|
19
27
|
.then(({ data }) => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
28
|
+
if (data.success) {
|
|
29
|
+
resolve({
|
|
30
|
+
status: +data.code,
|
|
31
|
+
message: data.msg,
|
|
32
|
+
data: data.result as T,
|
|
33
|
+
})
|
|
34
|
+
} else if (data.code !== '401') {
|
|
35
|
+
Taro.showToast({
|
|
36
|
+
title: data.msg,
|
|
37
|
+
icon: 'none',
|
|
38
|
+
})
|
|
39
|
+
}
|
|
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,
|
|
24
48
|
})
|
|
25
49
|
})
|
|
26
50
|
.catch((e: any) => {
|