qsh-webview-sdk 2.0.6 → 2.0.7

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 CHANGED
@@ -175,6 +175,12 @@ console.log('是否 APP:', env.isAppPlus);
175
175
  | `getLocationAsync` | 获取位置(Promise 版) | `{ type?: string; altitude?: boolean }` |
176
176
  | `openLocation` | 查看位置(打开地图) | `{ latitude: number; longitude: number; name?: string; address?: string; scale?: number; success?: Function; fail?: Function }` |
177
177
  | `openLocationAsync` | 查看位置(Promise 版) | `{ latitude: number; longitude: number; name?: string; address?: string; scale?: number }` |
178
+ | `startLocationUpdate` | 开启前台持续定位(仅 APP) | `{ type?: string; needFullAccuracy?: boolean; success?: Function; fail?: Function }` |
179
+ | `stopLocationUpdate` | 停止前台持续定位(仅 APP) | `{ success?: Function; fail?: Function }` |
180
+ | `onLocationChange` | 监听实时位置变化(仅 APP) | `callback: Function` |
181
+ | `offLocationChange` | 取消监听位置变化(仅 APP) | `callback?: Function` |
182
+ | `onLocationChangeError` | 监听位置更新错误(仅 APP) | `callback: Function` |
183
+ | `offLocationChangeError` | 取消监听位置更新错误(仅 APP) | `callback?: Function` |
178
184
 
179
185
  #### 实现原理
180
186
 
@@ -356,7 +362,7 @@ references/ # 开发参考(如原版 uni.webview.1.5.6.js)
356
362
  - [x] 获取位置 ✅
357
363
  - [x] 查看位置 ✅
358
364
  - [x] 照片选择 ✅
359
- - [ ] 持续定位
365
+ - [x] 持续定位
360
366
  - [ ] 相机
361
367
  - [ ] 蓝牙
362
368
  - [ ] WiFi
@@ -503,18 +509,35 @@ await qsh.openLocationAsync({
503
509
  参考文档:[UniApp getLocation](https://uniapp.dcloud.net.cn/api/location/location.html)
504
510
 
505
511
  #### 持续定位(仅 APP)
512
+
506
513
  ```javascript
507
- // 开始持续定位
514
+ // 1. 开启前台持续定位服务
508
515
  qsh.startLocationUpdate({
509
- type: 'wgs84',
510
- altitude: false,
511
- success: (res) => {
512
- console.log('位置更新:', res);
513
- }
516
+ type: 'wgs84', // 坐标类型
517
+ needFullAccuracy: true, // 是否需要高精度
518
+ success: () => console.log('定位服务已开启'),
519
+ fail: (err) => console.error('开启失败:', err)
520
+ });
521
+
522
+ // 2. 监听位置变化
523
+ qsh.onLocationChange((res) => {
524
+ console.log('位置:', res.latitude, res.longitude);
525
+ console.log('精度:', res.accuracy, '米');
514
526
  });
515
527
 
516
- // 停止持续定位
517
- qsh.stopLocationUpdate();
528
+ // 3. 监听定位错误(可选)
529
+ qsh.onLocationChangeError((err) => {
530
+ console.error('定位出错:', err);
531
+ });
532
+
533
+ // 4. 停止监听
534
+ qsh.offLocationChange();
535
+ qsh.offLocationChangeError();
536
+
537
+ // 5. 停止定位服务
538
+ qsh.stopLocationUpdate({
539
+ success: () => console.log('定位服务已停止')
540
+ });
518
541
  ```
519
542
 
520
543
  ### 相机功能