基础库版本 1.1.0 开始支持,低版本需做兼容处理
调起客户端小程序设置界面,返回用户设置的操作结果
object 参数说明:
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
success | function | 否 | 接口调用成功的回调函数,返回内容详见返回参数说明。 |
fail | function | 否 | 接口调用失败的回调函数 |
complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
success返回参数说明:
参数 | 类型 | 说明 |
---|---|---|
authsetting | object | 用户授权结果,其中 key 为 scope 值,value 为 bool 值,表示用户是否允许授权,详见 scope 列表 |
示例代码:
wx.opensetting({
success: (res) => {
/*
* res.authsetting = {
* "scope.userinfo": true,
* "scope.userlocation": true
* }
*/
}
})
支持版本 >= 2.0.7
创建打开设置页面的按钮。
按钮的类型
type 的合法值:
值 | 说明 |
---|---|
text | 可以设置背景色和文本的按钮 |
image | 只能设置背景贴图的按钮,背景贴图会直接拉伸到按钮的宽高 |
按钮上的文本,仅当 type 为 text 时有效
按钮的背景图片,仅当 type 为 image 时有效
按钮的样式
属性 | 类型 | 默认值 | 是否必填 | 说明 | 支持版本 |
---|---|---|---|---|---|
left | number | 是 | 左上角横坐标 | ||
top | number | 是 | 左上角纵坐标 | ||
width | number | 是 | 宽度 | ||
height | number | 是 | 高度 | ||
backgroundcolor | string | 是 | 背景颜色 | ||
bordercolor | string | 是 | 边框颜色 | ||
borderwidth | number | 是 | 边框宽度 | ||
borderradius | number | 是 | 边框圆角 | ||
textalign | string | 是 | 文本的水平居中方式 | ||
fontsize | number | 是 | 字号 | ||
lineheight | number | 是 | 文本的行高 |
style.textalign 的合法值:
值 | 说明 |
---|---|
left | 居左 |
center | 居中 |
right | 居右 |
let button = wx.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.0 开始支持,低版本需做兼容处理
获取用户的当前设置
object 参数说明:
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
success | function | 否 | 接口调用成功的回调函数,返回内容详见返回参数说明。 |
fail | function | 否 | 接口调用失败的回调函数 |
complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
success返回参数说明:
参数 | 类型 | 说明 |
---|---|---|
authsetting | object | 用户授权结果,其中 key 为 scope 值,value 为 bool 值,表示用户是否允许授权,详见 scope 列表 |
示例代码:
wx.getsetting({
success: (res) => {
/*
* res.authsetting = {
* "scope.userinfo": true,
* "scope.userlocation": true
* }
*/
}
})