<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          小程序 wx.getUserProfile

          共 1533字,需瀏覽 4分鐘

           ·

          2021-09-03 00:20

          最近微信小程序?qū)τ趯徍诵〕绦蛱岢隽藥в衱x.login、wx.getUserInfo接口的調(diào)整,并提出了一個新的接口供開發(fā)者調(diào)用

          下圖是對于新的接口的官方文檔詳情

          https://developers.weixin.qq.com/miniprogram/dev/api/open-api/user-info/wx.getUserProfile.html

          Wxml

          <view class="container">  <view class="userinfo">    <block wx:if="{{!hasUserInfo}}">      <button wx:if="{{canIUseGetUserProfile}}" bindtap="getUserProfile"> 獲取頭像昵稱 </button>      <button wx:else open-type="getUserInfo" bindgetuserinfo="getUserInfo"> 獲取頭像昵稱 </button>    </block>    <block wx:else>      <image bindtap="bindViewTap" class="userinfo-avatar" src="{{userInfo.avatarUrl}}" mode="cover"></image>      <text class="userinfo-nickname">{{userInfo.nickName}}</text>    </block>  </view></view>


          js

          Page({  data: {    userInfo: {},    hasUserInfo: false,    canIUseGetUserProfile: false,  },  onLoad() {    if (wx.getUserProfile) {      this.setData({        canIUseGetUserProfile: true      })    }  },  getUserProfile(e) {    // 推薦使用wx.getUserProfile獲取用戶信息,開發(fā)者每次通過該接口獲取用戶個人信息均需用戶確認    // 開發(fā)者妥善保管用戶快速填寫的頭像昵稱,避免重復(fù)彈窗    wx.getUserProfile({      desc: '用于完善會員資料', // 聲明獲取用戶個人信息后的用途,后續(xù)會展示在彈窗中,請謹慎填寫      success: (res) => {        this.setData({          userInfo: res.userInfo,          hasUserInfo: true        })      }    })  },  getUserInfo(e) {    // 不推薦使用getUserInfo獲取用戶信息,預(yù)計自2021年4月13日起,getUserInfo將不再彈出彈窗,并直接返回匿名的用戶個人信息    this.setData({      userInfo: e.detail.userInfo,      hasUserInfo: true    })  },})


          瀏覽 65
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          分享
          舉報
          評論
          圖片
          表情
          推薦
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          分享
          舉報
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  国产精品视频1000 | 婷婷久久福利 | 免费黄片网 | 精品无人区无码乱码毛片国产 | 亚洲高清视频在线观看 |