// pages/temporary_prove/index.js // index.js var verify = require('../../../utils/util/util') const face = require('../../../utils/faceCheck/faceCheck') const { pro_baseUrl_wxrlxf } = require('../../../utils/func/request'); const app = getApp() Page({ /** * 页面的初始数据 */ data: { // 胶囊位置信息 StatusBar: app.globalData.StatusBar, CustomBar: app.globalData.CustomBar, Custom: app.globalData.Custom, // 基础路径 baseUrl: pro_baseUrl_wxrlxf, inputName: '', inputIdcard: '', warnName: 1, //姓名校验信息 warnIdcard: 1, //身份证校验信息 disableSubmit: true }, //获得姓名 getInputName (e) { this.setData({ warnName: 1, inputName: e.detail.value }); if (!e.detail.value) { this.setData({ warnName: '您输入的姓名不可以为空!' }) } else { this.setData({ warnName: 2 }) } }, //获得身份证号 getInputIdcard (e) { var result = verify.isCardID(e.detail.value); if (!result.state) { this.setData({ warnIdcard: result.data }) } else { this.setData({ warnIdcard: 2, inputIdcard: e.detail.value }) } }, //实名认证 submit() { var a = this.data.inputName; var b = this.data.inputIdcard; var taskId = this.taskId; face.intoFace(a,b,taskId).then((suc) => { this.data.flag = 1 }, (err) => { console.log(err) }) }, //验证人脸 async doFaceCheck () { var taskId = this.taskId var res = await face.getFace('/nsapi/is_idc_ok','post',{ taskId: taskId }); //todo--人脸结果 if (res && res.success === 1) { wx.redirectTo({ url: '/pages/wx_airport/rlxf_pass/rlxf_pass', }) } else { wx.showModal({ title: '提示', content: '认证失败请重新认证!', showCancel: false, }) } }, //查看照片 watch () { wx.previewImage({ urls: [this.data.baseUrl+'/file/img/instruction.png'], }) }, /** * 生命周期函数--监听页面加载 */ onLoad: async function (options) { // this.taskId = "9000000020210602100757" var that = this var url = decodeURIComponent(options.q); var json = verify.GetQueryJson(url); if('machineCode' in json){ this.taskId = json.machineCode var result = await face.checkNotice(this.taskId) if (result.scan === 1) { wx.showModal({ title: '提示', content: '该二维码已被占用,请耐心等待其他用户完成认证哦~', showCancel: false }); that.setData({ disableSubmit: false }) } else { face.notice(this.taskId) } } else { wx.showModal({ title: '提示', content: '未检测到设备码,请扫正确的二维码进入小程序哦~', showCancel: false }); that.setData({ disableSubmit: false }) return } }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { if (this.data.flag === 1) { this.doFaceCheck(); } }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })