How does WeChat Mini Program obtain user information and user phone number at the same time

How does WeChat Mini Program obtain user information and user phone number at the same time

When I was writing the login page today, I needed to authorize personal information and mobile phone number, but wouldn’t it be stupid to just put two buttons on the page? ? ?

I simply wrote a mask layer to guide users to authorize their mobile phone numbers.

1. When I click on the WeChat login shortcut, the first thing that is triggered is the WeChat native method of obtaining user information userInfo, and then the mask layer is opened in its success callback...

2. There is a button in the mask layer. This button triggers the native getPhoneNumber method of WeChat to obtain the user's mobile phone number. I don't need to say more about it. . . .

Directly dump the code

<!--Quick Login-->
<button open-type="getUserInfo" @tap="getUserProfile">
    <view class="item column center">
	<image class="iconc" src="/static/img/share/wx.png"></image>
    </view>
</button>
<!--Login pop-up window-->
<view class="modal-mask" catchtouchmove="preventTouchMove" v-if="showModal"></view>
    <view class="modal-dialog" v-if="showModal">
	<view class="modal-content">
	<view><image src='' class='show'></image></view>
	<view >Bind mobile phone number</view>
	<view>Please bind your mobile number before performing this operation</view>  
	<button open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
		<image src='/static/img/share/wx.png' class='iconWx'></image>WeChat user one-click binding </button>
    </view>
</view>
methods: {
    getUserProfile(){
    // It is recommended to use wx.getUserProfile to obtain user information. Developers need to confirm each time they obtain user personal information through this interface. // Developers should properly keep the avatar nicknames quickly filled in by users to avoid repeated pop-ups. wx.getUserProfile({
            desc: 'Used to complete member information', //Declare the purpose of obtaining user personal information, which will be displayed in the pop-up window later, please fill in carefully success: (res) => {
		this.showDialogBtn(); //Call the pop-up window to get the mobile phone number with one click (written by myself)
            }
	})
    },
    // Display the pop-up window for getting the phone number with one click showDialogBtn: function () {
            this.showModal = true
                    },
                    // Hide the pop-up window for getting the phone number with one click hideModal: function () {
                             this.showModal = false
                    },
    //Get the user's phone numbergetPhoneNumber (e) {
        console,log(e.detael)
    },

Summarize

This is the end of this article about how WeChat Mini Programs can obtain user information and user mobile phone numbers at the same time. For more relevant content about how WeChat Mini Programs can obtain user information and mobile phone numbers, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • WeChat applet authorization to obtain user details openid example detailed explanation
  • WeChat applet obtains user information and saves login status
  • WeChat applet to obtain user information and store it in the database operation example
  • How does WeChat Mini Program obtain user information?
  • WeChat Mini Program determines whether the user needs to authorize the acquisition of personal information again
  • Two ways to obtain user information in WeChat applet development

<<:  Detailed explanation of the correct use of the if function in MySQL

>>:  MySQL 8.0.18 Hash Join does not support left/right join left and right join issues

Recommend

More popular and creative dark background web design examples

Dark background style page design is very popular...

How to track users with JS

Table of contents 1. Synchronous AJAX 2. Asynchro...

Detailed steps to use Redis in Docker

1. Introduction This article will show you how to...

How to use vue-video-player to achieve live broadcast

Table of contents 1. Install vue-video-player 2. ...

Steps of an excellent registration process

For a website, it is the most basic function. So l...

The whole process of installing and configuring Harbor1.7 on CentOS7.5

1. Download the required packages wget -P /usr/lo...

JavaScript destructuring assignment detailed explanation

Table of contents concept Array Destructuring Dec...

Use href to simply click on a link to jump to a specified place on the page

After clicking the a tag in the page, you want to ...

How to disable ads in the terminal welcome message in Ubuntu Server

If you are using the latest Ubuntu Server version...

MySQL quick recovery solution based on time point

The reason for writing such an article is that on...

Detailed explanation of MySQL startup options and system variables examples

Table of contents Boot Options Command Line Long ...

Tutorial on building nextcloud personal network disk with Docker

Table of contents 1. Introduction 2. Deployment E...

3 methods to restore table structure from frm file in mysql [recommended]

When mysql is running normally, it is not difficu...

Understand CSS3 Grid layout in 10 minutes

Basic Introduction In the previous article, we in...