# qq.openSetting

# qq.openSetting(Object object)

调起客户端小程序设置界面,返回用户设置的操作结果。设置界面只会出现小程序已经向用户请求过的权限。

# 参数

# Object object
属性 类型 默认值 必填 说明
withSubscriptions Boolean false 否 是否同时获取用户订阅消息的订阅状态,默认不获取。注意:withSubscriptions 只返回用户勾选过订阅面板中的“总是保持以上选择,不再询问”的订阅消息。
success function 否 接口调用成功的回调函数
fail function 否 接口调用失败的回调函数
complete function 否 接口调用结束的回调函数(调用成功、失败都会执行)
# object.success 回调函数

参数

Object res

属性 类型 说明
authSetting AuthSetting 用户授权结果
subscriptionsSetting SubscriptionsSetting 用户订阅消息设置,接口参数withSubscriptions值为true时才会返回。

# 示例代码

qq.openSetting({
  success(res) {
    console.log(res.authSetting)
    // res.authSetting = {
    //   "scope.userInfo": true,
    //   "scope.userLocation": true
    // }
  }
})
1
2
3
4
5
6
7
8
9
qq.openSetting({
  withSubscriptions: true,
  success (res) {
    console.log(res.authSetting)
    // res.authSetting = {
    //   "scope.userInfo": true,
    //   "scope.userLocation": true
    //   "setting.appMsgSubscribed": true, // 长期订阅开关,true:打开;false:关闭
    // }
    console.log(res.subscriptionsSetting)
    // res.subscriptionsSetting = {
    //   itemSettings: {   // 订阅消息
    //     SYS_MSG_TYPE_INTERACTIVE: 'accept', // 小游戏系统订阅消息:好友互动提醒
    //     SYS_MSG_TYPE_RANK: 'accept', // 小游戏系统订阅消息:排行榜超越提醒
    //     118d4118a4609537873d18fdsfe932332: 'reject', // 普通一次性订阅消息
    //     53231118a4609537873d18fdsfe932332: 'ban', // 普通一次性订阅消息
    //   }
    // }
  }
})
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

# qq.getSetting

# qq.getSetting(Object object)

获取用户的当前设置。返回值中只会出现小程序已经向用户请求过的权限。

# 参数

# Object object
属性 类型 默认值 必填 说明
withSubscriptions Boolean false 否 是否同时获取用户订阅消息的订阅状态,默认不获取。注意:withSubscriptions 只返回用户勾选过订阅面板中的“总是保持以上选择,不再询问”的订阅消息。
success function 否 接口调用成功的回调函数
fail function 否 接口调用失败的回调函数
complete function 否 接口调用结束的回调函数(调用成功、失败都会执行)
# object.success 回调函数

参数

Object res

属性 类型 说明
authSetting AuthSetting 用户授权结果
subscriptionsSetting SubscriptionsSetting 是否返回用户订阅消息设置,接口参数withSubscriptions值为true时才会返回。

# 示例代码

qq.getSetting({
  success(res) {
    console.log(res.authSetting)
    // res.authSetting = {
    //   "scope.userInfo": true,
    //   "scope.userLocation": true
    // }
  }
})
1
2
3
4
5
6
7
8
9
qq.getSetting({
  withSubscriptions: true,
  success (res) {
    console.log(res.authSetting)
    // res.authSetting = {
    //   "scope.userInfo": true,
    //   "scope.userLocation": true
    //   "setting.appMsgSubscribed": true, // 长期订阅开关,true:打开;false:关闭
    // }
    console.log(res.subscriptionsSetting)
    // res.subscriptionsSetting = {
    //   itemSettings: {   // 订阅消息
    //     SYS_MSG_TYPE_INTERACTIVE: 'accept', // 小游戏系统订阅消息:好友互动提醒
    //     SYS_MSG_TYPE_RANK: 'accept', // 小游戏系统订阅消息:排行榜超越提醒
    //     118d4118a4609537873d18fdsfe932332: 'reject', // 普通一次性订阅消息
    //     53231118a4609537873d18fdsfe932332: 'ban', // 普通一次性订阅消息
    //   }
    // }
  }
})
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

# qq.createOpenSettingButton

# OpenSettingButton qq.createOpenSettingButton(Object object)

创建打开设置页面的按钮

# 参数

# Object object
属性 类型 默认值 必填 说明
type string 是 按钮的类型
text string 否 按钮上的文本,仅当 type 为 text 时有效
image string 否 按钮的背景图片,仅当 type 为 image 时有效
style Object 是 按钮的样式

type 的合法值

值 说明
text 可以设置背景色和文本的按钮
image 只能设置背景贴图的按钮,背景贴图会直接拉伸到按钮的宽高

style 的结构

属性 类型 默认值 必填 说明
left number 是 左上角横坐标
top number 是 左上角纵坐标
width number 是 宽度
height number 是 高度
backgroundColor string 是 背景颜色。格式为 6位/8位 16进制数。
borderColor string 是 边框颜色。格式为 6位/8位 16进制数。
borderWidth number 是 边框宽度
borderRadius number 是 边框圆角
color string 是 文本的颜色。格式为 6位 16进制数。
textAlign string 是 文本的水平居中方式
fontSize number 是 字号
lineHeight number 是 文本的行高

style.textAlign 的合法值

值 说明
left 居左
center 居中
right 居右

# 返回值

# OpenSettingButton

# 示例代码

const button = qq.createOpenSettingButton({
  type: 'text',
  text: '打开设置页面',
  style: {
    left: 10,
    top: 76,
    width: 200,
    height: 40,
    lineHeight: 40,
    backgroundColor: '#ff0000',
    color: '#ffffff',
    textAlign: 'center',
    fontSize: 16,
    borderRadius: 4
  }
})
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

# AuthSetting

用户授权设置信息,详情参考权限

# 属性

# boolean scope.userInfo

是否授权用户信息,对应接口 qq.getUserInfo

# boolean scope.userLocation

是否授权地理位置,对应接口 qq.getLocation

# boolean scope.qqrun

是否授权QQ运动步数,对应接口 qq.getQQRunData

# boolean scope.writePhotosAlbum

是否授权保存到相册 qq.saveImageToPhotosAlbum

# boolean scope.appMsgSubscribed

订阅消息(833以下版本使用scope.appMsgSubscribed,833及以上版本使用setting.appMsgSubscribed), qq.subscribeAppMsg

# boolean scope.addFriend

允许被添加好友,主动调用qq.authorize接口进行授权

# SubscriptionsSetting

订阅消息设置

# 属性

# Object itemSettings

每一项订阅消息的订阅状态。itemSettings 对象的键为一次性订阅消息的模板id或系统订阅消息的类型,值为'accept'、'reject'、'ban'中的其中一种。'accept'表示用户同意订阅这条消息,'reject'表示用户拒绝订阅这条消息,'ban'表示已被后台封禁。一次性订阅消息使用方法详见 qq.subscribeAppMsg,系统订阅消息使用方法详见qq.requestSubscribeSystemMessage

# OpenSettingButton

用户点击后打开设置页面的按钮

# 属性

# string type

按钮的类型

type 的合法值

值 说明
text 可以设置背景色和文本的按钮
image 只能设置背景贴图的按钮,背景贴图会直接拉伸到按钮的宽高
# string text

按钮上的文本,仅当 type 为 text 时有效

# string image

按钮的背景图片,仅当 type 为 image 时有效

# Object style

按钮的样式

属性 类型 说明
left number 左上角横坐标
top number 左上角纵坐标
width number 宽度
height number 高度
backgroundColor string 背景颜色。格式为 6位/8位 16进制数。
borderColor string 边框颜色。格式为 6位/8位 16进制数。
borderWidth number 边框宽度
borderRadius number 边框圆角
color string 文本的颜色。格式为 6位 16进制数。
textAlign string 文本的水平居中方式
fontSize number 字号
lineHeight number 文本的行高

style.textAlign 的合法值

值 说明
left 居左
center 居中
right 居右

# 方法

# OpenSettingButton.show()

显示打开设置页面按钮

# OpenSettingButton.hide()

隐藏打开设置页面按钮。

# OpenSettingButton.destroy()

销毁打开设置页面按钮

# OpenSettingButton.onTap(function callback)

监听设置页面按钮的点击事件

# OpenSettingButton.offTap(function callback)

取消监听设置页面按钮的点击事件

# .destroy

# OpenSettingButton.destroy()

销毁打开设置页面按钮

# .hide

# OpenSettingButton.hide()

隐藏打开设置页面按钮。

# .offTap

# OpenSettingButton.offTap(function callback)

取消监听设置页面按钮的点击事件

# 参数

# function callback

设置页面按钮的点击事件的回调函数

# .onTap

# OpenSettingButton.onTap(function callback)

监听设置页面按钮的点击事件

# 参数

# function callback

设置页面按钮的点击事件的回调函数

# .show

# OpenSettingButton.show()

显示打开设置页面按钮