const app = getApp() Page({ data: { src: app.globalData.imgUrl + '/image/bg1.jpg', name: '', IdNumber: '', url: '', }, nameInput: function(e) { this.setData({ name: e.detail.value, }) }, IdNumberInput: function(e) { this.setData({ IdNumber: e.detail.value, }) }, onLoad: function(option) { this.setData({ url: decodeURIComponent(option.url), }) }, submit: function(e) { var that = this; var name = this.data.name; var idCardNumber = this.data.IdNumber; if (!name) { return app.showModal("请填写姓名!"); } if (!idCardNumber) { return app.showModal("请填写身份证号码!"); } wx.checkIsSupportFacialRecognition({ success() { wx.startFacialRecognitionVerify({ name: name, idCardNumber: idCardNumber, success() { // //成功调用后台方法 var openId = wx.getStorageSync("openId"); wx.request({ url: app.globalData.url + '/api/ma/user/update', method: 'POST', header: { "Content-Type": "application/json" }, data: { "wxUnionId": openId, 'userName': name, 'idcard': idCardNumber, }, success: function(res) { if (res.data.code == 0) { if (!res.data.data.mobile) { wx.showModal({ title: '信息补充确认', content: '为了更加便捷的为您服务,请补充您的个人信息', cancelText: '回到首页', confirmText: '前往补充', success: function (res) { if (res.confirm) { wx.navigateTo({ url: '../personInfo/personInfo?url=' + encodeURIComponent(that.data.url), }) } else if (res.cancel) { wx.redirectTo({ url: '../index/index', }) } } }) } else { wx.navigateTo({ url: that.data.url, }) } } else { wx.showToast({ title: '网络失败,请稍后再试', icon: 'none' }) } } }) }, fail(res) { //失败给出提示 } }) }, fail(res) { wx.showToast({ title: '暂不支持人脸识别,请升级微信后重试', icon: 'none', duration: 2000 }) wx.navigateTo({ url: that.data.url, }) } }) } })