wx.d.ts 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. declare namespace wx {
  2. interface SocketTask {
  3. send(obj: { data: any }): void;
  4. close(obj?: any): void;
  5. onOpen(func?: any): void;
  6. onClose(func?: any): void;
  7. onError(func?: any): void;
  8. onMessage(func?: any): void;
  9. }
  10. /**
  11. * 通用的回调型函数参数
  12. */
  13. interface CommonCallbackParam {
  14. /**
  15. * 接口调用成功的回调函数
  16. */
  17. success?: Function;
  18. /**
  19. * 接口调用失败的回调函数
  20. */
  21. fail?: Function;
  22. /**
  23. * 接口调用结束的回调函数(调用成功、失败都会执行)
  24. */
  25. complete?: Function;
  26. }
  27. interface SocketParam extends CommonCallbackParam {
  28. url: string;
  29. /**
  30. * HTTP Header,Header 中不能设置 Referer
  31. */
  32. header?: Object;
  33. /**
  34. * 子协议数组
  35. */
  36. protocols?: Array<string>;
  37. }
  38. function connectSocket(param: SocketParam): SocketTask;
  39. // 角色掉血震动
  40. function vibrateLong(param?: CommonCallbackParam);
  41. /**
  42. * 重启小游戏 低版本不支持
  43. */
  44. function restartMiniProgram(): void;
  45. function setKeepScreenOn(param: { keepScreenOn: boolean })
  46. function createRewardedVideoAd(param: { adUnitId: string })
  47. function showModal(param: { title: string, content: string, success: Function, confirmText?: string, showCancel?: boolean })
  48. function setClipboardData(param: { data: string, success: Function })
  49. function getClipboardData(param: { success: Function })
  50. function triggerGC()
  51. function getUpdateManager()
  52. function openCustomerServiceConversation(param?: { sessionFrom?: string, showMessageCard?: boolean, sendMessageTitle?: string, sendMessageImg?: string, sendMessagePath?: string, success?: Function })
  53. function showShareMenu(param: { menus: string[] })
  54. function requestSubscribeMessage(param: { tmplIds: string[], success: Function, fail: Function })
  55. function onShareAppMessage(callback: Function)
  56. function getAccountInfoSync() // 获取当前帐号信息。线上小程序版本号仅支持在正式版小程序中获取,开发版和体验版中无法获取。
  57. function showToast(param: { title: string, icon: string, duration: number })
  58. function getLaunchOptionsSync()
  59. function getEnterOptionsSync()
  60. function getSystemInfoSync()
  61. function showShareMenu(param: { withShareTicket: boolean, menus: string[] })
  62. function login(param: { success: Function })
  63. function getLaunchOptionsSync(callback: Function)
  64. function onShow(callback: Function)
  65. function onHide(callback: Function)
  66. function createUserInfoButton(param: { type: string, text: string, style: Object })
  67. function getUserInfo(param: { withCredentials?: boolean, lang: string, success: Function, fail: Function })
  68. function shareAppMessage(param: { title?: string, imageUrl?: string, imageUrlId?: string, query: string })
  69. function getSetting(param: { withSubscriptions: boolean, success: Function })
  70. function requestMidasPayment(param: { mode: string, env: number, offerId: string, currencyType: string, platform?: string, buyQuantity: number, zoneId?: string, outTradeNo: string, success: Function, fail: Function, complete?: Function })
  71. function getAppBaseInfo(): { SDKVersion: string }
  72. }