首先是小程序用户端的页面
<camera device-position="{
{position}}" flash="off" binderror="error" style="width: 100%; height: 300px;"></camera>
<view class="weui-cell__ft" >
<switch checked bindchange='switch1Change' style='margin:20rpx;'/>
</view>
<button type="primary" bindtap="takePhoto">刷脸登录</button>
接下来就是当点击刷脸登录时,可以看到绑定了一个事件 takePhone 此时在此事件中调用已经写好的接口在 .js中实现登录
js代码
takePhoto() {
const ctx = wx.createCameraContext()
ctx.takePhoto({
quality: 'high',
success: (res) => {
var tempImagePath = res.tempImagePath;
// console.log(tempImagePath);
wx.showLoading({
title: '正在核验身份....',
})
this.setData({logindisabled:true})
wx.uploadFile({
url: app.globalData.url.login, //仅为示例,非真实的接口地址
filePath: tempImageP

本文介绍了微信小程序如何实现刷脸登录功能。在用户端页面点击刷脸登录按钮后,触发takePhone事件,调用预先编写好的接口进行登录操作。通过详细讲解js代码和接口调用流程,揭示了小程序中人脸识别登录的技术细节。
最低0.47元/天 解锁文章
3202





