declare namespace wx {
    interface SocketTask {
        send(obj: { data: any }): void;
        close(obj?: any): void;
        onOpen(func?: any): void;
        onClose(func?: any): void;
        onError(func?: any): void;
        onMessage(func?: any): void;
    }

    /**
     * 通用的回调型函数参数
     */
    interface CommonCallbackParam {
        /**
        * 接口调用成功的回调函数
        */
        success?: Function;
        /**
         * 接口调用失败的回调函数
         */
        fail?: Function;
        /**
         * 接口调用结束的回调函数（调用成功、失败都会执行）
         */
        complete?: Function;
    }

    interface SocketParam extends CommonCallbackParam {
        url: string;
        /**
         * HTTP Header，Header 中不能设置 Referer
         */
        header?: Object;
        /**
         * 子协议数组
         */
        protocols?: Array<string>;
    }

    function connectSocket(param: SocketParam): SocketTask;
    // 角色掉血震动
    function vibrateLong(param?: CommonCallbackParam);
    /**
     * 重启小游戏 低版本不支持
     */
    function restartMiniProgram(): void;

    function setKeepScreenOn(param: { keepScreenOn: boolean })
    function createRewardedVideoAd(param: { adUnitId: string })
    function showModal(param: { title: string, content: string, success: Function, confirmText?: string, showCancel?: boolean })
    function setClipboardData(param: { data: string, success: Function })
    function getClipboardData(param: { success: Function })
    function triggerGC()
    function getUpdateManager()
    function openCustomerServiceConversation(param?: { sessionFrom?: string, showMessageCard?: boolean, sendMessageTitle?: string, sendMessageImg?: string, sendMessagePath?: string, success?: Function })
    function showShareMenu(param: { menus: string[] })
    function requestSubscribeMessage(param: { tmplIds: string[], success: Function, fail: Function })
    function onShareAppMessage(callback: Function)
    function getAccountInfoSync() // 获取当前帐号信息。线上小程序版本号仅支持在正式版小程序中获取，开发版和体验版中无法获取。
    function showToast(param: { title: string, icon: string, duration: number })
    function getLaunchOptionsSync()
    function getEnterOptionsSync()
    function getSystemInfoSync()
    function showShareMenu(param: { withShareTicket: boolean, menus: string[] })
    function login(param: { success: Function })
    function getLaunchOptionsSync(callback: Function)
    function onShow(callback: Function)
    function onHide(callback: Function)
    function createUserInfoButton(param: { type: string, text: string, style: Object })
    function getUserInfo(param: { withCredentials?: boolean, lang: string, success: Function, fail: Function })
    function shareAppMessage(param: { title?: string, imageUrl?: string, imageUrlId?: string, query: string })
    function getSetting(param: { withSubscriptions: boolean, success: Function })
    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 })
    function getAppBaseInfo(): { SDKVersion: string }
}