@lambo-design-mobile/lambo-js-bridge 1.0.0-beta.39 → 1.0.0-beta.40
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/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/src/sdk/WeComAdapter.js +56 -0
- package/src/sdk/WechatAdapter.js +45 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
|
+
## [1.0.0-beta.40](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/compare/@lambo-design-mobile/lambo-js-bridge@1.0.0-beta.39...@lambo-design-mobile/lambo-js-bridge@1.0.0-beta.40) (2025-12-08)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### ✨ Features | 新功能
|
|
6
|
+
|
|
7
|
+
* 微信jssdk认证增加回调钩子函数 ([00a331b](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/00a331bedb4c030acc7c6802c18ece3c7ecebe2b))
|
|
8
|
+
|
|
2
9
|
## [1.0.0-beta.39](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/compare/@lambo-design-mobile/lambo-js-bridge@1.0.0-beta.38...@lambo-design-mobile/lambo-js-bridge@1.0.0-beta.39) (2025-11-28)
|
|
3
10
|
|
|
4
11
|
|
package/package.json
CHANGED
package/src/sdk/WeComAdapter.js
CHANGED
|
@@ -57,9 +57,26 @@ class WeComAdapter {
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
/**
|
|
61
|
+
* 初始化jssdk
|
|
62
|
+
* 2025-12-4 16:49:11 修改,增加审计日志回调函数auditLog,在不同阶段会调用该回调函数,调用参数如下
|
|
63
|
+
* {
|
|
64
|
+
* seg: 阶段,当前有 beforeConfig、configError、afterConfig、ready
|
|
65
|
+
* title: 对阶段的文字描述
|
|
66
|
+
* }
|
|
67
|
+
* 业务系统有需要对初始化jssdk进行审计的需求,在初始化jssdk的时候,在options中增加auditLog属性,并根据需要记录所需记录日志的阶段或者全部记录
|
|
68
|
+
* @param {*} options
|
|
69
|
+
* @returns
|
|
70
|
+
*/
|
|
60
71
|
async init(options) {
|
|
61
72
|
// 在iOS小程序的webview中,currentUrl不能使用动态的,要使用小程序首次打开webview的URL,通过参数传进来
|
|
62
73
|
const currentUrl = encodeURIComponent(window.location.href.split('#')[0]);
|
|
74
|
+
if (options.auditLog && options.auditLog instanceof Function) {
|
|
75
|
+
options.auditLog({
|
|
76
|
+
seg: 'beforeConfig',
|
|
77
|
+
title: '开始企业微信jssdk认证',
|
|
78
|
+
});
|
|
79
|
+
}
|
|
63
80
|
ajax
|
|
64
81
|
.request({
|
|
65
82
|
url:
|
|
@@ -96,8 +113,20 @@ class WeComAdapter {
|
|
|
96
113
|
], // 必填,传入需要使用的接口名称
|
|
97
114
|
success(res) {
|
|
98
115
|
console.log('ready...');
|
|
116
|
+
if (options.auditLog && options.auditLog instanceof Function) {
|
|
117
|
+
options.auditLog({
|
|
118
|
+
seg: 'afterConfig',
|
|
119
|
+
title: '完成企业微信jssdk认证',
|
|
120
|
+
});
|
|
121
|
+
}
|
|
99
122
|
},
|
|
100
123
|
fail(res) {
|
|
124
|
+
if (options.auditLog && options.auditLog instanceof Function) {
|
|
125
|
+
options.auditLog({
|
|
126
|
+
seg: 'configError',
|
|
127
|
+
title: '企业微信jssdk认证异常' + res.errMsg,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
101
130
|
if (res.errMsg.indexOf('function not exist') > -1) {
|
|
102
131
|
alert('版本过低请升级');
|
|
103
132
|
}
|
|
@@ -105,9 +134,21 @@ class WeComAdapter {
|
|
|
105
134
|
});
|
|
106
135
|
|
|
107
136
|
wx.error(function (res) {
|
|
137
|
+
if (options.auditLog && options.auditLog instanceof Function) {
|
|
138
|
+
options.auditLog({
|
|
139
|
+
seg: 'configError',
|
|
140
|
+
title: '企业微信jssdk认证异常wxerror',
|
|
141
|
+
});
|
|
142
|
+
}
|
|
108
143
|
console.error(res);
|
|
109
144
|
});
|
|
110
145
|
wx.ready(function () {
|
|
146
|
+
if (options.auditLog && options.auditLog instanceof Function) {
|
|
147
|
+
options.auditLog({
|
|
148
|
+
seg: 'ready',
|
|
149
|
+
title: '完成企业微信jssdk认证,进入ready状态',
|
|
150
|
+
});
|
|
151
|
+
}
|
|
111
152
|
console.log('ready.....');
|
|
112
153
|
// config信息验证后会执行ready方法,所有接口调用都必须在config接口获得结果之后,config是一个客户端的异步操作,所以如果需要在页面加载时就调用相关接口,则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口,则可以直接调用,不需要放在ready函数中。
|
|
113
154
|
});
|
|
@@ -128,9 +169,24 @@ class WeComAdapter {
|
|
|
128
169
|
// 如:{"checkResult":{"chooseImage":true},"errMsg":"checkJsApi:ok"}
|
|
129
170
|
},
|
|
130
171
|
});
|
|
172
|
+
} else {
|
|
173
|
+
if (options.auditLog && options.auditLog instanceof Function) {
|
|
174
|
+
options.auditLog({
|
|
175
|
+
seg: 'configError',
|
|
176
|
+
title:
|
|
177
|
+
'企业微信jssdk认证异常请求认证参返回结果异常' +
|
|
178
|
+
JSON.stringify(resp),
|
|
179
|
+
});
|
|
180
|
+
}
|
|
131
181
|
}
|
|
132
182
|
})
|
|
133
183
|
.catch((err) => {
|
|
184
|
+
if (options.auditLog && options.auditLog instanceof Function) {
|
|
185
|
+
options.auditLog({
|
|
186
|
+
seg: 'configError',
|
|
187
|
+
title: '企业微信jssdk认证异常请求认证参数失败',
|
|
188
|
+
});
|
|
189
|
+
}
|
|
134
190
|
console.error(err);
|
|
135
191
|
});
|
|
136
192
|
}
|
package/src/sdk/WechatAdapter.js
CHANGED
|
@@ -36,8 +36,25 @@ class WechatAdapter {
|
|
|
36
36
|
.catch((err) => console.error(err));
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
/**
|
|
40
|
+
* 初始化jssdk
|
|
41
|
+
* 2025-12-4 16:49:11 修改,增加审计日志回调函数auditLog,在不同阶段会调用该回调函数,调用参数如下
|
|
42
|
+
* {
|
|
43
|
+
* seg: 阶段,当前有 beforeConfig、configError、afterConfig、ready
|
|
44
|
+
* title: 对阶段的文字描述
|
|
45
|
+
* }
|
|
46
|
+
* 业务系统有需要对初始化jssdk进行审计的需求,在初始化jssdk的时候,在options中增加auditLog属性,并根据需要记录所需记录日志的阶段或者全部记录
|
|
47
|
+
* @param {*} options
|
|
48
|
+
* @returns
|
|
49
|
+
*/
|
|
39
50
|
async init(options) {
|
|
40
51
|
const currentUrl = encodeURIComponent(window.location.href.split('#')[0]); // 确保URL编码且去除hash部分
|
|
52
|
+
if (options.auditLog && options.auditLog instanceof Function) {
|
|
53
|
+
options.auditLog({
|
|
54
|
+
seg: 'beforeConfig',
|
|
55
|
+
title: '开始小程序jssdk认证',
|
|
56
|
+
});
|
|
57
|
+
}
|
|
41
58
|
ajax
|
|
42
59
|
.request({
|
|
43
60
|
url: `${config.upmsServerContext}/manage/ibpWxMpBaseinfo/gtJsTicket?appId=${options.wechatId}&url=${currentUrl}`,
|
|
@@ -63,17 +80,43 @@ class WechatAdapter {
|
|
|
63
80
|
|
|
64
81
|
window.wx.error(function (res) {
|
|
65
82
|
console.log('error:', res);
|
|
66
|
-
|
|
83
|
+
if (options.auditLog && options.auditLog instanceof Function) {
|
|
84
|
+
options.auditLog({
|
|
85
|
+
seg: 'configError',
|
|
86
|
+
title: '小程序jssdk认证异常wxerror',
|
|
87
|
+
});
|
|
88
|
+
}
|
|
67
89
|
});
|
|
68
90
|
|
|
69
91
|
wx.ready(function () {
|
|
92
|
+
if (options.auditLog && options.auditLog instanceof Function) {
|
|
93
|
+
options.auditLog({
|
|
94
|
+
seg: 'afterConfig',
|
|
95
|
+
title: '完成小程序jssdk认证',
|
|
96
|
+
});
|
|
97
|
+
}
|
|
70
98
|
console.log('ready...');
|
|
71
99
|
// config信息验证后会执行ready方法
|
|
72
100
|
// 可以在这里调用相关接口
|
|
73
101
|
});
|
|
102
|
+
} else {
|
|
103
|
+
if (options.auditLog && options.auditLog instanceof Function) {
|
|
104
|
+
options.auditLog({
|
|
105
|
+
seg: 'configError',
|
|
106
|
+
title:
|
|
107
|
+
'小程序jssdk认证异常请求认证参返回结果异常' +
|
|
108
|
+
JSON.stringify(resp),
|
|
109
|
+
});
|
|
110
|
+
}
|
|
74
111
|
}
|
|
75
112
|
})
|
|
76
113
|
.catch((err) => {
|
|
114
|
+
if (options.auditLog && options.auditLog instanceof Function) {
|
|
115
|
+
options.auditLog({
|
|
116
|
+
seg: 'configError',
|
|
117
|
+
title: '小程序jssdk认证异常请求认证参数失败',
|
|
118
|
+
});
|
|
119
|
+
}
|
|
77
120
|
console.error(err);
|
|
78
121
|
});
|
|
79
122
|
}
|
|
@@ -188,8 +231,7 @@ class WechatAdapter {
|
|
|
188
231
|
) {
|
|
189
232
|
options.auditLog({
|
|
190
233
|
seg: 'errorLocation1',
|
|
191
|
-
title:
|
|
192
|
-
'小程序调用jssdk定位异常,未取到经纬度'
|
|
234
|
+
title: '小程序调用jssdk定位异常,未取到经纬度',
|
|
193
235
|
});
|
|
194
236
|
}
|
|
195
237
|
return reject(new Error('Invalid location data'));
|