SDKDefault.ts 5.5 KB

/** 返回参数类型 */
interface IResult<T> {
    /** 错误码 */
    code?: number;
    /** 错误信息 */
    msg?: string;
    /** 返回数据 */
    data?: T;
    /** 服务器时间 */
    servertime?: number;
}

/** 微信api 返回用户信息 */
interface WxUserInfo {
    /** 用户昵称 */
    nickName: string;
    /** 用户头像图片的 URL。URL 最后一个数值代表正方形头像大小
     * (有 0、46、64、96、132 数值可选,0 代表 640x640 的正方形头像,46 表示 46x46 的正方形头像,
     * 剩余数值以此类推。默认132),用户没有头像时该项为空。若用户更换头像,原有头像 URL 将失效。 */
    avatarUrl: string;
    /** 用户性别 gender的合法值(0未知,1男性,2女性) */
    gender: number;
    /** 用户所在国家 */
    country: string;
    /** 用户所在省份 */
    province: string;
    /** 用户所在城市 */
    city: string;
    /** 显示 country,province,city 所用的语言(en英文,zh_CN简体中文,zh_TW繁体中文) */
    language: string;
}

/** 显示模态对话框参数类型 */
interface ShowModalType {
    /** 提示的标题 */
    title: string;
    /** 提示的内容 */
    content: string;
    /** 是否显示取消按钮 */
    showCancel?: boolean;
    /** 取消按钮的文字,最多 4 个字符 */
    cancelText?: string;
    /** 取消按钮的文字颜色,必须是 16 进制格式的颜色字符串 */
    cancelColor?: string;
    /** 确认按钮的文字,最多 4 个字符 */
    confirmText?: string;
    /** 确认按钮的文字颜色,必须是 16 进制格式的颜色字符串 */
    confirmColor?: string;
    /** 接口调用成功的回调函数 */
    success?: (res: { confirm: boolean, cancel: boolean }) => void;
    /** 接口调用失败的回调函数 */
    fail?: () => void;
    /** 接口调用结束的回调函数(调用成功、失败都会执行) */
    complete?: () => void;
}
/**
 * 排行榜数据
 */
interface IRankData {
    fraction: number, // 对应type传入的分数、数量或者其他
    headurl: string, //头像
    nickname: string,//昵称
    uid: number//用户id
    rankData: any //扩展参数
}

interface _NetworkTypeSuccessObject {
    networkType: string;  // wifi/2g/3g/4g/unknown(Android 下不常见的网络类型)/none(无网络)
}
interface _StyleObject {
    left?: number;

    top?: number;

    width?: number;

    height?: number;
}
interface _StyleGameObject {
    left?: number;
    top?: number;
}

interface _BannerAdObject {
    adUnitId: string;
    adIntervals?: number;
    style: _StyleObject;
}
interface _FeedbackButtonObject {
    /**
     * 按钮的类型
     */
    type: string;

    /**
     * 按钮上的文本,仅当 type 为 text 时有效
     */
    text?: string;

    /**
     * 按钮的背景图片,仅当 type 为 image 时有效
     */
    image?: string;

    /**
     * 按钮的样式
     */
    style: _ButtonStyle;
}

interface _UserInfoButton {
    type: string;

    text: string;

    image: string;

    style: _ButtonStyle;

    show: Function;

    hide: Function;

    destroy: Function;

    onTap: (callback: Function) => void;

    offTap: (callback: Function) => void;
}

interface _ShareAppMessageObject {
    /**
     * 是否使用带 shareTicket 的转发详情
     */
    withShareTicket?: boolean;
    /**
     * 发标题,不传则默认使用当前小游戏的昵称。
     */
    title?: string;

    /**
     * 转发显示图片的链接,可以是网络图片路径或本地图片文件路径或相对代码包根目录的图片文件路径。显示图片长宽比是 5: 4
     */
    imageUrl?: string;

    /**
     * 查询字符串,必须是 key1 = val1 & key2=val2 的格式。从这条转发消息进入后,可通过 wx.getLaunchOptionSync() 或 wx.onShow() 获取启动参数中的 query。
     */
    query?: string;

    /**
     * 审核通过的图片 ID,详见 使用审核通过的转发图片	
     */
    imageUrlId?: string;

    /**
     * 10.10后废弃
     */
    success?: (ret?: any) => void;

    /**
     * 接口调用失败的回调函数
     */
    fail?: (err?: any) => void;

    /**
     * 接口调用结束的回调函数(调用成功、失败都会执行)
     */
    complete?: () => void;

    /**
     * 接口取消的回调
     */
    cancel?: () => void;
}
interface _UpdateShareMenuObject {
    /**
     * 是否使用带 shareTicket 的转发
     */
    withShareTicket?: boolean;

    /**
     * 接口调用成功的回调函数
     */
    success?: () => void;

    /**
     * 接口调用失败的回调函数
     */
    fail?: () => void;

    /**
     * 接口调用结束的回调函数(调用成功、失败都会执行)
     */
    complete?: () => void;

    /**
     * 接口取消的回调
     */
    cancel?: () => void;
}
interface _getShareInfoSuccessObject {
    /**
     * 错误信息
     */
    errMsg: string;

    /**
     * 包括敏感数据在内的完整转发信息的加密数据,详细见[加密数据解密算法](./signature.md#加密数据解密算法)
     */
    encryptedData: string;

    /**
     * 加密算法的初始向量,详细见[加密数据解密算法](./signature.md#加密数据解密算法)
     */
    iv: string;
}


interface IGameList {
    id: number,//唯一id
    appid: string,//微信appid
    path: string, //携带参数
    icon: string, //游戏icon
    game: string //游戏名称
    adtyp: string,//类型
    animation: string,//骨骼
    highlight: string,//是否高亮
}