const _my = require("../../__antmove/api/index.js")(my); const wx = _my; // components/face_verify/face_verify.js import international from "../../international/appointment_scence/index"; import { foreignAuthentication } from "../../utils/api/make_appointment"; const face = require("../../utils/faceCheck/faceCheck"); const { throttle } = require("/utils/throttle/throttle") // const getThree = require("/utils/getThree/zfb_getThree") // import { iotVspInit, iotVspUniqueId } from '/utils/ioTVsp/index' // const getPhone = require("../../utils/getPhone/wx_getPhone"); var verify = require("../../utils/util/util"); const util = require("../../utils/func/request"); const { isCardID, isPhone, isChineseWord, desensitization, isCornet } = require("../../utils/util/util"); const app = getApp(); Component({ options: { observers: true, lifetimes: false }, /** * 组件的属性列表 */ properties: { title: { type: String, value: "人员信息" }, language: { type: String, value: "ch" }, isDisabled: { type: Boolean, value: false }, userInfo: { type: Object }, companyName: { value: null }, type: { value: null } }, /** * 组件的初始数据 */ data: { international: international, //国际化语言包 username: "", idNumber: "", phone: "", userId: null, avatar: null }, /** * 组件的方法列表 */ methods: { authResult(e) { if (app.data.language === "ch") { this.setData({ username: e.detail.username, idNumber: e.detail.idNumber, phone: e.detail.phone, avatar: e.detail.avatar, userId: e.detail.userId }) } else { this.setData({ phone: e.detail.phone }) } setTimeout(() => { this.Certification() }, 800) }, goOCR() { let { username, idNumber, phone } = this.data; if (phone) { this.data.flag = 2; app.data.phone = phone; wx.navigateTo({ url: "/pages/ocr/ocr" }); } else { wx.showToast({ icon: "none", title: "Please obtain the phone number first" }); } }, /// 认证 Certification() { let { username, idNumber, phone } = this.data; if (app.data.language === "en") { this.goOCR() } else { if (username && idNumber && phone) { //(过审专用,禁止删除)- start // if (username == "曾英皓" && idNumber == "330821199603150212") { // app.data.fake = true; // app.data.userInfo = { // username: username, // idNumber: idNumber, // phone: phone, // userId: 42553, // avatar: "../../../static/comment/avator_no.png" // }; // wx.setStorageSync("userInfo", app.data.userInfo); // this.triggerEvent("certificationState", true); // return; // } //(过审专用,禁止删除)- end this.submit(); } else { wx.showToast({ icon: "none", title: "请将个人信息填写完整!" }); } } }, //实名认证 submit: throttle(function () { const that = this wx.requestSubscribeMessage({ entityIds: ["f72f5029f53e44c6baa45b8a0716ac0c", "9d4ddcd78f66444482ad66c5a262ffed"], success(res) { // if(res.behavior === 'subscribe') { // that.doZFBFaceCheck() // } }, complete: res => { that.doZFBFaceCheck() } }) // const that = this; // let { // username, // idNumber, // phone // } = this.data; // let orgId = app.data.adminId; // face.intoFace_wxrlxf(username, idNumber, phone, orgId = "00").then(() => { // that.data.flag = 1; // }).catch(err => {}); // wx.requestSubscribeMessage({ // entityIds: ["f72f5029f53e44c6baa45b8a0716ac0c", "9d4ddcd78f66444482ad66c5a262ffed"], // success(res) { // if(res.behavior === 'subscribe') { // face.intoFace_wxrlxf(username, idNumber, phone, orgId = "00").then(() => { // that.data.flag = 1; // }).catch(err => {}); // } // } // }); }, 5000), // 微信验证人脸 async doFaceCheck() { let taskId = wx.getStorageSync("wx_dateCode"); // taskId = '00-883306131355291200';//本地 if (!taskId) return; let res = await face.getFace_wxrlxf("/api/next/doQueryFaceSuccess", "get", { taskId: taskId }); if (res.data.status === true) { let userInfo = res.data; wx.setStorageSync("userInfo", userInfo); app.data.userInfo = userInfo; this.triggerEvent("certificationState", true); } else { this.triggerEvent("certificationState", false); } }, // 支付宝验证人脸 async doZFBFaceCheck() { let { username, idNumber, phone, userId } = this.data; let res = await face.getFace_wxrlxf("/api/next/ZFBConfirmFace", "post", { idNumber, phone, username, userId }); if (res.data.status === true) { let userInfo = res.data; userInfo.avatar = this.data.avatar || null app.data.userInfo = userInfo // iotVspUniqueId(userInfo.idNumber, userInfo.username, userInfo.phone, userInfo.avatar).then((res) => { // if(res) { // this.setCertificationState(true) // } // }) this.setCertificationState(true) } else { this.setCertificationState(false) } }, // 设置授权状态 setCertificationState(isSuccess) { if(isSuccess) { wx.setStorageSync("userInfo", app.data.userInfo) this.triggerEvent("certificationState", true) } else { app.data.userInfo = null this.triggerEvent("certificationState", false) } }, // 外宾确认或修改 update() { let data = { username: this.data.username, idNumber: this.data.idNumber, phone: this.data.phone || app.data.phone, avatar: this.data.userInfo.avatar, userId: this.data.userInfo.userId }; if (data.idNumber && data.phone && data.username) { foreignAuthentication(data).then(res => { if (res.code === 200) { wx.setStorageSync("userInfo", res.data); app.data.userInfo = res.data; wx.setStorageSync("language", "cn"); this.triggerEvent("certificationState", true); } else { wx.showToast({ icon: "none", title: res.msg }); } }); } else { wx.showToast({ icon: "none", title: "Please complete your personal information!" }); } }, getAuthCode: function () { const that = this // getThree((userInfo) => { // if (app.data.language === "ch") { // this.setData({ // username: userInfo.data.username, // idNumber: userInfo.data.idNumber, // phone: userInfo.data.phone, // avatar: userInfo.data.avatar, // userId: userInfo.data.userId // }) // } else { // this.setData({ // phone: userInfo.data.phone // }) // } // this.Certification() // }) }, //获取手机号 // getPhoneNumber(e) { // const that = this // my.getPhoneNumber({ // success: function(res) { // console.info('getPhoneNumber--->', res) // // 测试用 // const phone = '13173661471' // that.setData({ // "warnPhone.status": true, // phone: phone // }); // app.data.phone = phone; // // let encryptedData = res.response // // getPhone(encryptedData).then(phone => { // // if (phone) { // // this.setData({ // // "warnPhone.status": true, // // phone: phone // // }); // // app.data.phone = phone; // // } else { // // wx.showToast({ // // icon: "none", // // title: "网络异常请重新获取哦~" // // }); // // } // // }).catch(err => { // // console.log(err); // // }) // } // }) // }, antmoveAction: function () { //执行时动态赋值,请勿删除 } }, observers: { userInfo: function (userInfo) { if (userInfo) { this.setData({ username: userInfo.username, idNumber: userInfo.idNumber, phone: userInfo.phone, userId: userInfo.userId, avatar: userInfo.avatar }); } } }, lifetimes: { attached: function () { let userInfo = this.data.userInfo; if (userInfo) { this.setData({ username: userInfo.username, idNumber: userInfo.idNumber, phone: userInfo.phone, userId: userInfo.userId }); } } }, pageLifetimes: { show() { if (this.data.flag === 1) { this.data.flag = null; // this.doFaceCheck(); } else if (this.data.flag === 2) { this.data.flag = null; this.triggerEvent("updateState", app.data.temporary_userInfo ? true : false); } } } // rootEvents: { // onReady() { // const that = this // iotVspInit((res) => { // that.setCertificationState(res.success) // my.navigateBack() // }) // } // } })