API Reference

Methods

getFriendCloudStorage(param)

拉取当前用户所有同玩好友的托管数据

由于 QQ 浏览器小游戏当前暂不支持存储托管数据,所以该接口不限制必须在开放作用域使用

Parameters:
Name Type Description
param Object
Properties
Name Type Description
success getFriendCloudStorageCallback

接口调用成功的回调函数

fail callback

接口调用失败的回调函数

complete callback

接口调用结束的回调函数(调用成功、失败都会执行)

getSystemInfoSync() → {SystemInfo}

获取系统信息

可根据返回结果的 vendor 字段,区分微信与 QQ 浏览器平台,在同一份前端代码中兼容两个平台

Returns:

系统信息

Type
SystemInfo
Example
if ("qb" === wx.getSystemInfoSync().vendor) {
  console.log("QQBrowser Game");
} else {
  console.log("Wechat Game");
}

hideBannerAd(param)

隐藏 banner 广告

Parameters:
Name Type Description
param Object
Properties
Name Type Description
success callback

接口调用成功的回调函数

fail callback

接口调用失败的回调函数

complete callback

接口调用结束的回调函数(调用成功、失败都会执行)

hideGameClubButton(param)

隐藏游戏圈按钮

Parameters:
Name Type Description
param Object
Properties
Name Type Description
success callback

接口调用成功的回调函数

fail callback

接口调用失败的回调函数

complete callback

接口调用结束的回调函数(调用成功、失败都会执行)

requestMidasPayment(param)

发起米大师支付

QQ 浏览器小游戏只支持执行 buyQuantity 参数

Parameters:
Name Type Description
param Object
Properties
Name Type Description
buyQuantity number

购买数量

success callback

接口调用成功的回调函数

fail callback

接口调用失败的回调函数

complete callback

接口调用结束的回调函数(调用成功、失败都会执行)

shareAppMessage(param)

发起分享

QQ 浏览器小游戏分享自动组合游戏标题、截图和运行地址生成分享图片,所以微信 API 中的 title、imageUrl 等参数均无效,也无法携带 query 参数传递给启动时的 LaunchOptions

Parameters:
Name Type Description
param Object
Properties
Name Type Description
success callback

接口调用成功的回调函数

fail callback

接口调用失败的回调函数

complete callback

接口调用结束的回调函数(调用成功、失败都会执行)

showBannerAd(param)

显示 banner 广告

Parameters:
Name Type Description
param Object
Properties
Name Type Description
success callback

接口调用成功的回调函数

fail callback

接口调用失败的回调函数

complete callback

接口调用结束的回调函数(调用成功、失败都会执行)

showGameClubButton(param)

显示游戏圈按钮

QQ 浏览器小游戏游戏圈按钮默认显示,可通过 hideGameClubButton 隐藏

Parameters:
Name Type Description
param Object
Properties
Name Type Description
success callback

接口调用成功的回调函数

fail callback

接口调用失败的回调函数

complete callback

接口调用结束的回调函数(调用成功、失败都会执行)

showRewardedVideoAd(param)

显示激励视频广告

视频广告在倒计时结束时会自动关闭

Parameters:
Name Type Description
param Object
Properties
Name Type Description
success callback

用户完整观看视频的回调函数

fail callback

用户未完整观看视频的回调函数

complete callback

接口调用结束的回调函数(用户是否完整观看视频都会执行)

Type Definitions

callback(result)

微信 API 回调

Parameters:
Name Type Description
result Object
Properties
Name Type Description
errMsg string

错误信息

getFriendCloudStorageCallback(result)

拉取同玩好友列表成功回调

Parameters:
Name Type Description
result Object
Properties
Name Type Description
data Array.<UserGameData>

同玩好友信息

SystemInfo

系统信息

Type:
  • Object
Properties:
Name Type Description
brand string

手机品牌

model string

手机型号

pixelRatio number

设备像素比

screenWidth number

屏幕宽度

screenHeight number

屏幕高度

windowWidth number

可使用窗口宽度

windowHeight number

可使用窗口高度

statusBarHeight number

状态栏的高度

language string

QQ 浏览器设置的语言

version string

QQ 浏览器版本号

system string

操作系统版本

platform string

客户端平台

fontSizeSetting number

用户字体大小设置

SDKVersion string

客户端基础库版本

benchmarkLevel number

(仅Android小游戏) 性能等级,-2 或 0:该设备无法运行小游戏,-1:性能未知,>=1 设备性能值,该值越高,设备性能越好 (目前设备最高不到50)

vendor number

供应商信息,用以区分微信与 QQ 浏览器平台,始终为 'qb'

UserGameData

好友信息

Type:
  • Object
Properties:
Name Type Description
avatarUrl string

用户头像 url

nickname string

用户昵称

openid string

用户 openid