interface.uts 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. /**
  2. * 错误码
  3. */
  4. export type OpenLocationErrorCode =
  5. /**
  6. * 框架内部错误
  7. * @uniPlatform {
  8. * "app": {
  9. * "android": {
  10. * "osVer": "5.0",
  11. * "uniVer": "√",
  12. * "unixVer": "4.41"
  13. * },
  14. * "ios": {
  15. * "osVer": "12.0",
  16. * "uniVer": "√",
  17. * "unixVer": "4.41"
  18. * },
  19. * "harmony": {
  20. * "osVer": "3.0",
  21. * "uniVer": "4.23",
  22. * "unixVer": "4.61"
  23. * }
  24. * },
  25. * "web": {
  26. * "uniVer": "√",
  27. * "unixVer": "4.0"
  28. * },
  29. * "mp": {
  30. * "weixin": {
  31. * "uniVer": "x",
  32. * "unixVer": "x"
  33. * }
  34. * }
  35. * }
  36. */
  37. 4;
  38. export interface OpenLocationSuccess {
  39. errMsg: string
  40. }
  41. type OpenLocationSuccessCallback = (result : OpenLocationSuccess) => void
  42. export interface OpenLocationFail extends IUniError {
  43. errCode : OpenLocationErrorCode
  44. }
  45. type OpenLocationFailCallback = (result : OpenLocationFail) => void
  46. export type OpenLocationComplete = any
  47. type OpenLocationCompleteCallback = (result : OpenLocationComplete) => void
  48. /**
  49. * uni.openLocation函数参数定义
  50. */
  51. export type OpenLocationOptions = {
  52. /**
  53. * 纬度,范围为-90~90,负数表示南纬,使用 gcj02 国测局坐标系
  54. * @uniPlatform {
  55. * "app": {
  56. * "android": {
  57. * "osVer": "5.0",
  58. * "uniVer": "√",
  59. * "unixVer": "4.41"
  60. * },
  61. * "ios": {
  62. * "osVer": "12.0",
  63. * "uniVer": "√",
  64. * "unixVer": "4.41"
  65. * },
  66. * "harmony": {
  67. * "osVer": "3.0",
  68. * "uniVer": "4.23",
  69. * "unixVer": "4.61"
  70. * }
  71. * },
  72. * "web": {
  73. * "uniVer": "√",
  74. * "unixVer": "4.0"
  75. * },
  76. * "mp": {
  77. * "weixin": {
  78. * "uniVer": "√",
  79. * "unixVer": "4.41"
  80. * }
  81. * }
  82. * }
  83. */
  84. latitude : number,
  85. /**
  86. * 经度,范围为-180~180,负数表示西经,使用 gcj02 国测局坐标系
  87. * @uniPlatform {
  88. * "app": {
  89. * "android": {
  90. * "osVer": "5.0",
  91. * "uniVer": "√",
  92. * "unixVer": "4.41"
  93. * },
  94. * "ios": {
  95. * "osVer": "12.0",
  96. * "uniVer": "√",
  97. * "unixVer": "4.41"
  98. * },
  99. * "harmony": {
  100. * "osVer": "3.0",
  101. * "uniVer": "4.23",
  102. * "unixVer": "4.61"
  103. * }
  104. * },
  105. * "web": {
  106. * "uniVer": "√",
  107. * "unixVer": "4.0"
  108. * },
  109. * "mp": {
  110. * "weixin": {
  111. * "uniVer": "√",
  112. * "unixVer": "4.41"
  113. * }
  114. * }
  115. * }
  116. */
  117. longitude : number,
  118. /**
  119. * 缩放比例,范围5~18,默认为18(微信小程序)
  120. * @uniPlatform {
  121. * "app": {
  122. * "android": {
  123. * "osVer": "5.0",
  124. * "uniVer": "√",
  125. * "unixVer": "4.41"
  126. * },
  127. * "ios": {
  128. * "osVer": "12.0",
  129. * "uniVer": "√",
  130. * "unixVer": "4.41"
  131. * },
  132. * "harmony": {
  133. * "osVer": "3.0",
  134. * "uniVer": "4.23",
  135. * "unixVer": "4.61"
  136. * }
  137. * },
  138. * "web": {
  139. * "uniVer": "√",
  140. * "unixVer": "4.0"
  141. * },
  142. * "mp": {
  143. * "weixin": {
  144. * "uniVer": "√",
  145. * "unixVer": "4.41"
  146. * }
  147. * }
  148. * }
  149. */
  150. scale ?: number | null,
  151. /**
  152. * 位置名
  153. * @uniPlatform {
  154. * "app": {
  155. * "android": {
  156. * "osVer": "5.0",
  157. * "uniVer": "√",
  158. * "unixVer": "4.41"
  159. * },
  160. * "ios": {
  161. * "osVer": "12.0",
  162. * "uniVer": "√",
  163. * "unixVer": "4.41"
  164. * },
  165. * "harmony": {
  166. * "osVer": "3.0",
  167. * "uniVer": "4.23",
  168. * "unixVer": "4.61"
  169. * }
  170. * },
  171. * "web": {
  172. * "uniVer": "√",
  173. * "unixVer": "4.0"
  174. * },
  175. * "mp": {
  176. * "weixin": {
  177. * "uniVer": "√",
  178. * "unixVer": "4.41"
  179. * }
  180. * }
  181. * }
  182. */
  183. name ?: string | null,
  184. /**
  185. * 地址的详细说明
  186. * @uniPlatform {
  187. * "app": {
  188. * "android": {
  189. * "osVer": "5.0",
  190. * "uniVer": "√",
  191. * "unixVer": "4.41"
  192. * },
  193. * "ios": {
  194. * "osVer": "12.0",
  195. * "uniVer": "√",
  196. * "unixVer": "4.41"
  197. * },
  198. * "harmony": {
  199. * "osVer": "3.0",
  200. * "uniVer": "4.23",
  201. * "unixVer": "4.61"
  202. * }
  203. * },
  204. * "web": {
  205. * "uniVer": "√",
  206. * "unixVer": "4.0"
  207. * },
  208. * "mp": {
  209. * "weixin": {
  210. * "uniVer": "√",
  211. * "unixVer": "4.41"
  212. * }
  213. * }
  214. * }
  215. */
  216. address ?: string | null,
  217. /**
  218. * 接口调用成功的回调函数
  219. * @uniPlatform {
  220. * "app": {
  221. * "android": {
  222. * "osVer": "5.0",
  223. * "uniVer": "√",
  224. * "unixVer": "4.41"
  225. * },
  226. * "ios": {
  227. * "osVer": "12.0",
  228. * "uniVer": "√",
  229. * "unixVer": "4.41"
  230. * },
  231. * "harmony": {
  232. * "osVer": "3.0",
  233. * "uniVer": "4.23",
  234. * "unixVer": "4.61"
  235. * }
  236. * },
  237. * "web": {
  238. * "uniVer": "√",
  239. * "unixVer": "4.0"
  240. * },
  241. * "mp": {
  242. * "weixin": {
  243. * "uniVer": "√",
  244. * "unixVer": "4.41"
  245. * }
  246. * }
  247. * }
  248. */
  249. success ?: OpenLocationSuccessCallback | null,
  250. /**
  251. * 接口调用失败的回调函数
  252. * @uniPlatform {
  253. * "app": {
  254. * "android": {
  255. * "osVer": "5.0",
  256. * "uniVer": "√",
  257. * "unixVer": "4.41"
  258. * },
  259. * "ios": {
  260. * "osVer": "12.0",
  261. * "uniVer": "√",
  262. * "unixVer": "4.41"
  263. * },
  264. * "harmony": {
  265. * "osVer": "3.0",
  266. * "uniVer": "4.23",
  267. * "unixVer": "4.61"
  268. * }
  269. * },
  270. * "web": {
  271. * "uniVer": "√",
  272. * "unixVer": "4.0"
  273. * },
  274. * "mp": {
  275. * "weixin": {
  276. * "uniVer": "√",
  277. * "unixVer": "4.41"
  278. * }
  279. * }
  280. * }
  281. */
  282. fail ?: OpenLocationFailCallback | null,
  283. /**
  284. * 接口调用结束的回调函数(调用成功、失败都会执行)
  285. * @uniPlatform {
  286. * "app": {
  287. * "android": {
  288. * "osVer": "5.0",
  289. * "uniVer": "√",
  290. * "unixVer": "4.41"
  291. * },
  292. * "ios": {
  293. * "osVer": "12.0",
  294. * "uniVer": "√",
  295. * "unixVer": "4.41"
  296. * },
  297. * "harmony": {
  298. * "osVer": "3.0",
  299. * "uniVer": "4.23",
  300. * "unixVer": "4.61"
  301. * }
  302. * },
  303. * "web": {
  304. * "uniVer": "√",
  305. * "unixVer": "4.0"
  306. * },
  307. * "mp": {
  308. * "weixin": {
  309. * "uniVer": "√",
  310. * "unixVer": "4.41"
  311. * }
  312. * }
  313. * }
  314. */
  315. complete ?: OpenLocationCompleteCallback | null
  316. };
  317. /**
  318. * 使用应用内置地图查看位置
  319. *
  320. * @param {OpenLocationOptions} options
  321. * @tutorial https://doc.dcloud.net.cn/uni-app-x/api/prompt.html#openLocation
  322. * @uniPlatform {
  323. * "app": {
  324. * "android": {
  325. * "osVer": "5.0",
  326. * "uniVer": "√",
  327. * "unixVer": "4.41"
  328. * },
  329. * "ios": {
  330. * "osVer": "12.0",
  331. * "uniVer": "√",
  332. * "unixVer": "4.41"
  333. * },
  334. * "harmony": {
  335. * "osVer": "3.0",
  336. * "uniVer": "4.23",
  337. * "unixVer": "4.61"
  338. * }
  339. * },
  340. * "web": {
  341. * "uniVer": "√",
  342. * "unixVer": "4.0"
  343. * },
  344. * "mp": {
  345. * "weixin": {
  346. * "uniVer": "√",
  347. * "unixVer": "4.41"
  348. * }
  349. * }
  350. * }
  351. */
  352. export type OpenLocation = (options : OpenLocationOptions) => void;
  353. export interface Uni {
  354. /**
  355. * @description 使用应用内置地图查看位置
  356. * @example
  357. * ```typescript
  358. uni.openLocation({
  359. latitude: 39.908823,
  360. longitude: 116.39747,
  361. success: (res) => {
  362. console.log('res: ', res)
  363. },
  364. fail: (err) => {
  365. console.log('err: ', err)
  366. },
  367. complete: (res) => {
  368. console.log('complete: ', res)
  369. }
  370. });
  371. * ```
  372. * @tutorial https://doc.dcloud.net.cn/uni-app-x/api/prompt.html#openLocation
  373. * @uniPlatform {
  374. * "app": {
  375. * "android": {
  376. * "osVer": "5.0",
  377. * "uniVer": "√",
  378. * "unixVer": "4.41"
  379. * },
  380. * "ios": {
  381. * "osVer": "12.0",
  382. * "uniVer": "√",
  383. * "unixVer": "4.41"
  384. * },
  385. * "harmony": {
  386. * "osVer": "3.0",
  387. * "uniVer": "4.23",
  388. * "unixVer": "4.61"
  389. * }
  390. * },
  391. * "web": {
  392. * "uniVer": "√",
  393. * "unixVer": "4.0"
  394. * },
  395. * "mp": {
  396. * "weixin": {
  397. * "uniVer": "√",
  398. * "unixVer": "4.41"
  399. * }
  400. * }
  401. * }
  402. */
  403. openLocation(options : OpenLocationOptions) : void;
  404. }
  405. export class OpenLocationSuccessImpl implements OpenLocationSuccess {
  406. errMsg : string
  407. constructor(errMsg : string = 'chooseLocation:ok') {
  408. this.errMsg = errMsg
  409. }
  410. }