zoukankan      html  css  js  c++  java
  • 微信小程序 wx.getUserProfile 获取用户信息

    注意事项:
      基础库2.10.4后支持
      只能用户主动点击触发
    作用:
      获取用户信息。
      每次请求都会弹出授权窗口,用户同意后返回 userInfo对象
      成功时返回:
    userInfo:{
      avatarUrl: "头像链接"
      city: "城市"
      country: "国家"
      gender: 1(性别1/0)
      language: "语言"
      nickName: "昵称"
      province: "省份"
    }
    wxml
    <view class="box">
      <button class="btn" catchtap="GetUserInfo">登录</button>
    </view>

    js

     1  GetUserInfo(e) {
     2     wx.getUserProfile({
     3       desc:'正在获取',//不写不弹提示框
     4       success:function(res){
     5         console.log('获取成功: ',res)
     6       },
     7       fail:function(err){
     8         console.log("获取失败: ",err)
     9       }
    10     })
    11   }

    效果图

    时间若流水,恍惚间逝去
  • 相关阅读:
    bzoj1257
    bzoj1833
    bzoj3505
    bzoj2226
    bzoj1263
    bzoj2429
    bzoj1854
    bzoj3555
    bzoj1877
    放两个模版
  • 原文地址:https://www.cnblogs.com/alanshreck/p/14488906.html
Copyright © 2011-2022 走看看