小程序获取用户授权

<button @click="getuserinfo">授权登录</button>

// 获取用户授权信息
getuserinfo(e) {
  uni.getUserProfile({
    desc: "获取你的昵称、头像、地区及性别",
    success: (res) => {
      this.getUserId(res.userInfo.avatarUrl, res.userInfo.nickName);
    },
    fail: (res) => {
      //拒绝授权
      uni.showToast({
        title: "您拒绝了请求,不能正常使用小程序",
        icon: "error",
        duration: 2000,
      });
      return;
    },
  });
},

  

posted @ 2022-04-08 09:21  小万子呀  阅读(184)  评论(0编辑  收藏  举报