Mall WeChat Mini Programs authorized user information and mobile phone number of the correct process is what?

such as the title.
should I write two pages to click to get or write a page to authorize user information and then directly authorize to obtain the mobile phone number?

Sep.22,2021

generally, as soon as you enter Mini Program, you will jump out of the authorization request dialog box. If the user refuses authorization, you will jump to the corresponding page. But I think if you only need to get user information in some business, you can first determine whether there is user information when users operate these businesses that must authorize user information. If not, pop up the authorization request to obtain user information.


generally place a button to get it, and if the user is not authorized, jump to the page written by the user and let the user fill in the mobile phone number manually.

//wxml
<button open-type="getPhoneNumber" bindgetphonenumber='handler'></button>

//js
handler(e){
    let {encryptedData, iv} = e.detail;
    if(encryptedData && iv) {
        //
    } else {
        //
    }
}

official document: get the mobile number

Menu