Get User Phone Number
Phone
Usage Instructions
Using the Get Phone Number component allows you to obtain the user's phone number during the mini program runtime. The usage is as follows:
Please confirm that the selected application supports mini-program-side building. For specific operations, refer to Create Application Guide.
Add the Get Phone Number component in the editor.
- Create a string variable for the application to store the retrieved phone number.
- Configure a variable assignment event for the Get Phone Number component to assign the returned phone number information to the ordinary variable in Step 3 when user authorization is successful.
- This component only takes effect during the actual runtime of the mini program. Therefore, we add a text component in the editor and bind it to the ordinary variable. When the user clicks the "Get Phone Number" button in the mini program and successfully grants authorization, the text component will display the corresponding phone number information.
- Publish the application to the mini program. You can see that when clicking the "Get Phone Number" button and granting authorization, the text component will display the obtained phone number information.
Component Usage Limitations
This component is only supported on the mini-program side, and the mini-program must be an enterprise entity.
This component must be used in a real mini-program environment to see the actual effect.
Ensure the mini-program has completed WeChat Certification. Go to Certification
Properties
External properties received by the component
Property Name | Property Identifier | Type | Description |
---|
按钮标题(Mini Program) | text | string | 按钮组件的标题 Example: "获取用户手机号" |
按钮风格(Mini Program) | type | string | 按钮组件的风格,相对于普通按钮组件,新增“微信”按钮风格 Example: "wechat" |
按钮大小(Mini Program) | size | string | 按钮的大小 Example: "default" |
Events
Events exposed by the component. You can listen to component events to trigger external actions
Event Name | Event Code | Event Output Parameters event.detail | Applicable Scenarios | Description |
---|
手机号授权成功 | phonesuccess | object
| Mini Program | 弹窗中点击了允许按钮后触发的事件 |
手机号授权失败 | phonefail | Mini Program | 弹窗中点击了拒绝按钮后触发的事件 |