import { Vec2, Node } from "cc"; export interface toastParams { //属性 类型 默认值 必填 说明 title: string;// 是 提示的内容 icon?: string;// 'success' 否 图标 image?: string;// 否 自定义图标的本地路径,image 的优先级高于 icon 1.1.0 duration?: number;// 1500 否 提示的延迟时间 mask?: boolean;// false 否 是否显示透明蒙层,防止触摸穿透 success?: () => void;// 否 接口调用成功的回调函数 fail?: () => void;// 否 接口调用失败的回调函数 complete?: () => void;// 否 接口调用结束的回调函数(调用成功、失败都会执行 } export interface loadParams { //属性 类型 默认值 必填 说明 title: string;// 是 提示的内容 mask?: boolean;// false 否 是否显示透明蒙层,防止触摸穿透 success?: () => void;// 否 接口调用成功的回调函数 fail?: () => void;// 否 接口调用失败的回调函数 complete?: () => void;// 否 接口调用结束的回调函数(调用成功、失败都会执行) } export interface ModalParams { title?: string;// 否 标题 1.0.0 content?: string;// 否 内容 1.0.0 confirmText?: string;// 确定 否 确定按钮的文案,最多 4 个字符 1.0.0 showCancel?: boolean;// true 否 是否显示取消按钮 1.0.0 cancelText?: string;// 取消 否 取消按钮的文案,最多 4 个字符 1.0.0 success?: (result: { errMsg: string, confirm: boolean, cancel: boolean }) => void;// 否 接口调用成功后的回调函数 1.0.0 fail?: (err: { errMsg: string }) => void;// 否 接口调用失败后的回调函数 1.0.0 complete?: () => void;// 否 接口调用结束后的回调函数(调用成功、失败都会执行) 1.0.0 } export interface authorizeParams { // 属性 类型 默认值 必填 说明 最低版本 scope?: string; //是 需要获取权限的 scope,详见 scope 列表 success?: () => void; // 否 接口调用成功的回调函数 fail?: () => void; //否 接口调用失败的回调函数 complete?: () => void; //否 接口调用结束的回调函数(调用成功、失败都会执行) } export interface loginParams { // 属性 类型 默认值 必填 说明 最低版本 timeout?: number; // 否 超时时间,单位ms 1.9.90 success?: (res: { code: string }) => void; // 否 接口调用成功的回调函数 fail?: () => void; //否 接口调用失败的回调函数 complete?: () => void; //否 接口调用结束的回调函数(调用成功、失败都会执行) force?: boolean; } export interface UserInfo { nickName: string; //用户昵称 avatarUrl: string; //用户头像图片的 URL。URL 最后一个数值代表正方形头像大小(有 0、46、64、96、132 数值可选,0 代表 640x640 的正方形头像,46 表示 46x46 的正方形头像,剩余数值以此类推。默认132),用户没有头像时该项为空。若用户更换头像,原有头像 URL 将失效。 gender: number; //gender 的合法值 0 未知 1 男性 2 女性 country: string; //用户所在国家 province: string; //用户所在省份 city: string; //用户所在城市 language: string //显示country,province,city所用的语言 en 英文 zh_CN 简体中文 zh_TW 繁体中文 } export interface getUserInfoParams { //属性 类型 默认值 必填 说明 withCredentials?: boolean; // 否 是否带上登录态信息。当 withCredentials 为 true 时,要求此前有调用过 wx.login 且登录态尚未过期,此时返回的数据会包含 encryptedData, iv 等敏感信息;当 withCredentials 为 false 时,不要求有登录态,返回的数据不包含 encryptedData, iv 等敏感信息。 lang?: string; // en 否 显示用户信息的语言 success?: (res: { userInfo: UserInfo }) => void;// 否 接口调用成功的回调函数 fail?: () => void;// 否 接口调用失败的回调函数 complete?: () => void;// 否 接口调用结束的回调函数(调用成功、失败都会执行) } export interface recordedGameScreenParams { //属性 类型 默认值 是否必填 说明 最低版本 duration: number; // 10 否 录屏的时长,单位 s,必须大于 3s,最大值 300s(5 分钟)。 isMarkOpen?: boolean; // true 否 是否添加水印,会在录制出来的视频上添加默认水印,目前不支持自定义水印图案。 1.69.0+ locTop?: number; // 0 否 水印距离屏幕左边界的位置,单位为 dp。 1.69.0+ locLeft?: number; // 0 否 水印距离屏幕上边界的位置,单位为 dp。 frameRate?: number; // 30 否 设置录屏帧率,对于性能较差的手机可以调低参数以降低录屏性能消耗。 1.80.0+ } export abstract class MiniGameApiBase { /** 应用ID */ protected abstract m_AppId: string; /** 密匙 */ protected abstract m_Secret: string; /** 视频广告索引 */ protected abstract m_VideoAdIdIndex: number; /** 视频广告列表 */ protected abstract m_VideoAdIdList: string[]; /** banner广告索引 */ protected abstract m_BannerAdIdIndex: number; /** banner广告ID列表 */ protected abstract m_BannerAdId: string[]; /** 插屏广告索引 */ protected abstract m_InsertAdIdIndex: number; /** 插屏广告ID列表 */ protected abstract m_InsertAdId: string[]; /** 视频广告组件 */ protected abstract m_videoAd: unknown; /** banner广告组件 */ protected abstract m_BannerAd: unknown; /** 判断是否合法APP-ID */ abstract validAppId(): void; /** api准备 */ abstract ready(): void; /** 获取用户数据 */ abstract getUserInfo(params: getUserInfoParams): void; /** 显示提示框 */ abstract showToast(params: toastParams): void; /** 显示进度框 */ abstract showLoading(params: loadParams): void; /** 隐藏进度框 */ abstract hideLoading(): void; /** 显示对话框 */ abstract showModal(params: ModalParams): void; /** 授权 */ abstract authorize(params: authorizeParams): void; /** 登录 */ abstract login(params: loginParams): void; /** * 加载并显示视频广告 * @param successCB 成功回调 * @param errorCB 失败回调 * @param completeCB 完成回调 * @param reportAnalyticsExplain 成功上报描述 */ abstract loadAndShowVideoAd(successCB: () => void, errorCB?: (error: any) => void, completeCB?: () => void, reportAnalyticsExplain?: string): void; /** * 显示插屏 * @param onAdClose * @param onFailed */ abstract showInsertAd(onAdClose: () => void, onFailed: () => void): void; /** 显示banner广告 */ abstract showBannerAD(node: Node, successCB?: () => void, errorCB?: (error: any) => void, onCloseCB?: () => void, setBannerPos?: ({ screenWidth, screenHeight }) => Vec2): void; /** 隐藏banner广告 */ abstract hideBanner(): void; /** 录屏开始 */ abstract recordedGameScreenStart(params: recordedGameScreenParams, onStart?: (res) => void): void; /** 录屏停止 */ abstract recordedGameScreenStop(): boolean; /** 分享录屏 */ abstract shareRecordedGameScreen(successCb?: () => void, failCb?: (e?) => void): void; /** 是否有分享录屏 */ abstract isHaveRecordedGameScreen(): boolean; /** 获取本地数据 */ abstract getStorageSync(key?: string): any; /** 移除本地数据 */ abstract removeStorage(key?: string): any; /** 获取设备信息 */ abstract getDeviceInfo(): any; abstract setUnlockAllTime(time: number): any; abstract getUnlockAllTime(call: Function): any; abstract setUnitState(state?: string); /** * 打点 * @param eventName 事件名,注意不能超过 110 字符 * @param data 上报的数据 可选 {} */ abstract reportAnalytics(eventName: string, data?: { [key: string]: number | string | boolean }): any; abstract setSoundInfo(sound?: boolean, music?: boolean): any; abstract checkScene(successCB?: Function, errorCB?: Function): any; abstract navigateToScene(successCB?: Function, errorCB?: Function): any; abstract getLaunchOptionsSync(): any; }