当前位置:网站首页>Applet: how to get the user's mobile number in the plug-in
Applet: how to get the user's mobile number in the plug-in
2022-06-12 15:57:00 【Front end life of Lvan】
background
We know , It cannot be used in applet plug-ins open-type relevant API Of , Official documents There are also detailed instructions 
But if we want to make a login related plug-in , Is to get the user's mobile number , How do you do that , It can be used Refer to the custom component function of the applet
Introduce the custom component functions of the reference applet
Part of a plug-in ( Whether it's a component or a page ) You can pass in a component to render through an applet .
practice
Small program end
Introducing plug-ins
"plugins": {
"auth-login": {
"version": "dev",
"provider": "wxxxxxxxx",
"genericsImplementation": {
"auth-login-default": {
// Put this component (get-phone-number-btn) To the plug-in page (auth-login-default) Rendering
"get-phone-number-btn": "components/get-phone-number-btn/index"
}
}
}
},
Follow this path in the applet components/get-phone-number-btn/index , Create a new component
index.js
Component({
properties: {
show: {
type: Boolean,
value: false
},
phoneStyle: {
type: String,
value: ''
}
},
methods: {
getPhoneNumber (e) {
console.log('e', e)
this.triggerEvent('getPhoneNumber', e.detail)
}
}
})
index.wxml
<button wx:if="{
{ show }}" class="btn-com ok" open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber" style="{
{
phoneStyle }}"> Wechat authorized login </button>
index.json
{
"component": true,
"usingComponents": {
}
}
Plug in side
For example, there is a page on the plug-in side , It's called auth-login-default, Can be in plugin.json View in .
plugin.json
{
"publicComponents": {
},
"pages": {
"auth-login-default": "pages/auth-login/index"
},
"main": "index.js"
}
"auth-login-default": "pages/auth-login/index" The code in this page is as follows :
index.wxml
<text> I am the original code of the plug-in </text>
// I am a component passed in by an applet
<get-phone-number-btn show="{
{ loginCode && !token && checked }}" bind:getPhoneNumber="getPhoneNumber" phoneStyle="width: 100%;height: 88rpx;line-height: 88rpx;text-align: center;border-radius: 44rpx;border: none;font-size: 32rpx;border: none;outline: none;background: #02C160;color: #fff;" />
index.json
"componentGenerics": {
"get-phone-number-btn": true
}
index.js
Page({
async getPhoneNumber (e) {
// Get your mobile number
console.log(e.detail)
}
})
effect
Final , We see this plug-in page (auth-login-default) The effect of 
After clicking, you can also adjust the pop-up window of the authorized mobile phone number ~
边栏推荐
- Idea Encyclopedia (Reprinted)
- Two implementation methods of generic interface
- 当编程纳入到高考。。。
- 如何使用Grafana轻松实现OVL数据可视化
- Broadcast and multicast (tcp/ip details volume 1/2)
- 小程序:如何在插件中获取用户手机号
- Project training of Software College of Shandong University rendering engine system basic renderer (VII)
- Dongmingzhu talks about batteries: the most essential thing is safety
- IGMP报文(TCP/IP详解卷1/卷2)
- org. xml. sax. SAXParseException; lineNumber: 63; columnNumber: 10; The definition of "mapper" in the related type must be matched with "(CAC
猜你喜欢

Introduction and download website of common data of GIS, remote sensing, hydrology and Geography (2), supplementary~

Golang collaboration scheduling (I): Collaboration Status

IGMP message (tcp/ip details volume 1/ Volume 2)

Project training of Software College of Shandong University rendering engine system radiation pre calculation (VIII)

小飞页升级变智能修复Bug更快速了

当编程纳入到高考。。。

Idea Encyclopedia (Reprinted)

Servlet知识详解(2)

同源?跨域?如何解决跨域?

< 山东大学软件学院项目实训 > 渲染引擎系统——辐射预计算(九)
随机推荐
Homology? Cross domain? How to solve cross domain problems?
Remote control of other computers -- detailed tutorial
当编程纳入到高考。。。
Use and understanding of generics
ER diagram made by StarUML based on the last student achievement management system
RARP summary (tcp/ip explanation volume 1/2)
Divide training set, test set and verification set
记一篇IT培训日记067-好人感恩,坏人无错
Singleton mode instance
What is reflection-- The soul of frame design
The common hand, the original hand and the excellent hand from the sum of Fibonacci sequence
[jvm learning] class loading subsystem
POSTMAN-REST Client插件的应用
Install RHEL 7/8 (red hat) virtual machine (Reprint)
任务 输出密雪冰城主题曲 0612
Project training of Software College of Shandong University rendering engine system radiation pre calculation (VIII)
C语言 分割bin文件程序
Village to village communication (and collective search)
< 山东大学软件学院项目实训 > 渲染引擎系统——基础渲染器(四)
VIM installation and common commands