@spcsn/taro 0.1.0
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 +12 -0
- package/dist/index.js +147 -0
- package/dist/index.js.map +1 -0
- package/index.js +9 -0
- package/package.json +86 -0
- package/types/api/ad/index.d.ts +197 -0
- package/types/api/ai/face.d.ts +133 -0
- package/types/api/ai/inference.d.ts +129 -0
- package/types/api/ai/visionkit.d.ts +874 -0
- package/types/api/alipay/index.d.ts +69 -0
- package/types/api/base/crypto.d.ts +104 -0
- package/types/api/base/debug.d.ts +329 -0
- package/types/api/base/env.d.ts +19 -0
- package/types/api/base/index.d.ts +102 -0
- package/types/api/base/performance.d.ts +258 -0
- package/types/api/base/system.d.ts +742 -0
- package/types/api/base/update.d.ts +130 -0
- package/types/api/base/weapp/app-event.d.ts +265 -0
- package/types/api/base/weapp/life-cycle.d.ts +155 -0
- package/types/api/canvas/index.d.ts +2162 -0
- package/types/api/cloud/index.d.ts +2622 -0
- package/types/api/data-analysis/index.d.ts +122 -0
- package/types/api/device/accelerometer.d.ts +102 -0
- package/types/api/device/accessibility.d.ts +26 -0
- package/types/api/device/battery.d.ts +46 -0
- package/types/api/device/bluetooth-ble.d.ts +601 -0
- package/types/api/device/bluetooth-peripheral.d.ts +430 -0
- package/types/api/device/bluetooth.d.ts +463 -0
- package/types/api/device/calendar.d.ts +98 -0
- package/types/api/device/clipboard.d.ts +81 -0
- package/types/api/device/compass.d.ts +105 -0
- package/types/api/device/contact.d.ts +110 -0
- package/types/api/device/gyroscope.d.ts +85 -0
- package/types/api/device/iBeacon.d.ts +168 -0
- package/types/api/device/keyboard.d.ts +97 -0
- package/types/api/device/memory.d.ts +52 -0
- package/types/api/device/motion.d.ts +88 -0
- package/types/api/device/network.d.ts +172 -0
- package/types/api/device/nfc.d.ts +1238 -0
- package/types/api/device/phone.d.ts +30 -0
- package/types/api/device/scan.d.ts +111 -0
- package/types/api/device/screen.d.ts +217 -0
- package/types/api/device/sms.d.ts +26 -0
- package/types/api/device/vibrate.d.ts +51 -0
- package/types/api/device/wifi.d.ts +301 -0
- package/types/api/ext/index.d.ts +64 -0
- package/types/api/files/index.d.ts +1472 -0
- package/types/api/framework/index.d.ts +51 -0
- package/types/api/location/index.d.ts +517 -0
- package/types/api/media/audio.d.ts +1013 -0
- package/types/api/media/background-audio.d.ts +291 -0
- package/types/api/media/camera.d.ts +207 -0
- package/types/api/media/editor.d.ts +239 -0
- package/types/api/media/image.d.ts +469 -0
- package/types/api/media/live.d.ts +461 -0
- package/types/api/media/map.d.ts +638 -0
- package/types/api/media/media-recorder.d.ts +117 -0
- package/types/api/media/recorder.d.ts +317 -0
- package/types/api/media/video-decoder.d.ts +117 -0
- package/types/api/media/video-processing.d.ts +84 -0
- package/types/api/media/video.d.ts +527 -0
- package/types/api/media/voip.d.ts +393 -0
- package/types/api/navigate/index.d.ts +327 -0
- package/types/api/network/download.d.ts +173 -0
- package/types/api/network/mdns.d.ts +191 -0
- package/types/api/network/request.d.ts +480 -0
- package/types/api/network/tcp.d.ts +181 -0
- package/types/api/network/udp.d.ts +218 -0
- package/types/api/network/upload.d.ts +201 -0
- package/types/api/network/websocket.d.ts +383 -0
- package/types/api/open-api/account.d.ts +51 -0
- package/types/api/open-api/address.d.ts +68 -0
- package/types/api/open-api/authorize.d.ts +80 -0
- package/types/api/open-api/card.d.ts +110 -0
- package/types/api/open-api/channels.d.ts +225 -0
- package/types/api/open-api/customer-service.d.ts +45 -0
- package/types/api/open-api/device-voip.d.ts +103 -0
- package/types/api/open-api/facial.d.ts +98 -0
- package/types/api/open-api/favorites.d.ts +101 -0
- package/types/api/open-api/group.d.ts +59 -0
- package/types/api/open-api/invoice.d.ts +87 -0
- package/types/api/open-api/license-plate.d.ts +27 -0
- package/types/api/open-api/login.d.ts +115 -0
- package/types/api/open-api/my-miniprogram.d.ts +28 -0
- package/types/api/open-api/privacy.d.ts +107 -0
- package/types/api/open-api/redpackage.d.ts +24 -0
- package/types/api/open-api/settings.d.ts +174 -0
- package/types/api/open-api/soter.d.ts +184 -0
- package/types/api/open-api/sticker.d.ts +83 -0
- package/types/api/open-api/subscribe-message.d.ts +305 -0
- package/types/api/open-api/user-info.d.ts +182 -0
- package/types/api/open-api/werun.d.ts +101 -0
- package/types/api/payment/index.d.ts +119 -0
- package/types/api/qq/index.d.ts +354 -0
- package/types/api/route/index.d.ts +324 -0
- package/types/api/share/index.d.ts +354 -0
- package/types/api/skyline/index.d.ts +345 -0
- package/types/api/storage/background-fetch.d.ts +131 -0
- package/types/api/storage/cache-manager.d.ts +249 -0
- package/types/api/storage/index.d.ts +405 -0
- package/types/api/swan/bookshelf.d.ts +307 -0
- package/types/api/swan/download-package.d.ts +80 -0
- package/types/api/swan/index.d.ts +251 -0
- package/types/api/swan/pay.d.ts +139 -0
- package/types/api/taro.extend.d.ts +233 -0
- package/types/api/taro.hooks.d.ts +148 -0
- package/types/api/ui/animation.d.ts +427 -0
- package/types/api/ui/background.d.ts +69 -0
- package/types/api/ui/custom-component.d.ts +23 -0
- package/types/api/ui/fonts.d.ts +77 -0
- package/types/api/ui/interaction.d.ts +281 -0
- package/types/api/ui/menu.d.ts +29 -0
- package/types/api/ui/navigation-bar.d.ts +130 -0
- package/types/api/ui/pull-down-refresh.d.ts +50 -0
- package/types/api/ui/scroll.d.ts +114 -0
- package/types/api/ui/sticky.d.ts +32 -0
- package/types/api/ui/tab-bar.d.ts +196 -0
- package/types/api/ui/window.d.ts +71 -0
- package/types/api/worker/index.d.ts +83 -0
- package/types/api/wxml/index.d.ts +540 -0
- package/types/compile/compiler.d.ts +32 -0
- package/types/compile/config/h5.d.ts +134 -0
- package/types/compile/config/harmony.d.ts +118 -0
- package/types/compile/config/index.d.ts +8 -0
- package/types/compile/config/manifest.d.ts +155 -0
- package/types/compile/config/mini.d.ts +118 -0
- package/types/compile/config/plugin.d.ts +34 -0
- package/types/compile/config/project.d.ts +338 -0
- package/types/compile/config/rn.d.ts +85 -0
- package/types/compile/config/util.d.ts +179 -0
- package/types/compile/hooks.d.ts +13 -0
- package/types/compile/index.d.ts +11 -0
- package/types/compile/viteCompilerContext.d.ts +167 -0
- package/types/global.d.ts +428 -0
- package/types/index.d.ts +190 -0
- package/types/taro.api.d.ts +130 -0
- package/types/taro.component.d.ts +168 -0
- package/types/taro.config.d.ts +712 -0
- package/types/taro.lifecycle.d.ts +220 -0
- package/types/taro.runtime.d.ts +9 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import Taro from '../../index'
|
|
2
|
+
|
|
3
|
+
declare module '../../index' {
|
|
4
|
+
/** 注册小程序中的一个页面。接受一个 `Object` 类型参数,其指定页面的初始数据、生命周期回调、事件处理函数等。 */
|
|
5
|
+
interface Page {
|
|
6
|
+
/** 当前页面的路径
|
|
7
|
+
* @note 推荐使用 Taro.getCurrentInstance().router?.path 方法
|
|
8
|
+
*/
|
|
9
|
+
route?: string
|
|
10
|
+
__route__?: string
|
|
11
|
+
/** @ignore */
|
|
12
|
+
[k: string]: any
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
namespace getApp {
|
|
16
|
+
interface Option {
|
|
17
|
+
/** 在 `App` 未定义时返回默认实现。当App被调用时,默认实现中定义的属性会被覆盖合并到App中。一般用于独立分包 */
|
|
18
|
+
allowDefault?: boolean
|
|
19
|
+
}
|
|
20
|
+
type Instance<T extends App> = Option & T
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** 注册小程序。接受一个 `Object` 参数,其指定小程序的生命周期回调等。
|
|
24
|
+
* @ignore
|
|
25
|
+
*/
|
|
26
|
+
interface App extends TaroGeneral.IAnyObject {
|
|
27
|
+
/** @ignore */
|
|
28
|
+
[key: string]: any
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface TaroStatic {
|
|
32
|
+
/** 获取当前页面栈。数组中第一个元素为首页,最后一个元素为当前页面。
|
|
33
|
+
* __注意:__
|
|
34
|
+
* - __不要尝试修改页面栈,会导致路由以及页面状态错误。__
|
|
35
|
+
* - 不要在 `App.onLaunch` 的时候调用 `getCurrentPages()`,此时 `page` 还没有生成。
|
|
36
|
+
* @supported weapp, h5, rn, tt, harmony_hybrid
|
|
37
|
+
* @example
|
|
38
|
+
* ```tsx
|
|
39
|
+
* Taro.getCurrentPages().length
|
|
40
|
+
* ```
|
|
41
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/reference/api/getCurrentPages.html
|
|
42
|
+
*/
|
|
43
|
+
getCurrentPages(): Page[]
|
|
44
|
+
|
|
45
|
+
/** 获取到小程序全局唯一的 App 实例。
|
|
46
|
+
* @supported weapp, alipay, h5, rn, jd, qq, swan, tt, quickapp, harmony_hybrid
|
|
47
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/reference/api/getApp.html
|
|
48
|
+
*/
|
|
49
|
+
getApp<T = TaroGeneral.IAnyObject>(opts?: getApp.Option): getApp.Instance<T>
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,517 @@
|
|
|
1
|
+
import Taro from '../../index'
|
|
2
|
+
|
|
3
|
+
declare module '../../index' {
|
|
4
|
+
namespace openLocation {
|
|
5
|
+
interface Option {
|
|
6
|
+
/** 纬度,范围为-90~90,负数表示南纬。使用 gcj02 国测局坐标系 */
|
|
7
|
+
latitude: number
|
|
8
|
+
/** 经度,范围为-180~180,负数表示西经。使用 gcj02 国测局坐标系 */
|
|
9
|
+
longitude: number
|
|
10
|
+
/** 缩放比例
|
|
11
|
+
* @weapp 范围 5~18,默认值18
|
|
12
|
+
* @alipay 范围 3~19,默认值15
|
|
13
|
+
*/
|
|
14
|
+
scale?: number
|
|
15
|
+
/** 位置名 */
|
|
16
|
+
name?: string
|
|
17
|
+
/** 地址的详细说明 */
|
|
18
|
+
address?: string
|
|
19
|
+
/** 定义在拉起的地图 App 面板中需要被屏蔽的地图类 App
|
|
20
|
+
* @supported swan
|
|
21
|
+
*/
|
|
22
|
+
ignoredApps?: Array<any>
|
|
23
|
+
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
24
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
25
|
+
/** 接口调用失败的回调函数 */
|
|
26
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
27
|
+
/** 接口调用成功的回调函数 */
|
|
28
|
+
success?: (res: TaroGeneral.CallbackResult) => void
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
namespace getLocation {
|
|
33
|
+
interface Option {
|
|
34
|
+
/** 传入 true 会返回高度信息,由于获取高度需要较高精确度,会减慢接口返回速度
|
|
35
|
+
* @default false
|
|
36
|
+
*/
|
|
37
|
+
altitude?: boolean
|
|
38
|
+
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
39
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
40
|
+
/** 接口调用失败的回调函数 */
|
|
41
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
42
|
+
/** 高精度定位超时时间(ms),指定时间内返回最高精度,该值3000ms以上高精度定位才有效果 */
|
|
43
|
+
highAccuracyExpireTime?: number
|
|
44
|
+
/** 开启高精度定位
|
|
45
|
+
* @default false
|
|
46
|
+
*/
|
|
47
|
+
isHighAccuracy?: boolean
|
|
48
|
+
/** 接口调用成功的回调函数 */
|
|
49
|
+
success?: (result: SuccessCallbackResult) => void
|
|
50
|
+
/** wgs84 返回 gps 坐标,gcj02 返回可用于 Taro.openLocation 的坐标
|
|
51
|
+
* @default "wgs84"
|
|
52
|
+
*/
|
|
53
|
+
type?: string
|
|
54
|
+
/** 针对 iOS14/Android12 及以上的新特性,其他情况本参数忽略。默认情况宿主是精确定位就返回精确定位信息。
|
|
55
|
+
* 传入 true 会强制使用精确定位信息,iOS14/Android12 及以上如果没有精确定位权限,会弹出精确定位授权弹框
|
|
56
|
+
* @supported swan
|
|
57
|
+
* @default false
|
|
58
|
+
*/
|
|
59
|
+
needFullAccuracy?: boolean
|
|
60
|
+
}
|
|
61
|
+
interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
|
|
62
|
+
/** 位置的精确度 */
|
|
63
|
+
accuracy: number
|
|
64
|
+
/** 高度,单位 m */
|
|
65
|
+
altitude: number
|
|
66
|
+
/** 水平精度,单位 m */
|
|
67
|
+
horizontalAccuracy: number
|
|
68
|
+
/** 纬度,范围为 -90~90,负数表示南纬 */
|
|
69
|
+
latitude: number
|
|
70
|
+
/** 经度,范围为 -180~180,负数表示西经 */
|
|
71
|
+
longitude: number
|
|
72
|
+
/** 速度,单位 m/s */
|
|
73
|
+
speed: number
|
|
74
|
+
/** 垂直精度,单位 m(Android 无法获取,返回 0) */
|
|
75
|
+
verticalAccuracy: number
|
|
76
|
+
/** 城市名称
|
|
77
|
+
* @supported swan
|
|
78
|
+
*/
|
|
79
|
+
street?: string
|
|
80
|
+
/** 国家代码
|
|
81
|
+
* @supported swan
|
|
82
|
+
*/
|
|
83
|
+
cityCode?: string
|
|
84
|
+
/** 城市名称
|
|
85
|
+
* @supported swan, tt
|
|
86
|
+
*/
|
|
87
|
+
city?: string
|
|
88
|
+
/** 国家
|
|
89
|
+
* @supported swan
|
|
90
|
+
*/
|
|
91
|
+
country?: string
|
|
92
|
+
/** 国家代码
|
|
93
|
+
* @supported swan
|
|
94
|
+
*/
|
|
95
|
+
countryCode?: string
|
|
96
|
+
/** 省份
|
|
97
|
+
* @supported swan
|
|
98
|
+
*/
|
|
99
|
+
province?: string
|
|
100
|
+
/** 街道号码
|
|
101
|
+
* @supported swan
|
|
102
|
+
*/
|
|
103
|
+
streetNumber?: string
|
|
104
|
+
/** 区
|
|
105
|
+
* @supported swan
|
|
106
|
+
*/
|
|
107
|
+
district?: string
|
|
108
|
+
/** 是不是精确定位信息
|
|
109
|
+
* @supported swan
|
|
110
|
+
*/
|
|
111
|
+
isFullAccuracy?: boolean
|
|
112
|
+
/** 调用结果 */
|
|
113
|
+
errMsg: string
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
namespace choosePoi {
|
|
118
|
+
interface Option {
|
|
119
|
+
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
120
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
121
|
+
/** 接口调用失败的回调函数 */
|
|
122
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
123
|
+
/** 接口调用成功的回调函数 */
|
|
124
|
+
success?: (result: SuccessCallbackResult) => void
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
|
|
128
|
+
/** 选择城市时,值为 1,选择精确位置时,值为 2 */
|
|
129
|
+
type: number
|
|
130
|
+
/** 城市名称 */
|
|
131
|
+
city: number
|
|
132
|
+
/** 位置名称 */
|
|
133
|
+
name: string
|
|
134
|
+
/** 详细地址 */
|
|
135
|
+
address: string
|
|
136
|
+
/** 纬度,浮点数,范围为-90~90,负数表示南纬。使用 gcj02 国测局坐标系 */
|
|
137
|
+
latitude: number
|
|
138
|
+
/** 经度,浮点数,范围为-180~180,负数表示西经。使用 gcj02 国测局坐标系 */
|
|
139
|
+
longitude: number
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
namespace chooseLocation {
|
|
144
|
+
interface Option {
|
|
145
|
+
/** 目标地纬度 */
|
|
146
|
+
latitude?: number
|
|
147
|
+
/** 目标地经度 */
|
|
148
|
+
longitude?: number
|
|
149
|
+
/** 地图选点组件参数
|
|
150
|
+
* @supported h5
|
|
151
|
+
* @h5 仅支持 H5 使用
|
|
152
|
+
* @see https://lbs.qq.com/webApi/component/componentGuide/componentPicker
|
|
153
|
+
*/
|
|
154
|
+
mapOpts?: Record<string, unknown>
|
|
155
|
+
/** 页面显示标题
|
|
156
|
+
* @supported alipay
|
|
157
|
+
* @alipay 安卓默认值为 位置,iOS、IDE 默认值为 你在哪里?
|
|
158
|
+
* @see https://opendocs.alipay.com/mini/api/location?pathHash=951b46a1
|
|
159
|
+
*/
|
|
160
|
+
title?: string
|
|
161
|
+
/** 接口调用成功的回调函数 */
|
|
162
|
+
success?: (result: SuccessCallbackResult) => void
|
|
163
|
+
/** 接口调用失败的回调函数 */
|
|
164
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
165
|
+
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
166
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
|
|
170
|
+
/** 详细地址 */
|
|
171
|
+
address: string
|
|
172
|
+
/** 纬度,浮点数,范围为-90~90,负数表示南纬。使用 gcj02 国测局坐标系 */
|
|
173
|
+
latitude: number
|
|
174
|
+
/** 经度,浮点数,范围为-180~180,负数表示西经。使用 gcj02 国测局坐标系 */
|
|
175
|
+
longitude: number
|
|
176
|
+
/** 位置名称 */
|
|
177
|
+
name: string
|
|
178
|
+
/** 区县代码
|
|
179
|
+
* @supported alipay
|
|
180
|
+
*/
|
|
181
|
+
adCode?: number
|
|
182
|
+
/** 区县名称
|
|
183
|
+
* @supported alipay
|
|
184
|
+
*/
|
|
185
|
+
adName?: string
|
|
186
|
+
/** 城市代码
|
|
187
|
+
* @supported alipay
|
|
188
|
+
*/
|
|
189
|
+
cityCode?: string
|
|
190
|
+
/** 城市名称
|
|
191
|
+
* @supported alipay
|
|
192
|
+
*/
|
|
193
|
+
cityName?: string
|
|
194
|
+
/** 省份代码
|
|
195
|
+
* @supported alipay
|
|
196
|
+
*/
|
|
197
|
+
provinceCode?: number
|
|
198
|
+
/** 省份名称
|
|
199
|
+
* @supported alipay
|
|
200
|
+
*/
|
|
201
|
+
provinceName?: string
|
|
202
|
+
/** 调用结果 */
|
|
203
|
+
errMsg: string
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
namespace stopLocationUpdate {
|
|
208
|
+
interface Option {
|
|
209
|
+
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
210
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
211
|
+
/** 接口调用失败的回调函数 */
|
|
212
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
213
|
+
/** 接口调用成功的回调函数 */
|
|
214
|
+
success?: (res: TaroGeneral.CallbackResult) => void
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
namespace startLocationUpdateBackground {
|
|
219
|
+
interface Option {
|
|
220
|
+
/** wgs84 返回 gps 坐标,gcj02 返回可用于 wx.openLocation 的坐标
|
|
221
|
+
* @default "gcj02"
|
|
222
|
+
*/
|
|
223
|
+
type?: string
|
|
224
|
+
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
225
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
226
|
+
/** 接口调用失败的回调函数 */
|
|
227
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
228
|
+
/** 接口调用成功的回调函数 */
|
|
229
|
+
success?: (res: TaroGeneral.CallbackResult) => void
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
namespace startLocationUpdate {
|
|
234
|
+
interface Option {
|
|
235
|
+
/** wgs84 返回 gps 坐标,gcj02 返回可用于 wx.openLocation 的坐标
|
|
236
|
+
* @default "gcj02"
|
|
237
|
+
*/
|
|
238
|
+
type?: string
|
|
239
|
+
/** 针对 iOS14/Android12 及以上的新特性,其他情况本参数忽略。默认情况宿主是精确定位就返回精确定位信息。
|
|
240
|
+
* 传入 true 会强制使用精确定位信息,iOS14/Android12 及以上如果没有精确定位权限,会弹出精确定位授权弹框
|
|
241
|
+
* @supported swan
|
|
242
|
+
* @default false
|
|
243
|
+
*/
|
|
244
|
+
needFullAccuracy?: boolean
|
|
245
|
+
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
246
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
247
|
+
/** 接口调用失败的回调函数 */
|
|
248
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
249
|
+
/** 接口调用成功的回调函数 */
|
|
250
|
+
success?: (res: TaroGeneral.CallbackResult) => void
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
namespace onLocationChangeError {
|
|
255
|
+
/** 监听持续定位接口返回失败时触发的回调函数 */
|
|
256
|
+
type Callback = (
|
|
257
|
+
result: CallbackResult,
|
|
258
|
+
) => void
|
|
259
|
+
|
|
260
|
+
interface CallbackResult {
|
|
261
|
+
/** 错误码 */
|
|
262
|
+
errCode: number
|
|
263
|
+
/** 错误信息
|
|
264
|
+
* @supported tt
|
|
265
|
+
* @tt 最低支持版本 2.48.0
|
|
266
|
+
*/
|
|
267
|
+
errMsg?: string
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
namespace onLocationChange {
|
|
272
|
+
/** 实时地理位置变化事件的回调函数 */
|
|
273
|
+
type Callback = (
|
|
274
|
+
result: CallbackResult,
|
|
275
|
+
) => void
|
|
276
|
+
|
|
277
|
+
interface CallbackResult {
|
|
278
|
+
/** 位置的精确度 */
|
|
279
|
+
accuracy: number
|
|
280
|
+
/** 高度,单位 m */
|
|
281
|
+
altitude: number
|
|
282
|
+
/** 水平精度,单位 m */
|
|
283
|
+
horizontalAccuracy: number
|
|
284
|
+
/** 纬度,范围为 -90~90,负数表示南纬 */
|
|
285
|
+
latitude: number
|
|
286
|
+
/** 经度,范围为 -180~180,负数表示西经 */
|
|
287
|
+
longitude: number
|
|
288
|
+
/** 速度,单位 m/s */
|
|
289
|
+
speed: number
|
|
290
|
+
/** 垂直精度,单位 m(Android 无法获取,返回 0) */
|
|
291
|
+
verticalAccuracy: number
|
|
292
|
+
/** 街道名称
|
|
293
|
+
* @supported swan
|
|
294
|
+
*/
|
|
295
|
+
street?: string
|
|
296
|
+
/** 城市编码
|
|
297
|
+
* @supported swan
|
|
298
|
+
*/
|
|
299
|
+
cityCode?: string
|
|
300
|
+
/** 城市名称
|
|
301
|
+
* @supported swan, tt
|
|
302
|
+
* @tt iOS 不支持
|
|
303
|
+
*/
|
|
304
|
+
city?: string
|
|
305
|
+
/** 国家
|
|
306
|
+
* @supported swan
|
|
307
|
+
*/
|
|
308
|
+
country?: string
|
|
309
|
+
/** 国家代码
|
|
310
|
+
* @supported swan
|
|
311
|
+
*/
|
|
312
|
+
countryCode?: string
|
|
313
|
+
/** 省份
|
|
314
|
+
* @supported swan
|
|
315
|
+
*/
|
|
316
|
+
province?: string
|
|
317
|
+
/** 街道号码
|
|
318
|
+
* @supported swan
|
|
319
|
+
*/
|
|
320
|
+
streetNumber?: string
|
|
321
|
+
/** 区
|
|
322
|
+
* @supported swan
|
|
323
|
+
*/
|
|
324
|
+
district?: string
|
|
325
|
+
/** 是不是精确定位信息
|
|
326
|
+
* @supported swan
|
|
327
|
+
*/
|
|
328
|
+
isFullAccuracy?: boolean
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
namespace getFuzzyLocation {
|
|
333
|
+
interface Option {
|
|
334
|
+
/** wgs84 返回 gps 坐标,gcj02 返回可用于 Taro.openLocation 的坐标 */
|
|
335
|
+
type?: keyof Type
|
|
336
|
+
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
337
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
338
|
+
/** 接口调用失败的回调函数 */
|
|
339
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
340
|
+
/** 接口调用成功的回调函数 */
|
|
341
|
+
success?: (result: SuccessCallbackResult) => void
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
interface Type {
|
|
345
|
+
/** 返回 gps 坐标 */
|
|
346
|
+
wgs84
|
|
347
|
+
/** 返回 gcj02 坐标*/
|
|
348
|
+
gcj02
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
|
|
352
|
+
/** 纬度,范围为 -90~90,负数表示南纬 */
|
|
353
|
+
latitude: number
|
|
354
|
+
/** 经度,范围为 -180~180,负数表示西经 */
|
|
355
|
+
longitude: number
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
interface TaroStatic {
|
|
360
|
+
/** 关闭监听实时位置变化,前后台都停止消息接收
|
|
361
|
+
* @supported weapp, swan, tt, rn
|
|
362
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.stopLocationUpdate.html
|
|
363
|
+
*/
|
|
364
|
+
stopLocationUpdate(option?: stopLocationUpdate.Option): void
|
|
365
|
+
|
|
366
|
+
/** 开启小程序进入前后台时均接收位置消息,需引导用户开启[授权](../open-api/authorize/authorize.md#后台定位)。授权以后,小程序在运行中或进入后台均可接受位置消息变化。
|
|
367
|
+
*
|
|
368
|
+
* **注意**
|
|
369
|
+
* - 安卓微信7.0.6版本,iOS 7.0.5版本起支持该接口
|
|
370
|
+
* - 需在app.json中配置requiredBackgroundModes: ['location']后使用
|
|
371
|
+
* - 获取位置信息需配置[地理位置用途说明](https://developers.weixin.qq.com/miniprogram/dev/reference/configuration/app.html#permission)。
|
|
372
|
+
* @supported weapp
|
|
373
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.startLocationUpdateBackground.html
|
|
374
|
+
*/
|
|
375
|
+
startLocationUpdateBackground(
|
|
376
|
+
option?: startLocationUpdateBackground.Option,
|
|
377
|
+
): void
|
|
378
|
+
|
|
379
|
+
/** 开启小程序进入前台时接收位置消息
|
|
380
|
+
*
|
|
381
|
+
* **注意**
|
|
382
|
+
* - 获取位置信息需配置[地理位置用途说明](https://developers.weixin.qq.com/miniprogram/dev/reference/configuration/app.html#permission)。
|
|
383
|
+
* @supported weapp, swan, tt, rn
|
|
384
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.startLocationUpdate.html
|
|
385
|
+
*/
|
|
386
|
+
startLocationUpdate(option?: startLocationUpdate.Option): void
|
|
387
|
+
|
|
388
|
+
/** 使用微信内置地图查看位置
|
|
389
|
+
* @supported weapp, alipay, swan, jd, tt, h5, harmony_hybrid
|
|
390
|
+
* @example
|
|
391
|
+
* ```tsx
|
|
392
|
+
* Taro.getLocation({
|
|
393
|
+
* type: 'gcj02', //返回可以用于 Taro.openLocation的经纬度
|
|
394
|
+
* success: function (res) {
|
|
395
|
+
* const latitude = res.latitude
|
|
396
|
+
* const longitude = res.longitude
|
|
397
|
+
* Taro.openLocation({
|
|
398
|
+
* latitude,
|
|
399
|
+
* longitude,
|
|
400
|
+
* scale: 18
|
|
401
|
+
* })
|
|
402
|
+
* }
|
|
403
|
+
* })
|
|
404
|
+
* ```
|
|
405
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.openLocation.html
|
|
406
|
+
*/
|
|
407
|
+
openLocation(option: openLocation.Option): Promise<TaroGeneral.CallbackResult>
|
|
408
|
+
|
|
409
|
+
/** 监听持续定位接口返回失败时触发
|
|
410
|
+
* @supported weapp, tt
|
|
411
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.onLocationChangeError.html
|
|
412
|
+
*/
|
|
413
|
+
onLocationChangeError(
|
|
414
|
+
/** 监听持续定位接口返回失败时触发的回调函数 */
|
|
415
|
+
callback: onLocationChangeError.Callback,
|
|
416
|
+
): void
|
|
417
|
+
|
|
418
|
+
/** 监听实时地理位置变化事件,需结合 Taro.startLocationUpdateBackground、Taro.startLocationUpdate 使用。
|
|
419
|
+
* @supported weapp, swan, tt, rn
|
|
420
|
+
* @example
|
|
421
|
+
* ```tsx
|
|
422
|
+
* const _locationChangeFn = function (res) {
|
|
423
|
+
* console.log('location change', res)
|
|
424
|
+
* }
|
|
425
|
+
* Taro.onLocationChange(_locationChangeFn)
|
|
426
|
+
* Taro.offLocationChange(_locationChangeFn)
|
|
427
|
+
* ```
|
|
428
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.onLocationChange.html
|
|
429
|
+
*/
|
|
430
|
+
onLocationChange(
|
|
431
|
+
/** 实时地理位置变化事件的回调函数 */
|
|
432
|
+
callback: onLocationChange.Callback,
|
|
433
|
+
): void
|
|
434
|
+
|
|
435
|
+
/** 取消监听持续定位接口返回失败时触发
|
|
436
|
+
* @supported weapp, tt
|
|
437
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.offLocationChangeError.html
|
|
438
|
+
*/
|
|
439
|
+
offLocationChangeError(
|
|
440
|
+
/** 监听持续定位接口返回失败时触发的回调函数 */
|
|
441
|
+
callback?: onLocationChangeError.Callback,
|
|
442
|
+
): void
|
|
443
|
+
|
|
444
|
+
/** 取消监听实时地理位置变化事件
|
|
445
|
+
* @supported weapp, swan, tt, rn
|
|
446
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.offLocationChange.html
|
|
447
|
+
*/
|
|
448
|
+
offLocationChange(
|
|
449
|
+
/** 实时地理位置变化事件的回调函数 */
|
|
450
|
+
callback?: onLocationChange.Callback,
|
|
451
|
+
): void
|
|
452
|
+
|
|
453
|
+
/** 获取当前的地理位置、速度。当用户离开小程序后,此接口无法调用。开启高精度定位,接口耗时会增加,可指定 highAccuracyExpireTime 作为超时时间。
|
|
454
|
+
*
|
|
455
|
+
* **注意**
|
|
456
|
+
* - 工具中定位模拟使用IP定位,可能会有一定误差。且工具目前仅支持 gcj02 坐标。
|
|
457
|
+
* - 使用第三方服务进行逆地址解析时,请确认第三方服务默认的坐标系,正确进行坐标转换。
|
|
458
|
+
* @supported weapp, swan, jd, qq, tt, rn, harmony_hybrid, harmony
|
|
459
|
+
* @example
|
|
460
|
+
* ```tsx
|
|
461
|
+
* Taro.getLocation({
|
|
462
|
+
* type: 'wgs84',
|
|
463
|
+
* success: function (res) {
|
|
464
|
+
* const latitude = res.latitude
|
|
465
|
+
* const longitude = res.longitude
|
|
466
|
+
* const speed = res.speed
|
|
467
|
+
* const accuracy = res.accuracy
|
|
468
|
+
* }
|
|
469
|
+
* })
|
|
470
|
+
* ```
|
|
471
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.getLocation.html
|
|
472
|
+
*/
|
|
473
|
+
getLocation(option: getLocation.Option): Promise<getLocation.SuccessCallbackResult>
|
|
474
|
+
|
|
475
|
+
/** 打开POI列表选择位置,支持模糊定位(精确到市)和精确定位混选。
|
|
476
|
+
* @supported weapp
|
|
477
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.choosePoi.html
|
|
478
|
+
*/
|
|
479
|
+
choosePoi(option: choosePoi.Option): Promise<choosePoi.SuccessCallbackResult>
|
|
480
|
+
|
|
481
|
+
/** 打开地图选择位置。
|
|
482
|
+
*
|
|
483
|
+
* `chooseLocation` api功能是依赖于腾讯位置服务,所以需要使用 api 密钥。如果您没有,可以前往腾讯位置服务[开发者控制台](https://lbs.qq.com/console/mykey.html?console=mykey)进行申请。
|
|
484
|
+
* @supported weapp, alipay, swan, jd, tt, h5, harmony_hybrid
|
|
485
|
+
* @example
|
|
486
|
+
* ```tsx
|
|
487
|
+
* // config/index.js
|
|
488
|
+
*
|
|
489
|
+
* // 获得 api 密钥后,您需要将它填入项目的常量配置`defineConstants.LOCATION_APIKEY`中:
|
|
490
|
+
* const config = {
|
|
491
|
+
* defineConstants: {
|
|
492
|
+
* LOCATION_APIKEY: JSON.stringify('XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX')
|
|
493
|
+
* },
|
|
494
|
+
* // ...
|
|
495
|
+
* }
|
|
496
|
+
* ```
|
|
497
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.chooseLocation.html
|
|
498
|
+
*/
|
|
499
|
+
chooseLocation(option: chooseLocation.Option): Promise<chooseLocation.SuccessCallbackResult>
|
|
500
|
+
|
|
501
|
+
/** 获取当前的模糊地理位置
|
|
502
|
+
* @supported weapp, harmony_hybrid
|
|
503
|
+
* @example
|
|
504
|
+
* ```tsx
|
|
505
|
+
* Taro.getFuzzyLocation({
|
|
506
|
+
* type: 'wgs84',
|
|
507
|
+
* success (res) {
|
|
508
|
+
* const latitude = res.latitude
|
|
509
|
+
* const longitude = res.longitude
|
|
510
|
+
* },
|
|
511
|
+
* })
|
|
512
|
+
* ```
|
|
513
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.getFuzzyLocation.html
|
|
514
|
+
*/
|
|
515
|
+
getFuzzyLocation(option: getFuzzyLocation.Option): Promise<getFuzzyLocation.SuccessCallbackResult>
|
|
516
|
+
}
|
|
517
|
+
}
|