微信小程序 - 2023年最新版手机号快捷登录详细教程

前言

最近开发公司手机快捷登录的功能,花费了不少时间,这里附上详细教程。

这里以海底捞小程序的图片为例,如有侵权请联系小编删除。

代码如下

javascript 复制代码
<button open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">手机号快捷登录</button>

getPhoneNumber(e) {
	if (e.detail.errMsg == "getPhoneNumber:ok") {
		this.encryptedData = e.detail.encryptedData;
		this.iv = e.detail.iv;
		this.code = e.detail.code;
		this.Login(); // 这里调用登录/注册的接口
	} else {
	// 点击"不允许"
		uni.showModal({
			title: '提示',
			content: '需要通过授权才能继续,请重新点击并授权!',
			showCancel: false,
			success: function(res) {
				if (res.confirm) {
					console.log('');
				}
			}
		});
	}
}

开发中遇到的问题

1、如果在微信开发者工具弹出下边的提示,不要慌张,用真机预览,其实是生效的。

相关推荐
北极糊的狐10 分钟前
钉钉小程序报错data.formatTime is not a function是因为 axml 模板中不能直接调用 Page 内自定义方法!
java·小程序·钉钉
show4331 天前
多格式导出怎么做?2026免费小程序TXT/SRT实践
开发语言·小程序·c#
AI砖家1 天前
AI编程—微信小程序开发规范
微信小程序·小程序·notepad++·ai编程
show4331 天前
2026小程序端视频转文字技术对比:识别引擎精度实测
小程序·音视频
sam-zy2 天前
微信小程序+ESP8266+Arduino 开发智能插座,有本地OTA功能
微信小程序·小程序
A24207349302 天前
微信小程序开发:常用基础语法与指令详解
微信小程序·小程序·notepad++
黄华SJ520it2 天前
青蓝送水类型社交裂变小程序系统技术拆解
小程序·系统开发
weikecms2 天前
星巴克API接口,星巴克点餐接口开发
大数据·小程序
游戏开发爱好者83 天前
系统状态:专为iPhone和iPad设计的实时系统性能监控工具全面介绍
android·ios·小程序·uni-app·iphone·webview·ipad
2501_915909063 天前
全面解析iOS应用上架到App Store的完整流程与关键注意事项
android·macos·ios·小程序·uni-app·cocoa·iphone