@lambo-design-mobile/lambo-js-bridge 1.0.0-beta.32 → 1.0.0-beta.34

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 CHANGED
@@ -1,4 +1,18 @@
1
1
  # Changelog
2
+ ## [1.0.0-beta.34](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/compare/@lambo-design-mobile/lambo-js-bridge@1.0.0-beta.33...@lambo-design-mobile/lambo-js-bridge@1.0.0-beta.34) (2025-08-22)
3
+
4
+
5
+ ### ✨ Features | 新功能
6
+
7
+ * **@lambo-design-mobile/js-bridge:** 山东中烟定位增加provider参数,并把坐标系从bd09转为wgs84 ([7b11dec](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/7b11dec5e93bed712437769f6aa6349f66f824d5))
8
+
9
+ ## [1.0.0-beta.33](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/compare/@lambo-design-mobile/lambo-js-bridge@1.0.0-beta.32...@lambo-design-mobile/lambo-js-bridge@1.0.0-beta.33) (2025-07-21)
10
+
11
+
12
+ ### 🐛 Bug Fixes | Bug 修复
13
+
14
+ * **getLocation:** 解决在 URL 变化时,由于 wx.config 和 wx.ready 的异步特性导致的微信接口调用使用旧配置、签名失效或调用失败的问题 ([08b96b6](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/08b96b61e0fa07bc3cad53b5bb4c8025e297e12c))
15
+
2
16
  ## [1.0.0-beta.32](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/compare/@lambo-design-mobile/lambo-js-bridge@1.0.0-beta.31...@lambo-design-mobile/lambo-js-bridge@1.0.0-beta.32) (2025-07-16)
3
17
 
4
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lambo-design-mobile/lambo-js-bridge",
3
- "version": "1.0.0-beta.32",
3
+ "version": "1.0.0-beta.34",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "author": "lambo",
@@ -10,7 +10,8 @@
10
10
  "registry": "https://registry.npmjs.org/"
11
11
  },
12
12
  "dependencies": {
13
- "coordtransform": "^2.1.2"
13
+ "coordtransform": "^2.1.2",
14
+ "gcoord": "^0.1.2"
14
15
  },
15
16
  "scripts": {
16
17
  "release-js-bridge": "pnpm release-beta && git push --follow-tags && pnpm re-publish",
@@ -1,5 +1,6 @@
1
1
  import { getAddress } from './BdMapUtils';
2
2
  import config from "@lambo-design-mobile/shared/config/config";
3
+ import gcoord from 'gcoord'
3
4
 
4
5
  class MobileIMAdapter {
5
6
  constructor(_options) {
@@ -12,6 +13,7 @@ class MobileIMAdapter {
12
13
  let args = {
13
14
  // 是否获取地址信息
14
15
  // isNeedAddress: true,
16
+ provider: 'baidu', // 使用百度定位能力
15
17
  };
16
18
 
17
19
  const fetchLocation = () => {
@@ -48,9 +50,15 @@ class MobileIMAdapter {
48
50
  } else {
49
51
  return new Promise((resolve2) => {
50
52
  window.native.getLocation(args, (res) => {
53
+ const point = res.point;
54
+ let [lng, lat] = gcoord.transform(
55
+ [point.longitude, point.latitude], // 经纬度坐标
56
+ gcoord.BD09, // 当前坐标系
57
+ gcoord.WGS84, // 目标坐标系
58
+ );
51
59
  resolve2({
52
- latitude: res.point.latitude,
53
- longitude: res.point.longitude,
60
+ latitude: lat,
61
+ longitude: lng,
54
62
  accuracy: res.point.horizontalAccuracy,
55
63
  });
56
64
  });
@@ -90,7 +90,40 @@ class WeComAdapter {
90
90
 
91
91
  async getLocation(options) {
92
92
  return new Promise((resolve, reject) => {
93
- wx.ready(() => {
93
+ wx.ready(async () => {
94
+ // 解决在 URL 变化时,由于 wx.config 和 wx.ready 的异步特性导致的微信接口调用使用旧配置、签名失效或调用失败的问题
95
+ // 新增重试机制检查接口可用性
96
+ let retryInterval;
97
+ try {
98
+ await new Promise((retryResolve, retryReject) => {
99
+ let retryCount = 0;
100
+ const maxRetries = 30; // 最大重试次数 (30*100ms=3秒超时)
101
+ retryInterval = setInterval(async () => {
102
+ if (retryCount++ >= maxRetries) {
103
+ clearInterval(retryInterval);
104
+ retryReject(new Error("JS-SDK接口初始化超时"));
105
+ return;
106
+ }
107
+
108
+ // 检查getLocation接口是否可用
109
+ wx.checkJsApi({
110
+ jsApiList: ["getLocation"],
111
+ success: (res) => {
112
+ if (res.checkResult.getLocation === true) {
113
+ clearInterval(retryInterval);
114
+ retryResolve();
115
+ }
116
+ },
117
+ fail: () => {/* 失败不计入重试,继续轮询 */
118
+ }
119
+ });
120
+ }, 100); // 每100ms检查一次
121
+ });
122
+ } catch (error) {
123
+ reject(new Error(`接口初始化失败: ${error.message}`));
124
+ return;
125
+ }
126
+
94
127
  // 检查 options.type,如果为空或者不含有 'wgs84' 或 'bd09',则设置为 'gcj02'
95
128
  let locationType = options.type;
96
129
  if (!options.type || (options.type !== 'wgs84' && options.type !== 'bd09')) {
@@ -66,7 +66,40 @@ class WechatAdapter {
66
66
 
67
67
  async getLocation(options) {
68
68
  return new Promise((resolve, reject) => {
69
- wx.ready(() => {
69
+ wx.ready(async () => {
70
+ // 解决在 URL 变化时,由于 wx.config 和 wx.ready 的异步特性导致的微信接口调用使用旧配置、签名失效或调用失败的问题
71
+ // 新增重试机制检查接口可用性
72
+ let retryInterval;
73
+ try {
74
+ await new Promise((retryResolve, retryReject) => {
75
+ let retryCount = 0;
76
+ const maxRetries = 30; // 最大重试次数 (30*100ms=3秒超时)
77
+ retryInterval = setInterval(async () => {
78
+ if (retryCount++ >= maxRetries) {
79
+ clearInterval(retryInterval);
80
+ retryReject(new Error("JS-SDK接口初始化超时"));
81
+ return;
82
+ }
83
+
84
+ // 检查getLocation接口是否可用
85
+ wx.checkJsApi({
86
+ jsApiList: ["getLocation"],
87
+ success: (res) => {
88
+ if (res.checkResult.getLocation === true) {
89
+ clearInterval(retryInterval);
90
+ retryResolve();
91
+ }
92
+ },
93
+ fail: () => {/* 失败不计入重试,继续轮询 */
94
+ }
95
+ });
96
+ }, 100); // 每100ms检查一次
97
+ });
98
+ } catch (error) {
99
+ reject(new Error(`接口初始化失败: ${error.message}`));
100
+ return;
101
+ }
102
+
70
103
  // 检查 options.type,如果为空或者不含有 'wgs84' 或 'bd09',则设置为 'gcj02'
71
104
  let locationType = options.type;
72
105
  if (!options.type || (options.type !== 'wgs84' && options.type !== 'bd09')) {
@@ -108,18 +141,19 @@ class WechatAdapter {
108
141
  };
109
142
 
110
143
  // 先判断是否需要地理位置 如不需要 直接返回坐标
111
- if(options.needAddress) {
112
- fetchLocation('gcj02'.then(unifiedLocation => {
113
- const result = getAddressByType(unifiedLocation, locationType)
114
- if(!result) {
115
- return reject(new Error('Invalid location data'));
116
- }
117
- resolve(unifiedLocation);
118
- }))
119
- .catch(err => { reject(err) })
120
- }
121
- else {
122
- resolve(fetchLocation(locationType))
144
+ if (options.needAddress) {
145
+ fetchLocation('gcj02'.then(unifiedLocation => {
146
+ const result = getAddressByType(unifiedLocation, locationType)
147
+ if (!result) {
148
+ return reject(new Error('Invalid location data'));
149
+ }
150
+ resolve(unifiedLocation);
151
+ }))
152
+ .catch(err => {
153
+ reject(err)
154
+ })
155
+ } else {
156
+ resolve(fetchLocation(locationType))
123
157
  }
124
158
 
125
159
  // // 先取gcj02 再根据type转成不同坐标系