首页
学习
活动
专区
圈层
工具
发布

【微信小程序开发】使用button标签的open-type=getUserInfo引导用户去授权

一、 前言 小程序官方文档,上面说明 > wx.getUserInfo(OBJECT) 注意:此接口有调整,使用该接口将不再出现授权弹窗,请使用 open-type="getUserInfo..."> > 引导用户主动进行授权操作 > 当用户未授权过,调用该接口将直接报错 当用户授权过,可以使用该接口获取用户信息 如上文,之前用户未授权过时,调用wx.getUserInfo会调出授权框...index.wxml <button     wx:if="{{canIUse}}"     open-type="getUserInfo"     bindgetuserinfo="bindGetUserInfo...canIUse: wx.canIUse('button.open-type.getUserInfo')   },   onLoad: function() {     // 查看是否授权     wx.getSetting...({       success: function(res){         if (res.authSetting['scope.userInfo']) {           wx.getUserInfo

2.2K10
  • 您找到你想要的搜索结果了吗?
    是的
    没有找到

    微信小程序-用户授权获取信息

    从2018年4月30日开始,小程序与小游戏的体验版、开发版调用 wx.getUserInfo 接口,将无法弹出授权询问框,默认调用失败(但不意味着 wx.getUserInfo 不能用了)。...官网文档:open-data开放展示用户信息组件 2、使用 button 组件,并将 open-type 指定为 getUserInfo 类型,获取用户基本信息(重要) 在之前使用wx.getUserInfo...不受限制,在js任何地方都可以使用,可能是为了防止滥用它,微信就改成必须通过button组件来获取 用户点击按钮授权 wxml: open-type="getUserInfo" bindgetuserinfo...="getUserInfo">登陆 js: getUserInfo: function (e) { const userInfo = e.detail.userInfo;...console.log("用户已经授权") } }) } } }) }, //点击登陆 授权 getUserInfo

    1.9K60

    【微信官方】获取用户信息方案介绍

    开发者默认将 wx.login 和 wx.getUserInfo 绑定使用,这个是由于我们一开始的设计缺陷和实例代码导致: getUserInfo必须通过wx.login 在后台生成session_key...获取用户信息组件介绍 ✦✦02✦✦ 组件变化: open-type 属性增加 getUserInfo :用户点击时候会触发 bindgetuserinfo 事件。...新增事件 bindgetuserinfo :当 open-type 为 getUserInfo 时,用户点击会触发。...示例: open-type="getUserInfo" bindgetuserinfo="userInfoHandler"> Click me 和 wx.getUserInfo...getUserInfo 和 login ✦✦04✦✦ 很多开发者会把login和getUserInfo捆绑调用当成登录使用,其实login已经可以完成登录,可以建立账号体系了,getUserInfo只是获取额外的用户信息

    2.1K80

    微信小程序官方组件展示之表单组件button源码

    使用前建议先阅读使用指引 1.2.0 getPhoneNumber 获取用户手机号,可以从 bindgetphonenumber 回调中获取到用户信息,具体说明 (*小程序插件中不能使用*) 1.2.0 getUserInfo...open-type="contact"时有效 1.5.0 app-parameter string 否 打开 APP 时,向 APP 传递的参数,open-type=launchApp时有效 1.9.5...="contact"时有效 1.5.0 bindgetuserinfo eventhandle 否 用户点击该按钮时,会返回获取到的用户信息,回调的 detail 数据与wx.getUserInfo...返回的一致,open-type="getUserInfo"时有效 1.3.0 bindcontact eventhandle 否 客服消息回调,open-type="contact"时有效 1.5.0...否 当使用开放能力时,发生错误的回调,open-type=launchApp时有效 1.9.5 bindopensetting eventhandle 否 在打开授权设置页后回调,open-type=

    1.2K30

    如何在小程序中获取用户信息

    wx.getUserInfo 接口(不推荐使用) wx.getUserInfo接口已经不推荐使用,官方也有相关说明。本文将仅仅对该接口做简单介绍。首先,修改index.wxml文件如下。...open-type="getUserInfo" bindgetuserinfo="bindGetUserInfo">授权登录 接下来,打开index.js文件,修改代码如下...index.js下面相关的函数,不过值得注意的是,open-type="getUserInfo" bindgetuserinfo="bindGetUserInfo"这两个参数是小程序button组件特有的特性...详见小程序官方文档,当open-type参数为getUserInfo时bindgetuserinfo就可以回调相关函数,并返回相关数据,这里我们通过console.log将数据打印在控制台出来。...index.wxml <button wx:if="{{button_status}}" open-type="getUserInfo" bindgetuserinfo="bindGetUserInfo

    8.4K81
    领券