index.d.ts 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. /**
  2. * Copyright (c) 2015,Egret-Labs.org
  3. * All rights reserved.
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are met:
  6. *
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the Egret-Labs.org nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY EGRET-LABS.ORG AND CONTRIBUTORS "AS IS" AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL EGRET-LABS.ORG AND CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. *
  27. * Created by wibrst on 2015/1/10.
  28. */
  29. declare class wx {
  30. /**
  31. * 通过config接口注入权限验证配置
  32. * @param bodyConfig
  33. */
  34. static config( bodyConfig:BodyConfig ):void;
  35. /**
  36. * 通过ready接口处理成功验证
  37. * @param cbValidated 成功验证后的处理函数
  38. */
  39. static ready( cbValidated:Function ):void;
  40. /**
  41. * 通过error接口处理失败验证
  42. * @param cbError 处理失败验证后的处理函数
  43. */
  44. static error( cbError:Function ):void;
  45. /**
  46. * 判断当前客户端版本是否支持指定JS接口
  47. * @param bodyCheckJsAPISupport
  48. */
  49. static checkJsApi( bodyCheckJsAPISupport:BodyCheckJsAPISupport ):void;
  50. /**
  51. * 获取“分享到朋友圈”按钮点击状态及自定义分享内容接口
  52. * @param bodyMenuShareTimeline
  53. */
  54. static onMenuShareTimeline( bodyMenuShareTimeline:BodyMenuShareTimeline ):void;
  55. /**
  56. * 获取“分享给朋友”按钮点击状态及自定义分享内容接口
  57. * @param bodyMenuShareAppMessage
  58. */
  59. static onMenuShareAppMessage( bodyMenuShareAppMessage:BodyMenuShareAppMessage ):void;
  60. /**
  61. * 获取“分享到QQ”按钮点击状态及自定义分享内容接口
  62. * @param bodyMenuShareQQ
  63. */
  64. static onMenuShareQQ( bodyMenuShareQQ:BodyMenuShareQQ ):void;
  65. /**
  66. * 获取“分享到腾讯微博”按钮点击状态及自定义分享内容接口
  67. * @param bodyMenuShareWeibo
  68. */
  69. static onMenuShareWeibo( bodyMenuShareWeibo:BodyMenuShareWeibo ):void;
  70. /// 华丽的分界线, 以下接口参数结构较简单或使用较少,均可自行查阅微信官方api文档给出适合的参数
  71. /**
  72. * 拍照或从手机相册中选图接口
  73. * @param bodyChooseImage
  74. */
  75. static chooseImage( body:Object ):void;
  76. /**
  77. * 预览图片接口
  78. * @param body
  79. */
  80. static previewImage( body:Object ):void;
  81. /**
  82. * 上传图片接口
  83. * @param body
  84. */
  85. static uploadImage( body:Object ):void;
  86. /**
  87. * 下载图片接口
  88. * @param body
  89. */
  90. static downloadImage( body:Object ):void;
  91. /**
  92. * 开始录音接口
  93. * @param body
  94. */
  95. static startRecord( body:Object ):void;
  96. /**
  97. * 停止录音接口
  98. * @param body
  99. */
  100. static stopRecord( body:Object ):void;
  101. /**
  102. * 监听录音自动停止接口
  103. * @param body
  104. */
  105. static onVoiceRecordEnd( body:Object ):void;
  106. /**
  107. * 播放语音接口
  108. * @param body
  109. */
  110. static playVoice( body:Object ):void;
  111. /**
  112. * 暂停播放接口
  113. * @param body
  114. */
  115. static pauseVoice( body:Object ):void;
  116. /**
  117. * 停止播放接口
  118. * @param body
  119. */
  120. static stopVoice( body:Object ):void;
  121. /**
  122. * 监听语音播放完毕接口
  123. * @param body
  124. */
  125. static onVoicePlayEnd( body:Object ):void;
  126. /**
  127. * 上传语音接口
  128. * @param body
  129. */
  130. static uploadVoice( body:Object ):void;
  131. /**
  132. * 下载语音接口
  133. * @param body
  134. */
  135. static downloadVoice( body:Object ):void;
  136. // ---- 智能接口
  137. /**
  138. * 识别音频并返回识别结果接口
  139. * @param body
  140. */
  141. static translateVoice( body:Object ):void;
  142. /// ---- 设备信息
  143. /**
  144. * 获取网络状态接口
  145. * @param body
  146. */
  147. static getNetworkType( body:Object ):void;
  148. /// ---- 地理位置
  149. /**
  150. * 使用微信内置地图查看位置接口
  151. * @param body
  152. */
  153. static openLocation( body:Object ):void;
  154. /**
  155. * 获取地理位置接口
  156. * @param body
  157. */
  158. static getLocation( body:Object ):void;
  159. /// ---- 界面操作
  160. /**
  161. * 隐藏右上角菜单接口
  162. * @param body
  163. */
  164. static hideOptionMenu( body:Object ):void;
  165. /**
  166. * 显示右上角菜单接口
  167. * @param body
  168. */
  169. static showOptionMenu( body:Object ):void;
  170. /**
  171. * 关闭当前网页窗口接口
  172. * @param body
  173. */
  174. static closeWindow( body:Object ):void;
  175. /**
  176. * 批量隐藏功能按钮接口
  177. * @param body
  178. */
  179. static hideMenuItems( body:Object ):void;
  180. /**
  181. * 批量显示功能按钮接口
  182. * @param body
  183. */
  184. static showMenuItems( body:Object ):void;
  185. /**
  186. * 隐藏所有非基础按钮接口
  187. * @param body
  188. */
  189. static hideAllNonBaseMenuItem( body:Object ):void;
  190. /**
  191. * 显示所有功能按钮接口
  192. * @param body
  193. */
  194. static showAllNonBaseMenuItem( body:Object ):void;
  195. /// ---- 微信扫一扫
  196. /**
  197. * 调起微信扫一扫接口
  198. * @param body
  199. */
  200. static scanQRCode( body:Object ):void;
  201. /// ---- 微信小店
  202. /**
  203. * 跳转微信商品页接口
  204. * @param body
  205. */
  206. static openProductSpecificView( body:Object ):void;
  207. /// ---- 微信卡券
  208. /**
  209. * 调起适用于门店的卡券列表并获取用户选择列表
  210. * @param body
  211. */
  212. static chooseCard( body:Object ):void;
  213. /**
  214. * 批量添加卡券接口
  215. * @param body
  216. */
  217. static addCard( body:Object ):void;
  218. /**
  219. * 查看微信卡包中的卡券接口
  220. * @param body
  221. */
  222. static openCard( body:Object ):void;
  223. /// ---- 微信支付
  224. /**
  225. * 发起一个微信支付请求
  226. * @param body
  227. */
  228. static chooseWXPay( body:Object ):void;
  229. }
  230. ///////////////////////////////// 常用API的参数结构类
  231. /**
  232. * config 参数结构
  233. * jsApiList: 所有要调用的 API
  234. */
  235. declare class BodyConfig {
  236. debug:boolean;
  237. appId:string;
  238. timestamp:number;
  239. nonceStr:string;
  240. signature:string;
  241. jsApiList:Array<string>;
  242. }
  243. /**
  244. * checkJsApi 参数结构
  245. * jsApiList: 需要检测的JS接口列表
  246. */
  247. declare class BodyCheckJsAPISupport {
  248. success:Function;
  249. jsApiList:Array<string>;
  250. }
  251. /**
  252. * onMenuShareTimeline 参数结构
  253. */
  254. declare class BodyMenuShareTimeline {
  255. title:string;
  256. link:string;
  257. imgUrl:string;
  258. success:Function;
  259. cancel: Function;
  260. }
  261. /**
  262. * onMenuShareAppMessage 参数结构
  263. */
  264. declare class BodyMenuShareAppMessage {
  265. title:string;
  266. desc:string;
  267. link:string;
  268. imgUrl:string;
  269. type:string;
  270. dataUrl:string;
  271. success:Function;
  272. cancel: Function;
  273. }
  274. /**
  275. * onMenuShareQQ 参数结构
  276. */
  277. declare class BodyMenuShareQQ {
  278. title:string;
  279. desc:string;
  280. link:string;
  281. imgUrl:string;
  282. type:string;
  283. dataUrl:string;
  284. success:Function;
  285. cancel: Function;
  286. }
  287. /**
  288. * onMenuShareWeibo 参数结构
  289. */
  290. declare class BodyMenuShareWeibo {
  291. title:string;
  292. desc:string;
  293. link:string;
  294. imgUrl:string;
  295. success:Function;
  296. cancel: Function;
  297. }
  298. export default wx;