About the WeChat Mini Program to obtain the profile picture and nickname

I don't know why WeChat has been obtaining from developers: WeChat profile picture + WeChat nickname. I have always held a restrictive attitude, and I have been modifying the interface calling method!

open-type="getUserInfo" will be discontinued on April 13, 2021

wx.getUserInfo will be discontinued on April 28, 2021

wx.getUserProfile will be discontinued on November 8, 2022

But if you publish before the interface is deactivated , it can still be used normally!

So far, the beginning of 2023, to start using the new WeChat interface to obtain WeChat profile pictures and nicknames, we start:

WeChat applet wxml side:

<!--获取头像-->
<button open-type="chooseAvatar" bind:chooseavatar="onChooseAvatar"></button> 
<!--获取昵称-->
<input type="nickname" class="weui-input" placeholder="请输入昵称"/>

WeChat applet JS side:

onChooseAvatar(e) {
    console.log(e.detail.avatarUrl)
  }

But so far, there are still problems with the port:

1: Click the chooseAvatar button to report an error.

When you click to get the avatar, do not select the avatar, and click cancel, the chooseAvatar:fail cancel event will appear

But WeChat official did not give this description, and the reference operation of this method.

2: open-type="chooseAvatar" The avatar e.detail.avatarUrl obtained by this method is a temporary image and cannot be used externally:

For example: http://tmp/FmDQRKhbce0Ie239b08f13955f6b1b97ab8c53a649f5.jpeg

The temporary avatar will be released in the WeChat applet after it is closed and restarted.

So far, if you want to store customer avatars in your non-cloud development background, it is recommended to use the pictures uploaded by customers as avatars. There is no problem in obtaining nicknames.

If there is a better way, please leave a message!

Guess you like

Origin blog.csdn.net/munchmills/article/details/128588450