400-028-6601
建站资讯

网站建设资讯

为你提供网站建设行业资讯、网站优化知识、主机域名邮箱、网站开发常见问题等。

创新互联小程序教程:微信小程序API调起客户端小程序设置界面

wx.openSetting(OBJECT)


基础库版本 1.1.0 开始支持,低版本需做兼容处理

成都创新互联是专业的曲麻莱网站建设公司,曲麻莱接单;提供成都网站制作、做网站,网页设计,网站设计,建网站,PHP网站建设等专业做网站服务;采用PHP框架,可快速的进行曲麻莱网站开发网页制作和功能扩展;专业做搜索引擎喜爱的网站,专业的做网站团队,希望更多企业前来合作!

调起客户端小程序设置界面,返回用户设置的操作结果

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
     * }
     */
  }
})

OpenSettingButton wx.createOpenSettingButton(string type, string text, string image, Object style)


支持版本 >= 2.0.7

创建打开设置页面的按钮。

参数

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 是 背景颜色
borderColor string 是 边框颜色
borderWidth number 是 边框宽度
borderRadius number 是 边框圆角
textAlign string 是 文本的水平居中方式
fontSize number 是 字号
lineHeight number 是 文本的行高

style.textAlign 的合法值:

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

返回值

OpenSettingButton

示例代码

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
    }
})

wx.getSetting(OBJECT)


基础库 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
     * }
     */
  }
})


当前文章:创新互联小程序教程:微信小程序API调起客户端小程序设置界面
网页路径:http://hnjierui.cn/article/dhsiihh.html

其他资讯