@tarojs/taro 3.3.10 → 3.3.14
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/html5.css +5 -5
- package/package.json +5 -5
- package/types/api/ad/index.d.ts +34 -28
- package/types/api/alipay/index.d.ts +11 -7
- package/types/api/base/debug.d.ts +60 -54
- package/types/api/base/env.d.ts +12 -8
- package/types/api/base/index.d.ts +87 -83
- package/types/api/base/system.d.ts +59 -54
- package/types/api/base/update.d.ts +37 -33
- package/types/api/base/weapp/app-event.d.ts +147 -131
- package/types/api/base/weapp/life-cycle.d.ts +14 -10
- package/types/api/canvas/index.d.ts +115 -110
- package/types/api/cloud/index.d.ts +99 -94
- package/types/api/data-analysis/index.d.ts +72 -0
- package/types/api/device/accelerometer.d.ts +57 -50
- package/types/api/device/battery.d.ts +19 -15
- package/types/api/device/ble.d.ts +241 -228
- package/types/api/device/bluetooth.d.ts +207 -194
- package/types/api/device/clipboard.d.ts +48 -43
- package/types/api/device/compass.d.ts +55 -48
- package/types/api/device/contact.d.ts +13 -9
- package/types/api/device/gyroscope.d.ts +41 -35
- package/types/api/device/iBeacon.d.ts +79 -73
- package/types/api/device/motion.d.ts +42 -37
- package/types/api/device/network.d.ts +48 -42
- package/types/api/device/nfc.d.ts +105 -96
- package/types/api/device/performance.d.ts +22 -18
- package/types/api/device/phone.d.ts +20 -15
- package/types/api/device/scan.d.ts +31 -26
- package/types/api/device/screen.d.ts +74 -67
- package/types/api/device/vibrate.d.ts +31 -25
- package/types/api/device/wifi.d.ts +151 -140
- package/types/api/ext/index.d.ts +44 -39
- package/types/api/files/index.d.ts +219 -209
- package/types/api/framework/index.d.ts +25 -20
- package/types/api/location/index.d.ts +140 -136
- package/types/api/media/audio.d.ts +139 -127
- package/types/api/media/background-audio.d.ts +135 -126
- package/types/api/media/camera.d.ts +30 -26
- package/types/api/media/editor.d.ts +35 -33
- package/types/api/media/image.d.ts +190 -137
- package/types/api/media/live.d.ts +88 -82
- package/types/api/media/map.d.ts +47 -43
- package/types/api/media/recorder.d.ts +90 -84
- package/types/api/media/video-processing.d.ts +10 -6
- package/types/api/media/video.d.ts +63 -58
- package/types/api/network/download.d.ts +34 -30
- package/types/api/network/mdns.d.ts +104 -91
- package/types/api/network/request.d.ts +83 -79
- package/types/api/network/udp.d.ts +20 -16
- package/types/api/network/upload.d.ts +60 -56
- package/types/api/network/websocket.d.ts +201 -194
- package/types/api/open-api/account.d.ts +18 -14
- package/types/api/open-api/address.d.ts +27 -23
- package/types/api/open-api/authorize.d.ts +30 -26
- package/types/api/open-api/card.d.ts +55 -51
- package/types/api/open-api/customer-service.d.ts +45 -0
- package/types/api/open-api/facial.d.ts +28 -24
- package/types/api/open-api/invoice.d.ts +38 -34
- package/types/api/open-api/login.d.ts +56 -52
- package/types/api/open-api/navigate.d.ts +79 -75
- package/types/api/open-api/payment.d.ts +34 -30
- package/types/api/open-api/settings.d.ts +54 -45
- package/types/api/open-api/soter.d.ts +92 -86
- package/types/api/open-api/subscribe-message.d.ts +24 -20
- package/types/api/open-api/user-info.d.ts +60 -57
- package/types/api/open-api/werun.d.ts +50 -46
- package/types/api/route/index.d.ts +122 -118
- package/types/api/share/index.d.ts +68 -64
- package/types/api/storage/background-fetch.d.ts +40 -35
- package/types/api/storage/index.d.ts +267 -262
- package/types/api/swan/index.d.ts +47 -42
- package/types/api/ui/animation.d.ts +21 -17
- package/types/api/ui/background.d.ts +38 -34
- package/types/api/ui/custom-component.d.ts +22 -18
- package/types/api/ui/fonts.d.ts +26 -21
- package/types/api/ui/interaction.d.ts +167 -121
- package/types/api/ui/keyboard.d.ts +59 -55
- package/types/api/ui/menu.d.ts +10 -6
- package/types/api/ui/navigation-bar.d.ts +67 -63
- package/types/api/ui/pull-down-refresh.d.ts +33 -29
- package/types/api/ui/scroll.d.ts +30 -26
- package/types/api/ui/sticky.d.ts +22 -19
- package/types/api/ui/tab-bar.d.ts +101 -97
- package/types/api/ui/window.d.ts +24 -18
- package/types/api/worker/index.d.ts +28 -24
- package/types/api/wxml/index.d.ts +42 -38
- package/types/global.d.ts +350 -0
- package/types/index.d.ts +14 -99
- package/types/taro.api.d.ts +94 -0
- package/types/taro.component.d.ts +10 -57
- package/types/taro.config.d.ts +24 -6
- package/types/taro.extend.d.ts +70 -67
- package/types/taro.hooks.d.ts +68 -67
- package/types/taro.lifecycle.d.ts +47 -28
- package/types/api/ad/index.ts +0 -6
- package/types/api/alipay/index.ts +0 -7
- package/types/api/index.d.ts +0 -352
- package/types/api/open-api/data-analysis.d.ts +0 -19
- package/types/api/open-api/report.d.ts +0 -19
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import Taro from '../../index'
|
|
2
|
+
|
|
3
|
+
declare module '../../index' {
|
|
2
4
|
/** 注册小程序中的一个页面。接受一个 `Object` 类型参数,其指定页面的初始数据、生命周期回调、事件处理函数等。 */
|
|
3
5
|
interface Page {
|
|
4
6
|
/**
|
|
@@ -8,24 +10,6 @@ declare namespace Taro {
|
|
|
8
10
|
/** @ignore */
|
|
9
11
|
[k: string]: any
|
|
10
12
|
}
|
|
11
|
-
/** 获取当前页面栈。数组中第一个元素为首页,最后一个元素为当前页面。
|
|
12
|
-
* __注意:__
|
|
13
|
-
* - __不要尝试修改页面栈,会导致路由以及页面状态错误。__
|
|
14
|
-
* - 不要在 `App.onLaunch` 的时候调用 `getCurrentPages()`,此时 `page` 还没有生成。
|
|
15
|
-
* @supported weapp, h5
|
|
16
|
-
* @example
|
|
17
|
-
* ```tsx
|
|
18
|
-
* Taro.getCurrentPages().length
|
|
19
|
-
* ```
|
|
20
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/reference/api/getCurrentPages.html
|
|
21
|
-
*/
|
|
22
|
-
function getCurrentPages(): Page[]
|
|
23
|
-
|
|
24
|
-
/** 获取到小程序全局唯一的 App 实例。
|
|
25
|
-
* @supported weapp, alipay, h5, rn, jd, qq, swan, tt, quickapp
|
|
26
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/reference/api/getApp.html
|
|
27
|
-
*/
|
|
28
|
-
function getApp<T = General.IAnyObject>(opts?: getApp.Option): getApp.Instance<T>
|
|
29
13
|
|
|
30
14
|
namespace getApp {
|
|
31
15
|
interface Option {
|
|
@@ -38,8 +22,29 @@ declare namespace Taro {
|
|
|
38
22
|
/** 注册小程序。接受一个 `Object` 参数,其指定小程序的生命周期回调等。
|
|
39
23
|
* @ignore
|
|
40
24
|
*/
|
|
41
|
-
interface App extends
|
|
25
|
+
interface App extends TaroGeneral.IAnyObject {
|
|
42
26
|
/** @ignore */
|
|
43
27
|
[key: string]: any
|
|
44
28
|
}
|
|
29
|
+
|
|
30
|
+
interface TaroStatic {
|
|
31
|
+
/** 获取当前页面栈。数组中第一个元素为首页,最后一个元素为当前页面。
|
|
32
|
+
* __注意:__
|
|
33
|
+
* - __不要尝试修改页面栈,会导致路由以及页面状态错误。__
|
|
34
|
+
* - 不要在 `App.onLaunch` 的时候调用 `getCurrentPages()`,此时 `page` 还没有生成。
|
|
35
|
+
* @supported weapp, h5
|
|
36
|
+
* @example
|
|
37
|
+
* ```tsx
|
|
38
|
+
* Taro.getCurrentPages().length
|
|
39
|
+
* ```
|
|
40
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/reference/api/getCurrentPages.html
|
|
41
|
+
*/
|
|
42
|
+
getCurrentPages(): Page[]
|
|
43
|
+
|
|
44
|
+
/** 获取到小程序全局唯一的 App 实例。
|
|
45
|
+
* @supported weapp, alipay, h5, rn, jd, qq, swan, tt, quickapp
|
|
46
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/reference/api/getApp.html
|
|
47
|
+
*/
|
|
48
|
+
getApp<T = TaroGeneral.IAnyObject>(opts?: getApp.Option): getApp.Instance<T>
|
|
49
|
+
}
|
|
45
50
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import Taro from '../../index'
|
|
2
|
+
|
|
3
|
+
declare module '../../index' {
|
|
2
4
|
namespace openLocation {
|
|
3
5
|
interface Option {
|
|
4
6
|
/** 纬度,范围为-90~90,负数表示南纬。使用 gcj02 国测局坐标系 */
|
|
@@ -8,47 +10,26 @@ declare namespace Taro {
|
|
|
8
10
|
/** 地址的详细说明 */
|
|
9
11
|
address?: string
|
|
10
12
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
11
|
-
complete?: (res:
|
|
13
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
12
14
|
/** 接口调用失败的回调函数 */
|
|
13
|
-
fail?: (res:
|
|
15
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
14
16
|
/** 位置名 */
|
|
15
17
|
name?: string
|
|
16
18
|
/** 缩放比例,范围5~18 */
|
|
17
19
|
scale?: number
|
|
18
20
|
/** 接口调用成功的回调函数 */
|
|
19
|
-
success?: (res:
|
|
21
|
+
success?: (res: TaroGeneral.CallbackResult) => void
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
24
|
|
|
23
|
-
/** 使用微信内置地图查看位置
|
|
24
|
-
* @supported weapp, h5
|
|
25
|
-
* @example
|
|
26
|
-
* ```tsx
|
|
27
|
-
* Taro.getLocation({
|
|
28
|
-
* type: 'gcj02', //返回可以用于 Taro.openLocation的经纬度
|
|
29
|
-
* success: function (res) {
|
|
30
|
-
* const latitude = res.latitude
|
|
31
|
-
* const longitude = res.longitude
|
|
32
|
-
* Taro.openLocation({
|
|
33
|
-
* latitude,
|
|
34
|
-
* longitude,
|
|
35
|
-
* scale: 18
|
|
36
|
-
* })
|
|
37
|
-
* }
|
|
38
|
-
* })
|
|
39
|
-
* ```
|
|
40
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.openLocation.html
|
|
41
|
-
*/
|
|
42
|
-
function openLocation(option: openLocation.Option): Promise<General.CallbackResult>
|
|
43
|
-
|
|
44
25
|
namespace getLocation {
|
|
45
26
|
interface Option {
|
|
46
27
|
/** 传入 true 会返回高度信息,由于获取高度需要较高精确度,会减慢接口返回速度 */
|
|
47
28
|
altitude?: string
|
|
48
29
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
49
|
-
complete?: (res:
|
|
30
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
50
31
|
/** 接口调用失败的回调函数 */
|
|
51
|
-
fail?: (res:
|
|
32
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
52
33
|
/** 高精度定位超时时间(ms),指定时间内返回最高精度,该值3000ms以上高精度定位才有效果 */
|
|
53
34
|
highAccuracyExpireTime?: number
|
|
54
35
|
/** 开启高精度定位 */
|
|
@@ -58,7 +39,7 @@ declare namespace Taro {
|
|
|
58
39
|
/** wgs84 返回 gps 坐标,gcj02 返回可用于 Taro.openLocation 的坐标 */
|
|
59
40
|
type?: string
|
|
60
41
|
}
|
|
61
|
-
interface SuccessCallbackResult extends
|
|
42
|
+
interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
|
|
62
43
|
/** 位置的精确度 */
|
|
63
44
|
accuracy: number
|
|
64
45
|
/** 高度,单位 m */
|
|
@@ -78,34 +59,12 @@ declare namespace Taro {
|
|
|
78
59
|
}
|
|
79
60
|
}
|
|
80
61
|
|
|
81
|
-
/** 获取当前的地理位置、速度。当用户离开小程序后,此接口无法调用。开启高精度定位,接口耗时会增加,可指定 highAccuracyExpireTime 作为超时时间。
|
|
82
|
-
*
|
|
83
|
-
* **注意**
|
|
84
|
-
* - 工具中定位模拟使用IP定位,可能会有一定误差。且工具目前仅支持 gcj02 坐标。
|
|
85
|
-
* - 使用第三方服务进行逆地址解析时,请确认第三方服务默认的坐标系,正确进行坐标转换。
|
|
86
|
-
* @supported weapp
|
|
87
|
-
* @example
|
|
88
|
-
* ```tsx
|
|
89
|
-
* Taro.getLocation({
|
|
90
|
-
* type: 'wgs84',
|
|
91
|
-
* success: function (res) {
|
|
92
|
-
* const latitude = res.latitude
|
|
93
|
-
* const longitude = res.longitude
|
|
94
|
-
* const speed = res.speed
|
|
95
|
-
* const accuracy = res.accuracy
|
|
96
|
-
* }
|
|
97
|
-
* })
|
|
98
|
-
* ```
|
|
99
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.getLocation.html
|
|
100
|
-
*/
|
|
101
|
-
function getLocation(option: getLocation.Option): Promise<getLocation.SuccessCallbackResult>
|
|
102
|
-
|
|
103
62
|
namespace chooseLocation {
|
|
104
63
|
interface Option {
|
|
105
64
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
106
|
-
complete?: (res:
|
|
65
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
107
66
|
/** 接口调用失败的回调函数 */
|
|
108
|
-
fail?: (res:
|
|
67
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
109
68
|
/** 目标地纬度 */
|
|
110
69
|
latitude?: number
|
|
111
70
|
/** 目标地经度 */
|
|
@@ -113,8 +72,8 @@ declare namespace Taro {
|
|
|
113
72
|
/** 接口调用成功的回调函数 */
|
|
114
73
|
success?: (result: SuccessCallbackResult) => void
|
|
115
74
|
}
|
|
116
|
-
|
|
117
|
-
interface SuccessCallbackResult extends
|
|
75
|
+
|
|
76
|
+
interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
|
|
118
77
|
/** 详细地址 */
|
|
119
78
|
address: string
|
|
120
79
|
/** 纬度,浮点数,范围为-90~90,负数表示南纬。使用 gcj02 国测局坐标系 */
|
|
@@ -128,88 +87,39 @@ declare namespace Taro {
|
|
|
128
87
|
}
|
|
129
88
|
}
|
|
130
89
|
|
|
131
|
-
/** 打开地图选择位置。
|
|
132
|
-
*
|
|
133
|
-
* `chooseLocation` api功能是依赖于腾讯位置服务,所以需要使用 api 密钥。如果您没有,可以前往腾讯位置服务[开发者控制台](https://lbs.qq.com/console/mykey.html?console=mykey)进行申请。
|
|
134
|
-
* @supported weapp, h5
|
|
135
|
-
* @example
|
|
136
|
-
*
|
|
137
|
-
* ```tsx
|
|
138
|
-
* // config/index.js
|
|
139
|
-
*
|
|
140
|
-
* // 获得 api 密钥后,您需要将它填入项目的常量配置`defineConstants.LOCATION_APIKEY`中:
|
|
141
|
-
* const config = {
|
|
142
|
-
* defineConstants: {
|
|
143
|
-
* LOCATION_APIKEY: JSON.stringify('XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX')
|
|
144
|
-
* },
|
|
145
|
-
* // ...
|
|
146
|
-
* }
|
|
147
|
-
* ```
|
|
148
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.chooseLocation.html
|
|
149
|
-
*/
|
|
150
|
-
function chooseLocation(option: chooseLocation.Option): Promise<chooseLocation.SuccessCallbackResult>
|
|
151
|
-
|
|
152
90
|
namespace stopLocationUpdate {
|
|
153
91
|
interface Option {
|
|
154
92
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
155
|
-
complete?: (res:
|
|
93
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
156
94
|
/** 接口调用失败的回调函数 */
|
|
157
|
-
fail?: (res:
|
|
95
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
158
96
|
/** 接口调用成功的回调函数 */
|
|
159
|
-
success?: (res:
|
|
97
|
+
success?: (res: TaroGeneral.CallbackResult) => void
|
|
160
98
|
}
|
|
161
99
|
}
|
|
162
100
|
|
|
163
|
-
/** 关闭监听实时位置变化,前后台都停止消息接收
|
|
164
|
-
* @supported weapp
|
|
165
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.stopLocationUpdate.html
|
|
166
|
-
*/
|
|
167
|
-
function stopLocationUpdate(option?: stopLocationUpdate.Option): void
|
|
168
|
-
|
|
169
101
|
namespace startLocationUpdateBackground {
|
|
170
102
|
interface Option {
|
|
171
103
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
172
|
-
complete?: (res:
|
|
104
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
173
105
|
/** 接口调用失败的回调函数 */
|
|
174
|
-
fail?: (res:
|
|
106
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
175
107
|
/** 接口调用成功的回调函数 */
|
|
176
|
-
success?: (res:
|
|
108
|
+
success?: (res: TaroGeneral.CallbackResult) => void
|
|
177
109
|
}
|
|
178
110
|
}
|
|
179
111
|
|
|
180
|
-
/** 开启小程序进入前后台时均接收位置消息,需引导用户开启[授权]((open-ability/authorize#后台定位))。授权以后,小程序在运行中或进入后台均可接受位置消息变化。
|
|
181
|
-
*
|
|
182
|
-
* **注意**
|
|
183
|
-
* - 安卓微信7.0.6版本,iOS 7.0.5版本起支持该接口
|
|
184
|
-
* - 需在app.json中配置requiredBackgroundModes: ['location']后使用
|
|
185
|
-
* - 获取位置信息需配置[地理位置用途说明](https://developers.weixin.qq.com/miniprogram/dev/reference/configuration/app.html#permission)。
|
|
186
|
-
* @supported weapp
|
|
187
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.startLocationUpdateBackground.html
|
|
188
|
-
*/
|
|
189
|
-
function startLocationUpdateBackground(
|
|
190
|
-
option?: startLocationUpdateBackground.Option,
|
|
191
|
-
): void
|
|
192
|
-
|
|
193
112
|
namespace startLocationUpdate {
|
|
194
113
|
interface Option {
|
|
195
114
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
196
|
-
complete?: (res:
|
|
115
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
197
116
|
/** 接口调用失败的回调函数 */
|
|
198
|
-
fail?: (res:
|
|
117
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
199
118
|
/** 接口调用成功的回调函数 */
|
|
200
|
-
success?: (res:
|
|
119
|
+
success?: (res: TaroGeneral.CallbackResult) => void
|
|
201
120
|
}
|
|
202
121
|
}
|
|
203
122
|
|
|
204
|
-
/** 开启小程序进入前台时接收位置消息
|
|
205
|
-
*
|
|
206
|
-
* **注意**
|
|
207
|
-
* - 获取位置信息需配置[地理位置用途说明](https://developers.weixin.qq.com/miniprogram/dev/reference/configuration/app.html#permission)。
|
|
208
|
-
* @supported weapp
|
|
209
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.startLocationUpdate.html
|
|
210
|
-
*/
|
|
211
|
-
function startLocationUpdate(option?: startLocationUpdate.Option): void
|
|
212
|
-
|
|
213
123
|
namespace onLocationChange {
|
|
214
124
|
/** 实时地理位置变化事件的回调函数 */
|
|
215
125
|
type Callback = (
|
|
@@ -234,29 +144,123 @@ declare namespace Taro {
|
|
|
234
144
|
}
|
|
235
145
|
}
|
|
236
146
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
147
|
+
interface TaroStatic {
|
|
148
|
+
/** 使用微信内置地图查看位置
|
|
149
|
+
* @supported weapp, h5
|
|
150
|
+
* @example
|
|
151
|
+
* ```tsx
|
|
152
|
+
* Taro.getLocation({
|
|
153
|
+
* type: 'gcj02', //返回可以用于 Taro.openLocation的经纬度
|
|
154
|
+
* success: function (res) {
|
|
155
|
+
* const latitude = res.latitude
|
|
156
|
+
* const longitude = res.longitude
|
|
157
|
+
* Taro.openLocation({
|
|
158
|
+
* latitude,
|
|
159
|
+
* longitude,
|
|
160
|
+
* scale: 18
|
|
161
|
+
* })
|
|
162
|
+
* }
|
|
163
|
+
* })
|
|
164
|
+
* ```
|
|
165
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.openLocation.html
|
|
166
|
+
*/
|
|
167
|
+
openLocation(option: openLocation.Option): Promise<TaroGeneral.CallbackResult>
|
|
253
168
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
169
|
+
/** 获取当前的地理位置、速度。当用户离开小程序后,此接口无法调用。开启高精度定位,接口耗时会增加,可指定 highAccuracyExpireTime 作为超时时间。
|
|
170
|
+
*
|
|
171
|
+
* **注意**
|
|
172
|
+
* - 工具中定位模拟使用IP定位,可能会有一定误差。且工具目前仅支持 gcj02 坐标。
|
|
173
|
+
* - 使用第三方服务进行逆地址解析时,请确认第三方服务默认的坐标系,正确进行坐标转换。
|
|
174
|
+
* @supported weapp
|
|
175
|
+
* @example
|
|
176
|
+
* ```tsx
|
|
177
|
+
* Taro.getLocation({
|
|
178
|
+
* type: 'wgs84',
|
|
179
|
+
* success: function (res) {
|
|
180
|
+
* const latitude = res.latitude
|
|
181
|
+
* const longitude = res.longitude
|
|
182
|
+
* const speed = res.speed
|
|
183
|
+
* const accuracy = res.accuracy
|
|
184
|
+
* }
|
|
185
|
+
* })
|
|
186
|
+
* ```
|
|
187
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.getLocation.html
|
|
188
|
+
*/
|
|
189
|
+
getLocation(option: getLocation.Option): Promise<getLocation.SuccessCallbackResult>
|
|
190
|
+
|
|
191
|
+
/** 打开地图选择位置。
|
|
192
|
+
*
|
|
193
|
+
* `chooseLocation` api功能是依赖于腾讯位置服务,所以需要使用 api 密钥。如果您没有,可以前往腾讯位置服务[开发者控制台](https://lbs.qq.com/console/mykey.html?console=mykey)进行申请。
|
|
194
|
+
* @supported weapp, h5
|
|
195
|
+
* @example
|
|
196
|
+
*
|
|
197
|
+
* ```tsx
|
|
198
|
+
* // config/index.js
|
|
199
|
+
*
|
|
200
|
+
* // 获得 api 密钥后,您需要将它填入项目的常量配置`defineConstants.LOCATION_APIKEY`中:
|
|
201
|
+
* const config = {
|
|
202
|
+
* defineConstants: {
|
|
203
|
+
* LOCATION_APIKEY: JSON.stringify('XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX')
|
|
204
|
+
* },
|
|
205
|
+
* // ...
|
|
206
|
+
* }
|
|
207
|
+
* ```
|
|
208
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.chooseLocation.html
|
|
209
|
+
*/
|
|
210
|
+
chooseLocation(option: chooseLocation.Option): Promise<chooseLocation.SuccessCallbackResult>
|
|
211
|
+
|
|
212
|
+
/** 关闭监听实时位置变化,前后台都停止消息接收
|
|
213
|
+
* @supported weapp
|
|
214
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.stopLocationUpdate.html
|
|
215
|
+
*/
|
|
216
|
+
stopLocationUpdate(option?: stopLocationUpdate.Option): void
|
|
217
|
+
|
|
218
|
+
/** 开启小程序进入前后台时均接收位置消息,需引导用户开启[授权]((open-ability/authorize#后台定位))。授权以后,小程序在运行中或进入后台均可接受位置消息变化。
|
|
219
|
+
*
|
|
220
|
+
* **注意**
|
|
221
|
+
* - 安卓微信7.0.6版本,iOS 7.0.5版本起支持该接口
|
|
222
|
+
* - 需在app.json中配置requiredBackgroundModes: ['location']后使用
|
|
223
|
+
* - 获取位置信息需配置[地理位置用途说明](https://developers.weixin.qq.com/miniprogram/dev/reference/configuration/app.html#permission)。
|
|
224
|
+
* @supported weapp
|
|
225
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.startLocationUpdateBackground.html
|
|
226
|
+
*/
|
|
227
|
+
startLocationUpdateBackground(
|
|
228
|
+
option?: startLocationUpdateBackground.Option,
|
|
229
|
+
): void
|
|
230
|
+
|
|
231
|
+
/** 开启小程序进入前台时接收位置消息
|
|
232
|
+
*
|
|
233
|
+
* **注意**
|
|
234
|
+
* - 获取位置信息需配置[地理位置用途说明](https://developers.weixin.qq.com/miniprogram/dev/reference/configuration/app.html#permission)。
|
|
235
|
+
* @supported weapp
|
|
236
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.startLocationUpdate.html
|
|
237
|
+
*/
|
|
238
|
+
startLocationUpdate(option?: startLocationUpdate.Option): void
|
|
239
|
+
|
|
240
|
+
/** 监听实时地理位置变化事件,需结合 Taro.startLocationUpdateBackground、Taro.startLocationUpdate 使用。
|
|
241
|
+
* @supported weapp
|
|
242
|
+
* @example
|
|
243
|
+
* ```tsx
|
|
244
|
+
* const _locationChangeFn = function (res) {
|
|
245
|
+
* console.log('location change', res)
|
|
246
|
+
* }
|
|
247
|
+
* Taro.onLocationChange(_locationChangeFn)
|
|
248
|
+
* Taro.offLocationChange(_locationChangeFn)
|
|
249
|
+
* ```
|
|
250
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.onLocationChange.html
|
|
251
|
+
*/
|
|
252
|
+
onLocationChange(
|
|
253
|
+
/** 实时地理位置变化事件的回调函数 */
|
|
254
|
+
callback: onLocationChange.Callback,
|
|
255
|
+
): void
|
|
256
|
+
|
|
257
|
+
/** 取消监听实时地理位置变化事件
|
|
258
|
+
* @supported weapp
|
|
259
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.offLocationChange.html
|
|
260
|
+
*/
|
|
261
|
+
offLocationChange(
|
|
262
|
+
/** 实时地理位置变化事件的回调函数 */
|
|
263
|
+
callback: (res: TaroGeneral.CallbackResult) => void,
|
|
264
|
+
): void
|
|
265
|
+
}
|
|
262
266
|
}
|