wx.d.ts 89 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242
  1. // generate time:2017-08-23 21:12:06
  2. // Type definitions for wx app
  3. // Definitions by: hellopao <https://github.com/hellopao/wx.d.ts>
  4. /************************************************
  5. * *
  6. * 微信小程序 API *
  7. * *
  8. ************************************************/
  9. interface IAnimation {
  10. /**
  11. * 透明度,参数范围 0~1
  12. */
  13. opacity(value: number): IAnimation;
  14. /**
  15. * 颜色值
  16. */
  17. backgroundColor(color: string): IAnimation;
  18. /**
  19. * 长度值,如果传入 Number 则默认使用 px,可传入其他自定义单位的长度值
  20. */
  21. width(length: number): IAnimation;
  22. /**
  23. * 长度值,如果传入 Number 则默认使用 px,可传入其他自定义单位的长度值
  24. */
  25. height(length: number): IAnimation;
  26. /**
  27. * 长度值,如果传入 Number 则默认使用 px,可传入其他自定义单位的长度值
  28. */
  29. top(length: number): IAnimation;
  30. /**
  31. * 长度值,如果传入 Number 则默认使用 px,可传入其他自定义单位的长度值
  32. */
  33. left(length: number): IAnimation;
  34. /**
  35. * 长度值,如果传入 Number 则默认使用 px,可传入其他自定义单位的长度值
  36. */
  37. bottom(length: number): IAnimation;
  38. /**
  39. * 长度值,如果传入 Number 则默认使用 px,可传入其他自定义单位的长度值
  40. */
  41. right(length: number): IAnimation;
  42. /**
  43. * deg的范围-180~180,从原点顺时针旋转一个deg角度
  44. */
  45. rotate(deg: number): IAnimation;
  46. /**
  47. * deg的范围-180~180,在X轴旋转一个deg角度
  48. */
  49. rotateX(deg: number): IAnimation;
  50. /**
  51. * deg的范围-180~180,在Y轴旋转一个deg角度
  52. */
  53. rotateY(deg: number): IAnimation;
  54. /**
  55. * deg的范围-180~180,在Z轴旋转一个deg角度
  56. */
  57. rotateZ(deg: number): IAnimation;
  58. /**
  59. * 同transform-function rotate3d
  60. */
  61. rotate3d(x: number, y: number, z: number, deg: number): IAnimation;
  62. /**
  63. * 一个参数时,表示在X轴、Y轴同时缩放sx倍数;两个参数时表示在X轴缩放sx倍数,在Y轴缩放sy倍数
  64. */
  65. scale(sx: number, sy?: number): IAnimation;
  66. /**
  67. * 在X轴缩放sx倍数
  68. */
  69. scaleX(sx: number): IAnimation;
  70. /**
  71. * 在Y轴缩放sy倍数
  72. */
  73. scaleY(sy: number): IAnimation;
  74. /**
  75. * 在Z轴缩放sy倍数
  76. */
  77. scaleZ(sz: number): IAnimation;
  78. /**
  79. * 在X轴缩放sx倍数,在Y轴缩放sy倍数,在Z轴缩放sz倍数
  80. */
  81. scale3d(sx: number, sy: number, sz: number): IAnimation;
  82. /**
  83. * 一个参数时,表示在X轴偏移tx,单位px;两个参数时,表示在X轴偏移tx,在Y轴偏移ty,单位px。
  84. */
  85. translate(tx: number, ty?: number): IAnimation;
  86. /**
  87. * 在X轴偏移tx,单位px
  88. */
  89. translateX(tx: number): IAnimation;
  90. /**
  91. * 在Y轴偏移tx,单位px
  92. */
  93. translateY(tx: number): IAnimation;
  94. /**
  95. * 在Z轴偏移tx,单位px
  96. */
  97. translateZ(tx: number): IAnimation;
  98. /**
  99. * 在X轴偏移tx,在Y轴偏移ty,在Z轴偏移tz,单位px
  100. */
  101. translate3d(tx: number, ty: number, tz: number): IAnimation;
  102. /**
  103. * 参数范围-180~180;一个参数时,Y轴坐标不变,X轴坐标延顺时针倾斜ax度;两个参数时,分别在X轴倾斜ax度,在Y轴倾斜ay度
  104. */
  105. skew(ax: number, ay?: number): IAnimation;
  106. /**
  107. * 参数范围-180~180;Y轴坐标不变,X轴坐标延顺时针倾斜ax度
  108. */
  109. skewX(ax: number): IAnimation;
  110. /**
  111. * 参数范围-180~180;X轴坐标不变,Y轴坐标延顺时针倾斜ay度
  112. */
  113. skewY(ay: number): IAnimation;
  114. /**
  115. * 同transform-function matrix
  116. */
  117. matrix(a, b, c, d, tx, ty): IAnimation;
  118. /**
  119. * 同transform-function matrix3d
  120. */
  121. matrix3d(): IAnimation;
  122. }
  123. interface ICanvasContext {
  124. /**
  125. * 设置填充色, 如果没有设置 fillStyle,默认颜色为 black。
  126. */
  127. setFillStyle(color: string): void;
  128. /**
  129. * 设置边框颜色, 如果没有设置 fillStyle,默认颜色为 black。
  130. */
  131. setStrokeStyle(color: string): void;
  132. /**
  133. * 设置阴影
  134. */
  135. setShadow(offsetX: number, offsetY: number, blur: number, color: string): void;
  136. /**
  137. * 创建一个线性的渐变颜色。需要使用 addColorStop() 来指定渐变点,至少要两个。
  138. */
  139. createLinearGradient(x0: number, y0: number, x1: number, y1: number): void;
  140. /**
  141. * 创建一个圆形的渐变颜色。 起点在圆心,终点在圆环。 需要使用 addColorStop() 来指定渐变点,至少要两个。
  142. */
  143. createCircularGradient(x: number, y: number, r: number): void;
  144. /**
  145. * 创建一个颜色的渐变点。小于最小 stop 的部分会按最小 stop 的 color 来渲染,大于最大 stop 的部分会按最大 stop 的 color 来渲染。需要使用 addColorStop() 来指定渐变点,至少要两个。
  146. */
  147. addColorStop(stop: number, color: string): void;
  148. /**
  149. * 设置线条端点的样式
  150. */
  151. setLineCap(lineCap: 'butt' | 'round' | 'square'): void;
  152. /**
  153. * 设置两线相交处的样式
  154. */
  155. setLineJoin(lineJoin: 'bevel' | 'round' | 'miter'): void;
  156. /**
  157. * 设置线条宽度
  158. */
  159. setLineWidth(lineWidth: number): void;
  160. /**
  161. * 设置最大倾斜
  162. */
  163. setMiterLimit(miterLimit: number): void;
  164. /**
  165. * 添加一个矩形路径到当前路径。
  166. */
  167. rect(x: number, y: number, width: number, height: number): void;
  168. /**
  169. * 填充一个矩形。用 setFillStyle() 设置矩形的填充色,如果没设置默认是黑色。
  170. */
  171. fillRect(x: number, y: number, width: number, height: number): void;
  172. /**
  173. * 一个矩形(非填充)。用 setFillStroke() 设置矩形线条的颜色,如果没设置默认是黑色。
  174. */
  175. strokeRect(x: number, y: number, width: number, height: number): void;
  176. /**
  177. * 在给定的矩形区域内,清除画布上的像素
  178. */
  179. clearRect(x: number, y: number, width: number, height: number): void;
  180. /**
  181. * 对当前路径进行填充
  182. */
  183. fill(): void;
  184. /**
  185. * 对当前路径进行描边
  186. */
  187. stroke(): void;
  188. /**
  189. * 开始一个路径
  190. */
  191. beginPath(): void;
  192. /**
  193. * 关闭一个路径
  194. */
  195. closePath(): void;
  196. /**
  197. * 把路径移动到画布中的指定点,但不创建线条。
  198. */
  199. moveTo(x: number, y: number): void;
  200. /**
  201. * 添加一个新点,然后在画布中创建从该点到最后指定点的线条。
  202. */
  203. lineTo(x: number, y: number): void;
  204. /**
  205. * 添加一个弧形路径到当前路径,顺时针绘制。
  206. */
  207. arc(x: number, y: number, radius: number, startAngle: number, sweepAngle: number): void;
  208. /**
  209. * 创建二次方贝塞尔曲线
  210. */
  211. quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void;
  212. /**
  213. * 创建三次方贝塞尔曲线
  214. */
  215. bezierCurveTo(cpx1: number, cpy1: number, cpx2: number, cpy2: number, x: number, y: number): void;
  216. /**
  217. * 对横纵坐标进行缩放
  218. */
  219. scale(scaleWidth: number/**横坐标缩放的倍数1 = 100%,0.5 = 50%,2 = 200%,依次类 */, scaleHeight: number/** 纵坐标轴缩放的倍数1 = 100%,0.5 = 50%,2 = 200%,依次类 */): void;
  220. /**
  221. * 对坐标轴进行顺时针旋转
  222. */
  223. rotate(deg: number/**degrees * Math.PI/180;degrees范围为0~360;旋转角度,以弧度计 */): void;
  224. /**
  225. * 对坐标原点进行缩放
  226. */
  227. translate(x: number/**水平坐标平移量 */, y: number/**竖直坐标平移量 */): void;
  228. /**
  229. * 在画布上绘制被填充的文本
  230. */
  231. fillText(text: string, x: number, y: number): void;
  232. /**
  233. * 设置字体大小
  234. */
  235. setFontSize(fontSize: number): void;
  236. /**
  237. * 在画布上绘制图像
  238. */
  239. drawImage(imageResource: string, x: number, y: number, width: number, height: number): void;
  240. /**
  241. * 设置全局画笔透明度。
  242. */
  243. setGlobalAlpha(alpha: number): void;
  244. /**
  245. * 保存当前坐标轴的缩放、旋转、平移信息
  246. */
  247. save(): void;
  248. /**
  249. * 恢复之前保存过的坐标轴的缩放、旋转、平移信息
  250. */
  251. restore(): void;
  252. /**
  253. * 进行绘图
  254. */
  255. draw(): void;
  256. }
  257. interface IAudioContext {
  258. /**
  259. * 播放
  260. */
  261. play: () => void;
  262. /**
  263. * 暂停
  264. */
  265. pause: () => void;
  266. /**
  267. * 跳转到指定位置,单位 s
  268. */
  269. seek: (position: number) => void;
  270. }
  271. interface IVideoContext {
  272. /**
  273. * 播放
  274. */
  275. play: () => void;
  276. /**
  277. * 暂停
  278. */
  279. pause: () => void;
  280. /**
  281. * 跳转到指定位置,单位 s
  282. */
  283. seek: (position: number) => void;
  284. /**
  285. * 发送弹幕,danmu 包含两个属性 text, color。
  286. */
  287. sendDanmu: (danmu: {text: string; color: string;}) => void;
  288. }
  289. interface IMapContext {
  290. /**
  291. * 获取当前地图中心的经纬度,返回的是 gcj02 坐标系,可以用于 wx.openLocation
  292. */
  293. getCenterLocation: (obj: {
  294. /**
  295. * 接口调用成功的回调函数 ,res = { longitude: "经度", latitude: "纬度"}
  296. */
  297. success?: (res: {longitude: string; latitude: string}) => void;
  298. /**
  299. * 接口调用失败的回调函数
  300. */
  301. fail?: () => void;
  302. /**
  303. * 接口调用结束的回调函数(调用成功、失败都会执行)
  304. */
  305. complete?: () => void;
  306. }) => void;
  307. /**
  308. * 将地图中心移动到当前定位点,需要配合map组件的show-location使用
  309. */
  310. moveToLocation: () => void;
  311. }
  312. interface Application {
  313. setData: (obj: any) => void;
  314. }
  315. interface AppConstructor {
  316. new (): Application;
  317. (opts: {
  318. /**
  319. * 生命周期函数--监听小程序初始化
  320. */
  321. onLaunch?: () => void;
  322. /**
  323. * 生命周期函数--监听小程序显示
  324. */
  325. onShow?: () => void;
  326. /**
  327. * 生命周期函数--监听小程序隐藏
  328. */
  329. onHide?: () => void;
  330. [key: string]: any;
  331. }): Application;
  332. }
  333. declare var App: AppConstructor;
  334. declare function getApp(): Application;
  335. declare function getCurrentPages(): Page[];
  336. interface Page {
  337. setData: (obj: any) => void;
  338. }
  339. interface PageConstructor {
  340. new (): Page;
  341. (opts: {
  342. /**
  343. * 页面的初始数据
  344. */
  345. data?: any;
  346. /**
  347. * 页面的初始数据
  348. */
  349. onLoad?: () => void;
  350. /**
  351. * 生命周期函数--监听页面初次渲染完成
  352. */
  353. onReady?: () => void;
  354. /**
  355. * 生命周期函数--监听页面显示
  356. */
  357. onShow?: () => void;
  358. /**
  359. * 生命周期函数--监听页面隐藏
  360. */
  361. onHide?: () => void;
  362. /**
  363. * 生命周期函数--监听页面卸载
  364. */
  365. onUnload?: () => void;
  366. /**
  367. * 页面相关事件处理函数--监听用户下拉动作
  368. */
  369. onPullDownRefreash?: () => void;
  370. /**
  371. * 页面上拉触底事件的处理函数
  372. */
  373. onReachBottom?: () => void;
  374. /**
  375. * 用户点击右上角分享
  376. */
  377. onShareAppMessage?: () => {
  378. /**
  379. * 分享标题, 默认值当前小程序名称
  380. */
  381. title: string;
  382. /**
  383. * 分享描述, 默认值当前小程序名称
  384. */
  385. desc: string;
  386. /**
  387. * 分享路径 默认值当前页面 path ,必须是以 / 开头的完整路径
  388. */
  389. path: string;
  390. };
  391. [key: string]: any;
  392. }): Page;
  393. }
  394. declare var Page: PageConstructor;
  395. declare var wx: {
  396. // # 网络 #
  397. request(obj: {
  398. /**
  399. * 开发者服务器接口地址
  400. */
  401. url: string;
  402. /**
  403. * 请求的参数
  404. */
  405. data?: any | string;
  406. /**
  407. * 设置请求的 header , header 中不能设置 Referer
  408. */
  409. header?: any;
  410. /**
  411. * 默认为 GET,有效值:OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
  412. */
  413. method?: string;
  414. /**
  415. * 默认为 json。如果设置了 dataType 为 json,则会尝试对响应的数据做一次 JSON.parse
  416. */
  417. dataType?: string;
  418. /**
  419. * 收到开发者服务成功返回的回调函数,res = {data: '开发者服务器返回的内容'}
  420. */
  421. success?: Function;
  422. /**
  423. * 接口调用失败的回调函数
  424. */
  425. fail?: Function;
  426. /**
  427. * 接口调用结束的回调函数(调用成功、失败都会执行)
  428. */
  429. complete?: Function;
  430. }): void;
  431. /**
  432. * 将本地资源上传到开发者服务器。如页面通过 wx.chooseImage 等接口获取到一个本地资源的临时文件路径后,可通过此接口将本地资源上传到指定服务器。客户端发起一个 HTTPS POST 请求,其中 content-type 为 multipart/form-data 。
  433. */
  434. uploadFile(obj: {
  435. /**
  436. * 开发者服务器 url
  437. */
  438. url: string;
  439. /**
  440. * 要上传文件资源的路径
  441. */
  442. filePath: string;
  443. /**
  444. * 文件对应的 key , 开发者在服务器端通过这个 key 可以获取到文件二进制内容
  445. */
  446. name: string;
  447. /**
  448. * HTTP 请求 Header , header 中不能设置 Referer
  449. */
  450. header?: any;
  451. /**
  452. * HTTP 请求中其他额外的 form data
  453. */
  454. formData?: any;
  455. /**
  456. * 接口调用成功的回调函数
  457. */
  458. success?: Function;
  459. /**
  460. * 接口调用失败的回调函数
  461. */
  462. fail?: Function;
  463. /**
  464. * 接口调用结束的回调函数(调用成功、失败都会执行)
  465. */
  466. complete?: Function;
  467. }): void;
  468. /**
  469. * 下载文件资源到本地。客户端直接发起一个 HTTP GET 请求,返回文件的本地临时路径。
  470. */
  471. downloadFile(obj: {
  472. /**
  473. * 下载资源的 url
  474. */
  475. url: string;
  476. /**
  477. * HTTP 请求 Header
  478. */
  479. header?: any;
  480. /**
  481. * 下载成功后以 tempFilePath 的形式传给页面,res = {tempFilePath: '文件的临时路径'}
  482. */
  483. success?: Function;
  484. /**
  485. * 接口调用失败的回调函数
  486. */
  487. fail?: Function;
  488. /**
  489. * 接口调用结束的回调函数(调用成功、失败都会执行)
  490. */
  491. complete?: Function;
  492. }): void;
  493. /**
  494. * 创建一个 WebSocket 连接;一个微信小程序同时只能有一个 WebSocket 连接,如果当前已存在一个 WebSocket 连接,会自动关闭该连接,并重新创建一个 WebSocket 连接。
  495. */
  496. connectSocket(obj: {
  497. /**
  498. * 开发者服务器接口地址,必须是 wss 协议,且域名必须是后台配置的合法域名
  499. */
  500. url: string;
  501. /**
  502. * 请求的数据
  503. */
  504. data?: any;
  505. /**
  506. * HTTP Header , header 中不能设置 Referer
  507. */
  508. header?: any;
  509. /**
  510. * 默认是GET,有效值: OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
  511. */
  512. method?: string;
  513. /**
  514. * 子协议数组
  515. */
  516. protocols?: string[];
  517. /**
  518. * // generate time:2017-08-23 21:12:06
  519. // Type definitions for wx app
  520. // Definitions by: hellopao <https://github.com/hellopao/wx.d.ts>
  521. /************************************************
  522. * *
  523. * 微信小程序 API *
  524. * *
  525. ************************************************/
  526. interface IAnimation {
  527. /**
  528. * 透明度,参数范围 0~1
  529. */
  530. opacity(value: number): IAnimation;
  531. /**
  532. * 颜色值
  533. */
  534. backgroundColor(color: string): IAnimation;
  535. /**
  536. * 长度值,如果传入 Number 则默认使用 px,可传入其他自定义单位的长度值
  537. */
  538. width(length: number): IAnimation;
  539. /**
  540. * 长度值,如果传入 Number 则默认使用 px,可传入其他自定义单位的长度值
  541. */
  542. height(length: number): IAnimation;
  543. /**
  544. * 长度值,如果传入 Number 则默认使用 px,可传入其他自定义单位的长度值
  545. */
  546. top(length: number): IAnimation;
  547. /**
  548. * 长度值,如果传入 Number 则默认使用 px,可传入其他自定义单位的长度值
  549. */
  550. left(length: number): IAnimation;
  551. /**
  552. * 长度值,如果传入 Number 则默认使用 px,可传入其他自定义单位的长度值
  553. */
  554. bottom(length: number): IAnimation;
  555. /**
  556. * 长度值,如果传入 Number 则默认使用 px,可传入其他自定义单位的长度值
  557. */
  558. right(length: number): IAnimation;
  559. /**
  560. * deg的范围-180~180,从原点顺时针旋转一个deg角度
  561. */
  562. rotate(deg: number): IAnimation;
  563. /**
  564. * deg的范围-180~180,在X轴旋转一个deg角度
  565. */
  566. rotateX(deg: number): IAnimation;
  567. /**
  568. * deg的范围-180~180,在Y轴旋转一个deg角度
  569. */
  570. rotateY(deg: number): IAnimation;
  571. /**
  572. * deg的范围-180~180,在Z轴旋转一个deg角度
  573. */
  574. rotateZ(deg: number): IAnimation;
  575. /**
  576. * 同transform-function rotate3d
  577. */
  578. rotate3d(x: number, y: number, z: number, deg: number): IAnimation;
  579. /**
  580. * 一个参数时,表示在X轴、Y轴同时缩放sx倍数;两个参数时表示在X轴缩放sx倍数,在Y轴缩放sy倍数
  581. */
  582. scale(sx: number, sy?: number): IAnimation;
  583. /**
  584. * 在X轴缩放sx倍数
  585. */
  586. scaleX(sx: number): IAnimation;
  587. /**
  588. * 在Y轴缩放sy倍数
  589. */
  590. scaleY(sy: number): IAnimation;
  591. /**
  592. * 在Z轴缩放sy倍数
  593. */
  594. scaleZ(sz: number): IAnimation;
  595. /**
  596. * 在X轴缩放sx倍数,在Y轴缩放sy倍数,在Z轴缩放sz倍数
  597. */
  598. scale3d(sx: number, sy: number, sz: number): IAnimation;
  599. /**
  600. * 一个参数时,表示在X轴偏移tx,单位px;两个参数时,表示在X轴偏移tx,在Y轴偏移ty,单位px。
  601. */
  602. translate(tx: number, ty?: number): IAnimation;
  603. /**
  604. * 在X轴偏移tx,单位px
  605. */
  606. translateX(tx: number): IAnimation;
  607. /**
  608. * 在Y轴偏移tx,单位px
  609. */
  610. translateY(tx: number): IAnimation;
  611. /**
  612. * 在Z轴偏移tx,单位px
  613. */
  614. translateZ(tx: number): IAnimation;
  615. /**
  616. * 在X轴偏移tx,在Y轴偏移ty,在Z轴偏移tz,单位px
  617. */
  618. translate3d(tx: number, ty: number, tz: number): IAnimation;
  619. /**
  620. * 参数范围-180~180;一个参数时,Y轴坐标不变,X轴坐标延顺时针倾斜ax度;两个参数时,分别在X轴倾斜ax度,在Y轴倾斜ay度
  621. */
  622. skew(ax: number, ay?: number): IAnimation;
  623. /**
  624. * 参数范围-180~180;Y轴坐标不变,X轴坐标延顺时针倾斜ax度
  625. */
  626. skewX(ax: number): IAnimation;
  627. /**
  628. * 参数范围-180~180;X轴坐标不变,Y轴坐标延顺时针倾斜ay度
  629. */
  630. skewY(ay: number): IAnimation;
  631. /**
  632. * 同transform-function matrix
  633. */
  634. matrix(a, b, c, d, tx, ty): IAnimation;
  635. /**
  636. * 同transform-function matrix3d
  637. */
  638. matrix3d(): IAnimation;
  639. }
  640. interface ICanvasContext {
  641. /**
  642. * 设置填充色, 如果没有设置 fillStyle,默认颜色为 black。
  643. */
  644. setFillStyle(color: string): void;
  645. /**
  646. * 设置边框颜色, 如果没有设置 fillStyle,默认颜色为 black。
  647. */
  648. setStrokeStyle(color: string): void;
  649. /**
  650. * 设置阴影
  651. */
  652. setShadow(offsetX: number, offsetY: number, blur: number, color: string): void;
  653. /**
  654. * 创建一个线性的渐变颜色。需要使用 addColorStop() 来指定渐变点,至少要两个。
  655. */
  656. createLinearGradient(x0: number, y0: number, x1: number, y1: number): void;
  657. /**
  658. * 创建一个圆形的渐变颜色。 起点在圆心,终点在圆环。 需要使用 addColorStop() 来指定渐变点,至少要两个。
  659. */
  660. createCircularGradient(x: number, y: number, r: number): void;
  661. /**
  662. * 创建一个颜色的渐变点。小于最小 stop 的部分会按最小 stop 的 color 来渲染,大于最大 stop 的部分会按最大 stop 的 color 来渲染。需要使用 addColorStop() 来指定渐变点,至少要两个。
  663. */
  664. addColorStop(stop: number, color: string): void;
  665. /**
  666. * 设置线条端点的样式
  667. */
  668. setLineCap(lineCap: 'butt' | 'round' | 'square'): void;
  669. /**
  670. * 设置两线相交处的样式
  671. */
  672. setLineJoin(lineJoin: 'bevel' | 'round' | 'miter'): void;
  673. /**
  674. * 设置线条宽度
  675. */
  676. setLineWidth(lineWidth: number): void;
  677. /**
  678. * 设置最大倾斜
  679. */
  680. setMiterLimit(miterLimit: number): void;
  681. /**
  682. * 添加一个矩形路径到当前路径。
  683. */
  684. rect(x: number, y: number, width: number, height: number): void;
  685. /**
  686. * 填充一个矩形。用 setFillStyle() 设置矩形的填充色,如果没设置默认是黑色。
  687. */
  688. fillRect(x: number, y: number, width: number, height: number): void;
  689. /**
  690. * 一个矩形(非填充)。用 setFillStroke() 设置矩形线条的颜色,如果没设置默认是黑色。
  691. */
  692. strokeRect(x: number, y: number, width: number, height: number): void;
  693. /**
  694. * 在给定的矩形区域内,清除画布上的像素
  695. */
  696. clearRect(x: number, y: number, width: number, height: number): void;
  697. /**
  698. * 对当前路径进行填充
  699. */
  700. fill(): void;
  701. /**
  702. * 对当前路径进行描边
  703. */
  704. stroke(): void;
  705. /**
  706. * 开始一个路径
  707. */
  708. beginPath(): void;
  709. /**
  710. * 关闭一个路径
  711. */
  712. closePath(): void;
  713. /**
  714. * 把路径移动到画布中的指定点,但不创建线条。
  715. */
  716. moveTo(x: number, y: number): void;
  717. /**
  718. * 添加一个新点,然后在画布中创建从该点到最后指定点的线条。
  719. */
  720. lineTo(x: number, y: number): void;
  721. /**
  722. * 添加一个弧形路径到当前路径,顺时针绘制。
  723. */
  724. arc(x: number, y: number, radius: number, startAngle: number, sweepAngle: number): void;
  725. /**
  726. * 创建二次方贝塞尔曲线
  727. */
  728. quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void;
  729. /**
  730. * 创建三次方贝塞尔曲线
  731. */
  732. bezierCurveTo(cpx1: number, cpy1: number, cpx2: number, cpy2: number, x: number, y: number): void;
  733. /**
  734. * 对横纵坐标进行缩放
  735. */
  736. scale(scaleWidth: number/**横坐标缩放的倍数1 = 100%,0.5 = 50%,2 = 200%,依次类 */, scaleHeight: number/** 纵坐标轴缩放的倍数1 = 100%,0.5 = 50%,2 = 200%,依次类 */): void;
  737. /**
  738. * 对坐标轴进行顺时针旋转
  739. */
  740. rotate(deg: number/**degrees * Math.PI/180;degrees范围为0~360;旋转角度,以弧度计 */): void;
  741. /**
  742. * 对坐标原点进行缩放
  743. */
  744. translate(x: number/**水平坐标平移量 */, y: number/**竖直坐标平移量 */): void;
  745. /**
  746. * 在画布上绘制被填充的文本
  747. */
  748. fillText(text: string, x: number, y: number): void;
  749. /**
  750. * 设置字体大小
  751. */
  752. setFontSize(fontSize: number): void;
  753. /**
  754. * 在画布上绘制图像
  755. */
  756. drawImage(imageResource: string, x: number, y: number, width: number, height: number): void;
  757. /**
  758. * 设置全局画笔透明度。
  759. */
  760. setGlobalAlpha(alpha: number): void;
  761. /**
  762. * 保存当前坐标轴的缩放、旋转、平移信息
  763. */
  764. save(): void;
  765. /**
  766. * 恢复之前保存过的坐标轴的缩放、旋转、平移信息
  767. */
  768. restore(): void;
  769. /**
  770. * 进行绘图
  771. */
  772. draw(): void;
  773. }
  774. interface IAudioContext {
  775. /**
  776. * 播放
  777. */
  778. play: () => void;
  779. /**
  780. * 暂停
  781. */
  782. pause: () => void;
  783. /**
  784. * 跳转到指定位置,单位 s
  785. */
  786. seek: (position: number) => void;
  787. }
  788. interface IVideoContext {
  789. /**
  790. * 播放
  791. */
  792. play: () => void;
  793. /**
  794. * 暂停
  795. */
  796. pause: () => void;
  797. /**
  798. * 跳转到指定位置,单位 s
  799. */
  800. seek: (position: number) => void;
  801. /**
  802. * 发送弹幕,danmu 包含两个属性 text, color。
  803. */
  804. sendDanmu: (danmu: {text: string; color: string;}) => void;
  805. }
  806. interface IMapContext {
  807. /**
  808. * 获取当前地图中心的经纬度,返回的是 gcj02 坐标系,可以用于 wx.openLocation
  809. */
  810. getCenterLocation: (obj: {
  811. /**
  812. * 接口调用成功的回调函数 ,res = { longitude: "经度", latitude: "纬度"}
  813. */
  814. success?: (res: {longitude: string; latitude: string}) => void;
  815. /**
  816. * 接口调用失败的回调函数
  817. */
  818. fail?: () => void;
  819. /**
  820. * 接口调用结束的回调函数(调用成功、失败都会执行)
  821. */
  822. complete?: () => void;
  823. }) => void;
  824. /**
  825. * 将地图中心移动到当前定位点,需要配合map组件的show-location使用
  826. */
  827. moveToLocation: () => void;
  828. }
  829. interface Application {
  830. setData: (obj: any) => void;
  831. }
  832. interface AppConstructor {
  833. new (): Application;
  834. (opts: {
  835. /**
  836. * 生命周期函数--监听小程序初始化
  837. */
  838. onLaunch?: () => void;
  839. /**
  840. * 生命周期函数--监听小程序显示
  841. */
  842. onShow?: () => void;
  843. /**
  844. * 生命周期函数--监听小程序隐藏
  845. */
  846. onHide?: () => void;
  847. [key: string]: any;
  848. }): Application;
  849. }
  850. declare var App: AppConstructor;
  851. declare function getApp(): Application;
  852. declare function getCurrentPages(): Page[];
  853. interface Page {
  854. setData: (obj: any) => void;
  855. }
  856. interface PageConstructor {
  857. new (): Page;
  858. (opts: {
  859. /**
  860. * 页面的初始数据
  861. */
  862. data?: any;
  863. /**
  864. * 页面的初始数据
  865. */
  866. onLoad?: () => void;
  867. /**
  868. * 生命周期函数--监听页面初次渲染完成
  869. */
  870. onReady?: () => void;
  871. /**
  872. * 生命周期函数--监听页面显示
  873. */
  874. onShow?: () => void;
  875. /**
  876. * 生命周期函数--监听页面隐藏
  877. */
  878. onHide?: () => void;
  879. /**
  880. * 生命周期函数--监听页面卸载
  881. */
  882. onUnload?: () => void;
  883. /**
  884. * 页面相关事件处理函数--监听用户下拉动作
  885. */
  886. onPullDownRefreash?: () => void;
  887. /**
  888. * 页面上拉触底事件的处理函数
  889. */
  890. onReachBottom?: () => void;
  891. /**
  892. * 用户点击右上角分享
  893. */
  894. onShareAppMessage?: () => {
  895. /**
  896. * 分享标题, 默认值当前小程序名称
  897. */
  898. title: string;
  899. /**
  900. * 分享描述, 默认值当前小程序名称
  901. */
  902. desc: string;
  903. /**
  904. * 分享路径 默认值当前页面 path ,必须是以 / 开头的完整路径
  905. */
  906. path: string;
  907. };
  908. [key: string]: any;
  909. }): Page;
  910. }
  911. declare var Page: PageConstructor;
  912. declare var wx: {
  913. // # 网络 #
  914. request(obj: {
  915. /**
  916. * 开发者服务器接口地址
  917. */
  918. url: string;
  919. /**
  920. * 请求的参数
  921. */
  922. data?: any | string;
  923. /**
  924. * 设置请求的 header , header 中不能设置 Referer
  925. */
  926. header?: any;
  927. /**
  928. * 默认为 GET,有效值:OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
  929. */
  930. method?: string;
  931. /**
  932. * 默认为 json。如果设置了 dataType 为 json,则会尝试对响应的数据做一次 JSON.parse
  933. */
  934. dataType?: string;
  935. /**
  936. * 收到开发者服务成功返回的回调函数,res = {data: '开发者服务器返回的内容'}
  937. */
  938. success?: Function;
  939. /**
  940. * 接口调用失败的回调函数
  941. */
  942. fail?: Function;
  943. /**
  944. * 接口调用结束的回调函数(调用成功、失败都会执行)
  945. */
  946. complete?: Function;
  947. }): void;
  948. /**
  949. * 将本地资源上传到开发者服务器。如页面通过 wx.chooseImage 等接口获取到一个本地资源的临时文件路径后,可通过此接口将本地资源上传到指定服务器。客户端发起一个 HTTPS POST 请求,其中 content-type 为 multipart/form-data 。
  950. */
  951. uploadFile(obj: {
  952. /**
  953. * 开发者服务器 url
  954. */
  955. url: string;
  956. /**
  957. * 要上传文件资源的路径
  958. */
  959. filePath: string;
  960. /**
  961. * 文件对应的 key , 开发者在服务器端通过这个 key 可以获取到文件二进制内容
  962. */
  963. name: string;
  964. /**
  965. * HTTP 请求 Header , header 中不能设置 Referer
  966. */
  967. header?: any;
  968. /**
  969. * HTTP 请求中其他额外的 form data
  970. */
  971. formData?: any;
  972. /**
  973. * 接口调用成功的回调函数
  974. */
  975. success?: Function;
  976. /**
  977. * 接口调用失败的回调函数
  978. */
  979. fail?: Function;
  980. /**
  981. * 接口调用结束的回调函数(调用成功、失败都会执行)
  982. */
  983. complete?: Function;
  984. }): void;
  985. /**
  986. * 下载文件资源到本地。客户端直接发起一个 HTTP GET 请求,返回文件的本地临时路径。
  987. */
  988. downloadFile(obj: {
  989. /**
  990. * 下载资源的 url
  991. */
  992. url: string;
  993. /**
  994. * HTTP 请求 Header
  995. */
  996. header?: any;
  997. /**
  998. * 下载成功后以 tempFilePath 的形式传给页面,res = {tempFilePath: '文件的临时路径'}
  999. */
  1000. success?: Function;
  1001. /**
  1002. * 接口调用失败的回调函数
  1003. */
  1004. fail?: Function;
  1005. /**
  1006. * 接口调用结束的回调函数(调用成功、失败都会执行)
  1007. */
  1008. complete?: Function;
  1009. }): void;
  1010. /**
  1011. * 创建一个 WebSocket 连接;一个微信小程序同时只能有一个 WebSocket 连接,如果当前已存在一个 WebSocket 连接,会自动关闭该连接,并重新创建一个 WebSocket 连接。
  1012. */
  1013. connectSocket(obj: {
  1014. /**
  1015. * 开发者服务器接口地址,必须是 wss 协议,且域名必须是后台配置的合法域名
  1016. */
  1017. url: string;
  1018. /**
  1019. * 请求的数据
  1020. */
  1021. data?: any;
  1022. /**
  1023. * HTTP Header , header 中不能设置 Referer
  1024. */
  1025. header?: any;
  1026. /**
  1027. * 默认是GET,有效值: OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
  1028. */
  1029. method?: string;
  1030. /**
  1031. * 子协议数组
  1032. */
  1033. protocols?: string[];
  1034. /**
  1035. * 接口调用成功的回调函数
  1036. */
  1037. success?: Function;
  1038. /**
  1039. * 接口调用失败的回调函数
  1040. */
  1041. fail?: Function;
  1042. /**
  1043. * 接口调用结束的回调函数(调用成功、失败都会执行)
  1044. */
  1045. complete?: Function;
  1046. }): void;
  1047. /**
  1048. * 监听WebSocket连接打开事件。
  1049. */
  1050. onSocketOpen(callback: Function): void;
  1051. /**
  1052. * 监听WebSocket错误。
  1053. */
  1054. onSocketError(callback: Function): void;
  1055. /**
  1056. * 通过 WebSocket 连接发送数据,需要先 wx.connectSocket,并在 wx.onSocketOpen 回调之后才能发送。
  1057. */
  1058. sendSocketMessage(obj: {
  1059. /**
  1060. * 需要发送的内容
  1061. */
  1062. data: undefined;
  1063. /**
  1064. * 接口调用成功的回调函数
  1065. */
  1066. success?: Function;
  1067. /**
  1068. * 接口调用失败的回调函数
  1069. */
  1070. fail?: Function;
  1071. /**
  1072. * 接口调用结束的回调函数(调用成功、失败都会执行)
  1073. */
  1074. complete?: Function;
  1075. }): void;
  1076. /**
  1077. * 监听WebSocket接受到服务器的消息事件。
  1078. */
  1079. onSocketMessage(callback: Function): void;
  1080. /**
  1081. * 关闭WebSocket连接。
  1082. */
  1083. closeSocket(obj: {
  1084. /**
  1085. * 一个数字值表示关闭连接的状态号,表示连接被关闭的原因。如果这个参数没有被指定,默认的取值是1000 (表示正常连接关闭)
  1086. */
  1087. code?: number;
  1088. /**
  1089. * 一个可读的字符串,表示连接被关闭的原因。这个字符串必须是不长于123字节的UTF-8 文本(不是字符)
  1090. */
  1091. reason?: string;
  1092. /**
  1093. * 接口调用成功的回调函数
  1094. */
  1095. success?: Function;
  1096. /**
  1097. * 接口调用失败的回调函数
  1098. */
  1099. fail?: Function;
  1100. /**
  1101. * 接口调用结束的回调函数(调用成功、失败都会执行)
  1102. */
  1103. complete?: Function;
  1104. }): void;
  1105. /**
  1106. * 监听WebSocket关闭。
  1107. */
  1108. onSocketClose(callback: Function): void;
  1109. // # 媒体 #
  1110. /**
  1111. * 从本地相册选择图片或使用相机拍照。
  1112. */
  1113. chooseImage(obj: {
  1114. /**
  1115. * 最多可以选择的图片张数,默认9
  1116. */
  1117. count?: number;
  1118. /**
  1119. * original 原图,compressed 压缩图,默认二者都有
  1120. */
  1121. sizeType?: string[];
  1122. /**
  1123. * album 从相册选图,camera 使用相机,默认二者都有
  1124. */
  1125. sourceType?: string[];
  1126. /**
  1127. * 成功则返回图片的本地文件路径列表 tempFilePaths
  1128. */
  1129. success: Function;
  1130. /**
  1131. * 接口调用失败的回调函数
  1132. */
  1133. fail?: Function;
  1134. /**
  1135. * 接口调用结束的回调函数(调用成功、失败都会执行)
  1136. */
  1137. complete?: Function;
  1138. }): void;
  1139. /**
  1140. * 预览图片。
  1141. */
  1142. previewImage(obj: {
  1143. /**
  1144. * 当前显示图片的链接,不填则默认为 urls 的第一张
  1145. */
  1146. current?: string;
  1147. /**
  1148. * 需要预览的图片链接列表
  1149. */
  1150. urls: string[];
  1151. /**
  1152. * 接口调用成功的回调函数
  1153. */
  1154. success?: Function;
  1155. /**
  1156. * 接口调用失败的回调函数
  1157. */
  1158. fail?: Function;
  1159. /**
  1160. * 接口调用结束的回调函数(调用成功、失败都会执行)
  1161. */
  1162. complete?: Function;
  1163. }): void;
  1164. /**
  1165. * 获取图片信息
  1166. */
  1167. getImageInfo(obj: {
  1168. /**
  1169. * 图片的路径,可以是相对路径,临时文件路径,存储文件路径,网络图片路径
  1170. */
  1171. src: string;
  1172. /**
  1173. * 接口调用成功的回调函数
  1174. */
  1175. success?: Function;
  1176. /**
  1177. * 接口调用失败的回调函数
  1178. */
  1179. fail?: Function;
  1180. /**
  1181. * 接口调用结束的回调函数(调用成功、失败都会执行)
  1182. */
  1183. complete?: Function;
  1184. }): void;
  1185. saveImageToPhotosAlbum(obj: {
  1186. /**
  1187. * 图片文件路径,可以是临时文件路径也可以是永久文件路径,不支持网络图片路径
  1188. */
  1189. filePath: string;
  1190. /**
  1191. * 接口调用成功的回调函数
  1192. */
  1193. success?: Function;
  1194. /**
  1195. * 接口调用失败的回调函数
  1196. */
  1197. fail?: Function;
  1198. /**
  1199. * 接口调用结束的回调函数(调用成功、失败都会执行)
  1200. */
  1201. complete?: Function;
  1202. }): void;
  1203. /**
  1204. * 开始录音。当主动调用wx.stopRecord,或者录音超过1分钟时自动结束录音,返回录音文件的临时文件路径。当用户离开小程序时,此接口无法调用。
  1205. */
  1206. startRecord(obj: {
  1207. /**
  1208. * 录音成功后调用,返回录音文件的临时文件路径,res = {tempFilePath: '录音文件的临时路径'}
  1209. */
  1210. success?: Function;
  1211. /**
  1212. * 接口调用失败的回调函数
  1213. */
  1214. fail?: Function;
  1215. /**
  1216. * 接口调用结束的回调函数(调用成功、失败都会执行)
  1217. */
  1218. complete?: Function;
  1219. }): void;
  1220. /**
  1221. * ​ 主动调用停止录音。
  1222. */
  1223. stopRecord(): void;
  1224. /**
  1225. * 开始播放语音,同时只允许一个语音文件正在播放,如果前一个语音文件还没播放完,将中断前一个语音播放。
  1226. */
  1227. playVoice(obj: {
  1228. /**
  1229. * 需要播放的语音文件的文件路径
  1230. */
  1231. filePath: string;
  1232. /**
  1233. * 接口调用成功的回调函数
  1234. */
  1235. success?: Function;
  1236. /**
  1237. * 接口调用失败的回调函数
  1238. */
  1239. fail?: Function;
  1240. /**
  1241. * 接口调用结束的回调函数(调用成功、失败都会执行)
  1242. */
  1243. complete?: Function;
  1244. }): void;
  1245. /**
  1246. * 暂停正在播放的语音。再次调用wx.playVoice播放同一个文件时,会从暂停处开始播放。如果想从头开始播放,需要先调用 wx.stopVoice。
  1247. */
  1248. pauseVoice(): void;
  1249. /**
  1250. * 结束播放语音。
  1251. */
  1252. stopVoice(): void;
  1253. /**
  1254. * 获取后台音乐播放状态。
  1255. */
  1256. getBackgroundAudioPlayerState(obj: {
  1257. /**
  1258. * 接口调用成功的回调函数
  1259. */
  1260. success?: Function;
  1261. /**
  1262. * 接口调用失败的回调函数
  1263. */
  1264. fail?: Function;
  1265. /**
  1266. * 接口调用结束的回调函数(调用成功、失败都会执行)
  1267. */
  1268. complete?: Function;
  1269. }): void;
  1270. /**
  1271. * 使用后台播放器播放音乐,对于微信客户端来说,只能同时有一个后台音乐在播放。当用户离开小程序后,音乐将暂停播放;当用户点击“显示在聊天顶部”时,音乐不会暂停播放;当用户在其他小程序占用了音乐播放器,原有小程序内的音乐将停止播放。
  1272. */
  1273. playBackgroundAudio(obj: {
  1274. /**
  1275. * 音乐链接,目前支持的格式有 m4a, aac, mp3, wav
  1276. */
  1277. dataUrl: string;
  1278. /**
  1279. * 音乐标题
  1280. */
  1281. title?: string;
  1282. /**
  1283. * 封面URL
  1284. */
  1285. coverImgUrl?: string;
  1286. /**
  1287. * 接口调用成功的回调函数
  1288. */
  1289. success?: Function;
  1290. /**
  1291. * 接口调用失败的回调函数
  1292. */
  1293. fail?: Function;
  1294. /**
  1295. * 接口调用结束的回调函数(调用成功、失败都会执行)
  1296. */
  1297. complete?: Function;
  1298. }): void;
  1299. /**
  1300. * 暂停播放音乐。
  1301. */
  1302. pauseBackgroundAudio(): void;
  1303. /**
  1304. * 控制音乐播放进度。
  1305. */
  1306. seekBackgroundAudio(obj: {
  1307. /**
  1308. * 音乐位置,单位:秒
  1309. */
  1310. position: number;
  1311. /**
  1312. * 接口调用成功的回调函数
  1313. */
  1314. success?: Function;
  1315. /**
  1316. * 接口调用失败的回调函数
  1317. */
  1318. fail?: Function;
  1319. /**
  1320. * 接口调用结束的回调函数(调用成功、失败都会执行)
  1321. */
  1322. complete?: Function;
  1323. }): void;
  1324. /**
  1325. * 停止播放音乐。
  1326. */
  1327. stopBackgroundAudio(): void;
  1328. /**
  1329. * 监听音乐播放。
  1330. */
  1331. onBackgroundAudioPlay(callback: Function): void;
  1332. /**
  1333. * 监听音乐暂停。
  1334. */
  1335. onBackgroundAudioPause(callback: Function): void;
  1336. /**
  1337. * 监听音乐停止。
  1338. */
  1339. onBackgroundAudioStop(callback: Function): void;
  1340. getBackgroundAudioManager(): void;
  1341. /**
  1342. * 创建并返回 audio 上下文 audioContext 对象
  1343. */
  1344. createAudioContext(audioId: string): IAudioContext;
  1345. /**
  1346. * 拍摄视频或从手机相册中选视频,返回视频的临时文件路径。
  1347. */
  1348. chooseVideo(obj: {
  1349. /**
  1350. * album 从相册选视频,camera 使用相机拍摄,默认为:['album', 'camera']
  1351. */
  1352. sourceType?: string[];
  1353. /**
  1354. * 拍摄视频最长拍摄时间,单位秒。最长支持 60 秒
  1355. */
  1356. maxDuration?: number;
  1357. /**
  1358. * 默认调起的为前置还是后置摄像头。front: 前置,back: 后置,默认 back
  1359. */
  1360. camera?: string;
  1361. /**
  1362. * 接口调用成功,返回视频文件的临时文件路径,详见返回参数说明
  1363. */
  1364. success?: Function;
  1365. /**
  1366. * 接口调用失败的回调函数
  1367. */
  1368. fail?: Function;
  1369. /**
  1370. * 接口调用结束的回调函数(调用成功、失败都会执行)
  1371. */
  1372. complete?: Function;
  1373. }): void;
  1374. saveVideoToPhotosAlbum(obj: {
  1375. /**
  1376. * 视频文件路径,可以是临时文件路径也可以是永久文件路径
  1377. */
  1378. filePath: string;
  1379. /**
  1380. * 接口调用成功的回调函数
  1381. */
  1382. success?: Function;
  1383. /**
  1384. * 接口调用失败的回调函数
  1385. */
  1386. fail?: Function;
  1387. /**
  1388. * 接口调用结束的回调函数(调用成功、失败都会执行)
  1389. */
  1390. complete?: Function;
  1391. }): void;
  1392. /**
  1393. * 创建并返回 video 上下文 videoContext 对象
  1394. */
  1395. createVideoContext(videoId: string): IVideoContext;
  1396. // # 文件 #
  1397. /**
  1398. * 保存文件到本地。
  1399. */
  1400. saveFile(obj: {
  1401. /**
  1402. * 需要保存的文件的临时路径
  1403. */
  1404. tempFilePath: string;
  1405. /**
  1406. * 返回文件的保存路径,res = {savedFilePath: '文件的保存路径'}
  1407. */
  1408. success?: Function;
  1409. /**
  1410. * 接口调用失败的回调函数
  1411. */
  1412. fail?: Function;
  1413. /**
  1414. * 接口调用结束的回调函数(调用成功、失败都会执行)
  1415. */
  1416. complete?: Function;
  1417. }): void;
  1418. /**
  1419. * 获取本地已保存的文件列表
  1420. */
  1421. getSavedFileList(obj: {
  1422. /**
  1423. * 接口调用成功的回调函数,返回结果见success返回参数说明
  1424. */
  1425. success?: Function;
  1426. /**
  1427. * 接口调用失败的回调函数
  1428. */
  1429. fail?: Function;
  1430. /**
  1431. * 接口调用结束的回调函数(调用成功、失败都会执行)
  1432. */
  1433. complete?: Function;
  1434. }): void;
  1435. /**
  1436. * 获取本地文件的文件信息。此接口只能用于获取已保存到本地的文件,若需要获取临时文件信息,请使用 wx.getFileInfo 接口。
  1437. */
  1438. getSavedFileInfo(obj: {
  1439. /**
  1440. * 文件路径
  1441. */
  1442. filePath: string;
  1443. /**
  1444. * 接口调用成功的回调函数,返回结果见success返回参数说明
  1445. */
  1446. success?: Function;
  1447. /**
  1448. * 接口调用失败的回调函数
  1449. */
  1450. fail?: Function;
  1451. /**
  1452. * 接口调用结束的回调函数(调用成功、失败都会执行)
  1453. */
  1454. complete?: Function;
  1455. }): void;
  1456. /**
  1457. * 删除本地存储的文件
  1458. */
  1459. removeSavedFile(obj: {
  1460. /**
  1461. * 需要删除的文件路径
  1462. */
  1463. filePath: string;
  1464. /**
  1465. * 接口调用成功的回调函数
  1466. */
  1467. success?: Function;
  1468. /**
  1469. * 接口调用失败的回调函数
  1470. */
  1471. fail?: Function;
  1472. /**
  1473. * 接口调用结束的回调函数(调用成功、失败都会执行)
  1474. */
  1475. complete?: Function;
  1476. }): void;
  1477. /**
  1478. * 新开页面打开文档,支持格式:doc, xls, ppt, pdf, docx, xlsx, pptx
  1479. */
  1480. openDocument(obj: {
  1481. /**
  1482. * 文件路径,可通过 downFile 获得
  1483. */
  1484. filePath: string;
  1485. /**
  1486. * 文件类型,指定文件类型打开文件,有效值 doc, xls, ppt, pdf, docx, xlsx, pptx
  1487. */
  1488. fileType?: string;
  1489. /**
  1490. * 接口调用成功的回调函数
  1491. */
  1492. success?: Function;
  1493. /**
  1494. * 接口调用失败的回调函数
  1495. */
  1496. fail?: Function;
  1497. /**
  1498. * 接口调用结束的回调函数(调用成功、失败都会执行)
  1499. */
  1500. complete?: Function;
  1501. }): void;
  1502. getFileInfo(obj: {
  1503. /**
  1504. * 本地文件路径
  1505. */
  1506. filePath: string;
  1507. /**
  1508. * 计算文件摘要的算法,默认值 md5,有效值:md5,sha1
  1509. */
  1510. digestAlgorithm?: string;
  1511. /**
  1512. * 接口调用成功的回调函数
  1513. */
  1514. success?: Function;
  1515. /**
  1516. * 接口调用失败的回调函数
  1517. */
  1518. fail?: Function;
  1519. /**
  1520. * 接口调用结束的回调函数(调用成功、失败都会执行)
  1521. */
  1522. complete?: Function;
  1523. }): void;
  1524. // # 数据缓存 #
  1525. /**
  1526. * 将数据存储在本地缓存中指定的 key 中,会覆盖掉原来该 key 对应的内容,这是一个异步接口。
  1527. */
  1528. setStorage(obj: {
  1529. /**
  1530. * 本地缓存中的指定的 key
  1531. */
  1532. key: string;
  1533. /**
  1534. * 需要存储的内容
  1535. */
  1536. data: any;
  1537. /**
  1538. * 接口调用成功的回调函数
  1539. */
  1540. success?: Function;
  1541. /**
  1542. * 接口调用失败的回调函数
  1543. */
  1544. fail?: Function;
  1545. /**
  1546. * 接口调用结束的回调函数(调用成功、失败都会执行)
  1547. */
  1548. complete?: Function;
  1549. }): void;
  1550. /**
  1551. * 将 data 存储在本地缓存中指定的 key 中,会覆盖掉原来该 key 对应的内容,这是一个同步接口。
  1552. */
  1553. setStorageSync(key: string, data: any, ): void;
  1554. /**
  1555. * 从本地缓存中异步获取指定 key 对应的内容。
  1556. */
  1557. getStorage(obj: {
  1558. /**
  1559. * 本地缓存中的指定的 key
  1560. */
  1561. key: string;
  1562. /**
  1563. * 接口调用的回调函数,res = {data: key对应的内容}
  1564. */
  1565. success: Function;
  1566. /**
  1567. * 接口调用失败的回调函数
  1568. */
  1569. fail?: Function;
  1570. /**
  1571. * 接口调用结束的回调函数(调用成功、失败都会执行)
  1572. */
  1573. complete?: Function;
  1574. }): void;
  1575. /**
  1576. * 从本地缓存中同步获取指定 key 对应的内容。
  1577. */
  1578. getStorageSync(key: string): void;
  1579. /**
  1580. * 异步获取当前storage的相关信息
  1581. */
  1582. getStorageInfo(obj: {
  1583. /**
  1584. * 接口调用的回调函数,详见返回参数说明
  1585. */
  1586. success: Function;
  1587. /**
  1588. * 接口调用失败的回调函数
  1589. */
  1590. fail?: Function;
  1591. /**
  1592. * 接口调用结束的回调函数(调用成功、失败都会执行)
  1593. */
  1594. complete?: Function;
  1595. }): void;
  1596. /**
  1597. * 同步获取当前storage的相关信息
  1598. */
  1599. getStorageInfoSync(): void;
  1600. /**
  1601. * 从本地缓存中异步移除指定 key 。
  1602. */
  1603. removeStorage(obj: {
  1604. /**
  1605. * 本地缓存中的指定的 key
  1606. */
  1607. key: string;
  1608. /**
  1609. * 接口调用的回调函数
  1610. */
  1611. success: Function;
  1612. /**
  1613. * 接口调用失败的回调函数
  1614. */
  1615. fail?: Function;
  1616. /**
  1617. * 接口调用结束的回调函数(调用成功、失败都会执行)
  1618. */
  1619. complete?: Function;
  1620. }): void;
  1621. /**
  1622. * 从本地缓存中同步移除指定 key 。
  1623. */
  1624. removeStorageSync(key: string): void;
  1625. /**
  1626. * 清理本地数据缓存。
  1627. */
  1628. clearStorage(): void;
  1629. /**
  1630. * 同步清理本地数据缓存
  1631. */
  1632. clearStorageSync(): void;
  1633. // # 位置 #
  1634. /**
  1635. * 获取当前的地理位置、速度。当用户离开小程序后,此接口无法调用;当用户点击“显示在聊天顶部”时,此接口可继续调用。
  1636. */
  1637. getLocation(obj: {
  1638. /**
  1639. * 默认为 wgs84 返回 gps 坐标,gcj02 返回可用于wx.openLocation的坐标
  1640. */
  1641. type?: string;
  1642. /**
  1643. * 接口调用成功的回调函数,返回内容详见返回参数说明。
  1644. */
  1645. success: Function;
  1646. /**
  1647. * 接口调用失败的回调函数
  1648. */
  1649. fail?: Function;
  1650. /**
  1651. * 接口调用结束的回调函数(调用成功、失败都会执行)
  1652. */
  1653. complete?: Function;
  1654. }): void;
  1655. /**
  1656. * 打开地图选择位置
  1657. */
  1658. chooseLocation(obj: {
  1659. /**
  1660. * 接口调用成功的回调函数,返回内容详见返回参数说明。
  1661. */
  1662. success: Function;
  1663. /**
  1664. * 用户取消时调用
  1665. */
  1666. cancel?: Function;
  1667. /**
  1668. * 接口调用失败的回调函数
  1669. */
  1670. fail?: Function;
  1671. /**
  1672. * 接口调用结束的回调函数(调用成功、失败都会执行)
  1673. */
  1674. complete?: Function;
  1675. }): void;
  1676. /**
  1677. * ​ 使用微信内置地图查看位置
  1678. */
  1679. openLocation(obj: {
  1680. /**
  1681. * 纬度,范围为-90~90,负数表示南纬
  1682. */
  1683. latitude: number;
  1684. /**
  1685. * 经度,范围为-180~180,负数表示西经
  1686. */
  1687. longitude: number;
  1688. /**
  1689. * 缩放比例,范围5~18,默认为18
  1690. */
  1691. scale?: number;
  1692. /**
  1693. * 位置名
  1694. */
  1695. name?: string;
  1696. /**
  1697. * 地址的详细说明
  1698. */
  1699. address?: string;
  1700. /**
  1701. * 接口调用成功的回调函数
  1702. */
  1703. success?: Function;
  1704. /**
  1705. * 接口调用失败的回调函数
  1706. */
  1707. fail?: Function;
  1708. /**
  1709. * 接口调用结束的回调函数(调用成功、失败都会执行)
  1710. */
  1711. complete?: Function;
  1712. }): void;
  1713. /**
  1714. * 创建并返回 map 上下文 mapContext 对象
  1715. */
  1716. createMapContext(mapId: string): IMapContext;
  1717. // # 设备 #
  1718. /**
  1719. * 获取系统信息。
  1720. */
  1721. getSystemInfo(obj: {
  1722. /**
  1723. * 接口调用成功的回调
  1724. */
  1725. success: Function;
  1726. /**
  1727. * 接口调用失败的回调函数
  1728. */
  1729. fail?: Function;
  1730. /**
  1731. * 接口调用结束的回调函数(调用成功、失败都会执行)
  1732. */
  1733. complete?: Function;
  1734. }): void;
  1735. /**
  1736. * 获取系统信息同步接口
  1737. */
  1738. getSystemInfoSync(): void;
  1739. /**
  1740. * 获取网络类型。
  1741. */
  1742. getNetworkType(obj: {
  1743. /**
  1744. * 接口调用成功,返回网络类型 networkType
  1745. */
  1746. success: Function;
  1747. /**
  1748. * 接口调用失败的回调函数
  1749. */
  1750. fail?: Function;
  1751. /**
  1752. * 接口调用结束的回调函数(调用成功、失败都会执行)
  1753. */
  1754. complete?: Function;
  1755. }): void;
  1756. onNetworkStatusChange(callback: Function): void;
  1757. setScreenBrightness(obj: {
  1758. /**
  1759. * 屏幕亮度值,范围 0~1,0 最暗,1 最亮
  1760. */
  1761. value: number;
  1762. /**
  1763. * 接口调用成功
  1764. */
  1765. success?: Function;
  1766. /**
  1767. * 接口调用失败的回调函数
  1768. */
  1769. fail?: Function;
  1770. /**
  1771. * 接口调用结束的回调函数(调用成功、失败都会执行)
  1772. */
  1773. complete?: Function;
  1774. }): void;
  1775. getScreenBrightness(obj: {
  1776. /**
  1777. * 接口调用成功
  1778. */
  1779. success?: Function;
  1780. /**
  1781. * 接口调用失败的回调函数
  1782. */
  1783. fail?: Function;
  1784. /**
  1785. * 接口调用结束的回调函数(调用成功、失败都会执行)
  1786. */
  1787. complete?: Function;
  1788. }): void;
  1789. vibrateLong(obj: {
  1790. /**
  1791. * 接口调用成功的回调函数
  1792. */
  1793. success?: Function;
  1794. /**
  1795. * 接口调用失败的回调函数
  1796. */
  1797. fail?: Function;
  1798. /**
  1799. * 接口调用结束的回调函数(调用成功、失败都会执行)
  1800. */
  1801. complete?: Function;
  1802. }): void;
  1803. vibrateShort(obj: {
  1804. /**
  1805. * 接口调用成功的回调函数
  1806. */
  1807. success?: Function;
  1808. /**
  1809. * 接口调用失败的回调函数
  1810. */
  1811. fail?: Function;
  1812. /**
  1813. * 接口调用结束的回调函数(调用成功、失败都会执行)
  1814. */
  1815. complete?: Function;
  1816. }): void;
  1817. /**
  1818. * 监听加速度数据,频率:5次/秒,接口调用后会自动开始监听,可使用 wx.stopAccelerometer 停止监听。
  1819. */
  1820. onAccelerometerChange(callback: Function): void;
  1821. startAccelerometer(obj: {
  1822. /**
  1823. * 接口调用成功的回调函数
  1824. */
  1825. success?: Function;
  1826. /**
  1827. * 接口调用失败的回调函数
  1828. */
  1829. fail?: Function;
  1830. /**
  1831. * 接口调用结束的回调函数(调用成功、失败都会执行)
  1832. */
  1833. complete?: Function;
  1834. }): void;
  1835. stopAccelerometer(obj: {
  1836. /**
  1837. * 接口调用成功的回调函数
  1838. */
  1839. success?: Function;
  1840. /**
  1841. * 接口调用失败的回调函数
  1842. */
  1843. fail?: Function;
  1844. /**
  1845. * 接口调用结束的回调函数(调用成功、失败都会执行)
  1846. */
  1847. complete?: Function;
  1848. }): void;
  1849. /**
  1850. * 监听罗盘数据,频率:5次/秒,接口调用后会自动开始监听,可使用wx.stopCompass停止监听。
  1851. */
  1852. onCompassChange(callback: Function): void;
  1853. startCompass(obj: {
  1854. /**
  1855. * 接口调用成功的回调函数
  1856. */
  1857. success?: Function;
  1858. /**
  1859. * 接口调用失败的回调函数
  1860. */
  1861. fail?: Function;
  1862. /**
  1863. * 接口调用结束的回调函数(调用成功、失败都会执行)
  1864. */
  1865. complete?: Function;
  1866. }): void;
  1867. stopCompass(obj: {
  1868. /**
  1869. * 接口调用成功的回调函数
  1870. */
  1871. success?: Function;
  1872. /**
  1873. * 接口调用失败的回调函数
  1874. */
  1875. fail?: Function;
  1876. /**
  1877. * 接口调用结束的回调函数(调用成功、失败都会执行)
  1878. */
  1879. complete?: Function;
  1880. }): void;
  1881. makePhoneCall(obj: {
  1882. /**
  1883. * 需要拨打的电话号码
  1884. */
  1885. phoneNumber: string;
  1886. /**
  1887. * 接口调用成功的回调
  1888. */
  1889. success?: Function;
  1890. /**
  1891. * 接口调用失败的回调函数
  1892. */
  1893. fail?: Function;
  1894. /**
  1895. * 接口调用结束的回调函数(调用成功、失败都会执行)
  1896. */
  1897. complete?: Function;
  1898. }): void;
  1899. /**
  1900. * 调起客户端扫码界面,扫码成功后返回对应的结果
  1901. */
  1902. scanCode(obj: {
  1903. /**
  1904. * 是否只能从相机扫码,不允许从相册选择图片
  1905. */
  1906. onlyFromCamera?: boolean;
  1907. /**
  1908. * 接口调用成功的回调函数,返回内容详见返回参数说明。
  1909. */
  1910. success?: Function;
  1911. /**
  1912. * 接口调用失败的回调函数
  1913. */
  1914. fail?: Function;
  1915. /**
  1916. * 接口调用结束的回调函数(调用成功、失败都会执行)
  1917. */
  1918. complete?: Function;
  1919. }): void;
  1920. setClipboardData(obj: {
  1921. /**
  1922. * 需要设置的内容
  1923. */
  1924. data: string;
  1925. /**
  1926. * 接口调用成功的回调函数
  1927. */
  1928. success?: Function;
  1929. /**
  1930. * 接口调用失败的回调函数
  1931. */
  1932. fail?: Function;
  1933. /**
  1934. * 接口调用结束的回调函数(调用成功、失败都会执行)
  1935. */
  1936. complete?: Function;
  1937. }): void;
  1938. getClipboardData(obj: {
  1939. /**
  1940. * 接口调用成功的回调函数
  1941. */
  1942. success?: Function;
  1943. /**
  1944. * 接口调用失败的回调函数
  1945. */
  1946. fail?: Function;
  1947. /**
  1948. * 接口调用结束的回调函数(调用成功、失败都会执行)
  1949. */
  1950. complete?: Function;
  1951. }): void;
  1952. openBluetoothAdapter(obj: {
  1953. /**
  1954. * 成功则返回成功初始化信息
  1955. */
  1956. success: Function;
  1957. /**
  1958. * 接口调用失败的回调函数
  1959. */
  1960. fail?: Function;
  1961. /**
  1962. * 接口调用结束的回调函数(调用成功、失败都会执行)
  1963. */
  1964. complete?: Function;
  1965. }): void;
  1966. closeBluetoothAdapter(obj: {
  1967. /**
  1968. * 成功则返回成功关闭模块信息
  1969. */
  1970. success: Function;
  1971. /**
  1972. * 接口调用失败的回调函数
  1973. */
  1974. fail?: Function;
  1975. /**
  1976. * 接口调用结束的回调函数(调用成功、失败都会执行)
  1977. */
  1978. complete?: Function;
  1979. }): void;
  1980. getBluetoothAdapterState(obj: {
  1981. /**
  1982. * 成功则返回本机蓝牙适配器状态
  1983. */
  1984. success: Function;
  1985. /**
  1986. * 接口调用失败的回调函数
  1987. */
  1988. fail?: Function;
  1989. /**
  1990. * 接口调用结束的回调函数(调用成功、失败都会执行)
  1991. */
  1992. complete?: Function;
  1993. }): void;
  1994. onBluetoothAdapterStateChange(callback: Function): void;
  1995. startBluetoothDevicesDiscovery(obj: {
  1996. /**
  1997. * 蓝牙设备主 service 的 uuid 列表
  1998. */
  1999. services?: Array<any>;
  2000. /**
  2001. * 是否允许重复上报同一设备, 如果允许重复上报,则onDeviceFound 方法会多次上报同一设备,但是 RSSI 值会有不同
  2002. */
  2003. allowDuplicatesKey?: boolean;
  2004. /**
  2005. * 上报设备的间隔,默认为0,意思是找到新设备立即上报,否则根据传入的间隔上报
  2006. */
  2007. interval?: number;
  2008. /**
  2009. * 成功则返回本机蓝牙适配器状态
  2010. */
  2011. success: Function;
  2012. /**
  2013. * 接口调用失败的回调函数
  2014. */
  2015. fail?: Function;
  2016. /**
  2017. * 接口调用结束的回调函数(调用成功、失败都会执行)
  2018. */
  2019. complete?: Function;
  2020. }): void;
  2021. stopBluetoothDevicesDiscovery(obj: {
  2022. /**
  2023. * 成功则返回本机蓝牙适配器状态
  2024. */
  2025. success: Function;
  2026. /**
  2027. * 接口调用失败的回调函数
  2028. */
  2029. fail?: Function;
  2030. /**
  2031. * 接口调用结束的回调函数(调用成功、失败都会执行)
  2032. */
  2033. complete?: Function;
  2034. }): void;
  2035. getBluetoothDevices(obj: {
  2036. /**
  2037. * 成功则返回本机蓝牙适配器状态
  2038. */
  2039. success: Function;
  2040. /**
  2041. * 接口调用失败的回调函数
  2042. */
  2043. fail?: Function;
  2044. /**
  2045. * 接口调用结束的回调函数(调用成功、失败都会执行)
  2046. */
  2047. complete?: Function;
  2048. }): void;
  2049. onBluetoothDeviceFound(callback: Function): void;
  2050. getConnectedBluetoothDevices(obj: {
  2051. /**
  2052. * 蓝牙设备主 service 的 uuid 列表
  2053. */
  2054. services: Array<any>;
  2055. /**
  2056. * 成功则返回本机蓝牙适配器状态
  2057. */
  2058. success: Function;
  2059. /**
  2060. * 接口调用失败的回调函数
  2061. */
  2062. fail?: Function;
  2063. /**
  2064. * 接口调用结束的回调函数(调用成功、失败都会执行)
  2065. */
  2066. complete?: Function;
  2067. }): void;
  2068. createBLEConnection(obj: {
  2069. /**
  2070. * 蓝牙设备 id,参考 getDevices 接口
  2071. */
  2072. deviceId: string;
  2073. /**
  2074. * 成功则返回本机蓝牙适配器状态
  2075. */
  2076. success: Function;
  2077. /**
  2078. * 接口调用失败的回调函数
  2079. */
  2080. fail?: Function;
  2081. /**
  2082. * 接口调用结束的回调函数(调用成功、失败都会执行)
  2083. */
  2084. complete?: Function;
  2085. }): void;
  2086. closeBLEConnection(obj: {
  2087. /**
  2088. * 蓝牙设备 id,参考 getDevices 接口
  2089. */
  2090. deviceId: string;
  2091. /**
  2092. * 成功则返回本机蓝牙适配器状态
  2093. */
  2094. success: Function;
  2095. /**
  2096. * 接口调用失败的回调函数
  2097. */
  2098. fail?: Function;
  2099. /**
  2100. * 接口调用结束的回调函数(调用成功、失败都会执行)
  2101. */
  2102. complete?: Function;
  2103. }): void;
  2104. getBLEDeviceServices(obj: {
  2105. /**
  2106. * 蓝牙设备 id,参考 getDevices 接口
  2107. */
  2108. deviceId: string;
  2109. /**
  2110. * 成功则返回本机蓝牙适配器状态
  2111. */
  2112. success: Function;
  2113. /**
  2114. * 接口调用失败的回调函数
  2115. */
  2116. fail?: Function;
  2117. /**
  2118. * 接口调用结束的回调函数(调用成功、失败都会执行)
  2119. */
  2120. complete?: Function;
  2121. }): void;
  2122. getBLEDeviceCharacteristics(obj: {
  2123. /**
  2124. * 蓝牙设备 id,参考 device 对象
  2125. */
  2126. deviceId: string;
  2127. /**
  2128. * 蓝牙服务 uuid
  2129. */
  2130. serviceId: string;
  2131. /**
  2132. * 成功则返回本机蓝牙适配器状态
  2133. */
  2134. success: Function;
  2135. /**
  2136. * 接口调用失败的回调函数
  2137. */
  2138. fail?: Function;
  2139. /**
  2140. * 接口调用结束的回调函数(调用成功、失败都会执行)
  2141. */
  2142. complete?: Function;
  2143. }): void;
  2144. readBLECharacteristicValue(obj: {
  2145. /**
  2146. * 蓝牙设备 id,参考 device 对象
  2147. */
  2148. deviceId: string;
  2149. /**
  2150. * 蓝牙特征值对应服务的 uuid
  2151. */
  2152. serviceId: string;
  2153. /**
  2154. * 蓝牙特征值的 uuid
  2155. */
  2156. characteristicId: string;
  2157. /**
  2158. * 成功则返回本机蓝牙适配器状态
  2159. */
  2160. success: Function;
  2161. /**
  2162. * 接口调用失败的回调函数
  2163. */
  2164. fail?: Function;
  2165. /**
  2166. * 接口调用结束的回调函数(调用成功、失败都会执行)
  2167. */
  2168. complete?: Function;
  2169. }): void;
  2170. writeBLECharacteristicValue(obj: {
  2171. /**
  2172. * 蓝牙设备 id,参考 device 对象
  2173. */
  2174. deviceId: string;
  2175. /**
  2176. * 蓝牙特征值对应服务的 uuid
  2177. */
  2178. serviceId: string;
  2179. /**
  2180. * 蓝牙特征值的 uuid
  2181. */
  2182. characteristicId: string;
  2183. /**
  2184. * 蓝牙设备特征值对应的二进制值(注意:vConsole 无法打印出 ArrayBuffer 类型数据)
  2185. */
  2186. value: undefined;
  2187. /**
  2188. * 成功则返回本机蓝牙适配器状态
  2189. */
  2190. success: Function;
  2191. /**
  2192. * 接口调用失败的回调函数
  2193. */
  2194. fail?: Function;
  2195. /**
  2196. * 接口调用结束的回调函数(调用成功、失败都会执行)
  2197. */
  2198. complete?: Function;
  2199. }): void;
  2200. notifyBLECharacteristicValueChange(obj: {
  2201. /**
  2202. * 蓝牙设备 id,参考 device 对象
  2203. */
  2204. deviceId: string;
  2205. /**
  2206. * 蓝牙特征值对应服务的 uuid
  2207. */
  2208. serviceId: string;
  2209. /**
  2210. * 蓝牙特征值的 uuid
  2211. */
  2212. characteristicId: string;
  2213. /**
  2214. * true: 启用 notify; false: 停用 notify
  2215. */
  2216. state: boolean;
  2217. /**
  2218. * 成功则返回本机蓝牙适配器状态
  2219. */
  2220. success: Function;
  2221. /**
  2222. * 接口调用失败的回调函数
  2223. */
  2224. fail?: Function;
  2225. /**
  2226. * 接口调用结束的回调函数(调用成功、失败都会执行)
  2227. */
  2228. complete?: Function;
  2229. }): void;
  2230. onBLEConnectionStateChange(callback: Function): void;
  2231. onBLECharacteristicValueChange(callback: Function): void;
  2232. startBeaconDiscovery(obj: {
  2233. /**
  2234. * iBeacon设备广播的 uuids
  2235. */
  2236. uuids: string[];
  2237. /**
  2238. * 接口调用成功的回调函数
  2239. */
  2240. success?: Function;
  2241. /**
  2242. * 接口调用失败的回调函数
  2243. */
  2244. fail?: Function;
  2245. /**
  2246. * 接口调用结束的回调函数(调用成功、失败都会执行)
  2247. */
  2248. complete?: Function;
  2249. }): void;
  2250. stopBeaconDiscovery(obj: {
  2251. /**
  2252. * 接口调用成功的回调函数
  2253. */
  2254. success?: Function;
  2255. /**
  2256. * 接口调用失败的回调函数
  2257. */
  2258. fail?: Function;
  2259. /**
  2260. * 接口调用结束的回调函数(调用成功、失败都会执行)
  2261. */
  2262. complete?: Function;
  2263. }): void;
  2264. getBeacons(obj: {
  2265. /**
  2266. * 接口调用成功的回调函数
  2267. */
  2268. success?: Function;
  2269. /**
  2270. * 接口调用失败的回调函数
  2271. */
  2272. fail?: Function;
  2273. /**
  2274. * 接口调用结束的回调函数(调用成功、失败都会执行)
  2275. */
  2276. complete?: Function;
  2277. }): void;
  2278. onBeaconUpdate(callback: Function): void;
  2279. onBeaconServiceChange(callback: Function): void;
  2280. onUserCaptureScreen(callback: Function): void;
  2281. addPhoneContact(obj: {
  2282. /**
  2283. * 头像本地文件路径
  2284. */
  2285. photoFilePath?: string;
  2286. /**
  2287. * 昵称
  2288. */
  2289. nickName?: string;
  2290. /**
  2291. * 姓氏
  2292. */
  2293. lastName?: string;
  2294. /**
  2295. * 中间名
  2296. */
  2297. middleName?: string;
  2298. /**
  2299. * 名字
  2300. */
  2301. firstName: string;
  2302. /**
  2303. * 备注
  2304. */
  2305. remark?: string;
  2306. /**
  2307. * 手机号
  2308. */
  2309. mobilePhoneNumber?: string;
  2310. /**
  2311. * 微信号
  2312. */
  2313. weChatNumber?: string;
  2314. /**
  2315. * 联系地址国家
  2316. */
  2317. addressCountry?: string;
  2318. /**
  2319. * 联系地址省份
  2320. */
  2321. addressState?: string;
  2322. /**
  2323. * 联系地址城市
  2324. */
  2325. addressCity?: string;
  2326. /**
  2327. * 联系地址街道
  2328. */
  2329. addressStreet?: string;
  2330. /**
  2331. * 联系地址邮政编码
  2332. */
  2333. addressPostalCode?: string;
  2334. /**
  2335. * 公司
  2336. */
  2337. organization?: string;
  2338. /**
  2339. * 职位
  2340. */
  2341. title?: string;
  2342. /**
  2343. * 工作传真
  2344. */
  2345. workFaxNumber?: string;
  2346. /**
  2347. * 工作电话
  2348. */
  2349. workPhoneNumber?: string;
  2350. /**
  2351. * 公司电话
  2352. */
  2353. hostNumber?: string;
  2354. /**
  2355. * 电子邮件
  2356. */
  2357. email?: string;
  2358. /**
  2359. * 网站
  2360. */
  2361. url?: string;
  2362. /**
  2363. * 工作地址国家
  2364. */
  2365. workAddressCountry?: string;
  2366. /**
  2367. * 工作地址省份
  2368. */
  2369. workAddressState?: string;
  2370. /**
  2371. * 工作地址城市
  2372. */
  2373. workAddressCity?: string;
  2374. /**
  2375. * 工作地址街道
  2376. */
  2377. workAddressStreet?: string;
  2378. /**
  2379. * 工作地址邮政编码
  2380. */
  2381. workAddressPostalCode?: string;
  2382. /**
  2383. * 住宅传真
  2384. */
  2385. homeFaxNumber?: string;
  2386. /**
  2387. * 住宅电话
  2388. */
  2389. homePhoneNumber?: string;
  2390. /**
  2391. * 住宅地址国家
  2392. */
  2393. homeAddressCountry?: string;
  2394. /**
  2395. * 住宅地址省份
  2396. */
  2397. homeAddressState?: string;
  2398. /**
  2399. * 住宅地址城市
  2400. */
  2401. homeAddressCity?: string;
  2402. /**
  2403. * 住宅地址街道
  2404. */
  2405. homeAddressStreet?: string;
  2406. /**
  2407. * 住宅地址邮政编码
  2408. */
  2409. homeAddressPostalCode?: string;
  2410. /**
  2411. * 接口调用成功
  2412. */
  2413. success?: Function;
  2414. /**
  2415. * 接口调用失败的回调函数
  2416. */
  2417. fail?: Function;
  2418. /**
  2419. * 接口调用结束的回调函数(调用成功、失败都会执行)
  2420. */
  2421. complete?: Function;
  2422. }): void;
  2423. // # 界面 #
  2424. /**
  2425. * 显示消息提示框
  2426. */
  2427. showToast(obj: {
  2428. /**
  2429. * 提示的内容
  2430. */
  2431. title: string;
  2432. /**
  2433. * 图标,有效值 "success", "loading"
  2434. */
  2435. icon?: string;
  2436. /**
  2437. * 自定义图标的本地路径,image 的优先级高于 icon
  2438. */
  2439. image?: string;
  2440. /**
  2441. * 提示的延迟时间,单位毫秒,默认:1500
  2442. */
  2443. duration?: number;
  2444. /**
  2445. * 是否显示透明蒙层,防止触摸穿透,默认:false
  2446. */
  2447. mask?: boolean;
  2448. /**
  2449. * 接口调用成功的回调函数
  2450. */
  2451. success?: Function;
  2452. /**
  2453. * 接口调用失败的回调函数
  2454. */
  2455. fail?: Function;
  2456. /**
  2457. * 接口调用结束的回调函数(调用成功、失败都会执行)
  2458. */
  2459. complete?: Function;
  2460. }): void;
  2461. showLoading(obj: {
  2462. /**
  2463. * 提示的内容
  2464. */
  2465. title: string;
  2466. /**
  2467. * 是否显示透明蒙层,防止触摸穿透,默认:false
  2468. */
  2469. mask?: boolean;
  2470. /**
  2471. * 接口调用成功的回调函数
  2472. */
  2473. success?: Function;
  2474. /**
  2475. * 接口调用失败的回调函数
  2476. */
  2477. fail?: Function;
  2478. /**
  2479. * 接口调用结束的回调函数(调用成功、失败都会执行)
  2480. */
  2481. complete?: Function;
  2482. }): void;
  2483. /**
  2484. * 隐藏消息提示框
  2485. */
  2486. hideToast(): void;
  2487. hideLoading(): void;
  2488. /**
  2489. * ​显示模态弹窗
  2490. */
  2491. showModal(obj: {
  2492. /**
  2493. * 提示的标题
  2494. */
  2495. title: string;
  2496. /**
  2497. * 提示的内容
  2498. */
  2499. content: string;
  2500. /**
  2501. * 是否显示取消按钮,默认为 true
  2502. */
  2503. showCancel?: boolean;
  2504. /**
  2505. * 取消按钮的文字,默认为"取消",最多 4 个字符
  2506. */
  2507. cancelText?: string;
  2508. /**
  2509. * 取消按钮的文字颜色,默认为"#000000"
  2510. */
  2511. cancelColor?: undefined;
  2512. /**
  2513. * 确定按钮的文字,默认为"确定",最多 4 个字符
  2514. */
  2515. confirmText?: string;
  2516. /**
  2517. * 确定按钮的文字颜色,默认为"#3CC51F"
  2518. */
  2519. confirmColor?: undefined;
  2520. /**
  2521. * 接口调用成功的回调函数
  2522. */
  2523. success?: Function;
  2524. /**
  2525. * 接口调用失败的回调函数
  2526. */
  2527. fail?: Function;
  2528. /**
  2529. * 接口调用结束的回调函数(调用成功、失败都会执行)
  2530. */
  2531. complete?: Function;
  2532. }): void;
  2533. /**
  2534. * ​显示操作菜单
  2535. */
  2536. showActionSheet(obj: {
  2537. /**
  2538. * 按钮的文字数组,数组长度最大为6个
  2539. */
  2540. itemList: undefined;
  2541. /**
  2542. * 按钮的文字颜色,默认为"#000000"
  2543. */
  2544. itemColor?: undefined;
  2545. /**
  2546. * 接口调用成功的回调函数,详见返回参数说明
  2547. */
  2548. success?: Function;
  2549. /**
  2550. * 接口调用失败的回调函数
  2551. */
  2552. fail?: Function;
  2553. /**
  2554. * 接口调用结束的回调函数(调用成功、失败都会执行)
  2555. */
  2556. complete?: Function;
  2557. }): void;
  2558. setTopBarText(obj: {
  2559. /**
  2560. * 置顶栏文字内容
  2561. */
  2562. text: string;
  2563. /**
  2564. * 接口调用成功的回调函数
  2565. */
  2566. success?: Function;
  2567. /**
  2568. * 接口调用失败的回调函数
  2569. */
  2570. fail?: Function;
  2571. /**
  2572. * 接口调用结束的回调函数(调用成功、失败都会执行)
  2573. */
  2574. complete?: Function;
  2575. }): void;
  2576. /**
  2577. * 动态设置当前页面的标题。
  2578. */
  2579. setNavigationBarTitle(obj: {
  2580. /**
  2581. * 页面标题
  2582. */
  2583. title: string;
  2584. /**
  2585. * 接口调用成功的回调函数
  2586. */
  2587. success?: Function;
  2588. /**
  2589. * 接口调用失败的回调函数
  2590. */
  2591. fail?: Function;
  2592. /**
  2593. * 接口调用结束的回调函数(调用成功、失败都会执行)
  2594. */
  2595. complete?: Function;
  2596. }): void;
  2597. /**
  2598. * 在当前页面显示导航条加载动画。
  2599. */
  2600. showNavigationBarLoading(): void;
  2601. /**
  2602. * 隐藏导航条加载动画。
  2603. */
  2604. hideNavigationBarLoading(): void;
  2605. /**
  2606. * 保留当前页面,跳转到应用内的某个页面,使用wx.navigateBack可以返回到原页面。
  2607. */
  2608. navigateTo(obj: {
  2609. /**
  2610. * 需要跳转的应用内非 tabBar 的页面的路径 , 路径后可以带参数。参数与路径之间使用?分隔,参数键与参数值用=相连,不同参数用&分隔;如 'path?key=value&key2=value2'
  2611. */
  2612. url: string;
  2613. /**
  2614. * 接口调用成功的回调函数
  2615. */
  2616. success?: Function;
  2617. /**
  2618. * 接口调用失败的回调函数
  2619. */
  2620. fail?: Function;
  2621. /**
  2622. * 接口调用结束的回调函数(调用成功、失败都会执行)
  2623. */
  2624. complete?: Function;
  2625. }): void;
  2626. /**
  2627. * 关闭当前页面,跳转到应用内的某个页面。
  2628. */
  2629. redirectTo(obj: {
  2630. /**
  2631. * 需要跳转的应用内非 tabBar 的页面的路径,路径后可以带参数。参数与路径之间使用?分隔,参数键与参数值用=相连,不同参数用&分隔;如 'path?key=value&key2=value2'
  2632. */
  2633. url: string;
  2634. /**
  2635. * 接口调用成功的回调函数
  2636. */
  2637. success?: Function;
  2638. /**
  2639. * 接口调用失败的回调函数
  2640. */
  2641. fail?: Function;
  2642. /**
  2643. * 接口调用结束的回调函数(调用成功、失败都会执行)
  2644. */
  2645. complete?: Function;
  2646. }): void;
  2647. reLaunch(obj: {
  2648. /**
  2649. * 需要跳转的应用内页面路径 , 路径后可以带参数。参数与路径之间使用?分隔,参数键与参数值用=相连,不同参数用&分隔;如 'path?key=value&key2=value2',如果跳转的页面路径是 tabBar 页面则不能带参数
  2650. */
  2651. url: string;
  2652. /**
  2653. * 接口调用成功的回调函数
  2654. */
  2655. success?: Function;
  2656. /**
  2657. * 接口调用失败的回调函数
  2658. */
  2659. fail?: Function;
  2660. /**
  2661. * 接口调用结束的回调函数(调用成功、失败都会执行)
  2662. */
  2663. complete?: Function;
  2664. }): void;
  2665. /**
  2666. * 跳转到 tabBar 页面,并关闭其他所有非 tabBar 页面
  2667. */
  2668. switchTab(obj: {
  2669. /**
  2670. * 需要跳转的 tabBar 页面的路径(需在 app.json 的 tabBar 字段定义的页面),路径后不能带参数
  2671. */
  2672. url: string;
  2673. /**
  2674. * 接口调用成功的回调函数
  2675. */
  2676. success?: Function;
  2677. /**
  2678. * 接口调用失败的回调函数
  2679. */
  2680. fail?: Function;
  2681. /**
  2682. * 接口调用结束的回调函数(调用成功、失败都会执行)
  2683. */
  2684. complete?: Function;
  2685. }): void;
  2686. /**
  2687. * 关闭当前页面,返回上一页面或多级页面。可通过 getCurrentPages()) 获取当前的页面栈,决定需要返回几层。
  2688. */
  2689. navigateBack(obj: {
  2690. /**
  2691. * 返回的页面数,如果 delta 大于现有页面数,则返回到首页。
  2692. */
  2693. delta?: number;
  2694. }): void;
  2695. /**
  2696. * 创建一个动画实例animation。调用实例的方法来描述动画。最后通过动画实例的export方法导出动画数据传递给组件的animation属性。
  2697. */
  2698. createAnimation(obj: {
  2699. /**
  2700. * 400
  2701. */
  2702. duration?: number;
  2703. /**
  2704. * "linear"
  2705. */
  2706. timingFunction?: string;
  2707. /**
  2708. * 0
  2709. */
  2710. delay?: number;
  2711. /**
  2712. * "50% 50% 0"
  2713. */
  2714. transformOrigin?: string;
  2715. }): IAnimation;
  2716. pageScrollTo(obj: {
  2717. /**
  2718. * 滚动到页面的目标位置(单位px)
  2719. */
  2720. scrollTop: number;
  2721. }): void;
  2722. /**
  2723. * 创建 canvas 绘图上下文(指定 canvasId).Tip: 需要指定 canvasId,该绘图上下文只作用于对应的 <canvas/>
  2724. */
  2725. createCanvasContext(canvasId: string): ICanvasContext;
  2726. /**
  2727. * 把当前画布的内容导出生成图片,并返回文件路径
  2728. */
  2729. canvasToTempFilePath(canvasId: string): void;
  2730. startPullDownRefresh(obj: {
  2731. /**
  2732. * 接口调用成功的回调函数
  2733. */
  2734. success?: Function;
  2735. /**
  2736. * 接口调用失败的回调函数
  2737. */
  2738. fail?: Function;
  2739. /**
  2740. * 接口调用结束的回调函数(调用成功、失败都会执行)
  2741. */
  2742. complete?: Function;
  2743. }): void;
  2744. /**
  2745. * 停止当前页面下拉刷新。
  2746. */
  2747. stopPullDownRefresh(): void;
  2748. // # WXML节点信息 #
  2749. // # 第三方平台 #
  2750. getExtConfig(obj: {
  2751. /**
  2752. * 返回第三方平台自定义的数据
  2753. */
  2754. success?: Function;
  2755. /**
  2756. * 接口调用失败的回调函数
  2757. */
  2758. fail?: Function;
  2759. /**
  2760. * 接口调用结束的回调函数(调用成功、失败都会执行)
  2761. */
  2762. complete?: Function;
  2763. }): void;
  2764. getExtConfigSync(): void;
  2765. // # 开放接口 #
  2766. /**
  2767. * 调用接口获取登录凭证(code)进而换取用户登录态信息,包括用户的唯一标识(openid) 及本次登录的 会话密钥(session_key)。用户数据的加解密通讯需要依赖会话密钥完成。
  2768. */
  2769. login(obj: {
  2770. /**
  2771. * 接口调用成功的回调函数
  2772. */
  2773. success?: Function;
  2774. /**
  2775. * 接口调用失败的回调函数
  2776. */
  2777. fail?: Function;
  2778. /**
  2779. * 接口调用结束的回调函数(调用成功、失败都会执行)
  2780. */
  2781. complete?: Function;
  2782. }): void;
  2783. /**
  2784. * 通过上述接口获得的用户登录态拥有一定的时效性。用户越久未使用小程序,用户登录态越有可能失效。反之如果用户一直在使用小程序,则用户登录态一直保持有效。具体时效逻辑由微信维护,对开发者透明。开发者只需要调用wx.checkSession接口检测当前用户登录态是否有效。登录态过期后开发者可以再调用wx.login获取新的用户登录态。
  2785. */
  2786. checkSession(obj: {
  2787. /**
  2788. * 接口调用成功的回调函数,登录态未过期
  2789. */
  2790. success?: Function;
  2791. /**
  2792. * 接口调用失败的回调函数,登录态已过期
  2793. */
  2794. fail?: Function;
  2795. /**
  2796. * 接口调用结束的回调函数(调用成功、失败都会执行)
  2797. */
  2798. complete?: Function;
  2799. }): void;
  2800. authorize(obj: {
  2801. /**
  2802. * 需要获取权限的scope,详见 scope 列表
  2803. */
  2804. scope: string;
  2805. /**
  2806. * 接口调用成功的回调函数
  2807. */
  2808. success?: Function;
  2809. /**
  2810. * 接口调用失败的回调函数
  2811. */
  2812. fail?: Function;
  2813. /**
  2814. * 接口调用结束的回调函数(调用成功、失败都会执行)
  2815. */
  2816. complete?: Function;
  2817. }): void;
  2818. /**
  2819. * 获取用户信息,withCredentials 为 true 时需要先调用 wx.login 接口。
  2820. */
  2821. getUserInfo(obj: {
  2822. /**
  2823. * 是否带上登录态信息
  2824. */
  2825. withCredentials?: boolean;
  2826. /**
  2827. * 指定返回用户信息的语言,zh_CN 简体中文,zh_TW 繁体中文,en 英文
  2828. */
  2829. lang?: string;
  2830. /**
  2831. * 接口调用成功的回调函数
  2832. */
  2833. success?: Function;
  2834. /**
  2835. * 接口调用失败的回调函数
  2836. */
  2837. fail?: Function;
  2838. /**
  2839. * 接口调用结束的回调函数(调用成功、失败都会执行)
  2840. */
  2841. complete?: Function;
  2842. }): void;
  2843. /**
  2844. * 发起微信支付。
  2845. */
  2846. requestPayment(obj: {
  2847. /**
  2848. * 时间戳从1970年1月1日00:00:00至今的秒数,即当前的时间
  2849. */
  2850. timeStamp: string;
  2851. /**
  2852. * 随机字符串,长度为32个字符以下。
  2853. */
  2854. nonceStr: string;
  2855. /**
  2856. * 统一下单接口返回的 prepay_id 参数值,提交格式如:prepay_id=*
  2857. */
  2858. package: string;
  2859. /**
  2860. * 签名算法,暂支持 MD5
  2861. */
  2862. signType: string;
  2863. /**
  2864. * 签名,具体签名方案参见小程序支付接口文档;
  2865. */
  2866. paySign: string;
  2867. /**
  2868. * 接口调用成功的回调函数
  2869. */
  2870. success?: Function;
  2871. /**
  2872. * 接口调用失败的回调函数
  2873. */
  2874. fail?: Function;
  2875. /**
  2876. * 接口调用结束的回调函数(调用成功、失败都会执行)
  2877. */
  2878. complete?: Function;
  2879. }): void;
  2880. chooseAddress(obj: {
  2881. /**
  2882. * 返回用户选择的收货地址信息
  2883. */
  2884. success?: Function;
  2885. /**
  2886. * 接口调用失败的回调函数
  2887. */
  2888. fail?: Function;
  2889. /**
  2890. * 接口调用结束的回调函数(调用成功、失败都会执行)
  2891. */
  2892. complete?: Function;
  2893. }): void;
  2894. addCard(obj: {
  2895. /**
  2896. * 需要添加的卡券列表,列表内对象说明请参见请求对象说明
  2897. */
  2898. cardList: undefined;
  2899. /**
  2900. * 接口调用成功的回调函数
  2901. */
  2902. success?: Function;
  2903. /**
  2904. * 接口调用失败的回调函数
  2905. */
  2906. fail?: Function;
  2907. /**
  2908. * 接口调用结束的回调函数(调用成功、失败都会执行)
  2909. */
  2910. complete?: Function;
  2911. }): void;
  2912. openCard(obj: {
  2913. /**
  2914. * 需要打开的卡券列表,列表内参数详见openCard 请求对象说明
  2915. */
  2916. cardList: undefined;
  2917. /**
  2918. * 接口调用成功的回调函数
  2919. */
  2920. success?: Function;
  2921. /**
  2922. * 接口调用失败的回调函数
  2923. */
  2924. fail?: Function;
  2925. /**
  2926. * 接口调用结束的回调函数(调用成功、失败都会执行)
  2927. */
  2928. complete?: Function;
  2929. }): void;
  2930. openSetting(obj: {
  2931. /**
  2932. * 接口调用成功的回调函数,返回内容详见返回参数说明。
  2933. */
  2934. success?: Function;
  2935. /**
  2936. * 接口调用失败的回调函数
  2937. */
  2938. fail?: Function;
  2939. /**
  2940. * 接口调用结束的回调函数(调用成功、失败都会执行)
  2941. */
  2942. complete?: Function;
  2943. }): void;
  2944. getSetting(obj: {
  2945. /**
  2946. * 接口调用成功的回调函数,返回内容详见返回参数说明。
  2947. */
  2948. success?: Function;
  2949. /**
  2950. * 接口调用失败的回调函数
  2951. */
  2952. fail?: Function;
  2953. /**
  2954. * 接口调用结束的回调函数(调用成功、失败都会执行)
  2955. */
  2956. complete?: Function;
  2957. }): void;
  2958. getWeRunData(obj: {
  2959. /**
  2960. * 接口调用成功的回调函数
  2961. */
  2962. success?: Function;
  2963. /**
  2964. * 接口调用失败的回调函数
  2965. */
  2966. fail?: Function;
  2967. /**
  2968. * 接口调用结束的回调函数(调用成功、失败都会执行)
  2969. */
  2970. complete?: Function;
  2971. }): void;
  2972. navigateToMiniProgram(obj: {
  2973. /**
  2974. * 要打开的小程序 appId
  2975. */
  2976. appId: string;
  2977. /**
  2978. * 打开的页面路径,如果为空则打开首页
  2979. */
  2980. path?: string;
  2981. /**
  2982. * 需要传递给目标小程序的数据,目标小程序可在 App.onLaunch(),App.onShow() 中获取到这份数据。详情
  2983. */
  2984. extraData?: any;
  2985. /**
  2986. * 要打开的小程序版本,有效值 develop(开发版),trial(体验版),release(正式版) ,仅在当前小程序为开发版或体验版时此参数有效;如果当前小程序是体验版或正式版,则打开的小程序必定是正式版。默认值 release
  2987. */
  2988. envVersion?: string;
  2989. /**
  2990. * 接口调用成功的回调函数
  2991. */
  2992. success?: Function;
  2993. /**
  2994. * 接口调用失败的回调函数
  2995. */
  2996. fail?: Function;
  2997. /**
  2998. * 接口调用结束的回调函数(调用成功、失败都会执行)
  2999. */
  3000. complete?: Function;
  3001. }): void;
  3002. chooseInvoiceTitle(obj: {
  3003. /**
  3004. * 接口调用成功的回调函数
  3005. */
  3006. success?: Function;
  3007. /**
  3008. * 接口调用失败的回调函数
  3009. */
  3010. fail?: Function;
  3011. /**
  3012. * 接口调用结束的回调函数(调用成功、失败都会执行)
  3013. */
  3014. complete?: Function;
  3015. }): void;
  3016. checkIsSupportSoterAuthentication(obj: {
  3017. /**
  3018. * 接口调用成功的回调函数
  3019. */
  3020. success?: Function;
  3021. /**
  3022. * 接口调用失败的回调函数
  3023. */
  3024. fail?: Function;
  3025. /**
  3026. * 接口调用结束的回调函数(调用成功、失败都会执行)
  3027. */
  3028. complete?: Function;
  3029. }): void;
  3030. // # 数据 #
  3031. /**
  3032. * 自定义分析数据上报接口。使用前,需要在小程序管理后台自定义分析中新建事件,配置好事件名与字段。
  3033. */
  3034. reportAnalytics(eventName: string, data: string, ): void;
  3035. // # 拓展接口 #
  3036. arrayBufferToBase64(arrayBuffer: string): void;
  3037. base64ToArrayBuffer(base64: string): void;
  3038. // # 调试接口 #
  3039. setEnableDebug(obj: {
  3040. /**
  3041. * 是否打开调试
  3042. */
  3043. enableDebug: boolean;
  3044. /**
  3045. * 接口调用成功的回调函数
  3046. */
  3047. success?: Function;
  3048. /**
  3049. * 接口调用失败的回调函数
  3050. */
  3051. fail?: Function;
  3052. /**
  3053. * 接口调用结束的回调函数(调用成功、失败都会执行)
  3054. */
  3055. complete?: Function;
  3056. }): void;
  3057. }