E企盈营销工具技术服务商 热线:4006-838-530

支付宝小程序人脸识别认证

E企盈直播平台营销卖货系统

博主最近在做小程序开发, 之前支付宝小程序使用的是芝麻人脸识别认证,因为996,暂时先放代码1.芝麻认证submit(e) {if (gData.isclick) return;gData.isclick = truevar userName = _self.namevar idCard = _self.idCard_self.$api.showLoading();_self.$api.zhimaCreditApply({userName,idCard,}).then(({data}) = {return new Promise(function(resolve, reject) {if (data.resultCode == ‘Y’) {const bizNo = data.bizNo;// 个人支付宝且存在可用于调用芝麻信用的单号就调用人脸识别if (bizNo && _self.userType == “2”)my.startZMVerify({bizNo,success(res) {if (res.passed) {resolve();} else {reject(res.failed_reason);}},fail(err) {reject(err);}});else if (_self.userType == “1”)resolve();elsereject(‘认证失败,请联系客服进行反馈’)} else {reject()}})}).then(() = {if (_self.userType == “2”) {return _self.$api.zhimaCreditConfirm({})} else if (_self.userType == “1”) {return Promise.resolve({})} else {return Promise.reject()}}).then(({data}) = {if (_self.userType == “1” || data.resultCode == ‘Y’) {console.log(data)uni.showToast({icon: “none”,title: “认证成功”,success: () = {_self.doLogin({anew: 1,success() {uni.navigateBack();}})}})}uni.hideLoading();gData.isclick = false}, function(err) {uni.hideLoading();gData.isclick = falseif (err)_self.$api.alert(err);})},// 提交芝麻认证授权申请(姓名与身份证号码)function zhimaCreditApply(obj) {const userName = obj.userName;const idCard = obj.idCard;qcloud.request({url: api + ‘user/zhimaCreditApply’,data: {userName,idCard},login: true,success(res) {obj.res = res;success(obj);},fail(err) {obj.err = err;fail(obj)}});}2. 支付宝认证介绍:支付宝人脸识别认证是收费的功能,之前芝麻认证要下架,替换使用//原芝麻认证  现支付宝认证submit() {if (isclick) {return isclick = true;}var that = this;var _self = thislet userName = that.data.namelet idCard = that.data.idcardlet tradeNo = that.tradeNo().toString() //订单号let bizId = tradeNo;let userId = that.data.userId;console.log(userId)mcdj.zhimaCreditApply({userName,idCard,success(data) {if (data.resultCode == ‘Y’) {my.ap.faceVerify({bizId: tradeNo, //业务请求的唯一标识,需要保证唯一性bizType: ‘2’, //业务场景参数,必须填写‘2’,代表刷脸认证  success: (res) = {var zimId = res.zimId;mcdj.faceCheck({‘zimId’: zimId,’bizId’: bizId,’userId’: userId,success: (e) = {let msg = _self.IdMsg(e.data.code)mcdj.showToast(msg)console.log(e)},fail: () = {mcdj.showToast(‘服务器繁忙,请稍后再试’)}})},fail: () = {mcdj.showToast(‘服务器繁忙,请稍后再试’)}});}}})},//生成 唯一订单号tradeNo() {const now = new Date()const year = now.getFullYear();let month = now.getMonth() + 1;let day = now.getDate();let hour = now.getHours();let minutes = now.getMinutes();let seconds = now.getSeconds();let milliseconds = now.getMilliseconds(); //毫秒String(month).length 2 ? (month = “0” + month) : month;String(day).length 2 ? (day = “0” + day) : day;String(hour).length 2 ? (hour = “0” + hour) : hour;String(minutes).length 2 ? (minutes = “0” + minutes) : minutes;String(seconds).length 2 ? (seconds = “0” + seconds) : seconds;String(milliseconds).length 2 ? (milliseconds = “0” + milliseconds) : milliseconds;const yyyyMMddHHmmss = year + ” + month + ” + day + ” + hour + ” + minutes + ” + seconds + ” + milliseconds;var ob = yyyyMMddHHmmss + Math.random().toString(36).substr(2, 9);console.log(ob)return ob;},//根据身份验证返回码,提示信息IdMsg(e) {e = parseInt(e)let msg = ”; //返回if (e == 10000) {msg = ‘支付宝认证成功’mcdj.setStorageSync(‘face’, ‘1’) //1是 通过 0是未完成my.navigateBack();} else {msg = “认证失败,请联系客服进行反馈”mcdj.setStorageSync(‘face’, ‘0’)}return msg;},// 提交认证授权申请(姓名与身份证号码)function zhimaCreditApply(obj) {const userName = obj.userName;const idCard = obj.idCard;qcloud.request({url: api + ‘user/zhimaCreditApply’,data: {userName,idCard},login: true,success(res) {obj.res = res;success(obj);},fail(err) {obj.err = err;fail(obj)}});}

E企盈系统专业开发:直播系统,直播平台系统源码,小程序,商城版小程序,分销小程序,小程序定制,微分销,微商,微信分销,微信分销商城,微信分销系统,微信分销管理,微信分销平台,微商代理系统,E企盈是专业的直播小,E企盈是专业的直播小程序,公众号分销系统,营销系统,社群私域流量卖货系统技术开发商,热线:4006-838-530
赞(0) 打赏
未经允许不得转载:E企盈小程序开发-热线:4006-838-530 » 支付宝小程序人脸识别认证
分享到: 更多 (0)
E企盈小程序直播营销卖货系统
E企盈直播平台营销卖货系统

评论 抢沙发

E企盈小程序开发

联系我们联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏