@xybplugins/xyb-agent 0.0.17 → 0.0.19
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/README.md +512 -96
- package/dist/index.esm.js +1 -1
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,21 +1,11 @@
|
|
|
1
|
-
# xybAgent SDK
|
|
1
|
+
# xybAgent SDK文档
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
> 最新版本:
|
|
6
|
-
> * jssdk:2.0.10 (后续会停更)
|
|
7
|
-
> * npm-package: 0.0.17
|
|
3
|
+
> 最新版本:2.0.10
|
|
8
4
|
|
|
9
5
|
## 使用场景:
|
|
10
6
|
|
|
11
7
|
> 湘易办JSSDK为h5微应用/uni-app应用提供了数据追踪埋点等业务API(会持续扩展底层通用组件的适配能力),帮助开发者相关业务场景实现。此文档面向开发者介绍该JSSDK如何使用及相关注意事项。
|
|
12
8
|
|
|
13
|
-
## 安装
|
|
14
|
-
|
|
15
|
-
```shell
|
|
16
|
-
npm i @xybplugins/xyb-agent --save -dev
|
|
17
|
-
```
|
|
18
|
-
|
|
19
9
|
## 兼容性说明:
|
|
20
10
|
|
|
21
11
|
### 适配环境名词说明
|
|
@@ -24,6 +14,7 @@
|
|
|
24
14
|
> 1. `湘易办APP-小程序`:湘易办APP内的小程序
|
|
25
15
|
> 2. `湘易办APP-小程序-webview`:湘易办小程序内通过webview嵌套的H5页面
|
|
26
16
|
> 3. `湘易办APP-webview`:湘易办APP通过webview嵌套的H5页面
|
|
17
|
+
> 4. `三方小程序`: 微信/支付宝/百度/今日头条 等其他小程序环境(包含其使用webview嵌套的H5)
|
|
27
18
|
|
|
28
19
|
### 范围说明
|
|
29
20
|
|
|
@@ -49,7 +40,7 @@
|
|
|
49
40
|
* 工程化:在入口文件引入SDK文件,并挂载为全局变量(推荐)
|
|
50
41
|
|
|
51
42
|
```javascript
|
|
52
|
-
import xybAgent from 'xybAgent';
|
|
43
|
+
import xybAgent from '/$path/xybAgent.$version.esm.js';
|
|
53
44
|
|
|
54
45
|
// Vue2 示例 - main.js
|
|
55
46
|
Vue.prototype.$xybAgent = xybAgent;
|
|
@@ -71,14 +62,16 @@ app.config.globalProperties.$xybAgent = xybAgent;
|
|
|
71
62
|
|
|
72
63
|
```html
|
|
73
64
|
|
|
74
|
-
<script src="$path/xybAgent.umd.js"></script>
|
|
65
|
+
<script src="$path/xybAgent.$version.umd.js"></script>
|
|
75
66
|
```
|
|
76
67
|
|
|
77
68
|
## API使用
|
|
78
69
|
|
|
79
70
|
### 初始化SDK-`init` (非浏览器环境无需执行此步骤)
|
|
80
71
|
|
|
81
|
-
> 此API是一个异步任务,可使用async await / promise结构
|
|
72
|
+
> * 此API是一个异步任务,可使用async await / promise结构 调用;
|
|
73
|
+
> * 也可直接进行初始化动作,SDK内部有进行埋码的堆栈,当有埋点时,会自动进行埋点上报。
|
|
74
|
+
> * H5环境必须执行init动作,否则会导致埋点/其它API无法使用
|
|
82
75
|
|
|
83
76
|
* 入参
|
|
84
77
|
|
|
@@ -143,10 +136,13 @@ this.$xybAgent.track('xyb_ksj', {
|
|
|
143
136
|
unit_code: "",
|
|
144
137
|
unit_name: "",
|
|
145
138
|
user_id: "",//用户 ID
|
|
146
|
-
source: "",//渠道来源
|
|
147
139
|
});
|
|
148
140
|
```
|
|
149
141
|
|
|
142
|
+
* 注意事项
|
|
143
|
+
|
|
144
|
+
> * 对应字段必须使用埋点规范文档中的字段及字段类型,否则会导致埋点数据无法成功落库!!!!
|
|
145
|
+
|
|
150
146
|
### 获取AccessLink值-`getAccessLink`
|
|
151
147
|
|
|
152
148
|
> 此API是一个异步任务,需使用async await / promise结构 获取回调值
|
|
@@ -227,7 +223,11 @@ getAccessLink().then(res => {
|
|
|
227
223
|
```javascript
|
|
228
224
|
const userInfo = {
|
|
229
225
|
name: '张三',
|
|
230
|
-
certNo: '123456789012345678'
|
|
226
|
+
certNo: '123456789012345678',
|
|
227
|
+
appId: 'xxxxxxx',
|
|
228
|
+
sign: 'xxxxxx',
|
|
229
|
+
created: new Date().getTime(),
|
|
230
|
+
nonce: 'xxxxxxx'
|
|
231
231
|
}
|
|
232
232
|
const {isSuccess} = await this.$xybAgent.authFace(userInfo);
|
|
233
233
|
if (isSuccess) {
|
|
@@ -240,7 +240,11 @@ if (isSuccess) {
|
|
|
240
240
|
```javascript
|
|
241
241
|
const userInfo = {
|
|
242
242
|
name: '张三',
|
|
243
|
-
certNo: '123456789012345678'
|
|
243
|
+
certNo: '123456789012345678',
|
|
244
|
+
appId: 'xxxxxxx',
|
|
245
|
+
sign: 'xxxxxx',
|
|
246
|
+
created: new Date().getTime(),
|
|
247
|
+
nonce: 'xxxxxxx'
|
|
244
248
|
}
|
|
245
249
|
this.$xybAgent.authFace(userInfo).then(({isSuccess}) => {
|
|
246
250
|
if (isSuccess) {
|
|
@@ -446,7 +450,7 @@ this.$xybAgent.scanCode().then(({result}) => {
|
|
|
446
450
|
|:-------------|-----------|-----|------------------------------|------------------------------|---------------------------|
|
|
447
451
|
| count | `Number` | `否` | `9` | `1-9` | 最多选择图片数量 |
|
|
448
452
|
| sizeType | `Array` | `否` | `['original', 'compressed']` | `['original', 'compressed']` | 图片尺寸类型 |
|
|
449
|
-
| sourceType | `Array` | `否` | `['album']` | `['album', 'camera']` |
|
|
453
|
+
| sourceType | `Array` | `否` | `['album']` | `['album', 'camera']` | 图片来源 |
|
|
450
454
|
| isCircleCrop | `Boolean` | `否` | `false` | `true`/`false` | 是否圆形裁剪 |
|
|
451
455
|
|
|
452
456
|
* 出参-仅列出返回体内的子参数,整体是一个`Array`对象
|
|
@@ -477,53 +481,10 @@ this.$xybAgent.chooseImg().then(res => {
|
|
|
477
481
|
})
|
|
478
482
|
```
|
|
479
483
|
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
> 此API是一个异步任务,需使用async await / promise结构 获取回调值
|
|
483
|
-
|
|
484
|
-
* 环境适配说明
|
|
485
|
-
|
|
486
|
-
| 环境类型 | 是否适配 | 适配版本(最低) |
|
|
487
|
-
|----------------|:----:|:---------|
|
|
488
|
-
| 湘易办小程序 | `是` | `1.1.4` |
|
|
489
|
-
| 湘易办小程序-webview | `是` | `1.1.8` |
|
|
490
|
-
| 湘易办 - H5 | `否` | -- |
|
|
491
|
-
| 三方小程序 | `否` | -- |
|
|
492
|
-
|
|
493
|
-
* 入参
|
|
494
|
-
|
|
495
|
-
| 参数名 | 子参数名 | 类型 | 必填 | 描述 |
|
|
496
|
-
|:-------|------|----------|-----|----------|
|
|
497
|
-
| source | | `Object` | `是` | 图片源 |
|
|
498
|
-
| | path | `String` | `是` | 图片路径 |
|
|
499
|
-
| | type | `String` | `是` | 图片类型 |
|
|
500
|
-
| | size | `Number` | `是` | 图片大小(字节) |
|
|
501
|
-
|
|
502
|
-
* 出参-仅列出返回体内的子参数,整体是一个`Object`对象
|
|
503
|
-
|
|
504
|
-
| 参数名 | 类型 | 描述 |
|
|
505
|
-
|:----|----------|-----------|
|
|
506
|
-
| url | `String` | 上传图片的url |
|
|
507
|
-
| msg | `String` | 上传图片的提示信息 |
|
|
508
|
-
|
|
509
|
-
* 示例-`async await`
|
|
510
|
-
|
|
511
|
-
```javascript
|
|
512
|
-
const {url} = await this.$xybAgent.imgUpload(dataInfo);
|
|
513
|
-
if (url) {
|
|
514
|
-
// 上传图片成功
|
|
515
|
-
}
|
|
516
|
-
```
|
|
484
|
+
* 注意事项
|
|
517
485
|
|
|
518
|
-
*
|
|
519
|
-
|
|
520
|
-
```javascript
|
|
521
|
-
this.$xybAgent.imgUpload(dataInfo).then((url) => {
|
|
522
|
-
if (url) {
|
|
523
|
-
// 上传图片成功
|
|
524
|
-
}
|
|
525
|
-
});
|
|
526
|
-
```
|
|
486
|
+
> * 在湘易办APP-湘易办小程序-H5 中执行的选择图片,业务侧无法使用对应的临时文件路径执行上传动作(浏览器权限问题导致)
|
|
487
|
+
> * 在湘易办APP-湘易办小程序-H5 中可结合使用`this.$xybAgent.fileUpload` 进行搭配上传;具体查阅当前文档
|
|
527
488
|
|
|
528
489
|
### 图片预览-`imgPreview`
|
|
529
490
|
|
|
@@ -567,7 +528,6 @@ this.$xybAgent.imgPreview(dataInfo);
|
|
|
567
528
|
|
|
568
529
|
* 入参-`无`
|
|
569
530
|
|
|
570
|
-
|
|
571
531
|
* 出参-仅列出返回体内的子参数,整体是一个`Object`对象
|
|
572
532
|
|
|
573
533
|
| 参数名 | 类型 | 描述 |
|
|
@@ -596,6 +556,81 @@ this.$xybAgent.chooseFile().then(res => {
|
|
|
596
556
|
});
|
|
597
557
|
```
|
|
598
558
|
|
|
559
|
+
### 文件上传-`fileUpload`
|
|
560
|
+
|
|
561
|
+
> 此API是一个异步任务,需使用async await / promise结构 获取回调值
|
|
562
|
+
|
|
563
|
+
* 环境适配说明
|
|
564
|
+
|
|
565
|
+
| 环境类型 | 是否适配 | 适配版本(最低) |
|
|
566
|
+
|----------------|:----:|:---------|
|
|
567
|
+
| 湘易办小程序 | `是` | `1.1.4` |
|
|
568
|
+
| 湘易办小程序-webview | `是` | `1.1.8` |
|
|
569
|
+
| 湘易办 - H5 | `是` | `2.0.0` |
|
|
570
|
+
| 三方小程序 | `否` | -- |
|
|
571
|
+
|
|
572
|
+
* 入参
|
|
573
|
+
|
|
574
|
+
| 参数名 | 子参数名 | 类型 | 必填 | 描述 |
|
|
575
|
+
|:---------|------|-----------|-----|-----------------------------|
|
|
576
|
+
| source | | `String` | `是` | 文件信息 |
|
|
577
|
+
| | path | `String` | `是` | 文件的本地临时路径 |
|
|
578
|
+
| | type | `String` | `是` | 文件类型 |
|
|
579
|
+
| | size | ` Number` | `是` | 文件大小 |
|
|
580
|
+
| url | | `String` | `否` | 文件上传接口地址 |
|
|
581
|
+
| headers | | `Object` | `否` | 文件上传时的自定义请求头 |
|
|
582
|
+
| formdata | | `Object` | `否` | 文件上传时的额外参数(formData携带的额外参数) |
|
|
583
|
+
| name | | `String` | `否` | 上传的文件对应的key名 默认为`file` |
|
|
584
|
+
|
|
585
|
+
* 出参
|
|
586
|
+
|
|
587
|
+
| 参数名 | 子参数 | 类型 | 描述 |
|
|
588
|
+
|-----------|-----|-----------|----------------------|
|
|
589
|
+
| resultObj | | `Object` | 文件上传的结果(业务侧接口定义的返回体) |
|
|
590
|
+
| isSuccess | | `Boolean` | 文件上传是否成功 |
|
|
591
|
+
| errorMsg | | `String` | 错误信息 |
|
|
592
|
+
|
|
593
|
+
* 示例-`async await`
|
|
594
|
+
|
|
595
|
+
```javascript
|
|
596
|
+
const dataInfo = {
|
|
597
|
+
source: {
|
|
598
|
+
path: 'xxxxxx',
|
|
599
|
+
type: 'image/png', // 具体看业务侧选择的文件类型而定!!!!
|
|
600
|
+
size: xxxxxx
|
|
601
|
+
},
|
|
602
|
+
url: 'https://www.xxx.xxx.com/xxxxxx',
|
|
603
|
+
headers: {},
|
|
604
|
+
formdata: {},
|
|
605
|
+
name: 'file'
|
|
606
|
+
}
|
|
607
|
+
const res = await this.$xybAgent.fileUpload(dataInfo);
|
|
608
|
+
if (res?.isSuccess) {
|
|
609
|
+
// 文件上传成功
|
|
610
|
+
}
|
|
611
|
+
```
|
|
612
|
+
|
|
613
|
+
* 示例-`promise`
|
|
614
|
+
|
|
615
|
+
```javascript
|
|
616
|
+
const dataInfo = {
|
|
617
|
+
source: {
|
|
618
|
+
path: 'xxxxxx',
|
|
619
|
+
type: 'image/png', // 具体看业务侧选择的文件类型而定!!!!
|
|
620
|
+
size: xxxxxx
|
|
621
|
+
},
|
|
622
|
+
url: 'https://www.xxx.xxx.com/xxxxxx',
|
|
623
|
+
headers: {},
|
|
624
|
+
formdata: {},
|
|
625
|
+
name: 'file'
|
|
626
|
+
}
|
|
627
|
+
this.$xybAgent.fileUpload(dataInfo).then(res => {
|
|
628
|
+
if (res?.isSuccess) {
|
|
629
|
+
// 文件上传成功
|
|
630
|
+
}
|
|
631
|
+
});
|
|
632
|
+
```
|
|
633
|
+
|
|
599
634
|
### 文件下载-`fileDownload`
|
|
600
635
|
|
|
601
636
|
> 此API是一个异步任务,需使用async await / promise结构 获取回调值
|
|
@@ -611,10 +646,10 @@ this.$xybAgent.chooseFile().then(res => {
|
|
|
611
646
|
|
|
612
647
|
* 入参
|
|
613
648
|
|
|
614
|
-
| 参数名 | 类型 | 必填 | 描述
|
|
615
|
-
|
|
616
|
-
| url | `String` | `是` | 文件地址
|
|
617
|
-
| name | `String` |
|
|
649
|
+
| 参数名 | 类型 | 必填 | 描述 |
|
|
650
|
+
|:-----|----------|-----|---------------------|
|
|
651
|
+
| url | `String` | `是` | 文件地址 |
|
|
652
|
+
| name | `String` | `是` | 文件名 **(必须包含文件后缀名)** |
|
|
618
653
|
|
|
619
654
|
* 出参
|
|
620
655
|
|
|
@@ -628,6 +663,10 @@ this.$xybAgent.chooseFile().then(res => {
|
|
|
628
663
|
* 示例-`async await`
|
|
629
664
|
|
|
630
665
|
```javascript
|
|
666
|
+
const dataInfo = {
|
|
667
|
+
url: 'https://www.xxx.xxx.com/xxxx.pdf',
|
|
668
|
+
name: 'xxxx.pdf'
|
|
669
|
+
};
|
|
631
670
|
const res = await this.$xybAgent.fileDownload(dataInfo);
|
|
632
671
|
if (res?.isSuccess) {
|
|
633
672
|
// 文件下载成功
|
|
@@ -637,6 +676,10 @@ if (res?.isSuccess) {
|
|
|
637
676
|
* 示例-`promise`
|
|
638
677
|
|
|
639
678
|
```javascript
|
|
679
|
+
const dataInfo = {
|
|
680
|
+
url: 'https://www.xxx.xxx.com/xxxx.pdf',
|
|
681
|
+
name: 'xxxx.pdf'
|
|
682
|
+
};
|
|
640
683
|
this.$xybAgent.fileDownload(dataInfo).then(res => {
|
|
641
684
|
if (res?.isSuccess) {
|
|
642
685
|
// 文件下载成功
|
|
@@ -644,6 +687,11 @@ this.$xybAgent.fileDownload(dataInfo).then(res => {
|
|
|
644
687
|
});
|
|
645
688
|
```
|
|
646
689
|
|
|
690
|
+
* 注意事项:
|
|
691
|
+
|
|
692
|
+
> * 只有pdf、图片、world等标准可查看文档才会显示在【湘易办APP】-【我的】-【我的服务】-【我的下载】中
|
|
693
|
+
> * zip等相关文件不会在【我的下载】中展示
|
|
694
|
+
|
|
647
695
|
### 文件预览-`filePreview`
|
|
648
696
|
|
|
649
697
|
> 该API为单向事件,无回调事件
|
|
@@ -688,9 +736,9 @@ this.$xybAgent.filePreview(fileInfo);
|
|
|
688
736
|
|
|
689
737
|
* 入参
|
|
690
738
|
|
|
691
|
-
| 参数名 | 类型 | 必填
|
|
692
|
-
|
|
693
|
-
| localPath | `String` |
|
|
739
|
+
| 参数名 | 类型 | 必填 | 描述 |
|
|
740
|
+
|:----------|----------|-----|------|
|
|
741
|
+
| localPath | `String` | `是` | 文件路径 |
|
|
694
742
|
|
|
695
743
|
* 出参-`无`
|
|
696
744
|
|
|
@@ -1214,7 +1262,7 @@ App({
|
|
|
1214
1262
|
```html
|
|
1215
1263
|
|
|
1216
1264
|
<template>
|
|
1217
|
-
<web-view src="yourPageUrl" @message="formatMessageInfo"></web-view>
|
|
1265
|
+
<web-view id="webview" src="yourPageUrl" @message="formatMessageInfo"></web-view>
|
|
1218
1266
|
</template>
|
|
1219
1267
|
|
|
1220
1268
|
<script>
|
|
@@ -1240,9 +1288,13 @@ App({
|
|
|
1240
1288
|
| xybAgent | Object | SDK对象实例 |
|
|
1241
1289
|
| this | Object | 当前webview实例对象 |
|
|
1242
1290
|
|
|
1291
|
+
* 注意事项
|
|
1292
|
+
|
|
1293
|
+
> web-view 组件一定要有 id 而且 id 必须是 webview,否则会导致小程序嵌套的H5无法正常调用jssdk
|
|
1294
|
+
|
|
1243
1295
|
### 控制胶囊按钮的下拉菜单显示-`menuBtnConfig`
|
|
1244
1296
|
|
|
1245
|
-
> 此API
|
|
1297
|
+
> 此API是一个异步任务,需使用async await / promise结构 获取回调值
|
|
1246
1298
|
|
|
1247
1299
|
* 环境适配说明
|
|
1248
1300
|
|
|
@@ -1255,22 +1307,53 @@ App({
|
|
|
1255
1307
|
|
|
1256
1308
|
* 入参
|
|
1257
1309
|
|
|
1258
|
-
| 参数名 | 子参数
|
|
1259
|
-
|
|
1260
|
-
| share |
|
|
1261
|
-
| | show
|
|
1262
|
-
| | code
|
|
1263
|
-
| |
|
|
1264
|
-
|
|
|
1265
|
-
| |
|
|
1266
|
-
| |
|
|
1267
|
-
| |
|
|
1268
|
-
|
|
|
1269
|
-
| |
|
|
1270
|
-
|
|
1271
|
-
|
|
1310
|
+
| 参数名 | 子参数 | 类型 | 默认值 | 必填 | 描述 |
|
|
1311
|
+
|:---------|----------|-----------|-----------------|-----|----------------------------------|
|
|
1312
|
+
| share | | `Object` | `{show: false}` | `否` | 分享按钮配置信息 |
|
|
1313
|
+
| | show | `Boolean` | `false` | `否` | 是否显示分享按钮 |
|
|
1314
|
+
| | code | `String` | -- | `否` | 页面/专区/事项 编码 (**`show=true`时必填**) |
|
|
1315
|
+
| | matterID | `String` | -- | `否` | 页面/专区/事项 编码 (**`show=true`时必填**)
|
|
1316
|
+
| | type | `String` | -- | `否` | 事项-4;小程序-5 (**`show=true`时必填**) |
|
|
1317
|
+
| comment | | `Object` | `{show: false}` | `否` | 评论按钮配置信息 |
|
|
1318
|
+
| | show | `Boolean` | `false` | `否` | 是否显示评论按钮 |
|
|
1319
|
+
| | code | `String` | -- | `否` | 页面/专区/事项 编码 (**`show=true`时必填**) |
|
|
1320
|
+
| | matterID | `String` | -- | `否` | 页面/专区/事项 编码 (**`show=true`时必填**)
|
|
1321
|
+
| | type | `String` | -- | `否` | 事项-4;小程序-5 (**`show=true`时必填**) |
|
|
1322
|
+
| favorite | | `Object` | `{show: true}` | `否` | 收藏按钮配置信息 |
|
|
1323
|
+
| | show | `Boolean` | `true` | `否` | 是否显示收藏按钮 |
|
|
1324
|
+
|
|
1325
|
+
* 返回值
|
|
1326
|
+
|
|
1327
|
+
> 仅列出返回体内的子参数,整体是一个`Object`对象
|
|
1328
|
+
|
|
1329
|
+
| 参数名 | 类型 | 描述 |
|
|
1330
|
+
|:----------|-----------|----------------|
|
|
1331
|
+
| isSuccess | `Boolean` | 更改胶囊按钮下拉菜单是否成功 |
|
|
1272
1332
|
|
|
1273
|
-
*
|
|
1333
|
+
* 示例-`async await`
|
|
1334
|
+
|
|
1335
|
+
```javascript
|
|
1336
|
+
const {isSuccess} = await this.$xybAgent.menuBtnConfig({
|
|
1337
|
+
share: {
|
|
1338
|
+
show: true,
|
|
1339
|
+
type: 4,
|
|
1340
|
+
code: 'xxxxxx'
|
|
1341
|
+
},
|
|
1342
|
+
comment: {
|
|
1343
|
+
show: true,
|
|
1344
|
+
type: 4,
|
|
1345
|
+
code: 'xxxxxx'
|
|
1346
|
+
},
|
|
1347
|
+
favorite: {
|
|
1348
|
+
show: true
|
|
1349
|
+
}
|
|
1350
|
+
})
|
|
1351
|
+
if (isSuccess) {
|
|
1352
|
+
// 配置成功
|
|
1353
|
+
}
|
|
1354
|
+
```
|
|
1355
|
+
|
|
1356
|
+
* 示例-`promise`
|
|
1274
1357
|
|
|
1275
1358
|
```javascript
|
|
1276
1359
|
this.$xybAgent.menuBtnConfig({
|
|
@@ -1287,6 +1370,10 @@ this.$xybAgent.menuBtnConfig({
|
|
|
1287
1370
|
favorite: {
|
|
1288
1371
|
show: true
|
|
1289
1372
|
}
|
|
1373
|
+
}).then(({isSuccess}) => {
|
|
1374
|
+
if (isSuccess) {
|
|
1375
|
+
// 配置成功
|
|
1376
|
+
}
|
|
1290
1377
|
})
|
|
1291
1378
|
```
|
|
1292
1379
|
|
|
@@ -1523,8 +1610,8 @@ this.$xybAgent.openAlipayMiniApp('/pages/index/index').then(({isSuccess, code})
|
|
|
1523
1610
|
|
|
1524
1611
|
### 目的地导航 - `startNavigation`
|
|
1525
1612
|
|
|
1526
|
-
> 该任务是一个单向任务,无回调值信息
|
|
1527
|
-
> 该任务主要用于湘易办小程序/湘易办内嵌的H5页面,给用户提供快捷导航能力
|
|
1613
|
+
> * 该任务是一个单向任务,无回调值信息
|
|
1614
|
+
> * 该任务主要用于湘易办小程序/湘易办内嵌的H5页面,给用户提供快捷导航能力
|
|
1528
1615
|
|
|
1529
1616
|
* 环境适配说明
|
|
1530
1617
|
|
|
@@ -1538,7 +1625,7 @@ this.$xybAgent.openAlipayMiniApp('/pages/index/index').then(({isSuccess, code})
|
|
|
1538
1625
|
* 入参
|
|
1539
1626
|
|
|
1540
1627
|
| 参数名 | 类型 | 必填 | 描述 |
|
|
1541
|
-
|
|
1628
|
+
|:-----------|----------|-----|--------------------------------------|
|
|
1542
1629
|
| lat | `String` | `是` | 纬度 |
|
|
1543
1630
|
| lng | `String` | `是` | 经度 |
|
|
1544
1631
|
| address | `String` | `是` | 目的地地址信息 |
|
|
@@ -1558,9 +1645,334 @@ this.$xybAgent.startNavigation({
|
|
|
1558
1645
|
});
|
|
1559
1646
|
```
|
|
1560
1647
|
|
|
1561
|
-
|
|
1648
|
+
### 是否自动恢复胶囊按钮默认配置 - `autoUpdate`
|
|
1649
|
+
|
|
1650
|
+
> * 该任务是一个单向任务,无回调值信息
|
|
1651
|
+
> * 该任务主要用于湘易办小程序/湘易办内嵌的H5页面,用于恢复胶囊按钮的默认配置信息
|
|
1652
|
+
|
|
1653
|
+
* 环境适配说明
|
|
1654
|
+
|
|
1655
|
+
| 环境类型 | 是否适配 | 适配版本(最低) |
|
|
1656
|
+
|----------------|:----:|:---------|
|
|
1657
|
+
| 湘易办小程序 | `是` | `2.0.9` |
|
|
1658
|
+
| 湘易办小程序-webview | `是` | `2.0.9` |
|
|
1659
|
+
| 湘易办 - H5 | `否` | -- |
|
|
1660
|
+
| 三方小程序 | `否` | -- |
|
|
1661
|
+
|
|
1662
|
+
* 入参
|
|
1663
|
+
|
|
1664
|
+
| 参数名 | 类型 | 必填 | 默认值 | 描述 |
|
|
1665
|
+
|:-----------|----------|-----|--------|-------------------------|
|
|
1666
|
+
| autoUpdate | `Number` | `否` | `true` | 是否自动恢复默认配置(小程序不建议更改此配置) |
|
|
1667
|
+
|
|
1668
|
+
* 出参 - `无`
|
|
1669
|
+
|
|
1670
|
+
* 示例
|
|
1671
|
+
|
|
1672
|
+
```javascript
|
|
1673
|
+
// 页面切换时恢复默认配置
|
|
1674
|
+
xybAgent.autoUpdate = true;
|
|
1675
|
+
|
|
1676
|
+
// 页面切换时保留现有配置
|
|
1677
|
+
xybAgent.autoUpdate = false;
|
|
1678
|
+
```
|
|
1679
|
+
|
|
1680
|
+
* 注意事项
|
|
1681
|
+
|
|
1682
|
+
> 小程序不建议更改此配置,否则引起的一切问题,SDK不予以处理;推荐仅用于`uni-app`开发的`H5`项目使用
|
|
1683
|
+
|
|
1684
|
+
### 是否需要进行胶囊按钮自动化配置 - `autoConfigMenuBtn`
|
|
1685
|
+
|
|
1686
|
+
> * 该任务是一个单向任务,无回调值信息
|
|
1687
|
+
> * 该任务主要用于湘易办小程序/湘易办内嵌的H5页面,用于自动执行胶囊按钮的配置
|
|
1688
|
+
> * SDK会自动获取地址栏上的事项编码,若无事项编码,会恢复成默认配置
|
|
1689
|
+
|
|
1690
|
+
* 环境适配说明
|
|
1562
1691
|
|
|
1563
|
-
|
|
1692
|
+
| 环境类型 | 是否适配 | 适配版本(最低) |
|
|
1693
|
+
|----------------|:----:|:---------|
|
|
1694
|
+
| 湘易办小程序 | `是` | `2.0.9` |
|
|
1695
|
+
| 湘易办小程序-webview | `是` | `2.0.9` |
|
|
1696
|
+
| 湘易办 - H5 | `否` | -- |
|
|
1697
|
+
| 三方小程序 | `否` | -- |
|
|
1698
|
+
|
|
1699
|
+
* 入参
|
|
1700
|
+
|
|
1701
|
+
| 参数名 | 类型 | 必填 | 默认值 | 描述 |
|
|
1702
|
+
|:------------------|----------|-----|--------|-----------------|
|
|
1703
|
+
| autoConfigMenuBtn | `Number` | `否` | `true` | 是否需要进行胶囊按钮自动化配置 |
|
|
1704
|
+
|
|
1705
|
+
* 出参 - `无`
|
|
1706
|
+
|
|
1707
|
+
* 示例
|
|
1708
|
+
|
|
1709
|
+
```javascript
|
|
1710
|
+
// 页面切换时,默认需要进行胶囊按钮自动化配置
|
|
1711
|
+
xybAgent.autoConfigMenuBtn = true;
|
|
1712
|
+
|
|
1713
|
+
// 页面切换时,不需要自动化配置胶囊按钮配置
|
|
1714
|
+
xybAgent.autoConfigMenuBtn = false;
|
|
1715
|
+
```
|
|
1716
|
+
|
|
1717
|
+
* 注意事项
|
|
1718
|
+
|
|
1719
|
+
> 此配置不能与`autoUpdate=false`进行组合使用,推荐都为默认值(`true`),否则由此造成的一切损失,由业务侧自行承担结果
|
|
1720
|
+
|
|
1721
|
+
### 添加日历日程 - `addCalendarEvent`
|
|
1722
|
+
|
|
1723
|
+
> * 该任务是一个异步任务,有回调值信息
|
|
1724
|
+
> * 该任务主要用于湘易办小程序/湘易办内嵌的H5页面,用于添加日历日程信息
|
|
1725
|
+
|
|
1726
|
+
* 环境适配说明
|
|
1727
|
+
|
|
1728
|
+
| 环境类型 | 是否适配 | 适配版本(最低) |
|
|
1729
|
+
|----------------|:----:|:---------|
|
|
1730
|
+
| 湘易办小程序 | `是` | `2.0.9` |
|
|
1731
|
+
| 湘易办小程序-webview | `是` | `2.0.9` |
|
|
1732
|
+
| 湘易办 - H5 | `否` | -- |
|
|
1733
|
+
| 三方小程序 | `否` | -- |
|
|
1734
|
+
|
|
1735
|
+
* 入参
|
|
1736
|
+
|
|
1737
|
+
| 参数名 | 类型 | 必填 | 描述 |
|
|
1738
|
+
|:-------------|-------------|-- | ---|----------------|
|
|
1739
|
+
| title | `String` | `是` | 行程标题 |
|
|
1740
|
+
| startTime | `timeStamp` | `是` | 开始时间 **(时间戳)** |
|
|
1741
|
+
| endTime | `timeStamp` | `是` | 结束时间 **(时间戳)** |
|
|
1742
|
+
| reminderTime | `Number` | `否` | 即距开始时间提前x分钟提醒,不填时,**默认为不提醒** |
|
|
1743
|
+
|
|
1744
|
+
* 出参
|
|
1745
|
+
|
|
1746
|
+
| 参数名 | 类型 | 描述 |
|
|
1747
|
+
|:----------|-----------|----------|
|
|
1748
|
+
| isSuccess | `Boolean` | 创建行程是否成功 |
|
|
1749
|
+
| errorMsg | `String` | 错误消息内容 |
|
|
1750
|
+
| eventID | `String` | 行程ID |
|
|
1751
|
+
|
|
1752
|
+
* 示例 - `async、await 模式`
|
|
1753
|
+
|
|
1754
|
+
```javascript
|
|
1755
|
+
const res = await this.$xybAgent.addCalendarEvent({
|
|
1756
|
+
title: '日历行程标题',
|
|
1757
|
+
startTime: new Date('2026/01/01 00:00:00').getTime(),
|
|
1758
|
+
endTime: new Date(`2026/01/01 00:05:00`).getTime(),
|
|
1759
|
+
reminderTime: 5
|
|
1760
|
+
});
|
|
1761
|
+
if (res?.isSuccess) {
|
|
1762
|
+
// 添加日历日程信息完成
|
|
1763
|
+
}
|
|
1764
|
+
```
|
|
1765
|
+
|
|
1766
|
+
* 示例 - `promise 模式`
|
|
1767
|
+
|
|
1768
|
+
```javascript
|
|
1769
|
+
this.$xybAgent.addCalendarEvent({
|
|
1770
|
+
title: '日历行程标题',
|
|
1771
|
+
startTime: new Date('2026/01/01 00:00:00').getTime(),
|
|
1772
|
+
endTime: new Date(`2026/01/01 00:05:00`).getTime(),
|
|
1773
|
+
reminderTime: 5
|
|
1774
|
+
}).then(res => {
|
|
1775
|
+
if (res?.isSuccess) {
|
|
1776
|
+
// 添加日历日程信息完成
|
|
1777
|
+
}
|
|
1778
|
+
});
|
|
1779
|
+
```
|
|
1780
|
+
|
|
1781
|
+
### 查看日历日程信息 - `queryCalendarEvent`
|
|
1782
|
+
|
|
1783
|
+
> * 该任务是一个异步任务,有回调值信息
|
|
1784
|
+
> * 该任务主要用于湘易办小程序/湘易办内嵌的H5页面,用于添加日历日程信息
|
|
1785
|
+
|
|
1786
|
+
* 环境适配说明
|
|
1787
|
+
|
|
1788
|
+
| 环境类型 | 是否适配 | 适配版本(最低) |
|
|
1789
|
+
|----------------|:----:|:---------|
|
|
1790
|
+
| 湘易办小程序 | `是` | `2.0.9` |
|
|
1791
|
+
| 湘易办小程序-webview | `是` | `2.0.9` |
|
|
1792
|
+
| 湘易办 - H5 | `否` | -- |
|
|
1793
|
+
| 三方小程序 | `否` | -- |
|
|
1794
|
+
|
|
1795
|
+
* 入参
|
|
1796
|
+
|
|
1797
|
+
| 参数名 | 类型 | 必填 | 描述 |
|
|
1798
|
+
|:--------|----------|-----|------|
|
|
1799
|
+
| eventID | `String` | `是` | 日程ID |
|
|
1800
|
+
|
|
1801
|
+
* 出参
|
|
1802
|
+
|
|
1803
|
+
| 参数名 | 子参数名 | 类型 | 描述 |
|
|
1804
|
+
|:----------|--------------|-------------|----------------|
|
|
1805
|
+
| items | | | |
|
|
1806
|
+
| | itemID | `String` | 日程ID |
|
|
1807
|
+
| | title | `String` | 日程标题 |
|
|
1808
|
+
| | startTime | `Timestamp` | 开始时间 **(时间戳)** |
|
|
1809
|
+
| | endTime | `Timestamp` | 结束时间 **(时间戳)** |
|
|
1810
|
+
| | reminderTime | `Number` | 距离开始时间x分钟提醒 |
|
|
1811
|
+
| isSuccess | | `Boolean` | 创建行程是否成功 |
|
|
1812
|
+
| errorMsg | | `String` | 错误消息内容 |
|
|
1813
|
+
|
|
1814
|
+
* 示例 - `async、await 模式`
|
|
1815
|
+
|
|
1816
|
+
```javascript
|
|
1817
|
+
const res = await this.$xybAgent.queryCalendarEvent({
|
|
1818
|
+
eventID: 'xxx'
|
|
1819
|
+
});
|
|
1820
|
+
if (res?.isSuccess) {
|
|
1821
|
+
// 查询日历日程信息完成
|
|
1822
|
+
}
|
|
1823
|
+
```
|
|
1824
|
+
|
|
1825
|
+
* 示例 - `promise 模式`
|
|
1826
|
+
|
|
1827
|
+
```javascript
|
|
1828
|
+
this.$xybAgent.addCalendarEvent({
|
|
1829
|
+
eventID: 'xxx'
|
|
1830
|
+
}).then(res => {
|
|
1831
|
+
if (res?.isSuccess) {
|
|
1832
|
+
// 查询日历日程信息完成
|
|
1833
|
+
}
|
|
1834
|
+
});
|
|
1835
|
+
```
|
|
1836
|
+
|
|
1837
|
+
### 删除日历日程信息 - `deleteCalendarEvent`
|
|
1838
|
+
|
|
1839
|
+
> * 该任务是一个异步任务,有回调值信息
|
|
1840
|
+
> * 该任务主要用于湘易办小程序/湘易办内嵌的H5页面,用于删除日历日程信息
|
|
1841
|
+
|
|
1842
|
+
* 环境适配说明
|
|
1843
|
+
|
|
1844
|
+
| 环境类型 | 是否适配 | 适配版本(最低) |
|
|
1845
|
+
|----------------|:----:|:---------|
|
|
1846
|
+
| 湘易办小程序 | `是` | `2.0.9` |
|
|
1847
|
+
| 湘易办小程序-webview | `是` | `2.0.9` |
|
|
1848
|
+
| 湘易办 - H5 | `否` | -- |
|
|
1849
|
+
| 三方小程序 | `否` | -- |
|
|
1850
|
+
|
|
1851
|
+
* 入参
|
|
1852
|
+
|
|
1853
|
+
| 参数名 | 类型 | 必填 | 描述 |
|
|
1854
|
+
|:--------|----------|-----|------|
|
|
1855
|
+
| eventID | `String` | `是` | 日程ID |
|
|
1856
|
+
|
|
1857
|
+
* 出参
|
|
1858
|
+
|
|
1859
|
+
| 参数名 | 类型 | 描述 |
|
|
1860
|
+
|:----------|-----------|----------|
|
|
1861
|
+
| isSuccess | `Boolean` | 创建行程是否成功 |
|
|
1862
|
+
| errorMsg | `String` | 错误消息内容 |
|
|
1863
|
+
|
|
1864
|
+
* 示例 - `async、await 模式`
|
|
1865
|
+
|
|
1866
|
+
```javascript
|
|
1867
|
+
const res = await this.$xybAgent.deleteCalendarEvent({
|
|
1868
|
+
eventID: 'xxx'
|
|
1869
|
+
});
|
|
1870
|
+
if (res?.isSuccess) {
|
|
1871
|
+
// 删除日历日程信息完成
|
|
1872
|
+
}
|
|
1873
|
+
```
|
|
1874
|
+
|
|
1875
|
+
* 示例 - `promise 模式`
|
|
1876
|
+
|
|
1877
|
+
```javascript
|
|
1878
|
+
this.$xybAgent.deleteCalendarEvent({
|
|
1879
|
+
eventID: 'xxx'
|
|
1880
|
+
}).then(res => {
|
|
1881
|
+
if (res?.isSuccess) {
|
|
1882
|
+
// 删除日历日程信息完成
|
|
1883
|
+
}
|
|
1884
|
+
});
|
|
1885
|
+
```
|
|
1886
|
+
|
|
1887
|
+
### 更新日志
|
|
1888
|
+
|
|
1889
|
+
#### **`2.0.10`**
|
|
1890
|
+
|
|
1891
|
+
* 最后更新时间:`2025/12/09`
|
|
1892
|
+
* 更新内容:
|
|
1893
|
+
|
|
1894
|
+
> 1. 增加日历行程添加API
|
|
1895
|
+
> 2. 增加日历行程查看API
|
|
1896
|
+
> 3. 增加日历行程删除API
|
|
1897
|
+
> 4. 优化部分事件的内部逻辑
|
|
1898
|
+
|
|
1899
|
+
* 文件
|
|
1900
|
+
|
|
1901
|
+
[xybAgent-2.0.10 点击下载](https://xybfw.zwfw.hunan.gov.cn/gateway3/devplat/download?path=2025/12/09/xybAgent-2.0.10_20251209143709A3rL-AA001.zip)
|
|
1902
|
+
|
|
1903
|
+
#### **`2.0.9`**
|
|
1904
|
+
|
|
1905
|
+
* 最后更新时间:`2025/12/01`
|
|
1906
|
+
* 更新内容:
|
|
1907
|
+
|
|
1908
|
+
> 1. 优化IOS下执行文件下载时,无法获取到多次回调的情况
|
|
1909
|
+
|
|
1910
|
+
* 文件
|
|
1911
|
+
|
|
1912
|
+
[xybAgent-2.0.9 点击下载](https://xybfw.zwfw.hunan.gov.cn/gateway3/devplat/download?path=2025/12/03/xybAgent-2.0.9_20251203200349Aqo0jdA006.zip)
|
|
1913
|
+
|
|
1914
|
+
#### **`2.0.8`**
|
|
1915
|
+
|
|
1916
|
+
* 最后更新时间:`2025/11/24`
|
|
1917
|
+
* 更新内容:
|
|
1918
|
+
|
|
1919
|
+
> 1. 增加胶囊按钮自动化配置功能 - 当地址栏存在xybModuleCode参数,SDK内部会自动上报事项的分享、评价配置(默认开启)
|
|
1920
|
+
> 2. 增加胶囊按钮自动化配置开关功能 - 通过配置 xybAgent.autoConfigMenuBtn = true / false
|
|
1921
|
+
来控制是否需要完成自动化配置(默认值true)
|
|
1922
|
+
|
|
1923
|
+
* 文件
|
|
1924
|
+
|
|
1925
|
+
[xybAgent-2.0.8 点击下载](https://xybfw.zwfw.hunan.gov.cn/gateway3/devplat/download?path=2025/12/03/xybAgent-2.0.8_20251203200651AEOGihg002.zip)
|
|
1926
|
+
|
|
1927
|
+
#### **`2.0.7`**
|
|
1928
|
+
|
|
1929
|
+
* 最后更新时间:`2025/11/20`
|
|
1930
|
+
* 更新内容:
|
|
1931
|
+
|
|
1932
|
+
> 1. 优化鸿蒙下获取位置信息时,可能因系统底层差异导致返回的数据结构与API文档不一致的问题
|
|
1933
|
+
> 2. 优化H5埋点数据上报时的日志信息打印,会准确告知用户侧是否上报到生产环境
|
|
1934
|
+
> 3. 修复屏蔽胶囊按钮自动重置的BUG,默认把重置功能给屏蔽了的问题
|
|
1935
|
+
|
|
1936
|
+
* 文件
|
|
1937
|
+
|
|
1938
|
+
[xybAgent-2.0.7 点击下载](https://xybfw.zwfw.hunan.gov.cn/gateway3/devplat/download?path=2025/12/03/xybAgent-2.0.7_20251203200715AHOnf4g007.zip)
|
|
1939
|
+
|
|
1940
|
+
#### **`2.0.5`**
|
|
1941
|
+
|
|
1942
|
+
* 最后更新时间:`2025/11/03`
|
|
1943
|
+
* 更新内容:
|
|
1944
|
+
|
|
1945
|
+
> 1. 增加配置项,屏蔽整个应用的胶囊按钮自动重置的动作(只适用于基于uni-app开发的H5应用,且整个应用只有一个事项编码时使用)
|
|
1946
|
+
|
|
1947
|
+
* 文件
|
|
1948
|
+
|
|
1949
|
+
[xybAgent-2.0.5 点击下载](https://xybfw.zwfw.hunan.gov.cn/gateway3/devplat/download?path=2025/12/03/xybAgent-2.0.5_20251203200737Ag4PNBQ003.zip)
|
|
1950
|
+
|
|
1951
|
+
#### **`2.0.4`**
|
|
1952
|
+
|
|
1953
|
+
* 最后更新时间:`2025/11/03`
|
|
1954
|
+
* 更新内容:
|
|
1955
|
+
|
|
1956
|
+
> 1. 修复鸿蒙下的湘易办小程序无法与Webview嵌套的H5进行数据通信的问题
|
|
1957
|
+
> 2. 修正部分业务可能因withCredentials导致接口跨域的问题
|
|
1958
|
+
|
|
1959
|
+
* 文件
|
|
1960
|
+
|
|
1961
|
+
[xybAgent-2.0.4 点击下载](https://xybfw.zwfw.hunan.gov.cn/gateway3/devplat/download?path=2025/12/03/xybAgent-2.0.4_20251203200754AlBRzfw008.zip)
|
|
1962
|
+
|
|
1963
|
+
#### **`2.0.1`**
|
|
1964
|
+
|
|
1965
|
+
* 最后更新时间:`2025/10/15`
|
|
1966
|
+
* 更新内容:
|
|
1967
|
+
|
|
1968
|
+
> 1. 优化逻辑,修复小程序与H5进行事件通讯时,部分事件失效的问题
|
|
1969
|
+
> 2. 优化事件调用的效率
|
|
1970
|
+
|
|
1971
|
+
* 文件
|
|
1972
|
+
|
|
1973
|
+
[xybAgent-2.0.1 点击下载](https://xybfw.zwfw.hunan.gov.cn/gateway3/devplat/download?path=2025/12/03/xybAgent-2.0.1_20251203200813Aa_0jSg009.zip)
|
|
1974
|
+
|
|
1975
|
+
#### **`2.0.0`**
|
|
1564
1976
|
|
|
1565
1977
|
* 最后更新时间:`2025/09/26`
|
|
1566
1978
|
* 更新内容:
|
|
@@ -1573,7 +1985,9 @@ this.$xybAgent.startNavigation({
|
|
|
1573
1985
|
|
|
1574
1986
|
* 文件
|
|
1575
1987
|
|
|
1576
|
-
|
|
1988
|
+
[xybAgent-2.0.0 点击下载](https://xybfw.zwfw.hunan.gov.cn/gateway3/devplat/download?path=2025/12/03/xybAgent-2.0.0_20251203200833AmErUng004.zip)
|
|
1989
|
+
|
|
1990
|
+
#### **`1.1.8`**
|
|
1577
1991
|
|
|
1578
1992
|
* 最后更新时间:`2025/09/02`
|
|
1579
1993
|
* 更新内容:
|
|
@@ -1584,3 +1998,5 @@ this.$xybAgent.startNavigation({
|
|
|
1584
1998
|
> 4. 优化webview页面的数据回调,避免因短时间内多次调用导致的数据回传异常问题
|
|
1585
1999
|
|
|
1586
2000
|
* 文件
|
|
2001
|
+
|
|
2002
|
+
[xybAgent-1.1.8 点击下载](https://xybfw.zwfw.hunan.gov.cn/gateway3/devplat/download?path=2025/12/03/xybAgent-1.1.8_20251203200851A3NTr-A005.zip)
|
package/dist/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=(e="",t="",i="log",n="")=>{const o={error:"错误",warn:"警告",info:"提示",log:"日志"}[i]||"日志",a=JSON.stringify(n);console.log(`\n=============🚀START - V${x} 🚀=============\n【事件名称】:${e} \n【日志类型】:${o} \n【日志信息】:${t} ${"error"===i?`【错误信息】:${JSON.stringify(a)}`:""} \n==============🚀END🚀==============`),console.log("")},t=(t={})=>{if("function"==typeof t)return e("deepClone","数据类型为function,无法执行深拷贝,请检查","error"),t;try{return JSON.parse(JSON.stringify(t))}catch(i){return e("deepClone","执行数据深拷贝异常","error",i),t}},i=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}),n=(e={},t={})=>{for(let i in e)t[i]=e[i]},o=(t=!1)=>{let i={route:null,path:null,options:{}};try{const e="function"==typeof getCurrentPages?getCurrentPages():[],n=[];for(let t in e)n.push({route:e[t].route,path:e[t].$page?.fullPath,options:e[t].$page?.options});const o=n?.length||0;if(o){const e=n[o-1],a=n[o-2];i=(t?a:e)||{}}}catch(t){e("getCurrentPagePath","获取页面信息失败","error",t)}return i},a=e=>{try{return JSON.parse(e)}catch(t){return e}},s=(t={},i={})=>{let n=i;try{n=a(i)}catch(t){e("formatResponseData","格式化失败","error",t),n=i}t(n)},r=e=>null==e,c=(e="",t="")=>{let i=t||window?.location?.href;if(i=decodeURIComponent(i),i?.includes(e)){let t=i.split(`${e}=`)[1];return t?.includes("&")&&(t=t.split("&")[0]),t}return""},l=(t="",i="")=>{if(t)return e("loadWeChatSDK",`开始挂载 ${i} SDK文件`,"log"),new Promise(e=>{const i=document.createElement("script");i.src=t,i.onload=e,document.head.appendChild(i)})},u=(t,i)=>{window?.my?.navigateTo({url:t,fail:t=>{e("openAlipayMiniApp","跳转失败,请检查配置信息","error",t),i({code:-1,isSuccess:!1,message:"跳转失败,请检查配置信息"})}})},d=(t,i)=>{window?.wx?.miniProgram?.navigateTo({url:t,fail:t=>{e("executeAuthFaceInBrowser","跳转失败,请检查配置信息","error",t),i({code:-1,isSuccess:!1,message:"跳转失败,请检查配置信息"})}})};let m={finished:!1,result:!1},g={finished:!1,result:!1},h={finished:!1,result:!1},p={finished:!1,result:!1};const v=()=>w()?navigator.userAgent.toLowerCase():"",f=()=>{const e=v();return/android/i.test(e)?"android":/iphone|ipad|ipod|mac/i.test(e)&&!window.MSStream?"ios":/windows phone/i.test(e)?"windows":"harmony"},w=()=>window&&document,N=()=>{if(p.finished)return p.result;if(p.finished=!0,!w())return p.result=!1,!1;const t=v();return p.result=t.includes("uni-app"),e("checkIsMiniAppBrowserEnv",`当前是否为小程序的浏览器环境:${p.result}`),p.result},S=()=>{const{finished:t,result:i}=m;return t?i:(m.result=(()=>{if(h.finished)return h.result;if(h.finished=!0,!w())return h.result=!1,!1;const t=v();return h.result=t.includes("xybwebcomponent")||t.includes("uni-app"),e("checkIsXybBrowserEnv",`当前是否为湘易办浏览器环境:${h.result}`),h.result})()||N(),m.finished=!0,e("checkIsWebviewEnv",`当前是否为Webview环境:${m.result}`),m.result)},y=()=>{const{finished:t,result:i}=g;if(t)return i;if(g.finished=!0,!w())return g.result=!1,!1;const n=v();return g.result=n.includes("xybwebcomponent")&&!n.includes("uniminiapp"),e("checkIsAppWebviewEnv",`当前是否为APP的Webview环境:${g.result}`),g.result},C=()=>w()?v().includes("micromessenger"):"mp-weixin"===f(),I=()=>w()?v().includes("alipay"):"mp-alipay"===f(),A=()=>!!uni&&(!!uni.sendNativeEvent&&("function"==typeof uni.sendNativeEvent||"undefined"!=typeof uni&&Object.prototype.hasOwnProperty.call(uni,"sendNativeEvent"))),E=()=>window?.uni&&"function"==typeof window?.uni?.webView?.postMessage,$=()=>"function"==typeof window?.wx?.chooseImage,b=()=>"function"==typeof window?.my?.chooseImage,M=t=>{const{dinateType:i}=t;return e("replaceCoordinate",`坐标转换开始:${i}`,"log"),(e=>{const{lat:t,lng:i,address:n}=e,o=52.35987755982988,a=i-.0065,s=t-.006,r=Math.sqrt(a*a+s*s)-2e-5*Math.sin(s*o),c=Math.atan2(s,a)-3e-6*Math.cos(a*o);return{destinationName:n,destinationLongitude:r*Math.cos(c).toFixed(6),destinationLatitude:r*Math.sin(c).toFixed(6)}})(t)},D=[{isCustomEv:!0,eventName:"authFace",uniEvName:"Auth_face",description:"人脸识别功能",nativeEvName:"faceAuth",reqDataFormat:t=>{e("authFace",`执行人脸验证,参数信息:${JSON.stringify(t)}`);const{name:i,certNo:n,appId:o,sign:a,created:s,nonce:r}=t;return i&&n&&o&&a&&s&&r?t:(e("authFace","缺少必要参数:name, certNo, appId, sign, created, nonce","error","缺少必要参数"),!1)},resDataFormat:e=>({isSuccess:Boolean(e),certifyId:e}),resErrorFormat:e=>"harmony"===f().toLowerCase()?{isSuccess:!1,errorMsg:e}:e},{isCustomEv:!0,eventName:"startNavigation",uniEvName:"Start_navigation",description:"目的地导航",nativeEvName:"start_navigation",reqDataFormat:t=>{let i={};const{dinateType:n,lat:o,lng:a,address:s,destinationLatitude:r,destinationLongitude:c}=t;return r&&c?t:(e("replaceCoordinate",`坐标系值:LAT:${o},LNG:${a}`,"log"),i=n&&"GCJ02"!==n?M(t):{destinationLatitude:o,destinationLongitude:a,destinationName:s},e("replaceCoordinate",`转换后值:LAT:${i.destinationLatitude},LNG:${i.destinationLongitude}`,"log"),i)}},{isWindowEv:!0,eventName:"getLoginStatus",uniEvName:"Auth_checkLogin",description:"获取登录状态",nativeEvName:"CallNativeMethodGetUserInfo",resDataFormat:e=>{const i=t(e);return{logined:1===Number(i?.isLogin)}},resErrorFormat:()=>({logined:!1})},{isWindowEv:!0,eventName:"getLoginUserInfo",uniEvName:"Auth_getUserInfo",description:"获取登录用户数据信息",nativeEvName:"CallNativeMethodGetUserInfo",resDataFormat:e=>t(e),resErrorFormat:()=>({isSuccess:!1})},{isCustomEv:!0,eventName:"getAuthToken",uniEvName:"Auth_getToken",description:"获取授权token",nativeEvName:"get_token",resDataFormat:e=>{try{const i=t(e);return{token:i?.token,isSuccess:Boolean(i?.token)}}catch(t){return{token:e?.token,isSuccess:Boolean(e?.token)}}},resErrorFormat:()=>({isSuccess:!1})},{isWindowEv:!0,eventName:"getAccessLink",uniEvName:"Auth_getAccessLink",nativeEvName:"CallNativeMethodGetAccessLink",description:"获取授权链接",resDataFormat:e=>"ios"===f().toLowerCase()?{isSuccess:!0,accessLink:e}:t(e),resErrorFormat:()=>({isSuccess:!1})},{moduleName:"image",eventName:"chooseImg",uniEvName:"Image_choose",nativeEvName:"chooseImage",browserEvName:"chooseImage",description:"选择本地图片",reqDataFormat:e=>{const{count:t,sizeType:i,sourceType:n,isCircleCrop:o}=e||{};return{count:t||9,sizeType:i||["original","compressed"],sourceType:n||["album"],isCircleCrop:o||!1}},resDataFormat:e=>t(e),bResDataFormat:e=>{const{tempFiles:t}=e,i=[];for(let e in t){const{name:n,path:o,size:a,type:s}=t[e];i.push({name:n,path:o,size:a,type:s})}return{resultObj:i,isSuccess:!0,message:"选择图片功能操作完成"}}},{moduleName:"image",eventName:"imgPreview",uniEvName:"Image_preview",nativeEvName:"previewImage",browserEvName:"previewImage",description:"执行图片预览"},{moduleName:"image",eventName:"imgUpload",uniEvName:"Image_upload",nativeEvName:"uploadImage",description:"执行图片上传",resDataFormat:e=>t(e),resErrorFormat:e=>e},{eventName:"imgDownload",uniEvName:"Image_download",nativeEvName:"",browserEvName:"downloadImage",description:"执行图片下载"},{eventName:"fileUpload",uniEvName:"File_upload",nativeEvName:"",description:"执行文件上传"},{moduleName:"file",eventName:"fileDownload",uniEvName:"File_download",nativeEvName:"downloadFile",description:"执行文件下载",resDataFormat:e=>({isSuccess:Boolean(e),resultObj:{path:e}})},{moduleName:"file",eventName:"filePreview",uniEvName:"File_preview",nativeEvName:"previewFile",description:"执行文件预览"},{moduleName:"file",eventName:"openLocalFile",uniEvName:"File_openLocal",nativeEvName:"openLocalFile",description:"执行打开本地文件"},{moduleName:"file",eventName:"chooseLocalFile",uniEvName:"File_chooseLocal",nativeEvName:"chooseLocalFile",browserEvName:"chooseFile",description:"选择本地文件",resDataFormat:e=>t(e)},{moduleName:"file",eventName:"openThirdFile",uniEvName:"File_openThirdParty",nativeEvName:"openFileWithThirdParty",description:"执行打开第三方文件"},{eventName:"openApp",uniEvName:"Util_openApp",nativeEvName:"",description:"打开APP"},{isCustomEv:!0,eventName:"openXybApp",uniEvName:"Util_openXYBMiniApp",nativeEvName:"jumpToMiniApp",description:"打开湘易办融合APP小程序",reqDataFormat:e=>{if(y()){const{pageUrl:t}=e;return{...e,path:t}}return e}},{eventName:"postMsgToOtherApp",uniEvName:"Util_postMessageToXYBMiniApp",nativeEvName:"",description:"发送消息给其他小程序"},{isWindowEv:!0,eventName:"scanCode",uniEvName:"Scan_code",description:"扫描二维码",browserEvName:"scanQRCode",nativeEvName:"CallNativeMethodScanQRCode",resDataFormat:e=>({text:e}),bResDataFormat:e=>({text:e?.result||""})},{moduleName:"system",eventName:"getAppInfo",nativeEvName:"getAppInfo",description:"获取应用信息",uniEvName:"System_getAppInfo",resDataFormat:e=>t(e)},{moduleName:"util",eventName:"copyToClipboard",uniEvName:"Util_clipboardData",nativeEvName:"clipboardData",description:"复制内容到剪切板",reqDataFormat:e=>({text:e}),resDataFormat:e=>y()?{isSuccess:Boolean(e)}:{isSuccess:!0}},{moduleName:"util",eventName:"getCacheSize",uniEvName:"Util_getCacheSize",nativeEvName:"getCacheSize",description:"获取缓存大小",resDataFormat:e=>t(e)},{moduleName:"util",eventName:"clearCache",uniEvName:"Util_clearCache",nativeEvName:"clearCache",description:"执行缓存清除",resDataFormat:()=>({isSuccess:!0}),resErrorFormat:()=>({isSuccess:!1})},{moduleName:"telephone",eventName:"callPhone",uniEvName:"Util_callDesignateNumber",nativeEvName:"call",description:"拨打电话",browserEvName:"makePhoneCall",reqDataFormat:e=>"object"==typeof a(e)?a(e):y()?{phoneCode:"+86",phoneNumber:String(e).replace("+86","")}:{text:e}},{eventName:"forbidScreenShot",uniEvName:"Util_forbidScreenShot",nativeEvName:"",description:"执行禁止截屏"},{eventName:"setScreenLight",uniEvName:"Util_setScreenLight",nativeEvName:"",description:"设置屏幕是否常亮",reqDataFormat:e=>({idleTimerValue:e})},{eventName:"sendMatterId",uniEvName:"Param_MatterID",nativeEvName:"",description:"执行页面事件ID上报",reqDataFormat:e=>({matterID:e})},{isWindowEv:!0,description:"获取位置信息",eventName:"getLocationInfo",uniEvName:"Util_getLocationInformation",nativeEvName:"CallNativeMethodGetLocationInformation",resDataFormat:e=>{const{location:i,data:n}=e;let o=t(e);return i&&(o=t(e?.location)),n&&(o=t(e?.data)),{isSuccess:!0,location:o}},nativeResFormat:e=>{const{location:i,data:n}=e;let o=t(e);return i&&(o=t(e?.location)),n&&(o=t(e?.data)),{isSuccess:!0,location:o}},resErrorFormat:()=>({isSuccess:!1,location:{}})},{eventName:"checkPermission",uniEvName:"Auth_matterHandleAuthority",nativeEvName:"",description:"检查事项权限",reqDataFormat:e=>({matterCode:e})},{eventName:"showComment",uniEvName:"Util_jumpToComment",nativeEvName:"",description:"打开评价弹窗"},{isWindowEv:!0,description:"打开微信小程序",eventName:"openWechatMiniApp",uniEvName:"Util_openWechatMiniProgram",nativeEvName:"CallNativeMethodJumpToWechatMiniProgram",reqDataFormat:e=>{if(y()){const t={};for(let i in e)t[i]=String(e[i]);return JSON.stringify(t)}return e}},{isWindowEv:!0,description:"打开支付宝小程序",eventName:"openAliPayMiniApp",uniEvName:"Util_openAlipayMiniProgram",nativeEvName:"CallNativeMethodJumpToAliPay",reqDataFormat:e=>y()?JSON.stringify(e):e},{eventName:"showMenuPanel",uniEvName:"menu_present",nativeEvName:"",description:"显示菜单面板"}],x="0.0.17",k="http://172.16.7.71:3000",P={custom(t,i){e("custom",`通过custom调用${t}事件`);const n=D?.find(e=>e?.nativeEvName===t||e?.eventName===t);return new Promise((e,o)=>{const{reqDataFormat:a}=n||null,s=n||{isCustomEv:!0,moduleName:"custom",eventName:"call",description:"通过Custom调用的C2事件",nativeEvName:t};if(!y())return void e({code:-1,msg:"非APP环境的Webview环境,不支持该功能"});const r=a?a(i):i;this.executeSendMsgToApp({moduleName:"custom",eventName:"call",actionName:t,isCustomEv:!0,dataInfo:r,resolveInfo:e,evConfig:s})})}},O=e=>Number(e)>9?e:`0${e}`,F=()=>{const e=new Date;return`${e.getFullYear()}-${O(e.getMonth()+1)}-${O(e.getDate())} ${O(e.getHours())}:${O(e.getMinutes())}:${O(e.getSeconds())}`},L={trackStack:[],anaSDKLoadTimes:0,locationInfo:{},isProdEnv:!1,track(t="",n={}){if(t){if(n)return w()&&!this.anaSDKInit?(this.trackStack.push({id:i(),eventID:t,eventPro:n}),void e("track","埋点上报插件初始化未完成,本次数据在插件初始化后自动上报","log")):void this.executeTrack(t,n);e("track","埋点数据上报失败","error","请传入埋点数据")}else e("track","埋点数据上报失败","error","请传入埋点事件")},async executeTrack(t="",i={}){if("object"==typeof t)return void await this.track(t?.eventID,t?.eventPro);const n=await this.initTrackParams(i);if(e("track",`执行埋点数据上报,事件名称:${t},事项编码:${n.code},是否上报到生产环境:${this.isProdEnv},完整埋点数据:${JSON.stringify(n)}`,"log"),w()&&xybAgent?.AnalysysAgent)return e("track","通过浏览器插件执行埋点数据上报","log"),void window.xybAgent.AnalysysAgent.track(t,n);if(A())try{e("track",`埋点数据:${JSON.stringify(n)},埋点ID:${t}`,"log"),uni.sendNativeEvent("Analysis_common",{eventID:t,eventPro:n})}catch(t){e("track","执行数据埋点功能异常","error",t)}},trackSDKInit(t){return new Promise((i,n)=>{w()||(e("initTrack","非浏览器环境无需使用init执行初","error"),i(!0)),this.anaSDKInsert?this.configAnaSDK(t,i):l("https://mobile.zwfw.hunan.gov.cn:8088/AnalysysAgent_JS_SDK.min.js","极光").then(()=>{window.AnalysysAgent&&(xybAgent.AnalysysAgent=window.AnalysysAgent,this.anaSDKInsert=!0,this.configAnaSDK(t,i))})})},configAnaSDK(t,i){const n="800c298f0c42c94c",o="40d556c15f872084";let a=location?.host?.includes("hunan.gov.cn")?n:o;if("object"==typeof t)a=o;else{const e={production:n,development:o},i=[n,o];(e[t]||i.includes(t))&&(a=e[t]?e[t]:t)}this.isProdEnv=a===n,e("configAnaSDK",`配置信息:${JSON.stringify(t)},是否为生产环境:${this.isProdEnv},上报的key值:${a}`),w()?(window.xybAgent.AnalysysAgent&&(window.xybAgent.AnalysysAgent.init({appkey:a,uploadURL:"https://mobile.zwfw.hunan.gov.cn:8088/aurora-api"}),e("configAnaSDK","xybAgent已初始化完成,可正常执行埋点操作","log"),this.anaSDKInit=!0,this.isInit=!0,this.checkTrackStack(),i(!0)),!Boolean(window.xybAgent.AnalysysAgent)&&this.anaSDKLoadTimes<10&&setTimeout(()=>this.trackSDKInit(i),300),!Boolean(window.xybAgent.AnalysysAgent)&&this.anaSDKLoadTimes>=10&&(e("configAnaSDK","xybAgent初始化失败","error","请检查app key、uploadURL是否正确"),i(!1))):i(!1)},async initTrackParams(e={}){const{code:t,name:i,aff_city_code:n,aff_city_name:o,unit_code:a,area_code:s,unit_name:r,is_finish:c,category:l,user_id:u,miniAppCode:d,$url_domain:m}=e,g=this.getVisitSource(),h=this.getPageSource(),p=await this.getPositionInfo();return{code:t||void 0,name:i||void 0,aff_city_code:n||void 0,aff_city_name:o||void 0,unit_code:a||void 0,area_code:s||void 0,unit_name:r||void 0,is_finish:c||void 0,category:l||void 0,user_id:u||void 0,miniAppCode:d||void 0,$url_domain:m||void 0,curr_time:F(),source:g,page_source:h,location:p}},getVisitSource(){if(!w()){const e=uni?.getSystemInfoSync(),{uniPlatform:t}=e||{};return"mp-weixin"===t?"wx":"mp-alipay"===t?"alipay":"app"}return C()?"wx":I()?"alipay":"app"},checkTrackStack(){e("checkTrackStack","执行埋点数据堆栈检测","log");t(this.trackStack).forEach(t=>{const{eventID:i,eventPro:n,id:o}=t;e("checkTrackStack",`执行id值为${o} 的埋点数据再次上报`,"log"),this.track(i,n);const a=this.trackStack.findIndex(e=>e.id===o);a>-1&&this.trackStack.splice(a,1)})},getPageSource(){let e=null;e=w()?location.href:decodeURIComponent(o().path);const t=e?.includes("source=");if(!t)return"click";const i=e.split("source=")[1];let n="click";return n=i.includes("&")?i.split("&")[0]:i,["copy","share","click","search"].includes(n)?n:"click"},async getPositionInfo(){if(!this.locationInfo?.province)try{const{location:e}=await this.getLocationInfo()||{};this.locationInfo=e||""}catch(t){e("getLocationInfo","获取位置信息异常","error",t),this.locationInfo={}}return JSON.stringify(this.locationInfo)}},T={initMobileBridgeGlobalConfig(){const t=f();e("initMobileBridgeGlobalConfig",`开始初始化移动端桥链接配置,访问设备类型:${t}`),window.c2={},"ios"===t&&this.initIOSCallbackEvConfig(),"android"===t&&this.initAndroidCallbackEvConfig(),e("initMobileBridgeGlobalConfig","初始化移动端桥链接配置完成"),window.CreatorJsBridge=window.c2},initIOSCallbackEvConfig(){try{const t=this;window.c2.iOS={},window.c2.iOS.callJS=function(){window?.c2.iOS?.callJSCallback||(window.c2.iOS.callJSCallback={}),e("initIOSCallbackEvConfig",`开始处理IOS设备回调事件,回调数据:${JSON.stringify(arguments)}`),t.IOSCallbackEvFormat(arguments[0])}}catch(t){e("initIOSCallbackEvConfig","初始化IOS回调事件配置异常","error",t)}},initAndroidCallbackEvConfig(){window.c2.sendDataWarpToWeb=(e,t,i)=>{e(i)}},IOSCallbackEvFormat(i){const{returnValue:n,funcName:o}=i;let s=this.base64Decode(n);s=a(s),e("IOSCallbackEvFormat",`IOS设备回调事件处理开始,回调数据:${JSON.stringify(s)}, 格式:${typeof s}`);const r=o.split("_a")[0],c=o.replace(r,""),l=this.iosCallBackList.find(e=>e.id===r);if(!l)return;const{resolveInfo:u,configInfo:d}=l,{resDataFormat:m,resErrorFormat:g}=d;if(c.includes("onFail")&&g)return s=g({isSuccess:!1,errorMsg:t(n)}),void u(s);m&&(s=m(s)),e("IOSCallbackEvFormat",`IOS设备回调事件处理完成,返回数据:${JSON.stringify(s)}`),u(s);const h=this.iosCallBackList.findIndex(e=>e.id===r);this.iosCallBackList.splice(h,1)},base64Decode(e){let t,i,n,o,a,s,r,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",l="",u=0;for(e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");u<e.length;)o=c.indexOf(e.charAt(u++)),a=c.indexOf(e.charAt(u++)),s=c.indexOf(e.charAt(u++)),r=c.indexOf(e.charAt(u++)),t=o<<2|a>>4,i=(15&a)<<4|s>>2,n=(3&s)<<6|r,l+=String.fromCharCode(t),64!=s&&(l+=String.fromCharCode(i)),64!=r&&(l+=String.fromCharCode(n));return l=this._utf8_decode(l),l},_utf8_decode(e){let t="",i=0,n=0,o=0,a=0;for(;i<e.length;)n=e.charCodeAt(i),n<128?(t+=String.fromCharCode(n),i++):n>191&&n<224?(a=e.charCodeAt(i+1),t+=String.fromCharCode((31&n)<<6|63&a),i+=2):(a=e.charCodeAt(i+1),o=e.charCodeAt(i+2),t+=String.fromCharCode((15&n)<<12|(63&a)<<6|63&o),i+=3);return t},checkMobileModuleBack(e,t,i){const n=i?"custom":e,o=`${i?"call":t}Callback`;window.c2.hasOwnProperty(n)||(window.c2[n]={}),window.c2[n].hasOwnProperty(o)||(window.c2[n][o]={})}};let B=null,W=null,_=null;A()?(B=uni&&uni?.requireNativePlugin?uni?.requireNativePlugin("GCUniPlugin-RUM"):null,W=uni&&uni?.requireNativePlugin?uni?.requireNativePlugin("GCUniPlugin-Tracer"):null,_=uni&&uni?.getSystemInfoSync?uni.getSystemInfoSync().platform:null):e("请求插件初始化","未找到uni对象","warn");const J={defaults:{headers:{},baseURL:""},interceptor:{request:null,response:null},requestOb:!1,request(i={}){return new Promise((n,o)=>{let a=t(i);if(!this.interceptor.request||"function"!=typeof this.interceptor.request||i.ignore||(a=this.interceptor.request(i),a))if(A()&&this.requestOb&&Boolean(B)&&Boolean(W))try{e("request","走服务监控平台的请求配置","log"),this.executeCloudObRequest(a,n,o)}catch(t){e("request","走服务监控平台的请求配置失败","error",t)}else e("request","走uni的请求配置","log"),this.executeNormalRequest(a,n,o);else n(!1)})},executeCloudObRequest(t,n,o){let a=i();const s=this.checkCloudObRequestHeader(t,a);if(!s)return;const{traceHeader:c,filter:l}=s;let u,d,m;B.startResource({key:a}),uni.request({url:`${this.defaults.baseURL}${t.url}`,method:t.method,header:c,data:t.data,timeout:t.timeout,withCredentials:t?.withCredentials||void 0,success:i=>{if(e("executeCloudObRequest",`接口:${t.url},请求成功`,"log"),l||(u=i.header,d=i.data.toString(),m=i.statusCode),r(t.success)||t.success(i),this.interceptor.response&&"function"==typeof this.interceptor.response&&!t.ignore){const e=this.interceptor.response(i);return void n(e)}n(i)},fail:i=>{e("executeCloudObRequest",`接口:${t.url},请求失败`,"error",i),l||(d=i?.errMsg),r(t?.fail)||t.fail(i),o(i)},complete:()=>{if(e("executeCloudObRequest",`接口:${t.url},请求完成`,"log"),!l){e("executeCloudObRequest",`无filter配置的数据信息::::key值:${a};URL地址:${t.url};`),B.stopResource({key:a});const i={url:`${this.defaults.baseURL}${t.url}`,httpMethod:t.method,requestHeader:c,responseHeader:u,responseBody:d,resourceStatus:m};B.addResource({key:a,content:i})}Boolean(t?.complete)&&t?.complete()}})},checkCloudObRequestHeader(t,i){let n;r(t?.filterPlatform)?(e("executeCloudObRequest",`options.filterPlatform:${t.filterPlatform}`,"log"),n=!1):(n=t?.filterPlatform?.includes(_),e("executeCloudObRequest",`platform:${t.filterPlatform}`,"log")),e("executeCloudObRequest",`rum:${B},tracer:${W}`,"log");let o={};return n||(o=W?.getTraceHeader({key:i,url:t.url})),e("executeCloudObRequest",`是否读取到【tracer】插件配置:${Boolean(W)},是否读取到【rum】插件配置:${Boolean(B)}`,"log"),B&&W?(o=Object.assign({},o,t.header),o=Object.assign({},o,this.defaults.headers),{traceHeader:o,filter:n}):(e("executeCloudObRequest","请配置服务监控平台原生插件","log"),!1)},executeNormalRequest(t,i,n){const{url:o,header:a,data:s,method:r}=t||{},c=Object.assign({},this.defaults.headers,a);uni.request({url:`${this.defaults.baseURL}${o}`,header:c,data:s,method:r,withCredentials:t?.withCredentials||void 0,success:n=>{if(e("normalRequest",`接口:${o},请求成功`,"log"),this.interceptor.response&&"function"==typeof this.interceptor.response&&!t.ignore){const e=this.interceptor.response(n);return void i(e)}i(n)},fail:t=>{e("normalRequest",`接口:${o},请求异常`,"error",t),n(t)}})}},H={resetMenuBtnConfig(){e("hideNativeBtn","隐藏原生APP分享、评价按钮","log");const t={share:{show:!1},comment:{show:!1},favorite:{show:!0}};try{this.menuBtnConfig(t),this.pageChangeEv(i=>{if(!this.autoUpdate)return void e("resetMenuBtnConfig","业务侧设置不自动重置胶囊按钮,中断配置动作");const{options:n}=i,{xybModuleCode:o}=n||{};if(o&&this.autoConfigMenuBtn)return e("resetMenuBtnConfig",`页面拦截事件生效 自动设置原生APP分享、评价按钮,配置信息:${JSON.stringify(i)}`,"log"),void this.menuBtnConfig({share:{show:!0,code:o,type:4},comment:{show:!0,code:o,type:4},favorite:{show:!0}});e("resetMenuBtnConfig","页面拦截事件生效 自动重置原生APP分享、评价按钮配置信息","log"),this.menuBtnConfig(t)})}catch(t){e("resetMenuBtnConfig","配置APP的胶囊按钮清单显示失败,请检查参数是否正确","error",t)}},pageChangeEv(t){if(!uni)return;["navigateTo","redirectTo","switchTab","reLaunch","navigateBack","onBackPress"].forEach(i=>{try{uni.addInterceptor(i,{invoke(n){try{const{url:a}=n;let s={options:{},path:null,route:null},r=decodeURIComponent(a);s.path=r,s.route=r.split("?")[0],r?.includes("xybModuleCode=")&&(console.log(`🚀当前页面路径信息:${r}`),s.options.xybModuleCode=c("xybModuleCode",r)),r?.includes("?")&&(s.route=r.split("?")[0]),i?.includes("Back")&&(s=o(i?.includes("Back"))),e("pageChangeEv",`页面路径发生了变化,当前页面路径:${s.path}`,"log"),"function"==typeof t&&t(s)}catch(t){console.log("🚀 错误信息:::::",t),e("pageChangeEv","拦截路径变化时发生了异常","error",t)}return!0}})}catch(t){e("pageChangeEv","执行页面变化拦截异常","error",t)}})},menuBtnConfig(t={}){e("menuBtnConfig",`配置APP胶囊按钮清单显示,配置信息:${JSON.stringify(t)}`,"log");let i=!0;for(let n in t){if("object"!=typeof t[n]){i=!1,e("menuBtnConfig","配置参数错误","error","请传入一个Object配置数据");break}}if(i)if(S())this.miniAppH5SendMsgToApp(null,"menuBtnConfig",t,"配置APP的胶囊按钮清单显示");else if(!w()&&uni&&uni?.sendNativeEvent)try{e("menuBtnConfig","开始执行配置APP胶囊按钮清单显示","log"),uni?.sendNativeEvent("Util_MiniAppConfigMenu",t)}catch(t){e("menuBtnConfig","配置APP的胶囊按钮清单显示时发生异常","error",t)}else e("menuBtnConfig","配置APP胶囊按钮清单显示功能无法在非UNI环境运行","log")}},K={executeBrowserEvent(t,i={},n={},o={}){const a=C()?"微信小程序":I()?"支付宝小程序":"浏览器",{eventName:s,description:r,browserEvName:c,bResDataFormat:l}=o,u="startNavigation"===s?n:i;e("normalEvDataTransition",`开始调用${a}嵌套H5的能力,事件名称:${s},入参:${JSON.stringify(u)},配置信息:${JSON.stringify(o)}`);const d={authFace:"executeAuthFaceInBrowser",getLocationInfo:"executeGetLocationInBrowser",startNavigation:"startNavigationInBrowser"}[s];d?this[d](t,u,o):c?I()?this.executeAlipayBrowserEv(t,c,i,l):C()?this.executeWeChatBrowserEv(t,c,i,l):this.executeNativeBrowserEv(t,c,i,l):t({isSuccess:!1,code:-1,message:`非常抱歉,${r}功能无法在当前环境中使用`})},executeWeChatBrowserEv(e,i){let n=t(i);n.success=function(e){console.log(e)},n.fail=function(e){console.error(e)},window.wx[e](n)},executeAlipayBrowserEv(e,i){let n=t(i);n.success=function(e){console.log(e)},n.fail=function(e){console.error(e)},window.my[e](n)},executeNativeBrowserEv(e,i){let n=t(i);n.success=function(e){console.log(e)},n.fail=function(e){console.error(e)},window.uni[e](n)}},q={executeAuthFaceInBrowser(t,i={},n={}){const o=function(i){let n=c("faceKey",window?.location?.href);if(e("executeAuthFaceInBrowser",`获取到的faceKey参数值::::${n}`),!window?.location?.href.includes("faceKey"))return;window.history.go(-1);const a={result:Boolean(n),certifyId:n,portrait:null,errorMsg:null};window.removeEventListener("hashchange",o),setTimeout(()=>{e("executeAuthFaceInBrowser",`执行验证结果回抛给业务侧:${JSON.stringify(a)}`),t(a)},100)};window.addEventListener("hashchange",o);const a=encodeURIComponent(window.location.href),{certNo:s,name:r}=i;let l=`/pages/sdk/sdk?redirectUrl=${a}&type=authFace&idCard=${encodeURIComponent(s)}&name=${r}`;C()?d(l,t):I()?u(l,t):(e("executeAuthFaceInBrowser","当前环境不支持人脸识别","warning"),t({isSuccess:!1,code:-1,message:"当前环境下不支持人脸识别验证功能"}))}},U={locationCheck:!1,executeGetLocationInBrowser(t){e("executeGetLocationInBrowser","在微信/支付宝浏览器中获取定位信息"),I()?this.getLocationInAliPay(t):C()?this.getLocationInWeChat(t):"geolocation"in navigator?navigator.geolocation.getCurrentPosition(i=>{e("executeGetLocationInBrowser",`geolocation-res::::${JSON.stringify(i)}`);const{latitude:n,longitude:o}=i?.coords||{};this.executeGetDetailLocation(t,{latitude:n,longitude:o})},i=>{switch(i.code){case i.PERMISSION_DENIED:t({code:-1,isSuccess:!1,message:"用户拒绝了位置请求"}),e("executeGetLocationInBrowser","用户拒绝了位置信息请求","warning");break;case i.POSITION_UNAVAILABLE:t({code:-1,isSuccess:!1,message:"位置信息不可用"}),e("executeGetLocationInBrowser","位置信息不可用","warning");break;case i.TIMEOUT:t({code:-1,isSuccess:!1,message:"请求超时"}),e("executeGetLocationInBrowser","请求超时","warning");break;default:t({code:-1,isSuccess:!1,message:i.message}),e("executeGetLocationInBrowser","位置错误","warning",i.message)}}):t({isSuccess:!1,message:"当前环境无法支持位置信息获取,请检查是否为湘易办相关环境"})},getLocationInWeChat(t){if(this.locationCheck)return e("getLocationInWeChat","已缓存签名信息,直接调用对应API获取位置信息"),void this.executeGetLocationInfoData(t);this.executeGetLocationInfoData(t)},executeGetLocationInfoData(t){e("executeGetLocationInfoData","在微信环境中获取位置信息"),window?.wx?.getLocation({success:i=>{this.locationCheck=!0,e("executeGetLocationInfoData",`调用微信获取位置信息完成,结果是:${JSON.stringify(i)}`),this.executeGetDetailLocation(t,i)},fail:i=>{t({isSuccess:!1,message:"调用微信获取位置信息失败,请联系管理员"}),e("executeGetLocationInfoData",`调用微信获取位置信息失败,信息是:${JSON.stringify(i)}`)}})},executeGetDetailLocation(t,i){uni.request({url:`${k}/api/wechat/address?location=${i.latitude},${i?.longitude}`,method:"GET",success:i=>{const{data:n}=i?.data||{},o=n?.result||{},{lng:a,lat:s}=o?.location||{},{cityCode:r,formatted_address:c}=o||{},{district:l,city:u,country:d,adCode:m,province:g}=o?.addressComponent||{},h={isSuccess:!0,location:{district:l,city:u,longitude:a,country:d,cityCode:r,adCode:m,address:c,latitude:s,province:g}};e("executeGetDetailLocation",`获取位置信息调用完成,结果:${JSON.stringify(h)}`),t(h)},fail:t=>{e("executeGetDetailLocation","获取位置信息失败","error",JSON.stringify(t))}})},getLocationInAliPay(t){my?.getLocation({success:i=>{this.executeGetDetailLocation(t,i),e("getLocationInAliPay",`支付宝下获取位置信息完成:::${JSON.stringify(i)}`)},fail:i=>{e("getLocationInAliPay",`获取位置信息失败,错误信息:${JSON.stringify(i)}`,"error",i),t({isSuccess:!1,message:"获取位置信息失败,请联系湘易办相关技术人员"})}})}},R={navigationCheck:!1,startNavigationInBrowser(t,i={}){const n=encodeURIComponent(window?.location?.href),{lat:o,lng:a,address:s,name:r,dinateType:c}=i;let l=`/pages/sdk/sdk?redirectUrl=${n}&type=navigation&latitude=${o}&longitude=${a}&address=${s}&name=${r}`;if(c&&"GCJ02"!==c){const e=M(i),{destinationLatitude:t,destinationLongitude:o}=e;l=`/pages/sdk/sdk?redirectUrl=${n}&type=navigation&latitude=${t}&longitude=${o}&address=${s}&name=${r}`}e("startNavigationInBrowser",`跳转目标URL:${l}`),C()?d(l,t):I()?u(l,t):(e("startNavigationInBrowser","导航功能无法在当前环境下执行"),t({isSuccess:!1,code:-1,message:"导航功能无法在当前环境下执行,请检查是否为微信/支付宝小程序的浏览器环境中"}))}},G={wvInfo:null,isHarmony:!1,isCheckDevice:!1,async initMessage(...t){const i=t[0];await this.checkDeviceInfo(),await this.initVMInfo(t[2]),w()?window.addEventListener("message",t=>{e("initMessage",`浏览器webview接收到的消息内容,${JSON.stringify(t)}`,"log"),this.getMsgFromH5(t)}):(e("initMessage",`非浏览器中的webview接收到的消息内容,${JSON.stringify(i)}`,"log"),this.getMsgFromH5(i))},checkDeviceInfo(){this.isCheckDevice||(this.isCheckDevice=!0,uni.sendNativeEvent("System_getAppInfo",{},e=>{this.isHarmony=e?.platform?.toLowerCase().includes("harmony")}))},initVMInfo(t){if(!this.wvInfo)if(this.isHarmony)this.wvInfo=uni.createWebviewContext("webview",t);else try{this.wvInfo=t,t?.$scope?.$getAppWebview()&&(this.wvInfo=t.$scope.$getAppWebview().children()[0])}catch(t){e("initMessage","初始化消息模块,是否包含wvInfo:"+typeof this.wvInfo?.evalJS)}},getMsgFromH5(t={}){let i=this.getMsgDataFromH5(t);const{origin:n}=t||{},{href:o}=location||{};if(w()&&o?.includes(n))return!1;const{isH5Send:a,methodName:s,methodData:r}=i||{};return!!a&&(s?null==r?(e("getMsgFromH5","请传入需要执行的事件数据","warn"),!1):(e("getMsgFromH5",`需要执行的事件名称【${s}】,需要执行的事件数据【${JSON.stringify(r)}】,是否为H5发送的消息【${a}】`,"log"),void(this[s]?this.executeH5MethodName(s,i):e("getMsgFromH5",`【${s}】事件不存在`,"warn"))):(e("getMsgFromH5","请传入需要执行的事件名称","warn"),!1))},executeH5MethodName(t,i){const{msgId:n,methodData:o}=i;try{const i=this[t].toString();if(e("executeH5MethodName",`【${t}】方法定义:${i}`,"log"),i.includes("Promise"))return void this[t](o).then(i=>{e("executeH5MethodName",`${t}方法执行结果:${JSON.stringify(i)}`,"log");let o=i;try{o=JSON.parse(i)}catch(t){e("executeH5MethodName","强制给数据进行序列化失败","error",t)}this.postMsgToH5({msgId:n,sourceMethod:t,resultInfo:o,isWebviewSend:!0,resultMessage:`执行${t}方法完成`})}).catch(i=>{e("executeH5MethodName",`${t}方法执行失败`,"error",i),this.postMsgToH5({msgId:n,sourceMethod:t,resultInfo:null,isWebviewSend:!0,resultMessage:`执行${t}方法失败,具体错误信息,请查看控制台`})});this[t](o),this.postMsgToH5({msgId:n,sourceMethod:t,resultInfo:null,isWebviewSend:!0,resultMessage:`执行${t}方法完成`})}catch(i){e("getMsgFromH5",`${t}方法执行失败`,"error",i)}},postMsgToH5(t){const i=JSON.stringify(t);if(e("postMsgToH5",`消息内容:${i}`,"log"),w()){e("postMsgToH5","父页面运行在浏览器","log");document.querySelector("iframe").contentWindow.postMessage(JSON.stringify(i),"*")}else try{e("postMsgToH5","父页面运行在非浏览器","log"),this.wvInfo.evalJS(`getMessageFromWebview('${i}')`)}catch(t){e("postMsgToH5","执行浏览器的webview回传异常","error",t)}},getMsgDataFromH5(t){let i=null;const{data:n}=t;try{i=w()?n?.data?.arg?n?.data?.arg:n?.data?n.data:n:t.detail?.data[0]}catch(t){return e("getMsgDataFromH5","处理消息内容时发生异常","error",t),!1}return e("getMsgDataFromH5",`获取到的消息内容:${JSON.stringify(i)}`,"log"),i}},j=(t,i,n)=>{if(e("_parseFunction",`${JSON.stringify(t)}`),"function"==typeof t)return n[i]=t,void(t="[Function]::"+i);if("object"!=typeof t)return;let o=null;for(let e in t)switch(typeof t[e]){case"object":o=i?i+"_"+e:e,j(t[e],o,n);break;case"function":o=i?i+"_"+e:e,n[o]=t[e],t[e]="[Function]::"+o}},z=e=>{let t=0;return"string"==typeof e?t=1:"number"==typeof e?t=2:"boolean"==typeof e?t=3:"function"==typeof e?t=4:e instanceof Array?t=6:"object"==typeof e&&(t=5),t},V={appH5SendMsgToApp(e,t={},i={}){const{isWindowEv:n,moduleName:o,nativeEvName:a,isCustomEv:s}=t;if(n)return void this.h5SendMsgToAppByWindow(e,t,i);const r=s?"custom":o,c=s?"call":a;this.executeSendMsgToApp({resolveInfo:e,moduleName:r,eventName:c,actionName:a,dataInfo:i,isCustomEv:s,evConfig:t})},executeSendMsgToApp(i={}){const{moduleName:n,eventName:o,actionName:a,dataInfo:s,resolveInfo:r,isCustomEv:c,evConfig:l}=i||{},{description:u}=l,d=this;try{let i={};if(("object"==typeof s?Object.keys(s):[]).length>0&&(i=t(s)),c){const n=t(i);e("webviewSendMsgToApp",`${u}功能在是通过custom.call的方式调用,需要重新处理入参`),i.params=n,i.action=a}e("webviewSendMsgToApp",`${u}的完整参数:${JSON.stringify(i)}`),this.initEventCallbackEv(r,i,l);const m=function(){return d.formatBridgeData(window.c2[n][`${o}Callback`],arguments)}(i);e("webviewSendMsgToApp",`${u}功能在${f()}的Webview环境下执行,调用参数:${JSON.stringify(m)}`),this.h5SendMsgToAppByBrowser(r,l,m)}catch(t){console.log(`🚀发送消息给APP出现错误,错误信息:${t},${JSON.stringify(t)}`),e("webviewSendMsgToApp",`${u}执行数据处理失败`,"error",t)}},initEventCallbackEv(i,n,o={}){const{description:a,resDataFormat:s,resErrorFormat:r}=o;n.onSuccess=function(t){e("webviewSendMsgToApp",`${a}功能在App的Webview环境下执行完成`),i(s?s(t):t)},n.onFail=function(n){const o=t(n);e("webviewSendMsgToApp",`${a}功能在App的Webview环境下执行失败,收到的回调数据:::${JSON.stringify(o)}`),i(r?r(o):s?s(o):o)}},formatBridgeData(t,i){try{const n=Math.random().toString(32).slice(2),o=[];for(let e in i){const a=n+"_a"+e,s=i[e],r={};!1===/OpenHarmony ([5-9])|OpenHarmony (\d{2})/i.test(navigator.userAgent)&&j(s,a,r);for(let e in r)t[e]=r[e],this.C2ReceiveQueue.push(t);o.push({type:z(s),name:a,value:s})}return e("formatBridgeData",`格式化后的参数:${JSON.stringify(o)}`),{params:o,id:n}}catch(t){e("formatBridgeData","消息通讯数据格式化异常","error",t)}},h5SendMsgToAppByWindow(t,i={},n={}){const{nativeEvName:o,description:s,resDataFormat:r}=i,c=f(),l=`${o}Back`;let u=n;e("h5SendMsgToAppByWindow",`给【${c}】APP发送【${s}】-【${o}】事件调用,回调函数名称:【${l}】`,"log"),window[l]=i=>{let n=i;e("h5SendMsgToAppByWindow",`收到【${c}】APP发送的${s}事件调用的回调值:${JSON.stringify(n)},回调数据类型::${typeof n}`,"log"),n=a(n),t(r?r(n):n)},setTimeout(()=>{"ios"!==c.toLowerCase()?"android"!==c.toLowerCase()?window.harmony[o](u):window.android[o](u):window.webkit.messageHandlers[o].postMessage(u)},100)},h5SendMsgToAppByBrowser(t,i={},n={}){const o=f();e("h5SendMsgToAppByBrowser",`给【${o}】APP发送【${i.nativeEvName}】事件调用,入参:${JSON.stringify(n)}`,"log");const{nativeEvName:a,moduleName:s,isCustomEv:r}=i,{id:c,params:l}=n;if("android"!==o)return"ios"===o?(this.iosCallBackList.push({id:c,resolveInfo:t,configInfo:i}),void this.h5SendMsgToIOS(c,s,a,l,r)):void("harmony"===o&&this.h5SendMsgToHarmony(c,s,a,l,r));this.h5SendMsgToAndroid(c,s,a,l,r)},h5SendMsgToAndroid(t,i,n,o,a){const s={id:t,module:a?"custom":i,method:a?"call":n,parameters:o};return e("h5SendMsgToAndroid",`发送给安卓APP的消息:${JSON.stringify(s)}`),JSON.parse(window.AndroidFunction.callAndroidFun(JSON.stringify(s)))},h5SendMsgToIOS(t,i,n,o,a){const s={id:t,module:a?"custom":i,method:a?"call":n,parameters:o};return e("h5SendMsgToIOS",`发送给IOS APP的消息:${JSON.stringify(s)}`),JSON.parse(prompt(JSON.stringify(s)))},h5SendMsgToHarmony(t,i,n,o,a){const s={id:t,module:a?"custom":i,method:a?"call":n,parameters:o};return e("h5SendMsgToHarmony",`发送给鸿蒙APP的消息:${JSON.stringify(s)}`),JSON.parse(window.harmonyFunction.callHarmonyFun(s))}},Q={msgList:[],msgStack:[],async miniAppH5SendMsgToApp(t,i,n){try{e("miniAppH5SendMsgToApp",`发送消息给webview:${i}`,"log");const o=await this.sendMsgToMiniApp({methodName:i,methodData:n});t(o?.resultInfo)}catch(n){e("miniAppH5SendMsgToApp",`执行${i}失败`,"error",n),t({isSuccess:!1,message:"执行事件失败,详情查看控制台"})}},sendMsgToMiniApp(t){return new Promise((n,o)=>{e("postMsgToWebview",`消息内容:${JSON.stringify(t)}`,"log");const{methodName:a,methodData:s}=t||{};if(!a)return void e("postMsgToWebview","请传入要调用的事件名称","warn");if(!s)return void e("postMsgToWebview","请传入要调用事件的数据信息","warn");const r=i(),c={data:{msgId:r,isH5Send:!0,...t}};if(this.msgList.push({id:r,resolveInfo:n,rejectInfo:o}),e("postMsgToWebview",`发送消息给父容器页面:${JSON.stringify(c)}`,"log"),!this.uniSDKInit)return e("postMsgToWebview","SDK尚未初始化完成,先行执行堆栈","log"),void this.msgStack.push({id:i(),msgContent:c,resolve:n,reject:o});uni?.webView?.postMessage?uni.webView.postMessage(c):uni?.postMessage(c)}).catch(t=>{e("postMsgToWebview","发生异常","error",t)})}},X={getMessageFromWebview(t,i=!1){let n={};try{n=i?t:t?.data||"{}",n=a(n)}catch(t){e("getMessageFromWebview","解析数据异常","error",t)}if(e("getMessageFromWebview",`是否为webview发送的消息内容:${n?.isWebviewSend},消息内容:${JSON.stringify(n)}`,"log"),!n?.isWebviewSend)return;const{msgId:o}=n,s=this.msgList.findIndex(e=>e.id===o);if(-1===s)return;const r=this.msgList[s],{resolveInfo:c}=r;c(n),this.msgList.splice(s,1)}},Y=["getLoginUserInfo","getAuthToken"];let Z=new class{version="";isInit=!1;isWebviewPage=!1;anaSDKInit=!1;uniSDKInit=!1;weChatInit=!1;alipayInit=!1;iosCallBackList=[];C2ReceiveQueue=[];autoUpdate=!0;autoConfigMenuBtn=!0;constructor(e,t){this.version=e,this.isInit=!1,this.isWebviewPage=t,this.iosCallBackList=[],this.initModuleMethod(),this.initSDKAPI(),this.initDefaultConfig()}initModuleMethod(){n(P,this),n(L,this),n(T,this),n(J,this),n(K,this),n(U,this),n(H,this),n(G,this),n(V,this),n(q,this),n(R,this),n(X,this),n(Q,this)}init(t){w()?(S()&&this.initWebviewMsgFormat(),this.initSDKScriptFile(),this.trackSDKInit(t)):e("init","当前环境非浏览器环境,无需执行初始化动作","warn")}initSDKScriptFile(){if(C()||I())return C()?(window?.uni&&delete window.uni,void this.initWeChatSDK()):void this.initAliPaySDK();this.initUNISDK()}initWebviewMsgFormat(){e("initWebviewMsgFormat","初始化被嵌套的页面消息通讯","log"),w()?(window.addEventListener("message",t=>{e("initWebviewMsgFormat","浏览器消息处理","log"),this.getMessageFromWebview(t)}),window.getMessageFromWebview=t=>{e("initWebviewMsgFormat","事件注入消息处理","log"),this.getMessageFromWebview(t,!0)}):e("initWebviewMsgFormat","该API仅支持在被webview嵌套的H5页面中使用","error","")}initUNISDK(){w()&&(E()||l("https://mobile.zwfw.hunan.gov.cn:8088/uni.webview.1.5.6.js","UNI").then(()=>{E()&&(this.uniSDKInit=!0,e("initUNISDK","UNI Webview SDK 挂载完成"))}))}initWeChatSDK(){e("initWeChatSDK","初始化weChat SDK"),w()&&($()?e("initWeChatSDK","WeChat SDK已挂载完成,无需二次挂载"):l("https://res.wx.qq.com/open/js/jweixin-1.6.0.js","微信").then(t=>{$()&&(this.weChatInit=!0,e("initWeChatSDK","WeChat SDK挂载完成"))}))}initWeChatConfig(){uni.request({url:`${k}/api/wechat/signature`,method:"POST",data:{url:window.location.href.split("#")[0]},success:t=>{const i=t?.data?.data;e("getLocationInWeChat",`获取签名信息完成,结果是:${JSON.stringify(t)}`),window?.wx?.config({appId:"wx44bc5d5e34ac0c01",timestamp:i?.timestamp,nonceStr:i?.noncestr,signature:i?.signature,jsApiList:["getLocation","openLocation","chooseImage","chooseFile","scanQRCode","previewImage","downloadImage"]})},fail:t=>{e("getLocationInWeChat",`获取签名信息失败,信息是:${JSON.stringify(t)}`)}})}initAliPaySDK(){e("initAliPaySDK","初始化Alipay SDK"),w()&&(b()||I()&&l("https://appx/web-view.min.js","支付宝").then(t=>{b()&&(this.alipayInit=!0,e("initAliPaySDK","Alipay SDK挂载完成"))}))}initSDKAPI(){y()&&(e("initSDKAPI","App的Webview环境,初始化C2调用链的回调函数"),this.initMobileBridgeGlobalConfig()),e("initSDKAPI","开始初始化SDK API"),D.forEach(t=>{const{eventName:i,moduleName:n,nativeEvName:o,isCustomEv:a}=t;if((n&&o||a)&&y()&&(e("initSDKAPI",`初始化C2调用链的回调函数:${i}`),this.checkMobileModuleBack(n,o,a)),!Y?.includes(i))try{this[i]=e=>new Promise(i=>{this.normalEvDataTransition(i,e,t)})}catch(t){e("initSDKAPI","执行API初始化挂载异常","error",t)}})}normalEvDataTransition(t,i={},n={}){const{eventName:o,description:a,reqDataFormat:s}=n||{},r=f();let c=i;if(s&&(c=s(i)),c)return y()?(e("normalEvDataTransition",`开始调用APP的嵌套H5能力,事件名称:${o},入参:${JSON.stringify(c)}`),void this.appH5SendMsgToApp(t,n,c)):N()?(e("normalEvDataTransition",`开始调用小程序/H5嵌套的H5能力,事件名称:${o},入参:${JSON.stringify(c)}`),void this.miniAppH5SendMsgToApp(t,o,c,a)):void(C()||I()?this.executeBrowserEvent(t,c,i,n):this.executeEvByNative(t,c,n));e(o,`给【${r}】APP发送【${a}】-【${o}】事件失败,请检查数据格式是否正确`,"error")}executeEvByNative(t,i,n){const{description:o,uniEvName:a,eventName:r,nativeResFormat:c}=n;try{e("executeEvByNative",`开始调用原生${o}的能力,API名称:${a},格式化前的参数信息:${JSON.stringify(i)}`),uni.sendNativeEvent(a,i,i=>{e("executeEvByNative",`调用原生${o}的能力完成,结果:${JSON.stringify(i)}`,"log");let n=i;c&&(n=c(n),e("executeEvByNative",`调用原生${o}的能力完成,格式化后的结果:${JSON.stringify(n)}`,"log")),"fileDownload"===r&&i.hasOwnProperty("isSuccess")&&s(t,n),"fileDownload"!==r&&s(t,n)})}catch(i){t({isSuccess:!1,message:`${o}API执行失败,具体错误信息请查看控制台`}),e("executeEvByNative",`${o}API执行异常`,"error",i)}}initDefaultConfig(){e("initDefaultConfig","默认胶囊按钮配置执行初始化处理"),this.autoUpdate?this.resetMenuBtnConfig():e("initDefaultConfig","业务侧配置无需自动重置胶囊按钮,不至于页面切换事件监听")}}(x,S());w()&&(window.xybAgent=Z);export{Z as default};
|
|
1
|
+
const e=(e="",t="",i="log",n="")=>{const o={error:"错误",warn:"警告",info:"提示",log:"日志"}[i]||"日志",a=JSON.stringify(n);console.log(`\n=============🚀START - V${x} 🚀=============\n【事件名称】:${e} \n【日志类型】:${o} \n【日志信息】:${t} ${"error"===i?`【错误信息】:${JSON.stringify(a)}`:""} \n==============🚀END🚀==============`),console.log("")},t=(t={})=>{if("function"==typeof t)return e("deepClone","数据类型为function,无法执行深拷贝,请检查","error"),t;try{return JSON.parse(JSON.stringify(t))}catch(i){return e("deepClone","执行数据深拷贝异常","error",i),t}},i=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}),n=(e={},t={})=>{for(let i in e)t[i]=e[i]},o=(t=!1)=>{let i={route:null,path:null,options:{}};try{const e="function"==typeof getCurrentPages?getCurrentPages():[],n=[];for(let t in e)n.push({route:e[t].route,path:e[t].$page?.fullPath,options:e[t].$page?.options});const o=n?.length||0;if(o){const e=n[o-1],a=n[o-2];i=(t?a:e)||{}}}catch(t){e("getCurrentPagePath","获取页面信息失败","error",t)}return i},a=e=>{try{return JSON.parse(e)}catch(t){return e}},s=(t={},i={})=>{let n=i;try{n=a(i)}catch(t){e("formatResponseData","格式化失败","error",t),n=i}t(n)},r=e=>null==e,c=(e="",t="")=>{let i=t||window?.location?.href;if(i=decodeURIComponent(i),i?.includes(e)){let t=i.split(`${e}=`)[1];return t?.includes("&")&&(t=t.split("&")[0]),t}return""},l=(t="",i="")=>{if(t)return e("loadWeChatSDK",`开始挂载 ${i} SDK文件`,"log"),new Promise(e=>{const i=document.createElement("script");i.src=t,i.onload=e,document.head.appendChild(i)})},u=(t,i)=>{window?.my?.navigateTo({url:t,fail:t=>{e("openAlipayMiniApp","跳转失败,请检查配置信息","error",t),i({code:-1,isSuccess:!1,message:"跳转失败,请检查配置信息"})}})},d=(t,i)=>{window?.wx?.miniProgram?.navigateTo({url:t,fail:t=>{e("executeAuthFaceInBrowser","跳转失败,请检查配置信息","error",t),i({code:-1,isSuccess:!1,message:"跳转失败,请检查配置信息"})}})};let m={finished:!1,result:!1},g={finished:!1,result:!1},h={finished:!1,result:!1},v={finished:!1,result:!1};const p=()=>w()?navigator.userAgent.toLowerCase():"",f=()=>{const e=p();return/android/i.test(e)?"android":/iphone|ipad|ipod|mac/i.test(e)&&!window.MSStream?"ios":/windows phone/i.test(e)?"windows":"harmony"},w=()=>window&&document,N=()=>{if(v.finished)return v.result;if(v.finished=!0,!w())return v.result=!1,!1;const t=p();return v.result=t.includes("uni-app"),e("checkIsMiniAppBrowserEnv",`当前是否为小程序的浏览器环境:${v.result}`),v.result},S=()=>{const{finished:t,result:i}=m;return t?i:(m.result=(()=>{if(h.finished)return h.result;if(h.finished=!0,!w())return h.result=!1,!1;const t=p();return h.result=t.includes("xybwebcomponent")||t.includes("uni-app"),e("checkIsXybBrowserEnv",`当前是否为湘易办浏览器环境:${h.result}`),h.result})()||N(),m.finished=!0,e("checkIsWebviewEnv",`当前是否为Webview环境:${m.result}`),m.result)},y=()=>{const{finished:t,result:i}=g;if(t)return i;if(g.finished=!0,!w())return g.result=!1,!1;const n=p();return g.result=n.includes("xybwebcomponent")&&!n.includes("uniminiapp"),e("checkIsAppWebviewEnv",`当前是否为APP的Webview环境:${g.result}`),g.result},C=()=>w()?p().includes("micromessenger"):"mp-weixin"===f(),E=()=>w()?p().includes("alipay"):"mp-alipay"===f(),I=()=>!!uni&&(!!uni.sendNativeEvent&&("function"==typeof uni.sendNativeEvent||"undefined"!=typeof uni&&Object.prototype.hasOwnProperty.call(uni,"sendNativeEvent"))),A=()=>window?.uni&&"function"==typeof window?.uni?.webView?.postMessage,$=()=>"function"==typeof window?.wx?.chooseImage,b=()=>"function"==typeof window?.my?.chooseImage,M=t=>{const{dinateType:i}=t;return e("replaceCoordinate",`坐标转换开始:${i}`,"log"),(e=>{const{lat:t,lng:i,address:n}=e,o=52.35987755982988,a=i-.0065,s=t-.006,r=Math.sqrt(a*a+s*s)-2e-5*Math.sin(s*o),c=Math.atan2(s,a)-3e-6*Math.cos(a*o);return{destinationName:n,destinationLongitude:r*Math.cos(c).toFixed(6),destinationLatitude:r*Math.sin(c).toFixed(6)}})(t)},D=[{isCustomEv:!0,eventName:"authFace",uniEvName:"Auth_face",description:"人脸识别功能",nativeEvName:"faceAuth",reqDataFormat:t=>{e("authFace",`执行人脸验证,参数信息:${JSON.stringify(t)}`);const{name:i,certNo:n,appId:o,sign:a,created:s,nonce:r}=t;return i&&n&&o&&a&&s&&r?t:(e("authFace","缺少必要参数:name, certNo, appId, sign, created, nonce","error","缺少必要参数"),!1)},resDataFormat:e=>({isSuccess:Boolean(e),certifyId:e}),resErrorFormat:e=>"harmony"===f().toLowerCase()?{isSuccess:!1,errorMsg:e}:e},{isCustomEv:!0,eventName:"startNavigation",uniEvName:"Start_navigation",description:"目的地导航",nativeEvName:"start_navigation",reqDataFormat:t=>{let i={};const{dinateType:n,lat:o,lng:a,address:s,destinationLatitude:r,destinationLongitude:c}=t;return r&&c?t:(e("replaceCoordinate",`坐标系值:LAT:${o},LNG:${a}`,"log"),i=n&&"GCJ02"!==n?M(t):{destinationLatitude:o,destinationLongitude:a,destinationName:s},e("replaceCoordinate",`转换后值:LAT:${i.destinationLatitude},LNG:${i.destinationLongitude}`,"log"),i)}},{isWindowEv:!0,eventName:"getLoginStatus",uniEvName:"Auth_checkLogin",description:"获取登录状态",nativeEvName:"CallNativeMethodGetUserInfo",resDataFormat:e=>{const i=t(e);return{logined:1===Number(i?.isLogin)}},resErrorFormat:()=>({logined:!1})},{isWindowEv:!0,eventName:"getLoginUserInfo",uniEvName:"Auth_getUserInfo",description:"获取登录用户数据信息",nativeEvName:"CallNativeMethodGetUserInfo",resDataFormat:e=>t(e),resErrorFormat:()=>({isSuccess:!1})},{isCustomEv:!0,eventName:"getAuthToken",uniEvName:"Auth_getToken",description:"获取授权token",nativeEvName:"get_token",resDataFormat:e=>{try{const i=t(e);return{token:i?.token,isSuccess:Boolean(i?.token)}}catch(t){return{token:e?.token,isSuccess:Boolean(e?.token)}}},resErrorFormat:()=>({isSuccess:!1})},{isWindowEv:!0,eventName:"getAccessLink",uniEvName:"Auth_getAccessLink",nativeEvName:"CallNativeMethodGetAccessLink",description:"获取授权链接",resDataFormat:e=>"ios"===f().toLowerCase()?{isSuccess:!0,accessLink:e}:t(e),resErrorFormat:()=>({isSuccess:!1})},{moduleName:"image",eventName:"chooseImg",uniEvName:"Image_choose",nativeEvName:"chooseImage",browserEvName:"chooseImage",description:"选择本地图片",reqDataFormat:e=>{const{count:t,sizeType:i,sourceType:n,isCircleCrop:o}=e||{};return{count:t||9,sizeType:i||["original","compressed"],sourceType:n||["album"],isCircleCrop:o||!1}},resDataFormat:e=>t(e),bResDataFormat:e=>{const{tempFiles:t}=e,i=[];for(let e in t){const{name:n,path:o,size:a,type:s}=t[e];i.push({name:n,path:o,size:a,type:s})}return{resultObj:i,isSuccess:!0,message:"选择图片功能操作完成"}}},{moduleName:"image",eventName:"imgPreview",uniEvName:"Image_preview",nativeEvName:"previewImage",browserEvName:"previewImage",description:"执行图片预览"},{moduleName:"image",eventName:"imgUpload",uniEvName:"Image_upload",nativeEvName:"uploadImage",description:"执行图片上传",resDataFormat:e=>t(e),resErrorFormat:e=>e},{eventName:"imgDownload",uniEvName:"Image_download",nativeEvName:"",browserEvName:"downloadImage",description:"执行图片下载"},{eventName:"fileUpload",uniEvName:"File_upload",nativeEvName:"",description:"执行文件上传"},{moduleName:"file",eventName:"fileDownload",uniEvName:"File_download",nativeEvName:"downloadFile",description:"执行文件下载",resDataFormat:e=>({isSuccess:Boolean(e),resultObj:{path:e}})},{moduleName:"file",eventName:"filePreview",uniEvName:"File_preview",nativeEvName:"previewFile",description:"执行文件预览"},{moduleName:"file",eventName:"openLocalFile",uniEvName:"File_openLocal",nativeEvName:"openLocalFile",description:"执行打开本地文件"},{moduleName:"file",eventName:"chooseLocalFile",uniEvName:"File_chooseLocal",nativeEvName:"chooseLocalFile",browserEvName:"chooseFile",description:"选择本地文件",resDataFormat:e=>t(e)},{moduleName:"file",eventName:"openThirdFile",uniEvName:"File_openThirdParty",nativeEvName:"openFileWithThirdParty",description:"执行打开第三方文件"},{eventName:"openApp",uniEvName:"Util_openApp",nativeEvName:"",description:"打开APP"},{isCustomEv:!0,eventName:"openXybApp",uniEvName:"Util_openXYBMiniApp",nativeEvName:"jumpToMiniApp",description:"打开湘易办融合APP小程序",reqDataFormat:e=>{if(y()){const{pageUrl:t}=e;return{...e,path:t}}return e}},{eventName:"postMsgToOtherApp",uniEvName:"Util_postMessageToXYBMiniApp",nativeEvName:"",description:"发送消息给其他小程序"},{isWindowEv:!0,eventName:"scanCode",uniEvName:"Scan_code",description:"扫描二维码",browserEvName:"scanQRCode",nativeEvName:"CallNativeMethodScanQRCode",resDataFormat:e=>({text:e}),bResDataFormat:e=>({text:e?.result||""})},{moduleName:"system",eventName:"getAppInfo",nativeEvName:"getAppInfo",description:"获取应用信息",uniEvName:"System_getAppInfo",resDataFormat:e=>t(e)},{moduleName:"util",eventName:"copyToClipboard",uniEvName:"Util_clipboardData",nativeEvName:"clipboardData",description:"复制内容到剪切板",reqDataFormat:e=>({text:e}),resDataFormat:e=>y()?{isSuccess:Boolean(e)}:{isSuccess:!0}},{moduleName:"util",eventName:"getCacheSize",uniEvName:"Util_getCacheSize",nativeEvName:"getCacheSize",description:"获取缓存大小",resDataFormat:e=>t(e)},{moduleName:"util",eventName:"clearCache",uniEvName:"Util_clearCache",nativeEvName:"clearCache",description:"执行缓存清除",resDataFormat:()=>({isSuccess:!0}),resErrorFormat:()=>({isSuccess:!1})},{moduleName:"telephone",eventName:"callPhone",uniEvName:"Util_callDesignateNumber",nativeEvName:"call",description:"拨打电话",browserEvName:"makePhoneCall",reqDataFormat:e=>"object"==typeof a(e)?a(e):y()?{phoneCode:"+86",phoneNumber:String(e).replace("+86","")}:{text:e}},{eventName:"forbidScreenShot",uniEvName:"Util_forbidScreenShot",nativeEvName:"",description:"执行禁止截屏"},{eventName:"setScreenLight",uniEvName:"Util_setScreenLight",nativeEvName:"",description:"设置屏幕是否常亮",reqDataFormat:e=>({idleTimerValue:e})},{eventName:"sendMatterId",uniEvName:"Param_MatterID",nativeEvName:"",description:"执行页面事件ID上报",reqDataFormat:e=>({matterID:e})},{isWindowEv:!0,description:"获取位置信息",eventName:"getLocationInfo",uniEvName:"Util_getLocationInformation",nativeEvName:"CallNativeMethodGetLocationInformation",resDataFormat:e=>{const{location:i,data:n}=e;let o=t(e);return i&&(o=t(e?.location)),n&&(o=t(e?.data)),{isSuccess:!0,location:o}},nativeResFormat:e=>{const{location:i,data:n}=e;let o=t(e);return i&&(o=t(e?.location)),n&&(o=t(e?.data)),{isSuccess:!0,location:o}},resErrorFormat:()=>({isSuccess:!1,location:{}})},{eventName:"checkPermission",uniEvName:"Auth_matterHandleAuthority",nativeEvName:"",description:"检查事项权限",reqDataFormat:e=>({matterCode:e})},{eventName:"showComment",uniEvName:"Util_jumpToComment",nativeEvName:"",description:"打开评价弹窗"},{isWindowEv:!0,description:"打开微信小程序",eventName:"openWechatMiniApp",uniEvName:"Util_openWechatMiniProgram",nativeEvName:"CallNativeMethodJumpToWechatMiniProgram",reqDataFormat:e=>{if(y()){const t={};for(let i in e)t[i]=String(e[i]);return JSON.stringify(t)}return e}},{isWindowEv:!0,description:"打开支付宝小程序",eventName:"openAliPayMiniApp",uniEvName:"Util_openAlipayMiniProgram",nativeEvName:"CallNativeMethodJumpToAliPay",reqDataFormat:e=>y()?JSON.stringify(e):e},{eventName:"showMenuPanel",uniEvName:"menu_present",nativeEvName:"",description:"显示菜单面板"},{isCustomEv:!0,eventName:"addCalendarEvent",uniEvName:"Util_addCalendarEvent",nativeEvName:"addCalendarEvent",description:"添加日历日程"},{isCustomEv:!0,eventName:"deleteCalendarEvent",uniEvName:"Util_deleteCalendarEvent",nativeEvName:"deleteCalendarEvent",description:"删除日历日程"},{isCustomEv:!0,eventName:"queryCalendarEvent",uniEvName:"Util_queryCalendarEvent",nativeEvName:"queryCalendarEvent",description:"查询日历日程"}],x="0.0.19",k="http://172.16.7.71:3000",P={custom(t,i){e("custom",`通过custom调用${t}事件`);const n=D?.find(e=>e?.nativeEvName===t||e?.eventName===t);return new Promise((e,o)=>{const{reqDataFormat:a}=n||null,s=n||{isCustomEv:!0,moduleName:"custom",eventName:"call",description:"通过Custom调用的C2事件",nativeEvName:t};if(!y())return void e({code:-1,msg:"非APP环境的Webview环境,不支持该功能"});const r=a?a(i):i;this.executeSendMsgToApp({moduleName:"custom",eventName:"call",actionName:t,isCustomEv:!0,dataInfo:r,resolveInfo:e,evConfig:s})})}},O=e=>Number(e)>9?e:`0${e}`,F=()=>{const e=new Date;return`${e.getFullYear()}-${O(e.getMonth()+1)}-${O(e.getDate())} ${O(e.getHours())}:${O(e.getMinutes())}:${O(e.getSeconds())}`},L={trackStack:[],anaSDKLoadTimes:0,locationInfo:{},isProdEnv:!1,track(t="",n={}){if(t){if(n)return w()&&!this.anaSDKInit?(this.trackStack.push({id:i(),eventID:t,eventPro:n}),void e("track","埋点上报插件初始化未完成,本次数据在插件初始化后自动上报","log")):void this.executeTrack(t,n);e("track","埋点数据上报失败","error","请传入埋点数据")}else e("track","埋点数据上报失败","error","请传入埋点事件")},async executeTrack(t="",i={}){if("object"==typeof t)return void await this.track(t?.eventID,t?.eventPro);const n=await this.initTrackParams(i);if(e("track",`执行埋点数据上报,事件名称:${t},事项编码:${n.code},是否上报到生产环境:${this.isProdEnv},完整埋点数据:${JSON.stringify(n)}`,"log"),w()&&xybAgent?.AnalysysAgent)return e("track","通过浏览器插件执行埋点数据上报","log"),void window.xybAgent.AnalysysAgent.track(t,n);if(I())try{e("track",`埋点数据:${JSON.stringify(n)},埋点ID:${t}`,"log"),uni.sendNativeEvent("Analysis_common",{eventID:t,eventPro:n})}catch(t){e("track","执行数据埋点功能异常","error",t)}},trackSDKInit(t){return new Promise((i,n)=>{w()||(e("initTrack","非浏览器环境无需使用init执行初","error"),i(!0)),this.anaSDKInsert?this.configAnaSDK(t,i):l("https://mobile.zwfw.hunan.gov.cn:8088/AnalysysAgent_JS_SDK.min.js","极光").then(()=>{window.AnalysysAgent&&(xybAgent.AnalysysAgent=window.AnalysysAgent,this.anaSDKInsert=!0,this.configAnaSDK(t,i))})})},configAnaSDK(t,i){const n="800c298f0c42c94c",o="40d556c15f872084";let a=location?.host?.includes("hunan.gov.cn")?n:o;if("object"==typeof t)a=o;else{const e={production:n,development:o},i=[n,o];(e[t]||i.includes(t))&&(a=e[t]?e[t]:t)}this.isProdEnv=a===n,e("configAnaSDK",`配置信息:${JSON.stringify(t)},是否为生产环境:${this.isProdEnv},上报的key值:${a}`),w()?(window.xybAgent.AnalysysAgent&&(window.xybAgent.AnalysysAgent.init({appkey:a,uploadURL:"https://mobile.zwfw.hunan.gov.cn:8088/aurora-api"}),e("configAnaSDK","xybAgent已初始化完成,可正常执行埋点操作","log"),this.anaSDKInit=!0,this.isInit=!0,this.checkTrackStack(),i(!0)),!Boolean(window.xybAgent.AnalysysAgent)&&this.anaSDKLoadTimes<10&&setTimeout(()=>this.trackSDKInit(i),300),!Boolean(window.xybAgent.AnalysysAgent)&&this.anaSDKLoadTimes>=10&&(e("configAnaSDK","xybAgent初始化失败","error","请检查app key、uploadURL是否正确"),i(!1))):i(!1)},async initTrackParams(e={}){const{code:t,name:i,aff_city_code:n,aff_city_name:o,unit_code:a,area_code:s,unit_name:r,is_finish:c,category:l,user_id:u,miniAppCode:d,$url_domain:m}=e,g=this.getVisitSource(),h=this.getPageSource(),v=await this.getPositionInfo();return{code:t||void 0,name:i||void 0,aff_city_code:n||void 0,aff_city_name:o||void 0,unit_code:a||void 0,area_code:s||void 0,unit_name:r||void 0,is_finish:c||void 0,category:l||void 0,user_id:u||void 0,miniAppCode:d||void 0,$url_domain:m||void 0,curr_time:F(),source:g,page_source:h,location:v}},getVisitSource(){if(!w()){const e=uni?.getSystemInfoSync(),{uniPlatform:t}=e||{};return"mp-weixin"===t?"wx":"mp-alipay"===t?"alipay":"app"}return C()?"wx":E()?"alipay":"app"},checkTrackStack(){e("checkTrackStack","执行埋点数据堆栈检测","log");t(this.trackStack).forEach(t=>{const{eventID:i,eventPro:n,id:o}=t;e("checkTrackStack",`执行id值为${o} 的埋点数据再次上报`,"log"),this.track(i,n);const a=this.trackStack.findIndex(e=>e.id===o);a>-1&&this.trackStack.splice(a,1)})},getPageSource(){let e=null;e=w()?location.href:decodeURIComponent(o().path);const t=e?.includes("source=");if(!t)return"click";const i=e.split("source=")[1];let n="click";return n=i.includes("&")?i.split("&")[0]:i,["copy","share","click","search"].includes(n)?n:"click"},async getPositionInfo(){if(!this.locationInfo?.province)try{const{location:e}=await this.getLocationInfo()||{};this.locationInfo=e||""}catch(t){e("getLocationInfo","获取位置信息异常","error",t),this.locationInfo={}}return JSON.stringify(this.locationInfo)}},T={initMobileBridgeGlobalConfig(){const t=f();e("initMobileBridgeGlobalConfig",`开始初始化移动端桥链接配置,访问设备类型:${t}`),window.c2={},"ios"===t&&this.initIOSCallbackEvConfig(),"android"===t&&this.initAndroidCallbackEvConfig(),e("initMobileBridgeGlobalConfig","初始化移动端桥链接配置完成"),window.CreatorJsBridge=window.c2},initIOSCallbackEvConfig(){try{const t=this;window.c2.iOS={},window.c2.iOS.callJS=function(){window?.c2.iOS?.callJSCallback||(window.c2.iOS.callJSCallback={}),e("initIOSCallbackEvConfig",`开始处理IOS设备回调事件,回调数据:${JSON.stringify(arguments)}`),t.IOSCallbackEvFormat(arguments[0])}}catch(t){e("initIOSCallbackEvConfig","初始化IOS回调事件配置异常","error",t)}},initAndroidCallbackEvConfig(){window.c2.sendDataWarpToWeb=(e,t,i)=>{e(i)}},IOSCallbackEvFormat(i){const{returnValue:n,funcName:o}=i;let s=this.base64Decode(n);s=a(s),e("IOSCallbackEvFormat",`IOS设备回调事件处理开始,回调数据:${JSON.stringify(s)}, 格式:${typeof s}`);const r=o.split("_a")[0],c=o.replace(r,""),l=this.iosCallBackList.find(e=>e.id===r);if(!l)return;const{resolveInfo:u,configInfo:d}=l,{resDataFormat:m,resErrorFormat:g}=d;if(c.includes("onFail")&&g)return s=g({isSuccess:!1,errorMsg:t(n)}),void u(s);m&&(s=m(s)),e("IOSCallbackEvFormat",`IOS设备回调事件处理完成,返回数据:${JSON.stringify(s)}`),u(s);const h=this.iosCallBackList.findIndex(e=>e.id===r);this.iosCallBackList.splice(h,1)},base64Decode(e){let t,i,n,o,a,s,r,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",l="",u=0;for(e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");u<e.length;)o=c.indexOf(e.charAt(u++)),a=c.indexOf(e.charAt(u++)),s=c.indexOf(e.charAt(u++)),r=c.indexOf(e.charAt(u++)),t=o<<2|a>>4,i=(15&a)<<4|s>>2,n=(3&s)<<6|r,l+=String.fromCharCode(t),64!=s&&(l+=String.fromCharCode(i)),64!=r&&(l+=String.fromCharCode(n));return l=this._utf8_decode(l),l},_utf8_decode(e){let t="",i=0,n=0,o=0,a=0;for(;i<e.length;)n=e.charCodeAt(i),n<128?(t+=String.fromCharCode(n),i++):n>191&&n<224?(a=e.charCodeAt(i+1),t+=String.fromCharCode((31&n)<<6|63&a),i+=2):(a=e.charCodeAt(i+1),o=e.charCodeAt(i+2),t+=String.fromCharCode((15&n)<<12|(63&a)<<6|63&o),i+=3);return t},checkMobileModuleBack(e,t,i){const n=i?"custom":e,o=`${i?"call":t}Callback`;window.c2.hasOwnProperty(n)||(window.c2[n]={}),window.c2[n].hasOwnProperty(o)||(window.c2[n][o]={})}};let B=null,_=null,W=null;I()?(B=uni&&uni?.requireNativePlugin?uni?.requireNativePlugin("GCUniPlugin-RUM"):null,_=uni&&uni?.requireNativePlugin?uni?.requireNativePlugin("GCUniPlugin-Tracer"):null,W=uni&&uni?.getSystemInfoSync?uni.getSystemInfoSync().platform:null):e("请求插件初始化","未找到uni对象","warn");const J={defaults:{headers:{},baseURL:""},interceptor:{request:null,response:null},requestOb:!1,request(i={}){return new Promise((n,o)=>{let a=t(i);if(!this.interceptor.request||"function"!=typeof this.interceptor.request||i.ignore||(a=this.interceptor.request(i),a))if(I()&&this.requestOb&&Boolean(B)&&Boolean(_))try{e("request","走服务监控平台的请求配置","log"),this.executeCloudObRequest(a,n,o)}catch(t){e("request","走服务监控平台的请求配置失败","error",t)}else e("request","走uni的请求配置","log"),this.executeNormalRequest(a,n,o);else n(!1)})},executeCloudObRequest(t,n,o){let a=i();const s=this.checkCloudObRequestHeader(t,a);if(!s)return;const{traceHeader:c,filter:l}=s;let u,d,m;B.startResource({key:a}),uni.request({url:`${this.defaults.baseURL}${t.url}`,method:t.method,header:c,data:t.data,timeout:t.timeout,withCredentials:t?.withCredentials||void 0,success:i=>{if(e("executeCloudObRequest",`接口:${t.url},请求成功`,"log"),l||(u=i.header,d=i.data.toString(),m=i.statusCode),r(t.success)||t.success(i),this.interceptor.response&&"function"==typeof this.interceptor.response&&!t.ignore){const e=this.interceptor.response(i);return void n(e)}n(i)},fail:i=>{e("executeCloudObRequest",`接口:${t.url},请求失败`,"error",i),l||(d=i?.errMsg),r(t?.fail)||t.fail(i),o(i)},complete:()=>{if(e("executeCloudObRequest",`接口:${t.url},请求完成`,"log"),!l){e("executeCloudObRequest",`无filter配置的数据信息::::key值:${a};URL地址:${t.url};`),B.stopResource({key:a});const i={url:`${this.defaults.baseURL}${t.url}`,httpMethod:t.method,requestHeader:c,responseHeader:u,responseBody:d,resourceStatus:m};B.addResource({key:a,content:i})}Boolean(t?.complete)&&t?.complete()}})},checkCloudObRequestHeader(t,i){let n;r(t?.filterPlatform)?(e("executeCloudObRequest",`options.filterPlatform:${t.filterPlatform}`,"log"),n=!1):(n=t?.filterPlatform?.includes(W),e("executeCloudObRequest",`platform:${t.filterPlatform}`,"log")),e("executeCloudObRequest",`rum:${B},tracer:${_}`,"log");let o={};return n||(o=_?.getTraceHeader({key:i,url:t.url})),e("executeCloudObRequest",`是否读取到【tracer】插件配置:${Boolean(_)},是否读取到【rum】插件配置:${Boolean(B)}`,"log"),B&&_?(o=Object.assign({},o,t.header),o=Object.assign({},o,this.defaults.headers),{traceHeader:o,filter:n}):(e("executeCloudObRequest","请配置服务监控平台原生插件","log"),!1)},executeNormalRequest(t,i,n){const{url:o,header:a,data:s,method:r}=t||{},c=Object.assign({},this.defaults.headers,a);uni.request({url:`${this.defaults.baseURL}${o}`,header:c,data:s,method:r,withCredentials:t?.withCredentials||void 0,success:n=>{if(e("normalRequest",`接口:${o},请求成功`,"log"),this.interceptor.response&&"function"==typeof this.interceptor.response&&!t.ignore){const e=this.interceptor.response(n);return void i(e)}i(n)},fail:t=>{e("normalRequest",`接口:${o},请求异常`,"error",t),n(t)}})}},H={resetMenuBtnConfig(){e("hideNativeBtn","隐藏原生APP分享、评价按钮","log");const t={share:{show:!1},comment:{show:!1},favorite:{show:!0}};try{this.menuBtnConfig(t),this.pageChangeEv(i=>{if(!this.autoUpdate)return void e("resetMenuBtnConfig","业务侧设置不自动重置胶囊按钮,中断配置动作");const{options:n}=i,{xybModuleCode:o}=n||{};if(o&&this.autoConfigMenuBtn)return e("resetMenuBtnConfig",`页面拦截事件生效 自动设置原生APP分享、评价按钮,配置信息:${JSON.stringify(i)}`,"log"),void this.menuBtnConfig({share:{show:!0,code:o,type:4},comment:{show:!0,code:o,type:4},favorite:{show:!0}});e("resetMenuBtnConfig","页面拦截事件生效 自动重置原生APP分享、评价按钮配置信息","log"),this.menuBtnConfig(t)})}catch(t){e("resetMenuBtnConfig","配置APP的胶囊按钮清单显示失败,请检查参数是否正确","error",t)}},pageChangeEv(t){if(!uni)return;["navigateTo","redirectTo","switchTab","reLaunch","navigateBack","onBackPress"].forEach(i=>{try{uni.addInterceptor(i,{invoke(n){try{const{url:a}=n;let s={options:{},path:null,route:null},r=decodeURIComponent(a);s.path=r,s.route=r.split("?")[0],r?.includes("xybModuleCode=")&&(console.log(`🚀当前页面路径信息:${r}`),s.options.xybModuleCode=c("xybModuleCode",r)),r?.includes("?")&&(s.route=r.split("?")[0]),i?.includes("Back")&&(s=o(i?.includes("Back"))),e("pageChangeEv",`页面路径发生了变化,当前页面路径:${s.path}`,"log"),"function"==typeof t&&t(s)}catch(t){console.log("🚀 错误信息:::::",t),e("pageChangeEv","拦截路径变化时发生了异常","error",t)}return!0}})}catch(t){e("pageChangeEv","执行页面变化拦截异常","error",t)}})},menuBtnConfig(t={}){e("menuBtnConfig",`配置APP胶囊按钮清单显示,配置信息:${JSON.stringify(t)}`,"log");let i=!0;for(let n in t){if("object"!=typeof t[n]){i=!1,e("menuBtnConfig","配置参数错误","error","请传入一个Object配置数据");break}}if(i)if(S())this.miniAppH5SendMsgToApp(null,"menuBtnConfig",t,"配置APP的胶囊按钮清单显示");else if(!w()&&uni&&uni?.sendNativeEvent)try{e("menuBtnConfig","开始执行配置APP胶囊按钮清单显示","log"),uni?.sendNativeEvent("Util_MiniAppConfigMenu",t)}catch(t){e("menuBtnConfig","配置APP的胶囊按钮清单显示时发生异常","error",t)}else e("menuBtnConfig","配置APP胶囊按钮清单显示功能无法在非UNI环境运行","log")}},U={executeBrowserEvent(t,i={},n={},o={}){const a=C()?"微信小程序":E()?"支付宝小程序":"浏览器",{eventName:s,description:r,browserEvName:c,bResDataFormat:l}=o,u="startNavigation"===s?n:i;e("normalEvDataTransition",`开始调用${a}嵌套H5的能力,事件名称:${s},入参:${JSON.stringify(u)},配置信息:${JSON.stringify(o)}`);const d={authFace:"executeAuthFaceInBrowser",getLocationInfo:"executeGetLocationInBrowser",startNavigation:"startNavigationInBrowser",fileUpload:"executeFileUploadInBrowser"}[s];d?this[d](t,u,o):c?E()?this.executeAlipayBrowserEv(t,c,i,l):C()?this.executeWeChatBrowserEv(t,c,i,l):this.executeNativeBrowserEv(t,c,i,l):t({isSuccess:!1,code:-1,message:`非常抱歉,${r}功能无法在当前环境中使用`})},executeWeChatBrowserEv(e,i){let n=t(i);n.success=function(e){console.log(e)},n.fail=function(e){console.error(e)},window.wx[e](n)},executeAlipayBrowserEv(e,i){let n=t(i);n.success=function(e){console.log(e)},n.fail=function(e){console.error(e)},window.my[e](n)},executeNativeBrowserEv(e,i){let n=t(i);n.success=function(e){console.log(e)},n.fail=function(e){console.error(e)},window.uni[e](n)}},q={executeAuthFaceInBrowser(t,i={},n={}){const o=function(i){let n=c("faceKey",window?.location?.href);if(e("executeAuthFaceInBrowser",`获取到的faceKey参数值::::${n}`),!window?.location?.href.includes("faceKey"))return;const a={isSuccess:Boolean(n),certifyId:n,portrait:null,errorMsg:Boolean(n)?null:"人脸验证失败,请检查参数信息"};window.removeEventListener("hashchange",o),setTimeout(()=>{e("executeAuthFaceInBrowser",`执行验证结果回抛给业务侧:${JSON.stringify(a)}`),t(a)},100)};window.addEventListener("hashchange",o);const a=encodeURIComponent(window.location.href),{certNo:s,name:r}=i;let l=`/pages/sdk/sdk?redirectUrl=${a}&type=authFace&idCard=${encodeURIComponent(s)}&name=${r}`;C()?d(l,t):E()?u(l,t):(e("executeAuthFaceInBrowser","当前环境不支持人脸识别","warning"),t({isSuccess:!1,code:-1,message:"当前环境下不支持人脸识别验证功能"}))}},K={locationCheck:!1,executeGetLocationInBrowser(t){e("executeGetLocationInBrowser","在微信/支付宝浏览器中获取定位信息"),E()?this.getLocationInAliPay(t):C()?this.getLocationInWeChat(t):"geolocation"in navigator?navigator.geolocation.getCurrentPosition(i=>{e("executeGetLocationInBrowser",`geolocation-res::::${JSON.stringify(i)}`);const{latitude:n,longitude:o}=i?.coords||{};this.executeGetDetailLocation(t,{latitude:n,longitude:o})},i=>{switch(i.code){case i.PERMISSION_DENIED:t({code:-1,isSuccess:!1,message:"用户拒绝了位置请求"}),e("executeGetLocationInBrowser","用户拒绝了位置信息请求","warning");break;case i.POSITION_UNAVAILABLE:t({code:-1,isSuccess:!1,message:"位置信息不可用"}),e("executeGetLocationInBrowser","位置信息不可用","warning");break;case i.TIMEOUT:t({code:-1,isSuccess:!1,message:"请求超时"}),e("executeGetLocationInBrowser","请求超时","warning");break;default:t({code:-1,isSuccess:!1,message:i.message}),e("executeGetLocationInBrowser","位置错误","warning",i.message)}}):t({isSuccess:!1,message:"当前环境无法支持位置信息获取,请检查是否为湘易办相关环境"})},getLocationInWeChat(t){if(this.locationCheck)return e("getLocationInWeChat","已缓存签名信息,直接调用对应API获取位置信息"),void this.executeGetLocationInfoData(t);this.executeGetLocationInfoData(t)},executeGetLocationInfoData(t){e("executeGetLocationInfoData","在微信环境中获取位置信息"),window?.wx?.getLocation({success:i=>{this.locationCheck=!0,e("executeGetLocationInfoData",`调用微信获取位置信息完成,结果是:${JSON.stringify(i)}`),this.executeGetDetailLocation(t,i)},fail:i=>{t({isSuccess:!1,message:"调用微信获取位置信息失败,请联系管理员"}),e("executeGetLocationInfoData",`调用微信获取位置信息失败,信息是:${JSON.stringify(i)}`)}})},executeGetDetailLocation(t,i){uni.request({url:`${k}/api/wechat/address?location=${i.latitude},${i?.longitude}`,method:"GET",success:i=>{const{data:n}=i?.data||{},o=n?.result||{},{lng:a,lat:s}=o?.location||{},{cityCode:r,formatted_address:c}=o||{},{district:l,city:u,country:d,adCode:m,province:g}=o?.addressComponent||{},h={isSuccess:!0,location:{district:l,city:u,longitude:a,country:d,cityCode:r,adCode:m,address:c,latitude:s,province:g}};e("executeGetDetailLocation",`获取位置信息调用完成,结果:${JSON.stringify(h)}`),t(h)},fail:t=>{e("executeGetDetailLocation","获取位置信息失败","error",JSON.stringify(t))}})},getLocationInAliPay(t){my?.getLocation({success:i=>{this.executeGetDetailLocation(t,i),e("getLocationInAliPay",`支付宝下获取位置信息完成:::${JSON.stringify(i)}`)},fail:i=>{e("getLocationInAliPay",`获取位置信息失败,错误信息:${JSON.stringify(i)}`,"error",i),t({isSuccess:!1,message:"获取位置信息失败,请联系湘易办相关技术人员"})}})}},R={navigationCheck:!1,startNavigationInBrowser(t,i={}){const n=encodeURIComponent(window?.location?.href),{lat:o,lng:a,address:s,name:r,dinateType:c}=i;let l=`/pages/sdk/sdk?redirectUrl=${n}&type=navigation&latitude=${o}&longitude=${a}&address=${s}&name=${r}`;if(c&&"GCJ02"!==c){const e=M(i),{destinationLatitude:t,destinationLongitude:o}=e;l=`/pages/sdk/sdk?redirectUrl=${n}&type=navigation&latitude=${t}&longitude=${o}&address=${s}&name=${r}`}e("startNavigationInBrowser",`跳转目标URL:${l}`),C()?d(l,t):E()?u(l,t):(e("startNavigationInBrowser","导航功能无法在当前环境下执行"),t({isSuccess:!1,code:-1,message:"导航功能无法在当前环境下执行,请检查是否为微信/支付宝小程序的浏览器环境中"}))}},G={wvInfo:null,isHarmony:!1,isCheckDevice:!1,async initMessage(...t){const i=t[0];await this.checkDeviceInfo(),await this.initVMInfo(t[2]),w()?window.addEventListener("message",t=>{e("initMessage",`浏览器webview接收到的消息内容,${JSON.stringify(t)}`,"log"),this.getMsgFromH5(t)}):(e("initMessage",`非浏览器中的webview接收到的消息内容,${JSON.stringify(i)}`,"log"),this.getMsgFromH5(i))},checkDeviceInfo(){this.isCheckDevice||(this.isCheckDevice=!0,uni.sendNativeEvent("System_getAppInfo",{},e=>{this.isHarmony=e?.platform?.toLowerCase().includes("harmony")}))},initVMInfo(t){if(!this.wvInfo)if(this.isHarmony)this.wvInfo=uni.createWebviewContext("webview",t);else try{this.wvInfo=t,t?.$scope?.$getAppWebview()&&(this.wvInfo=t.$scope.$getAppWebview().children()[0])}catch(t){e("initMessage","初始化消息模块,是否包含wvInfo:"+typeof this.wvInfo?.evalJS)}},getMsgFromH5(t={}){let i=this.getMsgDataFromH5(t);const{origin:n}=t||{},{href:o}=location||{};if(w()&&o?.includes(n))return!1;const{isH5Send:a,methodName:s,methodData:r}=i||{};return!!a&&(s?null==r?(e("getMsgFromH5","请传入需要执行的事件数据","warn"),!1):(e("getMsgFromH5",`需要执行的事件名称【${s}】,需要执行的事件数据【${JSON.stringify(r)}】,是否为H5发送的消息【${a}】`,"log"),void(this[s]?this.executeH5MethodName(s,i):e("getMsgFromH5",`【${s}】事件不存在`,"warn"))):(e("getMsgFromH5","请传入需要执行的事件名称","warn"),!1))},executeH5MethodName(t,i){const{msgId:n,methodData:o}=i;try{const i=this[t].toString();if(e("executeH5MethodName",`【${t}】方法定义:${i}`,"log"),i.includes("Promise"))return void this[t](o).then(i=>{e("executeH5MethodName",`${t}方法执行结果:${JSON.stringify(i)}`,"log");let o=i;try{o=JSON.parse(i)}catch(t){e("executeH5MethodName","强制给数据进行序列化失败","error",t)}this.postMsgToH5({msgId:n,sourceMethod:t,resultInfo:o,isWebviewSend:!0,resultMessage:`执行${t}方法完成`})}).catch(i=>{e("executeH5MethodName",`${t}方法执行失败`,"error",i),this.postMsgToH5({msgId:n,sourceMethod:t,resultInfo:null,isWebviewSend:!0,resultMessage:`执行${t}方法失败,具体错误信息,请查看控制台`})});this[t](o),this.postMsgToH5({msgId:n,sourceMethod:t,resultInfo:null,isWebviewSend:!0,resultMessage:`执行${t}方法完成`})}catch(i){e("getMsgFromH5",`${t}方法执行失败`,"error",i)}},postMsgToH5(t){const i=JSON.stringify(t);if(e("postMsgToH5",`消息内容:${i}`,"log"),w()){e("postMsgToH5","父页面运行在浏览器","log");document.querySelector("iframe").contentWindow.postMessage(JSON.stringify(i),"*")}else try{e("postMsgToH5","父页面运行在非浏览器","log"),this.wvInfo.evalJS(`getMessageFromWebview('${i}')`)}catch(t){e("postMsgToH5","执行浏览器的webview回传异常","error",t)}},getMsgDataFromH5(t){let i=null;const{data:n}=t;try{i=w()?n?.data?.arg?n?.data?.arg:n?.data?n.data:n:t.detail?.data[0]}catch(t){return e("getMsgDataFromH5","处理消息内容时发生异常","error",t),!1}return e("getMsgDataFromH5",`获取到的消息内容:${JSON.stringify(i)}`,"log"),i}},j=(t,i,n)=>{if(e("_parseFunction",`${JSON.stringify(t)}`),"function"==typeof t)return n[i]=t,void(t="[Function]::"+i);if("object"!=typeof t)return;let o=null;for(let e in t)switch(typeof t[e]){case"object":o=i?i+"_"+e:e,j(t[e],o,n);break;case"function":o=i?i+"_"+e:e,n[o]=t[e],t[e]="[Function]::"+o}},z=e=>{let t=0;return"string"==typeof e?t=1:"number"==typeof e?t=2:"boolean"==typeof e?t=3:"function"==typeof e?t=4:e instanceof Array?t=6:"object"==typeof e&&(t=5),t},V={appH5SendMsgToApp(e,t={},i={}){const{isWindowEv:n,moduleName:o,nativeEvName:a,isCustomEv:s}=t;if(n)return void this.h5SendMsgToAppByWindow(e,t,i);const r=s?"custom":o,c=s?"call":a;this.executeSendMsgToApp({resolveInfo:e,moduleName:r,eventName:c,actionName:a,dataInfo:i,isCustomEv:s,evConfig:t})},executeSendMsgToApp(i={}){const{moduleName:n,eventName:o,actionName:a,dataInfo:s,resolveInfo:r,isCustomEv:c,evConfig:l}=i||{},{description:u}=l,d=this;try{let i={};if(("object"==typeof s?Object.keys(s):[]).length>0&&(i=t(s)),c){const n=t(i);e("webviewSendMsgToApp",`${u}功能在是通过custom.call的方式调用,需要重新处理入参`),i.params=n,i.action=a}e("webviewSendMsgToApp",`${u}的完整参数:${JSON.stringify(i)}`),this.initEventCallbackEv(r,i,l);const m=function(){return d.formatBridgeData(window.c2[n][`${o}Callback`],arguments)}(i);e("webviewSendMsgToApp",`${u}功能在${f()}的Webview环境下执行,调用参数:${JSON.stringify(m)}`),this.h5SendMsgToAppByBrowser(r,l,m)}catch(t){console.log(`🚀发送消息给APP出现错误,错误信息:${t},${JSON.stringify(t)}`),e("webviewSendMsgToApp",`${u}执行数据处理失败`,"error",t)}},initEventCallbackEv(i,n,o={}){const{description:a,resDataFormat:s,resErrorFormat:r}=o;n.onSuccess=function(t){e("webviewSendMsgToApp",`${a}功能在App的Webview环境下执行完成`),i(s?s(t):t)},n.onFail=function(n){const o=t(n);e("webviewSendMsgToApp",`${a}功能在App的Webview环境下执行失败,收到的回调数据:::${JSON.stringify(o)}`),i(r?r(o):s?s(o):o)}},formatBridgeData(t,i){try{const n=Math.random().toString(32).slice(2),o=[];for(let e in i){const a=n+"_a"+e,s=i[e],r={};!1===/OpenHarmony ([5-9])|OpenHarmony (\d{2})/i.test(navigator.userAgent)&&j(s,a,r);for(let e in r)t[e]=r[e],this.C2ReceiveQueue.push(t);o.push({type:z(s),name:a,value:s})}return e("formatBridgeData",`格式化后的参数:${JSON.stringify(o)}`),{params:o,id:n}}catch(t){e("formatBridgeData","消息通讯数据格式化异常","error",t)}},h5SendMsgToAppByWindow(t,i={},n={}){const{nativeEvName:o,description:s,resDataFormat:r}=i,c=f(),l=`${o}Back`;let u=n;e("h5SendMsgToAppByWindow",`给【${c}】APP发送【${s}】-【${o}】事件调用,回调函数名称:【${l}】`,"log"),window[l]=i=>{let n=i;e("h5SendMsgToAppByWindow",`收到【${c}】APP发送的${s}事件调用的回调值:${JSON.stringify(n)},回调数据类型::${typeof n}`,"log"),n=a(n),t(r?r(n):n)},setTimeout(()=>{"ios"!==c.toLowerCase()?"android"!==c.toLowerCase()?window.harmony[o](u):window.android[o](u):window.webkit.messageHandlers[o].postMessage(u)},100)},h5SendMsgToAppByBrowser(t,i={},n={}){const o=f();e("h5SendMsgToAppByBrowser",`给【${o}】APP发送【${i.nativeEvName}】事件调用,入参:${JSON.stringify(n)}`,"log");const{nativeEvName:a,moduleName:s,isCustomEv:r}=i,{id:c,params:l}=n;if("android"!==o)return"ios"===o?(this.iosCallBackList.push({id:c,resolveInfo:t,configInfo:i}),void this.h5SendMsgToIOS(c,s,a,l,r)):void("harmony"===o&&this.h5SendMsgToHarmony(c,s,a,l,r));this.h5SendMsgToAndroid(c,s,a,l,r)},h5SendMsgToAndroid(t,i,n,o,a){const s={id:t,module:a?"custom":i,method:a?"call":n,parameters:o};return e("h5SendMsgToAndroid",`发送给安卓APP的消息:${JSON.stringify(s)}`),JSON.parse(window.AndroidFunction.callAndroidFun(JSON.stringify(s)))},h5SendMsgToIOS(t,i,n,o,a){const s={id:t,module:a?"custom":i,method:a?"call":n,parameters:o};return e("h5SendMsgToIOS",`发送给IOS APP的消息:${JSON.stringify(s)}`),JSON.parse(prompt(JSON.stringify(s)))},h5SendMsgToHarmony(t,i,n,o,a){const s={id:t,module:a?"custom":i,method:a?"call":n,parameters:o};return e("h5SendMsgToHarmony",`发送给鸿蒙APP的消息:${JSON.stringify(s)}`),JSON.parse(window.harmonyFunction.callHarmonyFun(s))}},Q={msgList:[],msgStack:[],async miniAppH5SendMsgToApp(t,i,n){try{e("miniAppH5SendMsgToApp",`发送消息给webview:${i}`,"log");const o=await this.sendMsgToMiniApp({methodName:i,methodData:n});t(o?.resultInfo)}catch(n){e("miniAppH5SendMsgToApp",`执行${i}失败`,"error",n),t({isSuccess:!1,message:"执行事件失败,详情查看控制台"})}},sendMsgToMiniApp(t){return new Promise((n,o)=>{e("postMsgToWebview",`消息内容:${JSON.stringify(t)}`,"log");const{methodName:a,methodData:s}=t||{};if(!a)return void e("postMsgToWebview","请传入要调用的事件名称","warn");if(!s)return void e("postMsgToWebview","请传入要调用事件的数据信息","warn");const r=i(),c={data:{msgId:r,isH5Send:!0,...t}};if(this.msgList.push({id:r,resolveInfo:n,rejectInfo:o}),e("postMsgToWebview",`发送消息给父容器页面:${JSON.stringify(c)}`,"log"),!this.uniSDKInit)return e("postMsgToWebview","SDK尚未初始化完成,先行执行堆栈","log"),void this.msgStack.push({id:i(),msgContent:c,resolve:n,reject:o});uni?.webView?.postMessage?uni.webView.postMessage(c):uni?.postMessage(c)}).catch(t=>{e("postMsgToWebview","发生异常","error",t)})}},X={getMessageFromWebview(t,i=!1){let n={};try{n=i?t:t?.data||"{}",n=a(n)}catch(t){e("getMessageFromWebview","解析数据异常","error",t)}if(e("getMessageFromWebview",`是否为webview发送的消息内容:${n?.isWebviewSend},消息内容:${JSON.stringify(n)}`,"log"),!n?.isWebviewSend)return;const{msgId:o}=n,s=this.msgList.findIndex(e=>e.id===o);if(-1===s)return;const r=this.msgList[s],{resolveInfo:c}=r;c(n),this.msgList.splice(s,1)}},Y=["getLoginUserInfo","getAuthToken"];let Z=new class{version="";isInit=!1;isWebviewPage=!1;anaSDKInit=!1;uniSDKInit=!1;weChatInit=!1;alipayInit=!1;iosCallBackList=[];C2ReceiveQueue=[];autoUpdate=!0;autoConfigMenuBtn=!0;constructor(e,t){this.version=e,this.isInit=!1,this.isWebviewPage=t,this.iosCallBackList=[],this.initModuleMethod(),this.initSDKAPI(),this.initDefaultConfig()}initModuleMethod(){n(P,this),n(L,this),n(T,this),n(J,this),n(U,this),n(K,this),n(H,this),n(G,this),n(V,this),n(q,this),n(R,this),n(X,this),n(Q,this)}init(t){w()?(S()&&this.initWebviewMsgFormat(),this.initSDKScriptFile(),this.trackSDKInit(t)):e("init","当前环境非浏览器环境,无需执行初始化动作","warn")}initSDKScriptFile(){if(C()||E())return C()?(window?.uni&&delete window.uni,void this.initWeChatSDK()):void this.initAliPaySDK();this.initUNISDK()}initWebviewMsgFormat(){e("initWebviewMsgFormat","初始化被嵌套的页面消息通讯","log"),w()?(window.addEventListener("message",t=>{e("initWebviewMsgFormat","浏览器消息处理","log"),this.getMessageFromWebview(t)}),window.getMessageFromWebview=t=>{e("initWebviewMsgFormat","事件注入消息处理","log"),this.getMessageFromWebview(t,!0)}):e("initWebviewMsgFormat","该API仅支持在被webview嵌套的H5页面中使用","error","")}initUNISDK(){w()&&(A()||l("https://mobile.zwfw.hunan.gov.cn:8088/uni.webview.1.5.6.js","UNI").then(()=>{A()&&(this.uniSDKInit=!0,e("initUNISDK","UNI Webview SDK 挂载完成"))}))}initWeChatSDK(){e("initWeChatSDK","初始化weChat SDK"),w()&&($()?e("initWeChatSDK","WeChat SDK已挂载完成,无需二次挂载"):l("https://res.wx.qq.com/open/js/jweixin-1.6.0.js","微信").then(t=>{$()&&(this.weChatInit=!0,e("initWeChatSDK","WeChat SDK挂载完成"))}))}initWeChatConfig(){uni.request({url:`${k}/api/wechat/signature`,method:"POST",data:{url:window.location.href.split("#")[0]},success:t=>{const i=t?.data?.data;e("getLocationInWeChat",`获取签名信息完成,结果是:${JSON.stringify(t)}`),window?.wx?.config({appId:"wx44bc5d5e34ac0c01",timestamp:i?.timestamp,nonceStr:i?.noncestr,signature:i?.signature,jsApiList:["getLocation","openLocation","chooseImage","chooseFile","scanQRCode","previewImage","downloadImage"]})},fail:t=>{e("getLocationInWeChat",`获取签名信息失败,信息是:${JSON.stringify(t)}`)}})}initAliPaySDK(){e("initAliPaySDK","初始化Alipay SDK"),w()&&(b()||E()&&l("https://appx/web-view.min.js","支付宝").then(t=>{b()&&(this.alipayInit=!0,e("initAliPaySDK","Alipay SDK挂载完成"))}))}initSDKAPI(){y()&&(e("initSDKAPI","App的Webview环境,初始化C2调用链的回调函数"),this.initMobileBridgeGlobalConfig()),e("initSDKAPI","开始初始化SDK API"),D.forEach(t=>{const{eventName:i,moduleName:n,nativeEvName:o,isCustomEv:a}=t;if((n&&o||a)&&y()&&(e("initSDKAPI",`初始化C2调用链的回调函数:${i}`),this.checkMobileModuleBack(n,o,a)),!Y?.includes(i))try{this[i]=e=>new Promise(i=>{this.normalEvDataTransition(i,e,t)})}catch(t){e("initSDKAPI","执行API初始化挂载异常","error",t)}})}normalEvDataTransition(t,i={},n={}){const{eventName:o,description:a,reqDataFormat:s}=n||{},r=f();let c=i;if(s&&(c=s(i)),c)return y()?(e("normalEvDataTransition",`开始调用APP的嵌套H5能力,事件名称:${o},入参:${JSON.stringify(c)}`),void this.appH5SendMsgToApp(t,n,c)):N()?(e("normalEvDataTransition",`开始调用小程序/H5嵌套的H5能力,事件名称:${o},入参:${JSON.stringify(c)}`),void this.miniAppH5SendMsgToApp(t,o,c,a)):void(C()||E()?this.executeBrowserEvent(t,c,i,n):this.executeEvByNative(t,c,n));e(o,`给【${r}】APP发送【${a}】-【${o}】事件失败,请检查数据格式是否正确`,"error")}executeEvByNative(t,i,n){const{description:o,uniEvName:a,eventName:r,nativeResFormat:c}=n;try{e("executeEvByNative",`开始调用原生${o}的能力,API名称:${a},格式化前的参数信息:${JSON.stringify(i)}`),uni.sendNativeEvent(a,i,i=>{e("executeEvByNative",`调用原生${o}的能力完成,结果:${JSON.stringify(i)}`,"log");let n=i;c&&(n=c(n),e("executeEvByNative",`调用原生${o}的能力完成,格式化后的结果:${JSON.stringify(n)}`,"log")),"fileDownload"===r&&i.hasOwnProperty("isSuccess")&&s(t,n),"fileDownload"!==r&&s(t,n)})}catch(i){t({isSuccess:!1,message:`${o}API执行失败,具体错误信息请查看控制台`}),e("executeEvByNative",`${o}API执行异常`,"error",i)}}initDefaultConfig(){e("initDefaultConfig","默认胶囊按钮配置执行初始化处理"),this.autoUpdate?this.resetMenuBtnConfig():e("initDefaultConfig","业务侧配置无需自动重置胶囊按钮,不至于页面切换事件监听")}}(x,S());w()&&(window.xybAgent=Z);export{Z as default};
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).xybAgent=t()}(this,function(){"use strict";const e=(e="",t="",i="log",n="")=>{const o={error:"错误",warn:"警告",info:"提示",log:"日志"}[i]||"日志",a=JSON.stringify(n);console.log(`\n=============🚀START - V${x} 🚀=============\n【事件名称】:${e} \n【日志类型】:${o} \n【日志信息】:${t} ${"error"===i?`【错误信息】:${JSON.stringify(a)}`:""} \n==============🚀END🚀==============`),console.log("")},t=(t={})=>{if("function"==typeof t)return e("deepClone","数据类型为function,无法执行深拷贝,请检查","error"),t;try{return JSON.parse(JSON.stringify(t))}catch(i){return e("deepClone","执行数据深拷贝异常","error",i),t}},i=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}),n=(e={},t={})=>{for(let i in e)t[i]=e[i]},o=(t=!1)=>{let i={route:null,path:null,options:{}};try{const e="function"==typeof getCurrentPages?getCurrentPages():[],n=[];for(let t in e)n.push({route:e[t].route,path:e[t].$page?.fullPath,options:e[t].$page?.options});const o=n?.length||0;if(o){const e=n[o-1],a=n[o-2];i=(t?a:e)||{}}}catch(t){e("getCurrentPagePath","获取页面信息失败","error",t)}return i},a=e=>{try{return JSON.parse(e)}catch(t){return e}},s=(t={},i={})=>{let n=i;try{n=a(i)}catch(t){e("formatResponseData","格式化失败","error",t),n=i}t(n)},r=e=>null==e,c=(e="",t="")=>{let i=t||window?.location?.href;if(i=decodeURIComponent(i),i?.includes(e)){let t=i.split(`${e}=`)[1];return t?.includes("&")&&(t=t.split("&")[0]),t}return""},l=(t="",i="")=>{if(t)return e("loadWeChatSDK",`开始挂载 ${i} SDK文件`,"log"),new Promise(e=>{const i=document.createElement("script");i.src=t,i.onload=e,document.head.appendChild(i)})},u=(t,i)=>{window?.my?.navigateTo({url:t,fail:t=>{e("openAlipayMiniApp","跳转失败,请检查配置信息","error",t),i({code:-1,isSuccess:!1,message:"跳转失败,请检查配置信息"})}})},d=(t,i)=>{window?.wx?.miniProgram?.navigateTo({url:t,fail:t=>{e("executeAuthFaceInBrowser","跳转失败,请检查配置信息","error",t),i({code:-1,isSuccess:!1,message:"跳转失败,请检查配置信息"})}})};let m={finished:!1,result:!1},g={finished:!1,result:!1},h={finished:!1,result:!1},p={finished:!1,result:!1};const v=()=>w()?navigator.userAgent.toLowerCase():"",f=()=>{const e=v();return/android/i.test(e)?"android":/iphone|ipad|ipod|mac/i.test(e)&&!window.MSStream?"ios":/windows phone/i.test(e)?"windows":"harmony"},w=()=>window&&document,N=()=>{if(p.finished)return p.result;if(p.finished=!0,!w())return p.result=!1,!1;const t=v();return p.result=t.includes("uni-app"),e("checkIsMiniAppBrowserEnv",`当前是否为小程序的浏览器环境:${p.result}`),p.result},y=()=>{const{finished:t,result:i}=m;return t?i:(m.result=(()=>{if(h.finished)return h.result;if(h.finished=!0,!w())return h.result=!1,!1;const t=v();return h.result=t.includes("xybwebcomponent")||t.includes("uni-app"),e("checkIsXybBrowserEnv",`当前是否为湘易办浏览器环境:${h.result}`),h.result})()||N(),m.finished=!0,e("checkIsWebviewEnv",`当前是否为Webview环境:${m.result}`),m.result)},S=()=>{const{finished:t,result:i}=g;if(t)return i;if(g.finished=!0,!w())return g.result=!1,!1;const n=v();return g.result=n.includes("xybwebcomponent")&&!n.includes("uniminiapp"),e("checkIsAppWebviewEnv",`当前是否为APP的Webview环境:${g.result}`),g.result},C=()=>w()?v().includes("micromessenger"):"mp-weixin"===f(),I=()=>w()?v().includes("alipay"):"mp-alipay"===f(),A=()=>!!uni&&(!!uni.sendNativeEvent&&("function"==typeof uni.sendNativeEvent||"undefined"!=typeof uni&&Object.prototype.hasOwnProperty.call(uni,"sendNativeEvent"))),E=()=>window?.uni&&"function"==typeof window?.uni?.webView?.postMessage,b=()=>"function"==typeof window?.wx?.chooseImage,$=()=>"function"==typeof window?.my?.chooseImage,M=t=>{const{dinateType:i}=t;return e("replaceCoordinate",`坐标转换开始:${i}`,"log"),(e=>{const{lat:t,lng:i,address:n}=e,o=52.35987755982988,a=i-.0065,s=t-.006,r=Math.sqrt(a*a+s*s)-2e-5*Math.sin(s*o),c=Math.atan2(s,a)-3e-6*Math.cos(a*o);return{destinationName:n,destinationLongitude:r*Math.cos(c).toFixed(6),destinationLatitude:r*Math.sin(c).toFixed(6)}})(t)},D=[{isCustomEv:!0,eventName:"authFace",uniEvName:"Auth_face",description:"人脸识别功能",nativeEvName:"faceAuth",reqDataFormat:t=>{e("authFace",`执行人脸验证,参数信息:${JSON.stringify(t)}`);const{name:i,certNo:n,appId:o,sign:a,created:s,nonce:r}=t;return i&&n&&o&&a&&s&&r?t:(e("authFace","缺少必要参数:name, certNo, appId, sign, created, nonce","error","缺少必要参数"),!1)},resDataFormat:e=>({isSuccess:Boolean(e),certifyId:e}),resErrorFormat:e=>"harmony"===f().toLowerCase()?{isSuccess:!1,errorMsg:e}:e},{isCustomEv:!0,eventName:"startNavigation",uniEvName:"Start_navigation",description:"目的地导航",nativeEvName:"start_navigation",reqDataFormat:t=>{let i={};const{dinateType:n,lat:o,lng:a,address:s,destinationLatitude:r,destinationLongitude:c}=t;return r&&c?t:(e("replaceCoordinate",`坐标系值:LAT:${o},LNG:${a}`,"log"),i=n&&"GCJ02"!==n?M(t):{destinationLatitude:o,destinationLongitude:a,destinationName:s},e("replaceCoordinate",`转换后值:LAT:${i.destinationLatitude},LNG:${i.destinationLongitude}`,"log"),i)}},{isWindowEv:!0,eventName:"getLoginStatus",uniEvName:"Auth_checkLogin",description:"获取登录状态",nativeEvName:"CallNativeMethodGetUserInfo",resDataFormat:e=>{const i=t(e);return{logined:1===Number(i?.isLogin)}},resErrorFormat:()=>({logined:!1})},{isWindowEv:!0,eventName:"getLoginUserInfo",uniEvName:"Auth_getUserInfo",description:"获取登录用户数据信息",nativeEvName:"CallNativeMethodGetUserInfo",resDataFormat:e=>t(e),resErrorFormat:()=>({isSuccess:!1})},{isCustomEv:!0,eventName:"getAuthToken",uniEvName:"Auth_getToken",description:"获取授权token",nativeEvName:"get_token",resDataFormat:e=>{try{const i=t(e);return{token:i?.token,isSuccess:Boolean(i?.token)}}catch(t){return{token:e?.token,isSuccess:Boolean(e?.token)}}},resErrorFormat:()=>({isSuccess:!1})},{isWindowEv:!0,eventName:"getAccessLink",uniEvName:"Auth_getAccessLink",nativeEvName:"CallNativeMethodGetAccessLink",description:"获取授权链接",resDataFormat:e=>"ios"===f().toLowerCase()?{isSuccess:!0,accessLink:e}:t(e),resErrorFormat:()=>({isSuccess:!1})},{moduleName:"image",eventName:"chooseImg",uniEvName:"Image_choose",nativeEvName:"chooseImage",browserEvName:"chooseImage",description:"选择本地图片",reqDataFormat:e=>{const{count:t,sizeType:i,sourceType:n,isCircleCrop:o}=e||{};return{count:t||9,sizeType:i||["original","compressed"],sourceType:n||["album"],isCircleCrop:o||!1}},resDataFormat:e=>t(e),bResDataFormat:e=>{const{tempFiles:t}=e,i=[];for(let e in t){const{name:n,path:o,size:a,type:s}=t[e];i.push({name:n,path:o,size:a,type:s})}return{resultObj:i,isSuccess:!0,message:"选择图片功能操作完成"}}},{moduleName:"image",eventName:"imgPreview",uniEvName:"Image_preview",nativeEvName:"previewImage",browserEvName:"previewImage",description:"执行图片预览"},{moduleName:"image",eventName:"imgUpload",uniEvName:"Image_upload",nativeEvName:"uploadImage",description:"执行图片上传",resDataFormat:e=>t(e),resErrorFormat:e=>e},{eventName:"imgDownload",uniEvName:"Image_download",nativeEvName:"",browserEvName:"downloadImage",description:"执行图片下载"},{eventName:"fileUpload",uniEvName:"File_upload",nativeEvName:"",description:"执行文件上传"},{moduleName:"file",eventName:"fileDownload",uniEvName:"File_download",nativeEvName:"downloadFile",description:"执行文件下载",resDataFormat:e=>({isSuccess:Boolean(e),resultObj:{path:e}})},{moduleName:"file",eventName:"filePreview",uniEvName:"File_preview",nativeEvName:"previewFile",description:"执行文件预览"},{moduleName:"file",eventName:"openLocalFile",uniEvName:"File_openLocal",nativeEvName:"openLocalFile",description:"执行打开本地文件"},{moduleName:"file",eventName:"chooseLocalFile",uniEvName:"File_chooseLocal",nativeEvName:"chooseLocalFile",browserEvName:"chooseFile",description:"选择本地文件",resDataFormat:e=>t(e)},{moduleName:"file",eventName:"openThirdFile",uniEvName:"File_openThirdParty",nativeEvName:"openFileWithThirdParty",description:"执行打开第三方文件"},{eventName:"openApp",uniEvName:"Util_openApp",nativeEvName:"",description:"打开APP"},{isCustomEv:!0,eventName:"openXybApp",uniEvName:"Util_openXYBMiniApp",nativeEvName:"jumpToMiniApp",description:"打开湘易办融合APP小程序",reqDataFormat:e=>{if(S()){const{pageUrl:t}=e;return{...e,path:t}}return e}},{eventName:"postMsgToOtherApp",uniEvName:"Util_postMessageToXYBMiniApp",nativeEvName:"",description:"发送消息给其他小程序"},{isWindowEv:!0,eventName:"scanCode",uniEvName:"Scan_code",description:"扫描二维码",browserEvName:"scanQRCode",nativeEvName:"CallNativeMethodScanQRCode",resDataFormat:e=>({text:e}),bResDataFormat:e=>({text:e?.result||""})},{moduleName:"system",eventName:"getAppInfo",nativeEvName:"getAppInfo",description:"获取应用信息",uniEvName:"System_getAppInfo",resDataFormat:e=>t(e)},{moduleName:"util",eventName:"copyToClipboard",uniEvName:"Util_clipboardData",nativeEvName:"clipboardData",description:"复制内容到剪切板",reqDataFormat:e=>({text:e}),resDataFormat:e=>S()?{isSuccess:Boolean(e)}:{isSuccess:!0}},{moduleName:"util",eventName:"getCacheSize",uniEvName:"Util_getCacheSize",nativeEvName:"getCacheSize",description:"获取缓存大小",resDataFormat:e=>t(e)},{moduleName:"util",eventName:"clearCache",uniEvName:"Util_clearCache",nativeEvName:"clearCache",description:"执行缓存清除",resDataFormat:()=>({isSuccess:!0}),resErrorFormat:()=>({isSuccess:!1})},{moduleName:"telephone",eventName:"callPhone",uniEvName:"Util_callDesignateNumber",nativeEvName:"call",description:"拨打电话",browserEvName:"makePhoneCall",reqDataFormat:e=>"object"==typeof a(e)?a(e):S()?{phoneCode:"+86",phoneNumber:String(e).replace("+86","")}:{text:e}},{eventName:"forbidScreenShot",uniEvName:"Util_forbidScreenShot",nativeEvName:"",description:"执行禁止截屏"},{eventName:"setScreenLight",uniEvName:"Util_setScreenLight",nativeEvName:"",description:"设置屏幕是否常亮",reqDataFormat:e=>({idleTimerValue:e})},{eventName:"sendMatterId",uniEvName:"Param_MatterID",nativeEvName:"",description:"执行页面事件ID上报",reqDataFormat:e=>({matterID:e})},{isWindowEv:!0,description:"获取位置信息",eventName:"getLocationInfo",uniEvName:"Util_getLocationInformation",nativeEvName:"CallNativeMethodGetLocationInformation",resDataFormat:e=>{const{location:i,data:n}=e;let o=t(e);return i&&(o=t(e?.location)),n&&(o=t(e?.data)),{isSuccess:!0,location:o}},nativeResFormat:e=>{const{location:i,data:n}=e;let o=t(e);return i&&(o=t(e?.location)),n&&(o=t(e?.data)),{isSuccess:!0,location:o}},resErrorFormat:()=>({isSuccess:!1,location:{}})},{eventName:"checkPermission",uniEvName:"Auth_matterHandleAuthority",nativeEvName:"",description:"检查事项权限",reqDataFormat:e=>({matterCode:e})},{eventName:"showComment",uniEvName:"Util_jumpToComment",nativeEvName:"",description:"打开评价弹窗"},{isWindowEv:!0,description:"打开微信小程序",eventName:"openWechatMiniApp",uniEvName:"Util_openWechatMiniProgram",nativeEvName:"CallNativeMethodJumpToWechatMiniProgram",reqDataFormat:e=>{if(S()){const t={};for(let i in e)t[i]=String(e[i]);return JSON.stringify(t)}return e}},{isWindowEv:!0,description:"打开支付宝小程序",eventName:"openAliPayMiniApp",uniEvName:"Util_openAlipayMiniProgram",nativeEvName:"CallNativeMethodJumpToAliPay",reqDataFormat:e=>S()?JSON.stringify(e):e},{eventName:"showMenuPanel",uniEvName:"menu_present",nativeEvName:"",description:"显示菜单面板"}],x="0.0.17",k="http://172.16.7.71:3000",P={custom(t,i){e("custom",`通过custom调用${t}事件`);const n=D?.find(e=>e?.nativeEvName===t||e?.eventName===t);return new Promise((e,o)=>{const{reqDataFormat:a}=n||null,s=n||{isCustomEv:!0,moduleName:"custom",eventName:"call",description:"通过Custom调用的C2事件",nativeEvName:t};if(!S())return void e({code:-1,msg:"非APP环境的Webview环境,不支持该功能"});const r=a?a(i):i;this.executeSendMsgToApp({moduleName:"custom",eventName:"call",actionName:t,isCustomEv:!0,dataInfo:r,resolveInfo:e,evConfig:s})})}},O=e=>Number(e)>9?e:`0${e}`,F=()=>{const e=new Date;return`${e.getFullYear()}-${O(e.getMonth()+1)}-${O(e.getDate())} ${O(e.getHours())}:${O(e.getMinutes())}:${O(e.getSeconds())}`},T={trackStack:[],anaSDKLoadTimes:0,locationInfo:{},isProdEnv:!1,track(t="",n={}){if(t){if(n)return w()&&!this.anaSDKInit?(this.trackStack.push({id:i(),eventID:t,eventPro:n}),void e("track","埋点上报插件初始化未完成,本次数据在插件初始化后自动上报","log")):void this.executeTrack(t,n);e("track","埋点数据上报失败","error","请传入埋点数据")}else e("track","埋点数据上报失败","error","请传入埋点事件")},async executeTrack(t="",i={}){if("object"==typeof t)return void await this.track(t?.eventID,t?.eventPro);const n=await this.initTrackParams(i);if(e("track",`执行埋点数据上报,事件名称:${t},事项编码:${n.code},是否上报到生产环境:${this.isProdEnv},完整埋点数据:${JSON.stringify(n)}`,"log"),w()&&xybAgent?.AnalysysAgent)return e("track","通过浏览器插件执行埋点数据上报","log"),void window.xybAgent.AnalysysAgent.track(t,n);if(A())try{e("track",`埋点数据:${JSON.stringify(n)},埋点ID:${t}`,"log"),uni.sendNativeEvent("Analysis_common",{eventID:t,eventPro:n})}catch(t){e("track","执行数据埋点功能异常","error",t)}},trackSDKInit(t){return new Promise((i,n)=>{w()||(e("initTrack","非浏览器环境无需使用init执行初","error"),i(!0)),this.anaSDKInsert?this.configAnaSDK(t,i):l("https://mobile.zwfw.hunan.gov.cn:8088/AnalysysAgent_JS_SDK.min.js","极光").then(()=>{window.AnalysysAgent&&(xybAgent.AnalysysAgent=window.AnalysysAgent,this.anaSDKInsert=!0,this.configAnaSDK(t,i))})})},configAnaSDK(t,i){const n="800c298f0c42c94c",o="40d556c15f872084";let a=location?.host?.includes("hunan.gov.cn")?n:o;if("object"==typeof t)a=o;else{const e={production:n,development:o},i=[n,o];(e[t]||i.includes(t))&&(a=e[t]?e[t]:t)}this.isProdEnv=a===n,e("configAnaSDK",`配置信息:${JSON.stringify(t)},是否为生产环境:${this.isProdEnv},上报的key值:${a}`),w()?(window.xybAgent.AnalysysAgent&&(window.xybAgent.AnalysysAgent.init({appkey:a,uploadURL:"https://mobile.zwfw.hunan.gov.cn:8088/aurora-api"}),e("configAnaSDK","xybAgent已初始化完成,可正常执行埋点操作","log"),this.anaSDKInit=!0,this.isInit=!0,this.checkTrackStack(),i(!0)),!Boolean(window.xybAgent.AnalysysAgent)&&this.anaSDKLoadTimes<10&&setTimeout(()=>this.trackSDKInit(i),300),!Boolean(window.xybAgent.AnalysysAgent)&&this.anaSDKLoadTimes>=10&&(e("configAnaSDK","xybAgent初始化失败","error","请检查app key、uploadURL是否正确"),i(!1))):i(!1)},async initTrackParams(e={}){const{code:t,name:i,aff_city_code:n,aff_city_name:o,unit_code:a,area_code:s,unit_name:r,is_finish:c,category:l,user_id:u,miniAppCode:d,$url_domain:m}=e,g=this.getVisitSource(),h=this.getPageSource(),p=await this.getPositionInfo();return{code:t||void 0,name:i||void 0,aff_city_code:n||void 0,aff_city_name:o||void 0,unit_code:a||void 0,area_code:s||void 0,unit_name:r||void 0,is_finish:c||void 0,category:l||void 0,user_id:u||void 0,miniAppCode:d||void 0,$url_domain:m||void 0,curr_time:F(),source:g,page_source:h,location:p}},getVisitSource(){if(!w()){const e=uni?.getSystemInfoSync(),{uniPlatform:t}=e||{};return"mp-weixin"===t?"wx":"mp-alipay"===t?"alipay":"app"}return C()?"wx":I()?"alipay":"app"},checkTrackStack(){e("checkTrackStack","执行埋点数据堆栈检测","log");t(this.trackStack).forEach(t=>{const{eventID:i,eventPro:n,id:o}=t;e("checkTrackStack",`执行id值为${o} 的埋点数据再次上报`,"log"),this.track(i,n);const a=this.trackStack.findIndex(e=>e.id===o);a>-1&&this.trackStack.splice(a,1)})},getPageSource(){let e=null;e=w()?location.href:decodeURIComponent(o().path);const t=e?.includes("source=");if(!t)return"click";const i=e.split("source=")[1];let n="click";return n=i.includes("&")?i.split("&")[0]:i,["copy","share","click","search"].includes(n)?n:"click"},async getPositionInfo(){if(!this.locationInfo?.province)try{const{location:e}=await this.getLocationInfo()||{};this.locationInfo=e||""}catch(t){e("getLocationInfo","获取位置信息异常","error",t),this.locationInfo={}}return JSON.stringify(this.locationInfo)}},L={initMobileBridgeGlobalConfig(){const t=f();e("initMobileBridgeGlobalConfig",`开始初始化移动端桥链接配置,访问设备类型:${t}`),window.c2={},"ios"===t&&this.initIOSCallbackEvConfig(),"android"===t&&this.initAndroidCallbackEvConfig(),e("initMobileBridgeGlobalConfig","初始化移动端桥链接配置完成"),window.CreatorJsBridge=window.c2},initIOSCallbackEvConfig(){try{const t=this;window.c2.iOS={},window.c2.iOS.callJS=function(){window?.c2.iOS?.callJSCallback||(window.c2.iOS.callJSCallback={}),e("initIOSCallbackEvConfig",`开始处理IOS设备回调事件,回调数据:${JSON.stringify(arguments)}`),t.IOSCallbackEvFormat(arguments[0])}}catch(t){e("initIOSCallbackEvConfig","初始化IOS回调事件配置异常","error",t)}},initAndroidCallbackEvConfig(){window.c2.sendDataWarpToWeb=(e,t,i)=>{e(i)}},IOSCallbackEvFormat(i){const{returnValue:n,funcName:o}=i;let s=this.base64Decode(n);s=a(s),e("IOSCallbackEvFormat",`IOS设备回调事件处理开始,回调数据:${JSON.stringify(s)}, 格式:${typeof s}`);const r=o.split("_a")[0],c=o.replace(r,""),l=this.iosCallBackList.find(e=>e.id===r);if(!l)return;const{resolveInfo:u,configInfo:d}=l,{resDataFormat:m,resErrorFormat:g}=d;if(c.includes("onFail")&&g)return s=g({isSuccess:!1,errorMsg:t(n)}),void u(s);m&&(s=m(s)),e("IOSCallbackEvFormat",`IOS设备回调事件处理完成,返回数据:${JSON.stringify(s)}`),u(s);const h=this.iosCallBackList.findIndex(e=>e.id===r);this.iosCallBackList.splice(h,1)},base64Decode(e){let t,i,n,o,a,s,r,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",l="",u=0;for(e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");u<e.length;)o=c.indexOf(e.charAt(u++)),a=c.indexOf(e.charAt(u++)),s=c.indexOf(e.charAt(u++)),r=c.indexOf(e.charAt(u++)),t=o<<2|a>>4,i=(15&a)<<4|s>>2,n=(3&s)<<6|r,l+=String.fromCharCode(t),64!=s&&(l+=String.fromCharCode(i)),64!=r&&(l+=String.fromCharCode(n));return l=this._utf8_decode(l),l},_utf8_decode(e){let t="",i=0,n=0,o=0,a=0;for(;i<e.length;)n=e.charCodeAt(i),n<128?(t+=String.fromCharCode(n),i++):n>191&&n<224?(a=e.charCodeAt(i+1),t+=String.fromCharCode((31&n)<<6|63&a),i+=2):(a=e.charCodeAt(i+1),o=e.charCodeAt(i+2),t+=String.fromCharCode((15&n)<<12|(63&a)<<6|63&o),i+=3);return t},checkMobileModuleBack(e,t,i){const n=i?"custom":e,o=`${i?"call":t}Callback`;window.c2.hasOwnProperty(n)||(window.c2[n]={}),window.c2[n].hasOwnProperty(o)||(window.c2[n][o]={})}};let B=null,W=null,_=null;A()?(B=uni&&uni?.requireNativePlugin?uni?.requireNativePlugin("GCUniPlugin-RUM"):null,W=uni&&uni?.requireNativePlugin?uni?.requireNativePlugin("GCUniPlugin-Tracer"):null,_=uni&&uni?.getSystemInfoSync?uni.getSystemInfoSync().platform:null):e("请求插件初始化","未找到uni对象","warn");const J={defaults:{headers:{},baseURL:""},interceptor:{request:null,response:null},requestOb:!1,request(i={}){return new Promise((n,o)=>{let a=t(i);if(!this.interceptor.request||"function"!=typeof this.interceptor.request||i.ignore||(a=this.interceptor.request(i),a))if(A()&&this.requestOb&&Boolean(B)&&Boolean(W))try{e("request","走服务监控平台的请求配置","log"),this.executeCloudObRequest(a,n,o)}catch(t){e("request","走服务监控平台的请求配置失败","error",t)}else e("request","走uni的请求配置","log"),this.executeNormalRequest(a,n,o);else n(!1)})},executeCloudObRequest(t,n,o){let a=i();const s=this.checkCloudObRequestHeader(t,a);if(!s)return;const{traceHeader:c,filter:l}=s;let u,d,m;B.startResource({key:a}),uni.request({url:`${this.defaults.baseURL}${t.url}`,method:t.method,header:c,data:t.data,timeout:t.timeout,withCredentials:t?.withCredentials||void 0,success:i=>{if(e("executeCloudObRequest",`接口:${t.url},请求成功`,"log"),l||(u=i.header,d=i.data.toString(),m=i.statusCode),r(t.success)||t.success(i),this.interceptor.response&&"function"==typeof this.interceptor.response&&!t.ignore){const e=this.interceptor.response(i);return void n(e)}n(i)},fail:i=>{e("executeCloudObRequest",`接口:${t.url},请求失败`,"error",i),l||(d=i?.errMsg),r(t?.fail)||t.fail(i),o(i)},complete:()=>{if(e("executeCloudObRequest",`接口:${t.url},请求完成`,"log"),!l){e("executeCloudObRequest",`无filter配置的数据信息::::key值:${a};URL地址:${t.url};`),B.stopResource({key:a});const i={url:`${this.defaults.baseURL}${t.url}`,httpMethod:t.method,requestHeader:c,responseHeader:u,responseBody:d,resourceStatus:m};B.addResource({key:a,content:i})}Boolean(t?.complete)&&t?.complete()}})},checkCloudObRequestHeader(t,i){let n;r(t?.filterPlatform)?(e("executeCloudObRequest",`options.filterPlatform:${t.filterPlatform}`,"log"),n=!1):(n=t?.filterPlatform?.includes(_),e("executeCloudObRequest",`platform:${t.filterPlatform}`,"log")),e("executeCloudObRequest",`rum:${B},tracer:${W}`,"log");let o={};return n||(o=W?.getTraceHeader({key:i,url:t.url})),e("executeCloudObRequest",`是否读取到【tracer】插件配置:${Boolean(W)},是否读取到【rum】插件配置:${Boolean(B)}`,"log"),B&&W?(o=Object.assign({},o,t.header),o=Object.assign({},o,this.defaults.headers),{traceHeader:o,filter:n}):(e("executeCloudObRequest","请配置服务监控平台原生插件","log"),!1)},executeNormalRequest(t,i,n){const{url:o,header:a,data:s,method:r}=t||{},c=Object.assign({},this.defaults.headers,a);uni.request({url:`${this.defaults.baseURL}${o}`,header:c,data:s,method:r,withCredentials:t?.withCredentials||void 0,success:n=>{if(e("normalRequest",`接口:${o},请求成功`,"log"),this.interceptor.response&&"function"==typeof this.interceptor.response&&!t.ignore){const e=this.interceptor.response(n);return void i(e)}i(n)},fail:t=>{e("normalRequest",`接口:${o},请求异常`,"error",t),n(t)}})}},H={resetMenuBtnConfig(){e("hideNativeBtn","隐藏原生APP分享、评价按钮","log");const t={share:{show:!1},comment:{show:!1},favorite:{show:!0}};try{this.menuBtnConfig(t),this.pageChangeEv(i=>{if(!this.autoUpdate)return void e("resetMenuBtnConfig","业务侧设置不自动重置胶囊按钮,中断配置动作");const{options:n}=i,{xybModuleCode:o}=n||{};if(o&&this.autoConfigMenuBtn)return e("resetMenuBtnConfig",`页面拦截事件生效 自动设置原生APP分享、评价按钮,配置信息:${JSON.stringify(i)}`,"log"),void this.menuBtnConfig({share:{show:!0,code:o,type:4},comment:{show:!0,code:o,type:4},favorite:{show:!0}});e("resetMenuBtnConfig","页面拦截事件生效 自动重置原生APP分享、评价按钮配置信息","log"),this.menuBtnConfig(t)})}catch(t){e("resetMenuBtnConfig","配置APP的胶囊按钮清单显示失败,请检查参数是否正确","error",t)}},pageChangeEv(t){if(!uni)return;["navigateTo","redirectTo","switchTab","reLaunch","navigateBack","onBackPress"].forEach(i=>{try{uni.addInterceptor(i,{invoke(n){try{const{url:a}=n;let s={options:{},path:null,route:null},r=decodeURIComponent(a);s.path=r,s.route=r.split("?")[0],r?.includes("xybModuleCode=")&&(console.log(`🚀当前页面路径信息:${r}`),s.options.xybModuleCode=c("xybModuleCode",r)),r?.includes("?")&&(s.route=r.split("?")[0]),i?.includes("Back")&&(s=o(i?.includes("Back"))),e("pageChangeEv",`页面路径发生了变化,当前页面路径:${s.path}`,"log"),"function"==typeof t&&t(s)}catch(t){console.log("🚀 错误信息:::::",t),e("pageChangeEv","拦截路径变化时发生了异常","error",t)}return!0}})}catch(t){e("pageChangeEv","执行页面变化拦截异常","error",t)}})},menuBtnConfig(t={}){e("menuBtnConfig",`配置APP胶囊按钮清单显示,配置信息:${JSON.stringify(t)}`,"log");let i=!0;for(let n in t){if("object"!=typeof t[n]){i=!1,e("menuBtnConfig","配置参数错误","error","请传入一个Object配置数据");break}}if(i)if(y())this.miniAppH5SendMsgToApp(null,"menuBtnConfig",t,"配置APP的胶囊按钮清单显示");else if(!w()&&uni&&uni?.sendNativeEvent)try{e("menuBtnConfig","开始执行配置APP胶囊按钮清单显示","log"),uni?.sendNativeEvent("Util_MiniAppConfigMenu",t)}catch(t){e("menuBtnConfig","配置APP的胶囊按钮清单显示时发生异常","error",t)}else e("menuBtnConfig","配置APP胶囊按钮清单显示功能无法在非UNI环境运行","log")}},K={executeBrowserEvent(t,i={},n={},o={}){const a=C()?"微信小程序":I()?"支付宝小程序":"浏览器",{eventName:s,description:r,browserEvName:c,bResDataFormat:l}=o,u="startNavigation"===s?n:i;e("normalEvDataTransition",`开始调用${a}嵌套H5的能力,事件名称:${s},入参:${JSON.stringify(u)},配置信息:${JSON.stringify(o)}`);const d={authFace:"executeAuthFaceInBrowser",getLocationInfo:"executeGetLocationInBrowser",startNavigation:"startNavigationInBrowser"}[s];d?this[d](t,u,o):c?I()?this.executeAlipayBrowserEv(t,c,i,l):C()?this.executeWeChatBrowserEv(t,c,i,l):this.executeNativeBrowserEv(t,c,i,l):t({isSuccess:!1,code:-1,message:`非常抱歉,${r}功能无法在当前环境中使用`})},executeWeChatBrowserEv(e,i){let n=t(i);n.success=function(e){console.log(e)},n.fail=function(e){console.error(e)},window.wx[e](n)},executeAlipayBrowserEv(e,i){let n=t(i);n.success=function(e){console.log(e)},n.fail=function(e){console.error(e)},window.my[e](n)},executeNativeBrowserEv(e,i){let n=t(i);n.success=function(e){console.log(e)},n.fail=function(e){console.error(e)},window.uni[e](n)}},q={executeAuthFaceInBrowser(t,i={},n={}){const o=function(i){let n=c("faceKey",window?.location?.href);if(e("executeAuthFaceInBrowser",`获取到的faceKey参数值::::${n}`),!window?.location?.href.includes("faceKey"))return;window.history.go(-1);const a={result:Boolean(n),certifyId:n,portrait:null,errorMsg:null};window.removeEventListener("hashchange",o),setTimeout(()=>{e("executeAuthFaceInBrowser",`执行验证结果回抛给业务侧:${JSON.stringify(a)}`),t(a)},100)};window.addEventListener("hashchange",o);const a=encodeURIComponent(window.location.href),{certNo:s,name:r}=i;let l=`/pages/sdk/sdk?redirectUrl=${a}&type=authFace&idCard=${encodeURIComponent(s)}&name=${r}`;C()?d(l,t):I()?u(l,t):(e("executeAuthFaceInBrowser","当前环境不支持人脸识别","warning"),t({isSuccess:!1,code:-1,message:"当前环境下不支持人脸识别验证功能"}))}},U={locationCheck:!1,executeGetLocationInBrowser(t){e("executeGetLocationInBrowser","在微信/支付宝浏览器中获取定位信息"),I()?this.getLocationInAliPay(t):C()?this.getLocationInWeChat(t):"geolocation"in navigator?navigator.geolocation.getCurrentPosition(i=>{e("executeGetLocationInBrowser",`geolocation-res::::${JSON.stringify(i)}`);const{latitude:n,longitude:o}=i?.coords||{};this.executeGetDetailLocation(t,{latitude:n,longitude:o})},i=>{switch(i.code){case i.PERMISSION_DENIED:t({code:-1,isSuccess:!1,message:"用户拒绝了位置请求"}),e("executeGetLocationInBrowser","用户拒绝了位置信息请求","warning");break;case i.POSITION_UNAVAILABLE:t({code:-1,isSuccess:!1,message:"位置信息不可用"}),e("executeGetLocationInBrowser","位置信息不可用","warning");break;case i.TIMEOUT:t({code:-1,isSuccess:!1,message:"请求超时"}),e("executeGetLocationInBrowser","请求超时","warning");break;default:t({code:-1,isSuccess:!1,message:i.message}),e("executeGetLocationInBrowser","位置错误","warning",i.message)}}):t({isSuccess:!1,message:"当前环境无法支持位置信息获取,请检查是否为湘易办相关环境"})},getLocationInWeChat(t){if(this.locationCheck)return e("getLocationInWeChat","已缓存签名信息,直接调用对应API获取位置信息"),void this.executeGetLocationInfoData(t);this.executeGetLocationInfoData(t)},executeGetLocationInfoData(t){e("executeGetLocationInfoData","在微信环境中获取位置信息"),window?.wx?.getLocation({success:i=>{this.locationCheck=!0,e("executeGetLocationInfoData",`调用微信获取位置信息完成,结果是:${JSON.stringify(i)}`),this.executeGetDetailLocation(t,i)},fail:i=>{t({isSuccess:!1,message:"调用微信获取位置信息失败,请联系管理员"}),e("executeGetLocationInfoData",`调用微信获取位置信息失败,信息是:${JSON.stringify(i)}`)}})},executeGetDetailLocation(t,i){uni.request({url:`${k}/api/wechat/address?location=${i.latitude},${i?.longitude}`,method:"GET",success:i=>{const{data:n}=i?.data||{},o=n?.result||{},{lng:a,lat:s}=o?.location||{},{cityCode:r,formatted_address:c}=o||{},{district:l,city:u,country:d,adCode:m,province:g}=o?.addressComponent||{},h={isSuccess:!0,location:{district:l,city:u,longitude:a,country:d,cityCode:r,adCode:m,address:c,latitude:s,province:g}};e("executeGetDetailLocation",`获取位置信息调用完成,结果:${JSON.stringify(h)}`),t(h)},fail:t=>{e("executeGetDetailLocation","获取位置信息失败","error",JSON.stringify(t))}})},getLocationInAliPay(t){my?.getLocation({success:i=>{this.executeGetDetailLocation(t,i),e("getLocationInAliPay",`支付宝下获取位置信息完成:::${JSON.stringify(i)}`)},fail:i=>{e("getLocationInAliPay",`获取位置信息失败,错误信息:${JSON.stringify(i)}`,"error",i),t({isSuccess:!1,message:"获取位置信息失败,请联系湘易办相关技术人员"})}})}},R={navigationCheck:!1,startNavigationInBrowser(t,i={}){const n=encodeURIComponent(window?.location?.href),{lat:o,lng:a,address:s,name:r,dinateType:c}=i;let l=`/pages/sdk/sdk?redirectUrl=${n}&type=navigation&latitude=${o}&longitude=${a}&address=${s}&name=${r}`;if(c&&"GCJ02"!==c){const e=M(i),{destinationLatitude:t,destinationLongitude:o}=e;l=`/pages/sdk/sdk?redirectUrl=${n}&type=navigation&latitude=${t}&longitude=${o}&address=${s}&name=${r}`}e("startNavigationInBrowser",`跳转目标URL:${l}`),C()?d(l,t):I()?u(l,t):(e("startNavigationInBrowser","导航功能无法在当前环境下执行"),t({isSuccess:!1,code:-1,message:"导航功能无法在当前环境下执行,请检查是否为微信/支付宝小程序的浏览器环境中"}))}},G={wvInfo:null,isHarmony:!1,isCheckDevice:!1,async initMessage(...t){const i=t[0];await this.checkDeviceInfo(),await this.initVMInfo(t[2]),w()?window.addEventListener("message",t=>{e("initMessage",`浏览器webview接收到的消息内容,${JSON.stringify(t)}`,"log"),this.getMsgFromH5(t)}):(e("initMessage",`非浏览器中的webview接收到的消息内容,${JSON.stringify(i)}`,"log"),this.getMsgFromH5(i))},checkDeviceInfo(){this.isCheckDevice||(this.isCheckDevice=!0,uni.sendNativeEvent("System_getAppInfo",{},e=>{this.isHarmony=e?.platform?.toLowerCase().includes("harmony")}))},initVMInfo(t){if(!this.wvInfo)if(this.isHarmony)this.wvInfo=uni.createWebviewContext("webview",t);else try{this.wvInfo=t,t?.$scope?.$getAppWebview()&&(this.wvInfo=t.$scope.$getAppWebview().children()[0])}catch(t){e("initMessage","初始化消息模块,是否包含wvInfo:"+typeof this.wvInfo?.evalJS)}},getMsgFromH5(t={}){let i=this.getMsgDataFromH5(t);const{origin:n}=t||{},{href:o}=location||{};if(w()&&o?.includes(n))return!1;const{isH5Send:a,methodName:s,methodData:r}=i||{};return!!a&&(s?null==r?(e("getMsgFromH5","请传入需要执行的事件数据","warn"),!1):(e("getMsgFromH5",`需要执行的事件名称【${s}】,需要执行的事件数据【${JSON.stringify(r)}】,是否为H5发送的消息【${a}】`,"log"),void(this[s]?this.executeH5MethodName(s,i):e("getMsgFromH5",`【${s}】事件不存在`,"warn"))):(e("getMsgFromH5","请传入需要执行的事件名称","warn"),!1))},executeH5MethodName(t,i){const{msgId:n,methodData:o}=i;try{const i=this[t].toString();if(e("executeH5MethodName",`【${t}】方法定义:${i}`,"log"),i.includes("Promise"))return void this[t](o).then(i=>{e("executeH5MethodName",`${t}方法执行结果:${JSON.stringify(i)}`,"log");let o=i;try{o=JSON.parse(i)}catch(t){e("executeH5MethodName","强制给数据进行序列化失败","error",t)}this.postMsgToH5({msgId:n,sourceMethod:t,resultInfo:o,isWebviewSend:!0,resultMessage:`执行${t}方法完成`})}).catch(i=>{e("executeH5MethodName",`${t}方法执行失败`,"error",i),this.postMsgToH5({msgId:n,sourceMethod:t,resultInfo:null,isWebviewSend:!0,resultMessage:`执行${t}方法失败,具体错误信息,请查看控制台`})});this[t](o),this.postMsgToH5({msgId:n,sourceMethod:t,resultInfo:null,isWebviewSend:!0,resultMessage:`执行${t}方法完成`})}catch(i){e("getMsgFromH5",`${t}方法执行失败`,"error",i)}},postMsgToH5(t){const i=JSON.stringify(t);if(e("postMsgToH5",`消息内容:${i}`,"log"),w()){e("postMsgToH5","父页面运行在浏览器","log");document.querySelector("iframe").contentWindow.postMessage(JSON.stringify(i),"*")}else try{e("postMsgToH5","父页面运行在非浏览器","log"),this.wvInfo.evalJS(`getMessageFromWebview('${i}')`)}catch(t){e("postMsgToH5","执行浏览器的webview回传异常","error",t)}},getMsgDataFromH5(t){let i=null;const{data:n}=t;try{i=w()?n?.data?.arg?n?.data?.arg:n?.data?n.data:n:t.detail?.data[0]}catch(t){return e("getMsgDataFromH5","处理消息内容时发生异常","error",t),!1}return e("getMsgDataFromH5",`获取到的消息内容:${JSON.stringify(i)}`,"log"),i}},j=(t,i,n)=>{if(e("_parseFunction",`${JSON.stringify(t)}`),"function"==typeof t)return n[i]=t,void(t="[Function]::"+i);if("object"!=typeof t)return;let o=null;for(let e in t)switch(typeof t[e]){case"object":o=i?i+"_"+e:e,j(t[e],o,n);break;case"function":o=i?i+"_"+e:e,n[o]=t[e],t[e]="[Function]::"+o}},z=e=>{let t=0;return"string"==typeof e?t=1:"number"==typeof e?t=2:"boolean"==typeof e?t=3:"function"==typeof e?t=4:e instanceof Array?t=6:"object"==typeof e&&(t=5),t},V={appH5SendMsgToApp(e,t={},i={}){const{isWindowEv:n,moduleName:o,nativeEvName:a,isCustomEv:s}=t;if(n)return void this.h5SendMsgToAppByWindow(e,t,i);const r=s?"custom":o,c=s?"call":a;this.executeSendMsgToApp({resolveInfo:e,moduleName:r,eventName:c,actionName:a,dataInfo:i,isCustomEv:s,evConfig:t})},executeSendMsgToApp(i={}){const{moduleName:n,eventName:o,actionName:a,dataInfo:s,resolveInfo:r,isCustomEv:c,evConfig:l}=i||{},{description:u}=l,d=this;try{let i={};if(("object"==typeof s?Object.keys(s):[]).length>0&&(i=t(s)),c){const n=t(i);e("webviewSendMsgToApp",`${u}功能在是通过custom.call的方式调用,需要重新处理入参`),i.params=n,i.action=a}e("webviewSendMsgToApp",`${u}的完整参数:${JSON.stringify(i)}`),this.initEventCallbackEv(r,i,l);const m=function(){return d.formatBridgeData(window.c2[n][`${o}Callback`],arguments)}(i);e("webviewSendMsgToApp",`${u}功能在${f()}的Webview环境下执行,调用参数:${JSON.stringify(m)}`),this.h5SendMsgToAppByBrowser(r,l,m)}catch(t){console.log(`🚀发送消息给APP出现错误,错误信息:${t},${JSON.stringify(t)}`),e("webviewSendMsgToApp",`${u}执行数据处理失败`,"error",t)}},initEventCallbackEv(i,n,o={}){const{description:a,resDataFormat:s,resErrorFormat:r}=o;n.onSuccess=function(t){e("webviewSendMsgToApp",`${a}功能在App的Webview环境下执行完成`),i(s?s(t):t)},n.onFail=function(n){const o=t(n);e("webviewSendMsgToApp",`${a}功能在App的Webview环境下执行失败,收到的回调数据:::${JSON.stringify(o)}`),i(r?r(o):s?s(o):o)}},formatBridgeData(t,i){try{const n=Math.random().toString(32).slice(2),o=[];for(let e in i){const a=n+"_a"+e,s=i[e],r={};!1===/OpenHarmony ([5-9])|OpenHarmony (\d{2})/i.test(navigator.userAgent)&&j(s,a,r);for(let e in r)t[e]=r[e],this.C2ReceiveQueue.push(t);o.push({type:z(s),name:a,value:s})}return e("formatBridgeData",`格式化后的参数:${JSON.stringify(o)}`),{params:o,id:n}}catch(t){e("formatBridgeData","消息通讯数据格式化异常","error",t)}},h5SendMsgToAppByWindow(t,i={},n={}){const{nativeEvName:o,description:s,resDataFormat:r}=i,c=f(),l=`${o}Back`;let u=n;e("h5SendMsgToAppByWindow",`给【${c}】APP发送【${s}】-【${o}】事件调用,回调函数名称:【${l}】`,"log"),window[l]=i=>{let n=i;e("h5SendMsgToAppByWindow",`收到【${c}】APP发送的${s}事件调用的回调值:${JSON.stringify(n)},回调数据类型::${typeof n}`,"log"),n=a(n),t(r?r(n):n)},setTimeout(()=>{"ios"!==c.toLowerCase()?"android"!==c.toLowerCase()?window.harmony[o](u):window.android[o](u):window.webkit.messageHandlers[o].postMessage(u)},100)},h5SendMsgToAppByBrowser(t,i={},n={}){const o=f();e("h5SendMsgToAppByBrowser",`给【${o}】APP发送【${i.nativeEvName}】事件调用,入参:${JSON.stringify(n)}`,"log");const{nativeEvName:a,moduleName:s,isCustomEv:r}=i,{id:c,params:l}=n;if("android"!==o)return"ios"===o?(this.iosCallBackList.push({id:c,resolveInfo:t,configInfo:i}),void this.h5SendMsgToIOS(c,s,a,l,r)):void("harmony"===o&&this.h5SendMsgToHarmony(c,s,a,l,r));this.h5SendMsgToAndroid(c,s,a,l,r)},h5SendMsgToAndroid(t,i,n,o,a){const s={id:t,module:a?"custom":i,method:a?"call":n,parameters:o};return e("h5SendMsgToAndroid",`发送给安卓APP的消息:${JSON.stringify(s)}`),JSON.parse(window.AndroidFunction.callAndroidFun(JSON.stringify(s)))},h5SendMsgToIOS(t,i,n,o,a){const s={id:t,module:a?"custom":i,method:a?"call":n,parameters:o};return e("h5SendMsgToIOS",`发送给IOS APP的消息:${JSON.stringify(s)}`),JSON.parse(prompt(JSON.stringify(s)))},h5SendMsgToHarmony(t,i,n,o,a){const s={id:t,module:a?"custom":i,method:a?"call":n,parameters:o};return e("h5SendMsgToHarmony",`发送给鸿蒙APP的消息:${JSON.stringify(s)}`),JSON.parse(window.harmonyFunction.callHarmonyFun(s))}},Q={msgList:[],msgStack:[],async miniAppH5SendMsgToApp(t,i,n){try{e("miniAppH5SendMsgToApp",`发送消息给webview:${i}`,"log");const o=await this.sendMsgToMiniApp({methodName:i,methodData:n});t(o?.resultInfo)}catch(n){e("miniAppH5SendMsgToApp",`执行${i}失败`,"error",n),t({isSuccess:!1,message:"执行事件失败,详情查看控制台"})}},sendMsgToMiniApp(t){return new Promise((n,o)=>{e("postMsgToWebview",`消息内容:${JSON.stringify(t)}`,"log");const{methodName:a,methodData:s}=t||{};if(!a)return void e("postMsgToWebview","请传入要调用的事件名称","warn");if(!s)return void e("postMsgToWebview","请传入要调用事件的数据信息","warn");const r=i(),c={data:{msgId:r,isH5Send:!0,...t}};if(this.msgList.push({id:r,resolveInfo:n,rejectInfo:o}),e("postMsgToWebview",`发送消息给父容器页面:${JSON.stringify(c)}`,"log"),!this.uniSDKInit)return e("postMsgToWebview","SDK尚未初始化完成,先行执行堆栈","log"),void this.msgStack.push({id:i(),msgContent:c,resolve:n,reject:o});uni?.webView?.postMessage?uni.webView.postMessage(c):uni?.postMessage(c)}).catch(t=>{e("postMsgToWebview","发生异常","error",t)})}},X={getMessageFromWebview(t,i=!1){let n={};try{n=i?t:t?.data||"{}",n=a(n)}catch(t){e("getMessageFromWebview","解析数据异常","error",t)}if(e("getMessageFromWebview",`是否为webview发送的消息内容:${n?.isWebviewSend},消息内容:${JSON.stringify(n)}`,"log"),!n?.isWebviewSend)return;const{msgId:o}=n,s=this.msgList.findIndex(e=>e.id===o);if(-1===s)return;const r=this.msgList[s],{resolveInfo:c}=r;c(n),this.msgList.splice(s,1)}},Y=["getLoginUserInfo","getAuthToken"];let Z=new class{version="";isInit=!1;isWebviewPage=!1;anaSDKInit=!1;uniSDKInit=!1;weChatInit=!1;alipayInit=!1;iosCallBackList=[];C2ReceiveQueue=[];autoUpdate=!0;autoConfigMenuBtn=!0;constructor(e,t){this.version=e,this.isInit=!1,this.isWebviewPage=t,this.iosCallBackList=[],this.initModuleMethod(),this.initSDKAPI(),this.initDefaultConfig()}initModuleMethod(){n(P,this),n(T,this),n(L,this),n(J,this),n(K,this),n(U,this),n(H,this),n(G,this),n(V,this),n(q,this),n(R,this),n(X,this),n(Q,this)}init(t){w()?(y()&&this.initWebviewMsgFormat(),this.initSDKScriptFile(),this.trackSDKInit(t)):e("init","当前环境非浏览器环境,无需执行初始化动作","warn")}initSDKScriptFile(){if(C()||I())return C()?(window?.uni&&delete window.uni,void this.initWeChatSDK()):void this.initAliPaySDK();this.initUNISDK()}initWebviewMsgFormat(){e("initWebviewMsgFormat","初始化被嵌套的页面消息通讯","log"),w()?(window.addEventListener("message",t=>{e("initWebviewMsgFormat","浏览器消息处理","log"),this.getMessageFromWebview(t)}),window.getMessageFromWebview=t=>{e("initWebviewMsgFormat","事件注入消息处理","log"),this.getMessageFromWebview(t,!0)}):e("initWebviewMsgFormat","该API仅支持在被webview嵌套的H5页面中使用","error","")}initUNISDK(){w()&&(E()||l("https://mobile.zwfw.hunan.gov.cn:8088/uni.webview.1.5.6.js","UNI").then(()=>{E()&&(this.uniSDKInit=!0,e("initUNISDK","UNI Webview SDK 挂载完成"))}))}initWeChatSDK(){e("initWeChatSDK","初始化weChat SDK"),w()&&(b()?e("initWeChatSDK","WeChat SDK已挂载完成,无需二次挂载"):l("https://res.wx.qq.com/open/js/jweixin-1.6.0.js","微信").then(t=>{b()&&(this.weChatInit=!0,e("initWeChatSDK","WeChat SDK挂载完成"))}))}initWeChatConfig(){uni.request({url:`${k}/api/wechat/signature`,method:"POST",data:{url:window.location.href.split("#")[0]},success:t=>{const i=t?.data?.data;e("getLocationInWeChat",`获取签名信息完成,结果是:${JSON.stringify(t)}`),window?.wx?.config({appId:"wx44bc5d5e34ac0c01",timestamp:i?.timestamp,nonceStr:i?.noncestr,signature:i?.signature,jsApiList:["getLocation","openLocation","chooseImage","chooseFile","scanQRCode","previewImage","downloadImage"]})},fail:t=>{e("getLocationInWeChat",`获取签名信息失败,信息是:${JSON.stringify(t)}`)}})}initAliPaySDK(){e("initAliPaySDK","初始化Alipay SDK"),w()&&($()||I()&&l("https://appx/web-view.min.js","支付宝").then(t=>{$()&&(this.alipayInit=!0,e("initAliPaySDK","Alipay SDK挂载完成"))}))}initSDKAPI(){S()&&(e("initSDKAPI","App的Webview环境,初始化C2调用链的回调函数"),this.initMobileBridgeGlobalConfig()),e("initSDKAPI","开始初始化SDK API"),D.forEach(t=>{const{eventName:i,moduleName:n,nativeEvName:o,isCustomEv:a}=t;if((n&&o||a)&&S()&&(e("initSDKAPI",`初始化C2调用链的回调函数:${i}`),this.checkMobileModuleBack(n,o,a)),!Y?.includes(i))try{this[i]=e=>new Promise(i=>{this.normalEvDataTransition(i,e,t)})}catch(t){e("initSDKAPI","执行API初始化挂载异常","error",t)}})}normalEvDataTransition(t,i={},n={}){const{eventName:o,description:a,reqDataFormat:s}=n||{},r=f();let c=i;if(s&&(c=s(i)),c)return S()?(e("normalEvDataTransition",`开始调用APP的嵌套H5能力,事件名称:${o},入参:${JSON.stringify(c)}`),void this.appH5SendMsgToApp(t,n,c)):N()?(e("normalEvDataTransition",`开始调用小程序/H5嵌套的H5能力,事件名称:${o},入参:${JSON.stringify(c)}`),void this.miniAppH5SendMsgToApp(t,o,c,a)):void(C()||I()?this.executeBrowserEvent(t,c,i,n):this.executeEvByNative(t,c,n));e(o,`给【${r}】APP发送【${a}】-【${o}】事件失败,请检查数据格式是否正确`,"error")}executeEvByNative(t,i,n){const{description:o,uniEvName:a,eventName:r,nativeResFormat:c}=n;try{e("executeEvByNative",`开始调用原生${o}的能力,API名称:${a},格式化前的参数信息:${JSON.stringify(i)}`),uni.sendNativeEvent(a,i,i=>{e("executeEvByNative",`调用原生${o}的能力完成,结果:${JSON.stringify(i)}`,"log");let n=i;c&&(n=c(n),e("executeEvByNative",`调用原生${o}的能力完成,格式化后的结果:${JSON.stringify(n)}`,"log")),"fileDownload"===r&&i.hasOwnProperty("isSuccess")&&s(t,n),"fileDownload"!==r&&s(t,n)})}catch(i){t({isSuccess:!1,message:`${o}API执行失败,具体错误信息请查看控制台`}),e("executeEvByNative",`${o}API执行异常`,"error",i)}}initDefaultConfig(){e("initDefaultConfig","默认胶囊按钮配置执行初始化处理"),this.autoUpdate?this.resetMenuBtnConfig():e("initDefaultConfig","业务侧配置无需自动重置胶囊按钮,不至于页面切换事件监听")}}(x,y());return w()&&(window.xybAgent=Z),Z});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).xybAgent=t()}(this,function(){"use strict";const e=(e="",t="",i="log",n="")=>{const o={error:"错误",warn:"警告",info:"提示",log:"日志"}[i]||"日志",a=JSON.stringify(n);console.log(`\n=============🚀START - V${x} 🚀=============\n【事件名称】:${e} \n【日志类型】:${o} \n【日志信息】:${t} ${"error"===i?`【错误信息】:${JSON.stringify(a)}`:""} \n==============🚀END🚀==============`),console.log("")},t=(t={})=>{if("function"==typeof t)return e("deepClone","数据类型为function,无法执行深拷贝,请检查","error"),t;try{return JSON.parse(JSON.stringify(t))}catch(i){return e("deepClone","执行数据深拷贝异常","error",i),t}},i=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}),n=(e={},t={})=>{for(let i in e)t[i]=e[i]},o=(t=!1)=>{let i={route:null,path:null,options:{}};try{const e="function"==typeof getCurrentPages?getCurrentPages():[],n=[];for(let t in e)n.push({route:e[t].route,path:e[t].$page?.fullPath,options:e[t].$page?.options});const o=n?.length||0;if(o){const e=n[o-1],a=n[o-2];i=(t?a:e)||{}}}catch(t){e("getCurrentPagePath","获取页面信息失败","error",t)}return i},a=e=>{try{return JSON.parse(e)}catch(t){return e}},s=(t={},i={})=>{let n=i;try{n=a(i)}catch(t){e("formatResponseData","格式化失败","error",t),n=i}t(n)},r=e=>null==e,c=(e="",t="")=>{let i=t||window?.location?.href;if(i=decodeURIComponent(i),i?.includes(e)){let t=i.split(`${e}=`)[1];return t?.includes("&")&&(t=t.split("&")[0]),t}return""},l=(t="",i="")=>{if(t)return e("loadWeChatSDK",`开始挂载 ${i} SDK文件`,"log"),new Promise(e=>{const i=document.createElement("script");i.src=t,i.onload=e,document.head.appendChild(i)})},u=(t,i)=>{window?.my?.navigateTo({url:t,fail:t=>{e("openAlipayMiniApp","跳转失败,请检查配置信息","error",t),i({code:-1,isSuccess:!1,message:"跳转失败,请检查配置信息"})}})},d=(t,i)=>{window?.wx?.miniProgram?.navigateTo({url:t,fail:t=>{e("executeAuthFaceInBrowser","跳转失败,请检查配置信息","error",t),i({code:-1,isSuccess:!1,message:"跳转失败,请检查配置信息"})}})};let m={finished:!1,result:!1},g={finished:!1,result:!1},h={finished:!1,result:!1},v={finished:!1,result:!1};const p=()=>w()?navigator.userAgent.toLowerCase():"",f=()=>{const e=p();return/android/i.test(e)?"android":/iphone|ipad|ipod|mac/i.test(e)&&!window.MSStream?"ios":/windows phone/i.test(e)?"windows":"harmony"},w=()=>window&&document,N=()=>{if(v.finished)return v.result;if(v.finished=!0,!w())return v.result=!1,!1;const t=p();return v.result=t.includes("uni-app"),e("checkIsMiniAppBrowserEnv",`当前是否为小程序的浏览器环境:${v.result}`),v.result},y=()=>{const{finished:t,result:i}=m;return t?i:(m.result=(()=>{if(h.finished)return h.result;if(h.finished=!0,!w())return h.result=!1,!1;const t=p();return h.result=t.includes("xybwebcomponent")||t.includes("uni-app"),e("checkIsXybBrowserEnv",`当前是否为湘易办浏览器环境:${h.result}`),h.result})()||N(),m.finished=!0,e("checkIsWebviewEnv",`当前是否为Webview环境:${m.result}`),m.result)},S=()=>{const{finished:t,result:i}=g;if(t)return i;if(g.finished=!0,!w())return g.result=!1,!1;const n=p();return g.result=n.includes("xybwebcomponent")&&!n.includes("uniminiapp"),e("checkIsAppWebviewEnv",`当前是否为APP的Webview环境:${g.result}`),g.result},C=()=>w()?p().includes("micromessenger"):"mp-weixin"===f(),E=()=>w()?p().includes("alipay"):"mp-alipay"===f(),I=()=>!!uni&&(!!uni.sendNativeEvent&&("function"==typeof uni.sendNativeEvent||"undefined"!=typeof uni&&Object.prototype.hasOwnProperty.call(uni,"sendNativeEvent"))),A=()=>window?.uni&&"function"==typeof window?.uni?.webView?.postMessage,b=()=>"function"==typeof window?.wx?.chooseImage,$=()=>"function"==typeof window?.my?.chooseImage,M=t=>{const{dinateType:i}=t;return e("replaceCoordinate",`坐标转换开始:${i}`,"log"),(e=>{const{lat:t,lng:i,address:n}=e,o=52.35987755982988,a=i-.0065,s=t-.006,r=Math.sqrt(a*a+s*s)-2e-5*Math.sin(s*o),c=Math.atan2(s,a)-3e-6*Math.cos(a*o);return{destinationName:n,destinationLongitude:r*Math.cos(c).toFixed(6),destinationLatitude:r*Math.sin(c).toFixed(6)}})(t)},D=[{isCustomEv:!0,eventName:"authFace",uniEvName:"Auth_face",description:"人脸识别功能",nativeEvName:"faceAuth",reqDataFormat:t=>{e("authFace",`执行人脸验证,参数信息:${JSON.stringify(t)}`);const{name:i,certNo:n,appId:o,sign:a,created:s,nonce:r}=t;return i&&n&&o&&a&&s&&r?t:(e("authFace","缺少必要参数:name, certNo, appId, sign, created, nonce","error","缺少必要参数"),!1)},resDataFormat:e=>({isSuccess:Boolean(e),certifyId:e}),resErrorFormat:e=>"harmony"===f().toLowerCase()?{isSuccess:!1,errorMsg:e}:e},{isCustomEv:!0,eventName:"startNavigation",uniEvName:"Start_navigation",description:"目的地导航",nativeEvName:"start_navigation",reqDataFormat:t=>{let i={};const{dinateType:n,lat:o,lng:a,address:s,destinationLatitude:r,destinationLongitude:c}=t;return r&&c?t:(e("replaceCoordinate",`坐标系值:LAT:${o},LNG:${a}`,"log"),i=n&&"GCJ02"!==n?M(t):{destinationLatitude:o,destinationLongitude:a,destinationName:s},e("replaceCoordinate",`转换后值:LAT:${i.destinationLatitude},LNG:${i.destinationLongitude}`,"log"),i)}},{isWindowEv:!0,eventName:"getLoginStatus",uniEvName:"Auth_checkLogin",description:"获取登录状态",nativeEvName:"CallNativeMethodGetUserInfo",resDataFormat:e=>{const i=t(e);return{logined:1===Number(i?.isLogin)}},resErrorFormat:()=>({logined:!1})},{isWindowEv:!0,eventName:"getLoginUserInfo",uniEvName:"Auth_getUserInfo",description:"获取登录用户数据信息",nativeEvName:"CallNativeMethodGetUserInfo",resDataFormat:e=>t(e),resErrorFormat:()=>({isSuccess:!1})},{isCustomEv:!0,eventName:"getAuthToken",uniEvName:"Auth_getToken",description:"获取授权token",nativeEvName:"get_token",resDataFormat:e=>{try{const i=t(e);return{token:i?.token,isSuccess:Boolean(i?.token)}}catch(t){return{token:e?.token,isSuccess:Boolean(e?.token)}}},resErrorFormat:()=>({isSuccess:!1})},{isWindowEv:!0,eventName:"getAccessLink",uniEvName:"Auth_getAccessLink",nativeEvName:"CallNativeMethodGetAccessLink",description:"获取授权链接",resDataFormat:e=>"ios"===f().toLowerCase()?{isSuccess:!0,accessLink:e}:t(e),resErrorFormat:()=>({isSuccess:!1})},{moduleName:"image",eventName:"chooseImg",uniEvName:"Image_choose",nativeEvName:"chooseImage",browserEvName:"chooseImage",description:"选择本地图片",reqDataFormat:e=>{const{count:t,sizeType:i,sourceType:n,isCircleCrop:o}=e||{};return{count:t||9,sizeType:i||["original","compressed"],sourceType:n||["album"],isCircleCrop:o||!1}},resDataFormat:e=>t(e),bResDataFormat:e=>{const{tempFiles:t}=e,i=[];for(let e in t){const{name:n,path:o,size:a,type:s}=t[e];i.push({name:n,path:o,size:a,type:s})}return{resultObj:i,isSuccess:!0,message:"选择图片功能操作完成"}}},{moduleName:"image",eventName:"imgPreview",uniEvName:"Image_preview",nativeEvName:"previewImage",browserEvName:"previewImage",description:"执行图片预览"},{moduleName:"image",eventName:"imgUpload",uniEvName:"Image_upload",nativeEvName:"uploadImage",description:"执行图片上传",resDataFormat:e=>t(e),resErrorFormat:e=>e},{eventName:"imgDownload",uniEvName:"Image_download",nativeEvName:"",browserEvName:"downloadImage",description:"执行图片下载"},{eventName:"fileUpload",uniEvName:"File_upload",nativeEvName:"",description:"执行文件上传"},{moduleName:"file",eventName:"fileDownload",uniEvName:"File_download",nativeEvName:"downloadFile",description:"执行文件下载",resDataFormat:e=>({isSuccess:Boolean(e),resultObj:{path:e}})},{moduleName:"file",eventName:"filePreview",uniEvName:"File_preview",nativeEvName:"previewFile",description:"执行文件预览"},{moduleName:"file",eventName:"openLocalFile",uniEvName:"File_openLocal",nativeEvName:"openLocalFile",description:"执行打开本地文件"},{moduleName:"file",eventName:"chooseLocalFile",uniEvName:"File_chooseLocal",nativeEvName:"chooseLocalFile",browserEvName:"chooseFile",description:"选择本地文件",resDataFormat:e=>t(e)},{moduleName:"file",eventName:"openThirdFile",uniEvName:"File_openThirdParty",nativeEvName:"openFileWithThirdParty",description:"执行打开第三方文件"},{eventName:"openApp",uniEvName:"Util_openApp",nativeEvName:"",description:"打开APP"},{isCustomEv:!0,eventName:"openXybApp",uniEvName:"Util_openXYBMiniApp",nativeEvName:"jumpToMiniApp",description:"打开湘易办融合APP小程序",reqDataFormat:e=>{if(S()){const{pageUrl:t}=e;return{...e,path:t}}return e}},{eventName:"postMsgToOtherApp",uniEvName:"Util_postMessageToXYBMiniApp",nativeEvName:"",description:"发送消息给其他小程序"},{isWindowEv:!0,eventName:"scanCode",uniEvName:"Scan_code",description:"扫描二维码",browserEvName:"scanQRCode",nativeEvName:"CallNativeMethodScanQRCode",resDataFormat:e=>({text:e}),bResDataFormat:e=>({text:e?.result||""})},{moduleName:"system",eventName:"getAppInfo",nativeEvName:"getAppInfo",description:"获取应用信息",uniEvName:"System_getAppInfo",resDataFormat:e=>t(e)},{moduleName:"util",eventName:"copyToClipboard",uniEvName:"Util_clipboardData",nativeEvName:"clipboardData",description:"复制内容到剪切板",reqDataFormat:e=>({text:e}),resDataFormat:e=>S()?{isSuccess:Boolean(e)}:{isSuccess:!0}},{moduleName:"util",eventName:"getCacheSize",uniEvName:"Util_getCacheSize",nativeEvName:"getCacheSize",description:"获取缓存大小",resDataFormat:e=>t(e)},{moduleName:"util",eventName:"clearCache",uniEvName:"Util_clearCache",nativeEvName:"clearCache",description:"执行缓存清除",resDataFormat:()=>({isSuccess:!0}),resErrorFormat:()=>({isSuccess:!1})},{moduleName:"telephone",eventName:"callPhone",uniEvName:"Util_callDesignateNumber",nativeEvName:"call",description:"拨打电话",browserEvName:"makePhoneCall",reqDataFormat:e=>"object"==typeof a(e)?a(e):S()?{phoneCode:"+86",phoneNumber:String(e).replace("+86","")}:{text:e}},{eventName:"forbidScreenShot",uniEvName:"Util_forbidScreenShot",nativeEvName:"",description:"执行禁止截屏"},{eventName:"setScreenLight",uniEvName:"Util_setScreenLight",nativeEvName:"",description:"设置屏幕是否常亮",reqDataFormat:e=>({idleTimerValue:e})},{eventName:"sendMatterId",uniEvName:"Param_MatterID",nativeEvName:"",description:"执行页面事件ID上报",reqDataFormat:e=>({matterID:e})},{isWindowEv:!0,description:"获取位置信息",eventName:"getLocationInfo",uniEvName:"Util_getLocationInformation",nativeEvName:"CallNativeMethodGetLocationInformation",resDataFormat:e=>{const{location:i,data:n}=e;let o=t(e);return i&&(o=t(e?.location)),n&&(o=t(e?.data)),{isSuccess:!0,location:o}},nativeResFormat:e=>{const{location:i,data:n}=e;let o=t(e);return i&&(o=t(e?.location)),n&&(o=t(e?.data)),{isSuccess:!0,location:o}},resErrorFormat:()=>({isSuccess:!1,location:{}})},{eventName:"checkPermission",uniEvName:"Auth_matterHandleAuthority",nativeEvName:"",description:"检查事项权限",reqDataFormat:e=>({matterCode:e})},{eventName:"showComment",uniEvName:"Util_jumpToComment",nativeEvName:"",description:"打开评价弹窗"},{isWindowEv:!0,description:"打开微信小程序",eventName:"openWechatMiniApp",uniEvName:"Util_openWechatMiniProgram",nativeEvName:"CallNativeMethodJumpToWechatMiniProgram",reqDataFormat:e=>{if(S()){const t={};for(let i in e)t[i]=String(e[i]);return JSON.stringify(t)}return e}},{isWindowEv:!0,description:"打开支付宝小程序",eventName:"openAliPayMiniApp",uniEvName:"Util_openAlipayMiniProgram",nativeEvName:"CallNativeMethodJumpToAliPay",reqDataFormat:e=>S()?JSON.stringify(e):e},{eventName:"showMenuPanel",uniEvName:"menu_present",nativeEvName:"",description:"显示菜单面板"},{isCustomEv:!0,eventName:"addCalendarEvent",uniEvName:"Util_addCalendarEvent",nativeEvName:"addCalendarEvent",description:"添加日历日程"},{isCustomEv:!0,eventName:"deleteCalendarEvent",uniEvName:"Util_deleteCalendarEvent",nativeEvName:"deleteCalendarEvent",description:"删除日历日程"},{isCustomEv:!0,eventName:"queryCalendarEvent",uniEvName:"Util_queryCalendarEvent",nativeEvName:"queryCalendarEvent",description:"查询日历日程"}],x="0.0.19",k="http://172.16.7.71:3000",P={custom(t,i){e("custom",`通过custom调用${t}事件`);const n=D?.find(e=>e?.nativeEvName===t||e?.eventName===t);return new Promise((e,o)=>{const{reqDataFormat:a}=n||null,s=n||{isCustomEv:!0,moduleName:"custom",eventName:"call",description:"通过Custom调用的C2事件",nativeEvName:t};if(!S())return void e({code:-1,msg:"非APP环境的Webview环境,不支持该功能"});const r=a?a(i):i;this.executeSendMsgToApp({moduleName:"custom",eventName:"call",actionName:t,isCustomEv:!0,dataInfo:r,resolveInfo:e,evConfig:s})})}},O=e=>Number(e)>9?e:`0${e}`,F=()=>{const e=new Date;return`${e.getFullYear()}-${O(e.getMonth()+1)}-${O(e.getDate())} ${O(e.getHours())}:${O(e.getMinutes())}:${O(e.getSeconds())}`},T={trackStack:[],anaSDKLoadTimes:0,locationInfo:{},isProdEnv:!1,track(t="",n={}){if(t){if(n)return w()&&!this.anaSDKInit?(this.trackStack.push({id:i(),eventID:t,eventPro:n}),void e("track","埋点上报插件初始化未完成,本次数据在插件初始化后自动上报","log")):void this.executeTrack(t,n);e("track","埋点数据上报失败","error","请传入埋点数据")}else e("track","埋点数据上报失败","error","请传入埋点事件")},async executeTrack(t="",i={}){if("object"==typeof t)return void await this.track(t?.eventID,t?.eventPro);const n=await this.initTrackParams(i);if(e("track",`执行埋点数据上报,事件名称:${t},事项编码:${n.code},是否上报到生产环境:${this.isProdEnv},完整埋点数据:${JSON.stringify(n)}`,"log"),w()&&xybAgent?.AnalysysAgent)return e("track","通过浏览器插件执行埋点数据上报","log"),void window.xybAgent.AnalysysAgent.track(t,n);if(I())try{e("track",`埋点数据:${JSON.stringify(n)},埋点ID:${t}`,"log"),uni.sendNativeEvent("Analysis_common",{eventID:t,eventPro:n})}catch(t){e("track","执行数据埋点功能异常","error",t)}},trackSDKInit(t){return new Promise((i,n)=>{w()||(e("initTrack","非浏览器环境无需使用init执行初","error"),i(!0)),this.anaSDKInsert?this.configAnaSDK(t,i):l("https://mobile.zwfw.hunan.gov.cn:8088/AnalysysAgent_JS_SDK.min.js","极光").then(()=>{window.AnalysysAgent&&(xybAgent.AnalysysAgent=window.AnalysysAgent,this.anaSDKInsert=!0,this.configAnaSDK(t,i))})})},configAnaSDK(t,i){const n="800c298f0c42c94c",o="40d556c15f872084";let a=location?.host?.includes("hunan.gov.cn")?n:o;if("object"==typeof t)a=o;else{const e={production:n,development:o},i=[n,o];(e[t]||i.includes(t))&&(a=e[t]?e[t]:t)}this.isProdEnv=a===n,e("configAnaSDK",`配置信息:${JSON.stringify(t)},是否为生产环境:${this.isProdEnv},上报的key值:${a}`),w()?(window.xybAgent.AnalysysAgent&&(window.xybAgent.AnalysysAgent.init({appkey:a,uploadURL:"https://mobile.zwfw.hunan.gov.cn:8088/aurora-api"}),e("configAnaSDK","xybAgent已初始化完成,可正常执行埋点操作","log"),this.anaSDKInit=!0,this.isInit=!0,this.checkTrackStack(),i(!0)),!Boolean(window.xybAgent.AnalysysAgent)&&this.anaSDKLoadTimes<10&&setTimeout(()=>this.trackSDKInit(i),300),!Boolean(window.xybAgent.AnalysysAgent)&&this.anaSDKLoadTimes>=10&&(e("configAnaSDK","xybAgent初始化失败","error","请检查app key、uploadURL是否正确"),i(!1))):i(!1)},async initTrackParams(e={}){const{code:t,name:i,aff_city_code:n,aff_city_name:o,unit_code:a,area_code:s,unit_name:r,is_finish:c,category:l,user_id:u,miniAppCode:d,$url_domain:m}=e,g=this.getVisitSource(),h=this.getPageSource(),v=await this.getPositionInfo();return{code:t||void 0,name:i||void 0,aff_city_code:n||void 0,aff_city_name:o||void 0,unit_code:a||void 0,area_code:s||void 0,unit_name:r||void 0,is_finish:c||void 0,category:l||void 0,user_id:u||void 0,miniAppCode:d||void 0,$url_domain:m||void 0,curr_time:F(),source:g,page_source:h,location:v}},getVisitSource(){if(!w()){const e=uni?.getSystemInfoSync(),{uniPlatform:t}=e||{};return"mp-weixin"===t?"wx":"mp-alipay"===t?"alipay":"app"}return C()?"wx":E()?"alipay":"app"},checkTrackStack(){e("checkTrackStack","执行埋点数据堆栈检测","log");t(this.trackStack).forEach(t=>{const{eventID:i,eventPro:n,id:o}=t;e("checkTrackStack",`执行id值为${o} 的埋点数据再次上报`,"log"),this.track(i,n);const a=this.trackStack.findIndex(e=>e.id===o);a>-1&&this.trackStack.splice(a,1)})},getPageSource(){let e=null;e=w()?location.href:decodeURIComponent(o().path);const t=e?.includes("source=");if(!t)return"click";const i=e.split("source=")[1];let n="click";return n=i.includes("&")?i.split("&")[0]:i,["copy","share","click","search"].includes(n)?n:"click"},async getPositionInfo(){if(!this.locationInfo?.province)try{const{location:e}=await this.getLocationInfo()||{};this.locationInfo=e||""}catch(t){e("getLocationInfo","获取位置信息异常","error",t),this.locationInfo={}}return JSON.stringify(this.locationInfo)}},L={initMobileBridgeGlobalConfig(){const t=f();e("initMobileBridgeGlobalConfig",`开始初始化移动端桥链接配置,访问设备类型:${t}`),window.c2={},"ios"===t&&this.initIOSCallbackEvConfig(),"android"===t&&this.initAndroidCallbackEvConfig(),e("initMobileBridgeGlobalConfig","初始化移动端桥链接配置完成"),window.CreatorJsBridge=window.c2},initIOSCallbackEvConfig(){try{const t=this;window.c2.iOS={},window.c2.iOS.callJS=function(){window?.c2.iOS?.callJSCallback||(window.c2.iOS.callJSCallback={}),e("initIOSCallbackEvConfig",`开始处理IOS设备回调事件,回调数据:${JSON.stringify(arguments)}`),t.IOSCallbackEvFormat(arguments[0])}}catch(t){e("initIOSCallbackEvConfig","初始化IOS回调事件配置异常","error",t)}},initAndroidCallbackEvConfig(){window.c2.sendDataWarpToWeb=(e,t,i)=>{e(i)}},IOSCallbackEvFormat(i){const{returnValue:n,funcName:o}=i;let s=this.base64Decode(n);s=a(s),e("IOSCallbackEvFormat",`IOS设备回调事件处理开始,回调数据:${JSON.stringify(s)}, 格式:${typeof s}`);const r=o.split("_a")[0],c=o.replace(r,""),l=this.iosCallBackList.find(e=>e.id===r);if(!l)return;const{resolveInfo:u,configInfo:d}=l,{resDataFormat:m,resErrorFormat:g}=d;if(c.includes("onFail")&&g)return s=g({isSuccess:!1,errorMsg:t(n)}),void u(s);m&&(s=m(s)),e("IOSCallbackEvFormat",`IOS设备回调事件处理完成,返回数据:${JSON.stringify(s)}`),u(s);const h=this.iosCallBackList.findIndex(e=>e.id===r);this.iosCallBackList.splice(h,1)},base64Decode(e){let t,i,n,o,a,s,r,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",l="",u=0;for(e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");u<e.length;)o=c.indexOf(e.charAt(u++)),a=c.indexOf(e.charAt(u++)),s=c.indexOf(e.charAt(u++)),r=c.indexOf(e.charAt(u++)),t=o<<2|a>>4,i=(15&a)<<4|s>>2,n=(3&s)<<6|r,l+=String.fromCharCode(t),64!=s&&(l+=String.fromCharCode(i)),64!=r&&(l+=String.fromCharCode(n));return l=this._utf8_decode(l),l},_utf8_decode(e){let t="",i=0,n=0,o=0,a=0;for(;i<e.length;)n=e.charCodeAt(i),n<128?(t+=String.fromCharCode(n),i++):n>191&&n<224?(a=e.charCodeAt(i+1),t+=String.fromCharCode((31&n)<<6|63&a),i+=2):(a=e.charCodeAt(i+1),o=e.charCodeAt(i+2),t+=String.fromCharCode((15&n)<<12|(63&a)<<6|63&o),i+=3);return t},checkMobileModuleBack(e,t,i){const n=i?"custom":e,o=`${i?"call":t}Callback`;window.c2.hasOwnProperty(n)||(window.c2[n]={}),window.c2[n].hasOwnProperty(o)||(window.c2[n][o]={})}};let B=null,_=null,W=null;I()?(B=uni&&uni?.requireNativePlugin?uni?.requireNativePlugin("GCUniPlugin-RUM"):null,_=uni&&uni?.requireNativePlugin?uni?.requireNativePlugin("GCUniPlugin-Tracer"):null,W=uni&&uni?.getSystemInfoSync?uni.getSystemInfoSync().platform:null):e("请求插件初始化","未找到uni对象","warn");const J={defaults:{headers:{},baseURL:""},interceptor:{request:null,response:null},requestOb:!1,request(i={}){return new Promise((n,o)=>{let a=t(i);if(!this.interceptor.request||"function"!=typeof this.interceptor.request||i.ignore||(a=this.interceptor.request(i),a))if(I()&&this.requestOb&&Boolean(B)&&Boolean(_))try{e("request","走服务监控平台的请求配置","log"),this.executeCloudObRequest(a,n,o)}catch(t){e("request","走服务监控平台的请求配置失败","error",t)}else e("request","走uni的请求配置","log"),this.executeNormalRequest(a,n,o);else n(!1)})},executeCloudObRequest(t,n,o){let a=i();const s=this.checkCloudObRequestHeader(t,a);if(!s)return;const{traceHeader:c,filter:l}=s;let u,d,m;B.startResource({key:a}),uni.request({url:`${this.defaults.baseURL}${t.url}`,method:t.method,header:c,data:t.data,timeout:t.timeout,withCredentials:t?.withCredentials||void 0,success:i=>{if(e("executeCloudObRequest",`接口:${t.url},请求成功`,"log"),l||(u=i.header,d=i.data.toString(),m=i.statusCode),r(t.success)||t.success(i),this.interceptor.response&&"function"==typeof this.interceptor.response&&!t.ignore){const e=this.interceptor.response(i);return void n(e)}n(i)},fail:i=>{e("executeCloudObRequest",`接口:${t.url},请求失败`,"error",i),l||(d=i?.errMsg),r(t?.fail)||t.fail(i),o(i)},complete:()=>{if(e("executeCloudObRequest",`接口:${t.url},请求完成`,"log"),!l){e("executeCloudObRequest",`无filter配置的数据信息::::key值:${a};URL地址:${t.url};`),B.stopResource({key:a});const i={url:`${this.defaults.baseURL}${t.url}`,httpMethod:t.method,requestHeader:c,responseHeader:u,responseBody:d,resourceStatus:m};B.addResource({key:a,content:i})}Boolean(t?.complete)&&t?.complete()}})},checkCloudObRequestHeader(t,i){let n;r(t?.filterPlatform)?(e("executeCloudObRequest",`options.filterPlatform:${t.filterPlatform}`,"log"),n=!1):(n=t?.filterPlatform?.includes(W),e("executeCloudObRequest",`platform:${t.filterPlatform}`,"log")),e("executeCloudObRequest",`rum:${B},tracer:${_}`,"log");let o={};return n||(o=_?.getTraceHeader({key:i,url:t.url})),e("executeCloudObRequest",`是否读取到【tracer】插件配置:${Boolean(_)},是否读取到【rum】插件配置:${Boolean(B)}`,"log"),B&&_?(o=Object.assign({},o,t.header),o=Object.assign({},o,this.defaults.headers),{traceHeader:o,filter:n}):(e("executeCloudObRequest","请配置服务监控平台原生插件","log"),!1)},executeNormalRequest(t,i,n){const{url:o,header:a,data:s,method:r}=t||{},c=Object.assign({},this.defaults.headers,a);uni.request({url:`${this.defaults.baseURL}${o}`,header:c,data:s,method:r,withCredentials:t?.withCredentials||void 0,success:n=>{if(e("normalRequest",`接口:${o},请求成功`,"log"),this.interceptor.response&&"function"==typeof this.interceptor.response&&!t.ignore){const e=this.interceptor.response(n);return void i(e)}i(n)},fail:t=>{e("normalRequest",`接口:${o},请求异常`,"error",t),n(t)}})}},H={resetMenuBtnConfig(){e("hideNativeBtn","隐藏原生APP分享、评价按钮","log");const t={share:{show:!1},comment:{show:!1},favorite:{show:!0}};try{this.menuBtnConfig(t),this.pageChangeEv(i=>{if(!this.autoUpdate)return void e("resetMenuBtnConfig","业务侧设置不自动重置胶囊按钮,中断配置动作");const{options:n}=i,{xybModuleCode:o}=n||{};if(o&&this.autoConfigMenuBtn)return e("resetMenuBtnConfig",`页面拦截事件生效 自动设置原生APP分享、评价按钮,配置信息:${JSON.stringify(i)}`,"log"),void this.menuBtnConfig({share:{show:!0,code:o,type:4},comment:{show:!0,code:o,type:4},favorite:{show:!0}});e("resetMenuBtnConfig","页面拦截事件生效 自动重置原生APP分享、评价按钮配置信息","log"),this.menuBtnConfig(t)})}catch(t){e("resetMenuBtnConfig","配置APP的胶囊按钮清单显示失败,请检查参数是否正确","error",t)}},pageChangeEv(t){if(!uni)return;["navigateTo","redirectTo","switchTab","reLaunch","navigateBack","onBackPress"].forEach(i=>{try{uni.addInterceptor(i,{invoke(n){try{const{url:a}=n;let s={options:{},path:null,route:null},r=decodeURIComponent(a);s.path=r,s.route=r.split("?")[0],r?.includes("xybModuleCode=")&&(console.log(`🚀当前页面路径信息:${r}`),s.options.xybModuleCode=c("xybModuleCode",r)),r?.includes("?")&&(s.route=r.split("?")[0]),i?.includes("Back")&&(s=o(i?.includes("Back"))),e("pageChangeEv",`页面路径发生了变化,当前页面路径:${s.path}`,"log"),"function"==typeof t&&t(s)}catch(t){console.log("🚀 错误信息:::::",t),e("pageChangeEv","拦截路径变化时发生了异常","error",t)}return!0}})}catch(t){e("pageChangeEv","执行页面变化拦截异常","error",t)}})},menuBtnConfig(t={}){e("menuBtnConfig",`配置APP胶囊按钮清单显示,配置信息:${JSON.stringify(t)}`,"log");let i=!0;for(let n in t){if("object"!=typeof t[n]){i=!1,e("menuBtnConfig","配置参数错误","error","请传入一个Object配置数据");break}}if(i)if(y())this.miniAppH5SendMsgToApp(null,"menuBtnConfig",t,"配置APP的胶囊按钮清单显示");else if(!w()&&uni&&uni?.sendNativeEvent)try{e("menuBtnConfig","开始执行配置APP胶囊按钮清单显示","log"),uni?.sendNativeEvent("Util_MiniAppConfigMenu",t)}catch(t){e("menuBtnConfig","配置APP的胶囊按钮清单显示时发生异常","error",t)}else e("menuBtnConfig","配置APP胶囊按钮清单显示功能无法在非UNI环境运行","log")}},U={executeBrowserEvent(t,i={},n={},o={}){const a=C()?"微信小程序":E()?"支付宝小程序":"浏览器",{eventName:s,description:r,browserEvName:c,bResDataFormat:l}=o,u="startNavigation"===s?n:i;e("normalEvDataTransition",`开始调用${a}嵌套H5的能力,事件名称:${s},入参:${JSON.stringify(u)},配置信息:${JSON.stringify(o)}`);const d={authFace:"executeAuthFaceInBrowser",getLocationInfo:"executeGetLocationInBrowser",startNavigation:"startNavigationInBrowser",fileUpload:"executeFileUploadInBrowser"}[s];d?this[d](t,u,o):c?E()?this.executeAlipayBrowserEv(t,c,i,l):C()?this.executeWeChatBrowserEv(t,c,i,l):this.executeNativeBrowserEv(t,c,i,l):t({isSuccess:!1,code:-1,message:`非常抱歉,${r}功能无法在当前环境中使用`})},executeWeChatBrowserEv(e,i){let n=t(i);n.success=function(e){console.log(e)},n.fail=function(e){console.error(e)},window.wx[e](n)},executeAlipayBrowserEv(e,i){let n=t(i);n.success=function(e){console.log(e)},n.fail=function(e){console.error(e)},window.my[e](n)},executeNativeBrowserEv(e,i){let n=t(i);n.success=function(e){console.log(e)},n.fail=function(e){console.error(e)},window.uni[e](n)}},q={executeAuthFaceInBrowser(t,i={},n={}){const o=function(i){let n=c("faceKey",window?.location?.href);if(e("executeAuthFaceInBrowser",`获取到的faceKey参数值::::${n}`),!window?.location?.href.includes("faceKey"))return;const a={isSuccess:Boolean(n),certifyId:n,portrait:null,errorMsg:Boolean(n)?null:"人脸验证失败,请检查参数信息"};window.removeEventListener("hashchange",o),setTimeout(()=>{e("executeAuthFaceInBrowser",`执行验证结果回抛给业务侧:${JSON.stringify(a)}`),t(a)},100)};window.addEventListener("hashchange",o);const a=encodeURIComponent(window.location.href),{certNo:s,name:r}=i;let l=`/pages/sdk/sdk?redirectUrl=${a}&type=authFace&idCard=${encodeURIComponent(s)}&name=${r}`;C()?d(l,t):E()?u(l,t):(e("executeAuthFaceInBrowser","当前环境不支持人脸识别","warning"),t({isSuccess:!1,code:-1,message:"当前环境下不支持人脸识别验证功能"}))}},K={locationCheck:!1,executeGetLocationInBrowser(t){e("executeGetLocationInBrowser","在微信/支付宝浏览器中获取定位信息"),E()?this.getLocationInAliPay(t):C()?this.getLocationInWeChat(t):"geolocation"in navigator?navigator.geolocation.getCurrentPosition(i=>{e("executeGetLocationInBrowser",`geolocation-res::::${JSON.stringify(i)}`);const{latitude:n,longitude:o}=i?.coords||{};this.executeGetDetailLocation(t,{latitude:n,longitude:o})},i=>{switch(i.code){case i.PERMISSION_DENIED:t({code:-1,isSuccess:!1,message:"用户拒绝了位置请求"}),e("executeGetLocationInBrowser","用户拒绝了位置信息请求","warning");break;case i.POSITION_UNAVAILABLE:t({code:-1,isSuccess:!1,message:"位置信息不可用"}),e("executeGetLocationInBrowser","位置信息不可用","warning");break;case i.TIMEOUT:t({code:-1,isSuccess:!1,message:"请求超时"}),e("executeGetLocationInBrowser","请求超时","warning");break;default:t({code:-1,isSuccess:!1,message:i.message}),e("executeGetLocationInBrowser","位置错误","warning",i.message)}}):t({isSuccess:!1,message:"当前环境无法支持位置信息获取,请检查是否为湘易办相关环境"})},getLocationInWeChat(t){if(this.locationCheck)return e("getLocationInWeChat","已缓存签名信息,直接调用对应API获取位置信息"),void this.executeGetLocationInfoData(t);this.executeGetLocationInfoData(t)},executeGetLocationInfoData(t){e("executeGetLocationInfoData","在微信环境中获取位置信息"),window?.wx?.getLocation({success:i=>{this.locationCheck=!0,e("executeGetLocationInfoData",`调用微信获取位置信息完成,结果是:${JSON.stringify(i)}`),this.executeGetDetailLocation(t,i)},fail:i=>{t({isSuccess:!1,message:"调用微信获取位置信息失败,请联系管理员"}),e("executeGetLocationInfoData",`调用微信获取位置信息失败,信息是:${JSON.stringify(i)}`)}})},executeGetDetailLocation(t,i){uni.request({url:`${k}/api/wechat/address?location=${i.latitude},${i?.longitude}`,method:"GET",success:i=>{const{data:n}=i?.data||{},o=n?.result||{},{lng:a,lat:s}=o?.location||{},{cityCode:r,formatted_address:c}=o||{},{district:l,city:u,country:d,adCode:m,province:g}=o?.addressComponent||{},h={isSuccess:!0,location:{district:l,city:u,longitude:a,country:d,cityCode:r,adCode:m,address:c,latitude:s,province:g}};e("executeGetDetailLocation",`获取位置信息调用完成,结果:${JSON.stringify(h)}`),t(h)},fail:t=>{e("executeGetDetailLocation","获取位置信息失败","error",JSON.stringify(t))}})},getLocationInAliPay(t){my?.getLocation({success:i=>{this.executeGetDetailLocation(t,i),e("getLocationInAliPay",`支付宝下获取位置信息完成:::${JSON.stringify(i)}`)},fail:i=>{e("getLocationInAliPay",`获取位置信息失败,错误信息:${JSON.stringify(i)}`,"error",i),t({isSuccess:!1,message:"获取位置信息失败,请联系湘易办相关技术人员"})}})}},R={navigationCheck:!1,startNavigationInBrowser(t,i={}){const n=encodeURIComponent(window?.location?.href),{lat:o,lng:a,address:s,name:r,dinateType:c}=i;let l=`/pages/sdk/sdk?redirectUrl=${n}&type=navigation&latitude=${o}&longitude=${a}&address=${s}&name=${r}`;if(c&&"GCJ02"!==c){const e=M(i),{destinationLatitude:t,destinationLongitude:o}=e;l=`/pages/sdk/sdk?redirectUrl=${n}&type=navigation&latitude=${t}&longitude=${o}&address=${s}&name=${r}`}e("startNavigationInBrowser",`跳转目标URL:${l}`),C()?d(l,t):E()?u(l,t):(e("startNavigationInBrowser","导航功能无法在当前环境下执行"),t({isSuccess:!1,code:-1,message:"导航功能无法在当前环境下执行,请检查是否为微信/支付宝小程序的浏览器环境中"}))}},G={wvInfo:null,isHarmony:!1,isCheckDevice:!1,async initMessage(...t){const i=t[0];await this.checkDeviceInfo(),await this.initVMInfo(t[2]),w()?window.addEventListener("message",t=>{e("initMessage",`浏览器webview接收到的消息内容,${JSON.stringify(t)}`,"log"),this.getMsgFromH5(t)}):(e("initMessage",`非浏览器中的webview接收到的消息内容,${JSON.stringify(i)}`,"log"),this.getMsgFromH5(i))},checkDeviceInfo(){this.isCheckDevice||(this.isCheckDevice=!0,uni.sendNativeEvent("System_getAppInfo",{},e=>{this.isHarmony=e?.platform?.toLowerCase().includes("harmony")}))},initVMInfo(t){if(!this.wvInfo)if(this.isHarmony)this.wvInfo=uni.createWebviewContext("webview",t);else try{this.wvInfo=t,t?.$scope?.$getAppWebview()&&(this.wvInfo=t.$scope.$getAppWebview().children()[0])}catch(t){e("initMessage","初始化消息模块,是否包含wvInfo:"+typeof this.wvInfo?.evalJS)}},getMsgFromH5(t={}){let i=this.getMsgDataFromH5(t);const{origin:n}=t||{},{href:o}=location||{};if(w()&&o?.includes(n))return!1;const{isH5Send:a,methodName:s,methodData:r}=i||{};return!!a&&(s?null==r?(e("getMsgFromH5","请传入需要执行的事件数据","warn"),!1):(e("getMsgFromH5",`需要执行的事件名称【${s}】,需要执行的事件数据【${JSON.stringify(r)}】,是否为H5发送的消息【${a}】`,"log"),void(this[s]?this.executeH5MethodName(s,i):e("getMsgFromH5",`【${s}】事件不存在`,"warn"))):(e("getMsgFromH5","请传入需要执行的事件名称","warn"),!1))},executeH5MethodName(t,i){const{msgId:n,methodData:o}=i;try{const i=this[t].toString();if(e("executeH5MethodName",`【${t}】方法定义:${i}`,"log"),i.includes("Promise"))return void this[t](o).then(i=>{e("executeH5MethodName",`${t}方法执行结果:${JSON.stringify(i)}`,"log");let o=i;try{o=JSON.parse(i)}catch(t){e("executeH5MethodName","强制给数据进行序列化失败","error",t)}this.postMsgToH5({msgId:n,sourceMethod:t,resultInfo:o,isWebviewSend:!0,resultMessage:`执行${t}方法完成`})}).catch(i=>{e("executeH5MethodName",`${t}方法执行失败`,"error",i),this.postMsgToH5({msgId:n,sourceMethod:t,resultInfo:null,isWebviewSend:!0,resultMessage:`执行${t}方法失败,具体错误信息,请查看控制台`})});this[t](o),this.postMsgToH5({msgId:n,sourceMethod:t,resultInfo:null,isWebviewSend:!0,resultMessage:`执行${t}方法完成`})}catch(i){e("getMsgFromH5",`${t}方法执行失败`,"error",i)}},postMsgToH5(t){const i=JSON.stringify(t);if(e("postMsgToH5",`消息内容:${i}`,"log"),w()){e("postMsgToH5","父页面运行在浏览器","log");document.querySelector("iframe").contentWindow.postMessage(JSON.stringify(i),"*")}else try{e("postMsgToH5","父页面运行在非浏览器","log"),this.wvInfo.evalJS(`getMessageFromWebview('${i}')`)}catch(t){e("postMsgToH5","执行浏览器的webview回传异常","error",t)}},getMsgDataFromH5(t){let i=null;const{data:n}=t;try{i=w()?n?.data?.arg?n?.data?.arg:n?.data?n.data:n:t.detail?.data[0]}catch(t){return e("getMsgDataFromH5","处理消息内容时发生异常","error",t),!1}return e("getMsgDataFromH5",`获取到的消息内容:${JSON.stringify(i)}`,"log"),i}},j=(t,i,n)=>{if(e("_parseFunction",`${JSON.stringify(t)}`),"function"==typeof t)return n[i]=t,void(t="[Function]::"+i);if("object"!=typeof t)return;let o=null;for(let e in t)switch(typeof t[e]){case"object":o=i?i+"_"+e:e,j(t[e],o,n);break;case"function":o=i?i+"_"+e:e,n[o]=t[e],t[e]="[Function]::"+o}},z=e=>{let t=0;return"string"==typeof e?t=1:"number"==typeof e?t=2:"boolean"==typeof e?t=3:"function"==typeof e?t=4:e instanceof Array?t=6:"object"==typeof e&&(t=5),t},V={appH5SendMsgToApp(e,t={},i={}){const{isWindowEv:n,moduleName:o,nativeEvName:a,isCustomEv:s}=t;if(n)return void this.h5SendMsgToAppByWindow(e,t,i);const r=s?"custom":o,c=s?"call":a;this.executeSendMsgToApp({resolveInfo:e,moduleName:r,eventName:c,actionName:a,dataInfo:i,isCustomEv:s,evConfig:t})},executeSendMsgToApp(i={}){const{moduleName:n,eventName:o,actionName:a,dataInfo:s,resolveInfo:r,isCustomEv:c,evConfig:l}=i||{},{description:u}=l,d=this;try{let i={};if(("object"==typeof s?Object.keys(s):[]).length>0&&(i=t(s)),c){const n=t(i);e("webviewSendMsgToApp",`${u}功能在是通过custom.call的方式调用,需要重新处理入参`),i.params=n,i.action=a}e("webviewSendMsgToApp",`${u}的完整参数:${JSON.stringify(i)}`),this.initEventCallbackEv(r,i,l);const m=function(){return d.formatBridgeData(window.c2[n][`${o}Callback`],arguments)}(i);e("webviewSendMsgToApp",`${u}功能在${f()}的Webview环境下执行,调用参数:${JSON.stringify(m)}`),this.h5SendMsgToAppByBrowser(r,l,m)}catch(t){console.log(`🚀发送消息给APP出现错误,错误信息:${t},${JSON.stringify(t)}`),e("webviewSendMsgToApp",`${u}执行数据处理失败`,"error",t)}},initEventCallbackEv(i,n,o={}){const{description:a,resDataFormat:s,resErrorFormat:r}=o;n.onSuccess=function(t){e("webviewSendMsgToApp",`${a}功能在App的Webview环境下执行完成`),i(s?s(t):t)},n.onFail=function(n){const o=t(n);e("webviewSendMsgToApp",`${a}功能在App的Webview环境下执行失败,收到的回调数据:::${JSON.stringify(o)}`),i(r?r(o):s?s(o):o)}},formatBridgeData(t,i){try{const n=Math.random().toString(32).slice(2),o=[];for(let e in i){const a=n+"_a"+e,s=i[e],r={};!1===/OpenHarmony ([5-9])|OpenHarmony (\d{2})/i.test(navigator.userAgent)&&j(s,a,r);for(let e in r)t[e]=r[e],this.C2ReceiveQueue.push(t);o.push({type:z(s),name:a,value:s})}return e("formatBridgeData",`格式化后的参数:${JSON.stringify(o)}`),{params:o,id:n}}catch(t){e("formatBridgeData","消息通讯数据格式化异常","error",t)}},h5SendMsgToAppByWindow(t,i={},n={}){const{nativeEvName:o,description:s,resDataFormat:r}=i,c=f(),l=`${o}Back`;let u=n;e("h5SendMsgToAppByWindow",`给【${c}】APP发送【${s}】-【${o}】事件调用,回调函数名称:【${l}】`,"log"),window[l]=i=>{let n=i;e("h5SendMsgToAppByWindow",`收到【${c}】APP发送的${s}事件调用的回调值:${JSON.stringify(n)},回调数据类型::${typeof n}`,"log"),n=a(n),t(r?r(n):n)},setTimeout(()=>{"ios"!==c.toLowerCase()?"android"!==c.toLowerCase()?window.harmony[o](u):window.android[o](u):window.webkit.messageHandlers[o].postMessage(u)},100)},h5SendMsgToAppByBrowser(t,i={},n={}){const o=f();e("h5SendMsgToAppByBrowser",`给【${o}】APP发送【${i.nativeEvName}】事件调用,入参:${JSON.stringify(n)}`,"log");const{nativeEvName:a,moduleName:s,isCustomEv:r}=i,{id:c,params:l}=n;if("android"!==o)return"ios"===o?(this.iosCallBackList.push({id:c,resolveInfo:t,configInfo:i}),void this.h5SendMsgToIOS(c,s,a,l,r)):void("harmony"===o&&this.h5SendMsgToHarmony(c,s,a,l,r));this.h5SendMsgToAndroid(c,s,a,l,r)},h5SendMsgToAndroid(t,i,n,o,a){const s={id:t,module:a?"custom":i,method:a?"call":n,parameters:o};return e("h5SendMsgToAndroid",`发送给安卓APP的消息:${JSON.stringify(s)}`),JSON.parse(window.AndroidFunction.callAndroidFun(JSON.stringify(s)))},h5SendMsgToIOS(t,i,n,o,a){const s={id:t,module:a?"custom":i,method:a?"call":n,parameters:o};return e("h5SendMsgToIOS",`发送给IOS APP的消息:${JSON.stringify(s)}`),JSON.parse(prompt(JSON.stringify(s)))},h5SendMsgToHarmony(t,i,n,o,a){const s={id:t,module:a?"custom":i,method:a?"call":n,parameters:o};return e("h5SendMsgToHarmony",`发送给鸿蒙APP的消息:${JSON.stringify(s)}`),JSON.parse(window.harmonyFunction.callHarmonyFun(s))}},Q={msgList:[],msgStack:[],async miniAppH5SendMsgToApp(t,i,n){try{e("miniAppH5SendMsgToApp",`发送消息给webview:${i}`,"log");const o=await this.sendMsgToMiniApp({methodName:i,methodData:n});t(o?.resultInfo)}catch(n){e("miniAppH5SendMsgToApp",`执行${i}失败`,"error",n),t({isSuccess:!1,message:"执行事件失败,详情查看控制台"})}},sendMsgToMiniApp(t){return new Promise((n,o)=>{e("postMsgToWebview",`消息内容:${JSON.stringify(t)}`,"log");const{methodName:a,methodData:s}=t||{};if(!a)return void e("postMsgToWebview","请传入要调用的事件名称","warn");if(!s)return void e("postMsgToWebview","请传入要调用事件的数据信息","warn");const r=i(),c={data:{msgId:r,isH5Send:!0,...t}};if(this.msgList.push({id:r,resolveInfo:n,rejectInfo:o}),e("postMsgToWebview",`发送消息给父容器页面:${JSON.stringify(c)}`,"log"),!this.uniSDKInit)return e("postMsgToWebview","SDK尚未初始化完成,先行执行堆栈","log"),void this.msgStack.push({id:i(),msgContent:c,resolve:n,reject:o});uni?.webView?.postMessage?uni.webView.postMessage(c):uni?.postMessage(c)}).catch(t=>{e("postMsgToWebview","发生异常","error",t)})}},X={getMessageFromWebview(t,i=!1){let n={};try{n=i?t:t?.data||"{}",n=a(n)}catch(t){e("getMessageFromWebview","解析数据异常","error",t)}if(e("getMessageFromWebview",`是否为webview发送的消息内容:${n?.isWebviewSend},消息内容:${JSON.stringify(n)}`,"log"),!n?.isWebviewSend)return;const{msgId:o}=n,s=this.msgList.findIndex(e=>e.id===o);if(-1===s)return;const r=this.msgList[s],{resolveInfo:c}=r;c(n),this.msgList.splice(s,1)}},Y=["getLoginUserInfo","getAuthToken"];let Z=new class{version="";isInit=!1;isWebviewPage=!1;anaSDKInit=!1;uniSDKInit=!1;weChatInit=!1;alipayInit=!1;iosCallBackList=[];C2ReceiveQueue=[];autoUpdate=!0;autoConfigMenuBtn=!0;constructor(e,t){this.version=e,this.isInit=!1,this.isWebviewPage=t,this.iosCallBackList=[],this.initModuleMethod(),this.initSDKAPI(),this.initDefaultConfig()}initModuleMethod(){n(P,this),n(T,this),n(L,this),n(J,this),n(U,this),n(K,this),n(H,this),n(G,this),n(V,this),n(q,this),n(R,this),n(X,this),n(Q,this)}init(t){w()?(y()&&this.initWebviewMsgFormat(),this.initSDKScriptFile(),this.trackSDKInit(t)):e("init","当前环境非浏览器环境,无需执行初始化动作","warn")}initSDKScriptFile(){if(C()||E())return C()?(window?.uni&&delete window.uni,void this.initWeChatSDK()):void this.initAliPaySDK();this.initUNISDK()}initWebviewMsgFormat(){e("initWebviewMsgFormat","初始化被嵌套的页面消息通讯","log"),w()?(window.addEventListener("message",t=>{e("initWebviewMsgFormat","浏览器消息处理","log"),this.getMessageFromWebview(t)}),window.getMessageFromWebview=t=>{e("initWebviewMsgFormat","事件注入消息处理","log"),this.getMessageFromWebview(t,!0)}):e("initWebviewMsgFormat","该API仅支持在被webview嵌套的H5页面中使用","error","")}initUNISDK(){w()&&(A()||l("https://mobile.zwfw.hunan.gov.cn:8088/uni.webview.1.5.6.js","UNI").then(()=>{A()&&(this.uniSDKInit=!0,e("initUNISDK","UNI Webview SDK 挂载完成"))}))}initWeChatSDK(){e("initWeChatSDK","初始化weChat SDK"),w()&&(b()?e("initWeChatSDK","WeChat SDK已挂载完成,无需二次挂载"):l("https://res.wx.qq.com/open/js/jweixin-1.6.0.js","微信").then(t=>{b()&&(this.weChatInit=!0,e("initWeChatSDK","WeChat SDK挂载完成"))}))}initWeChatConfig(){uni.request({url:`${k}/api/wechat/signature`,method:"POST",data:{url:window.location.href.split("#")[0]},success:t=>{const i=t?.data?.data;e("getLocationInWeChat",`获取签名信息完成,结果是:${JSON.stringify(t)}`),window?.wx?.config({appId:"wx44bc5d5e34ac0c01",timestamp:i?.timestamp,nonceStr:i?.noncestr,signature:i?.signature,jsApiList:["getLocation","openLocation","chooseImage","chooseFile","scanQRCode","previewImage","downloadImage"]})},fail:t=>{e("getLocationInWeChat",`获取签名信息失败,信息是:${JSON.stringify(t)}`)}})}initAliPaySDK(){e("initAliPaySDK","初始化Alipay SDK"),w()&&($()||E()&&l("https://appx/web-view.min.js","支付宝").then(t=>{$()&&(this.alipayInit=!0,e("initAliPaySDK","Alipay SDK挂载完成"))}))}initSDKAPI(){S()&&(e("initSDKAPI","App的Webview环境,初始化C2调用链的回调函数"),this.initMobileBridgeGlobalConfig()),e("initSDKAPI","开始初始化SDK API"),D.forEach(t=>{const{eventName:i,moduleName:n,nativeEvName:o,isCustomEv:a}=t;if((n&&o||a)&&S()&&(e("initSDKAPI",`初始化C2调用链的回调函数:${i}`),this.checkMobileModuleBack(n,o,a)),!Y?.includes(i))try{this[i]=e=>new Promise(i=>{this.normalEvDataTransition(i,e,t)})}catch(t){e("initSDKAPI","执行API初始化挂载异常","error",t)}})}normalEvDataTransition(t,i={},n={}){const{eventName:o,description:a,reqDataFormat:s}=n||{},r=f();let c=i;if(s&&(c=s(i)),c)return S()?(e("normalEvDataTransition",`开始调用APP的嵌套H5能力,事件名称:${o},入参:${JSON.stringify(c)}`),void this.appH5SendMsgToApp(t,n,c)):N()?(e("normalEvDataTransition",`开始调用小程序/H5嵌套的H5能力,事件名称:${o},入参:${JSON.stringify(c)}`),void this.miniAppH5SendMsgToApp(t,o,c,a)):void(C()||E()?this.executeBrowserEvent(t,c,i,n):this.executeEvByNative(t,c,n));e(o,`给【${r}】APP发送【${a}】-【${o}】事件失败,请检查数据格式是否正确`,"error")}executeEvByNative(t,i,n){const{description:o,uniEvName:a,eventName:r,nativeResFormat:c}=n;try{e("executeEvByNative",`开始调用原生${o}的能力,API名称:${a},格式化前的参数信息:${JSON.stringify(i)}`),uni.sendNativeEvent(a,i,i=>{e("executeEvByNative",`调用原生${o}的能力完成,结果:${JSON.stringify(i)}`,"log");let n=i;c&&(n=c(n),e("executeEvByNative",`调用原生${o}的能力完成,格式化后的结果:${JSON.stringify(n)}`,"log")),"fileDownload"===r&&i.hasOwnProperty("isSuccess")&&s(t,n),"fileDownload"!==r&&s(t,n)})}catch(i){t({isSuccess:!1,message:`${o}API执行失败,具体错误信息请查看控制台`}),e("executeEvByNative",`${o}API执行异常`,"error",i)}}initDefaultConfig(){e("initDefaultConfig","默认胶囊按钮配置执行初始化处理"),this.autoUpdate?this.resetMenuBtnConfig():e("initDefaultConfig","业务侧配置无需自动重置胶囊按钮,不至于页面切换事件监听")}}(x,y());return w()&&(window.xybAgent=Z),Z});
|