调起客户端小程序设置界面,返回用户设置的操作结果。设置界面只会出现小程序已经向用户请求过的权限。
| 属性 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| withSubscriptions | Boolean | false | 否 | 是否同时获取用户订阅消息的订阅状态,默认不获取。注意:withSubscriptions 只返回用户勾选过订阅面板中的“总是保持以上选择,不再询问”的订阅消息。 |
| success | function | 否 | 接口调用成功的回调函数 | |
| fail | function | 否 | 接口调用失败的回调函数 | |
| complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
参数
Object res
| 属性 | 类型 | 说明 |
|---|---|---|
| authSetting | AuthSetting | 用户授权结果 |
| subscriptionsSetting | SubscriptionsSetting | 用户订阅消息设置,接口参数withSubscriptions值为true时才会返回。 |
qq.openSetting({
success(res) {
console.log(res.authSetting)
// res.authSetting = {
// "scope.userInfo": true,
// "scope.userLocation": true
// }
}
})
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', // 普通一次性订阅消息
// }
// }
}
})
获取用户的当前设置。返回值中只会出现小程序已经向用户请求过的权限。
| 属性 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| withSubscriptions | Boolean | false | 否 | 是否同时获取用户订阅消息的订阅状态,默认不获取。注意:withSubscriptions 只返回用户勾选过订阅面板中的“总是保持以上选择,不再询问”的订阅消息。 |
| success | function | 否 | 接口调用成功的回调函数 | |
| fail | function | 否 | 接口调用失败的回调函数 | |
| complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
参数
Object res
| 属性 | 类型 | 说明 |
|---|---|---|
| authSetting | AuthSetting | 用户授权结果 |
| subscriptionsSetting | SubscriptionsSetting | 是否返回用户订阅消息设置,接口参数withSubscriptions值为true时才会返回。 |
qq.getSetting({
success(res) {
console.log(res.authSetting)
// res.authSetting = {
// "scope.userInfo": true,
// "scope.userLocation": true
// }
}
})
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', // 普通一次性订阅消息
// }
// }
}
})
创建打开设置页面的按钮
| 属性 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| 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 | 居右 |
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
}
})
用户授权设置信息,详情参考权限
是否授权用户信息,对应接口 qq.getUserInfo
是否授权地理位置,对应接口 qq.getLocation
是否授权QQ运动步数,对应接口 qq.getQQRunData
是否授权保存到相册 qq.saveImageToPhotosAlbum
订阅消息(833以下版本使用scope.appMsgSubscribed,833及以上版本使用setting.appMsgSubscribed), qq.subscribeAppMsg
允许被添加好友,主动调用qq.authorize接口进行授权
订阅消息设置
每一项订阅消息的订阅状态。itemSettings 对象的键为一次性订阅消息的模板id或系统订阅消息的类型,值为'accept'、'reject'、'ban'中的其中一种。'accept'表示用户同意订阅这条消息,'reject'表示用户拒绝订阅这条消息,'ban'表示已被后台封禁。一次性订阅消息使用方法详见 qq.subscribeAppMsg,系统订阅消息使用方法详见qq.requestSubscribeSystemMessage
用户点击后打开设置页面的按钮
按钮的类型
type 的合法值
| 值 | 说明 |
|---|---|
| text | 可以设置背景色和文本的按钮 |
| image | 只能设置背景贴图的按钮,背景贴图会直接拉伸到按钮的宽高 |
按钮上的文本,仅当 type 为 text 时有效
按钮的背景图片,仅当 type 为 image 时有效
按钮的样式
| 属性 | 类型 | 说明 |
|---|---|---|
| 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 | 居右 |
显示打开设置页面按钮
隐藏打开设置页面按钮。
销毁打开设置页面按钮
监听设置页面按钮的点击事件
取消监听设置页面按钮的点击事件
销毁打开设置页面按钮
隐藏打开设置页面按钮。
取消监听设置页面按钮的点击事件
设置页面按钮的点击事件的回调函数
监听设置页面按钮的点击事件
设置页面按钮的点击事件的回调函数
显示打开设置页面按钮