// rlxf_index.js var verify = require('../../../utils/util/util') const face = require('../../../utils/faceCheck/faceCheck') const getPhone = require('../../../utils/getPhone/wx_getPhone'); const util = require('../../../utils/func/request') const { getContextByAdminId, realAuthenticationType, getAdminConfig, // getUserWhiteByCardIdEx, getPicture, getAdminInfoById, doConfirmFaceNotifyNew, } = require('../../../utils/api/api'); const { pro_baseUrl_wxrlxf, } = require('../../../utils/func/request'); const { throttle } = require('../../../utils/throttle/throttle'); const { weixinTestFuncAdmin, weixinTestFuncSloveOrgId } = require('../../../utils/testForWeixin/index'); import { getWxCode } from '../../../utils/util' const app = getApp() Page({ /** * 页面的初始数据 */ data: { checked:false, // 胶囊位置信息 StatusBar: app.globalData.StatusBar, CustomBar: app.globalData.CustomBar, Custom: app.globalData.Custom, // 基础路径 baseUrl: pro_baseUrl_wxrlxf, // 输入信息 inputName: '', inputIdcard: '', phoneNumber: '', cardIdEx: '', warnName: { //姓名校验信息 status: null, errMsg: null }, warnIdcard: { //身份证校验信息 status: null, errMsg: null }, warnPhone: 1, //手机号校验信息 isShowApplet: null, isNeedRealAuthentication: true, //是否需要实名认证 disabledSubmit: true, disabledSubmitScan: false, xcx_title: 'http://hanghui.oss-cn-gz-ysgzlt-d01-a.ltops.gzdata.com.cn/photo/20221206/ad963f8c73e547fab9a8a8284ef095dc.jpg', xcx_bg: 'http://hanghui.oss-cn-gz-ysgzlt-d01-a.ltops.gzdata.com.cn/photo/20221206/95ad88c62007442dbe0276b8217ea786.jpg', mobileAutoInputFlag: 2, needLoginList: [], //登录参数列表 needPhone: null, //是否输入手机号 0-否 1-需要 needPhoto: null, //是否需要照片 0-否 1-需要 }, //获得姓名 getInputName(e) { let { warnName, inputName } = this.data; inputName = e.detail.value if (e.detail.value) { warnName.status = true } else { warnName.status = false warnName.errMsg = '您输入的姓名不可以为空!' }; this.setData({ warnName, inputName }) this.disabledSubmitFun() }, //获得身份证号 getInputIdcard(e) { let { warnIdcard, inputIdcard } = this.data inputIdcard = e.detail.value let res = verify.isCardID(inputIdcard); if (res.state) { warnIdcard.status = true; /** * 开始 * 测试身份证号,若要修改,请联系负责人 */ var that = this; weixinTestFuncSloveOrgId.call(that, inputIdcard); /** * 结束 */ } else { warnIdcard.status = false warnIdcard.errMsg = res.data }; this.setData({ warnIdcard, inputIdcard }); this.disabledSubmitFun() }, // 获取卡号 getInputCardIdEx(e) { this.setData({ cardIdEx: e.detail.value }) this.disabledSubmitFun() }, // 输入手机号 getInputPhone(e) { let phoneNumber = e.detail.value let res = verify.isCornet(phoneNumber); if (!res.state) { this.setData({ warnPhone: res.data }) } else { this.setData({ warnPhone: 1, phoneNumber: e.detail.value }) } this.disabledSubmitFun() }, //获取手机号 async getPhoneNumber(e) { wx.showLoading({ title: '获取中...', mask: true }); var result = await getPhone(e); wx.hideLoading() this.setData({ phoneNumber: result }) this.disabledSubmitFun() }, //查看照片 watch() { wx.previewImage({ urls: [this.data.baseUrl + '/file/img/instruction.png'], }) }, //实名认证 submit: throttle(async function () { /** * 开始 * 测试身份证号,若要修改,请联系负责人 */ const isAdmin = await weixinTestFuncAdmin(this.data) if (isAdmin) return; /** * 结束 */ // if (this.data.wxLoginType === 2) { // await this.getUserWhiteByCardIdEx() // } let { inputName, inputIdcard, phoneNumber, // cardIdEx, orgId, isShowApplet, org, isNeedRealAuthentication, needPhoto, } = this.data // if (!inputIdcard) { // return // } let isAge = 1 if (isNeedRealAuthentication) { isAge = await this.judgeAge(inputIdcard, orgId) } else { isAge = 2 } // isAge:1人脸认证 2:拍照 if (isAge == 1) { face.intoFace_wxrlxf(inputName, inputIdcard, phoneNumber, orgId).then(() => { this.data.flag = 1 }).catch(err => {}) } else if (isAge == 2) { // 是否需要照片 if (needPhoto) { wx.navigateTo({ url: '/pages/faceCheck/faceCheck?orgId=' + orgId + '&&inputName=' + inputName + '&&inputIdcard=' + inputIdcard + '&&phoneNumber=' + phoneNumber + '&&isShowApplet=' + isShowApplet + '&&org=' + org // + '&&cardIdEx=' + cardIdEx }) } else { this.doConfirmFaceNotifyNew() } } else { console.log(isAge) wx.showToast({ title: isAge, icon: 'none', }) } }, 5000), //验证人脸 async doFaceCheck() { let taskId = wx.getStorageSync('wx_dateCode'); // taskId = '00-2024052714115242855'; if (!taskId) return; let res = await face.getFace_wxrlxf('/api/next/doQueryFaceSuccess', 'get', { taskId: taskId }); if (res.data.status === true) { res.data.org = this.data.org; res.data.orgId = this.data.orgId; // res.data.cardIdEx = this.data.cardIdEx; res.data.options = this.data.options; wx.setStorageSync('userInfo', res.data); this.changePage(true); } else { wx.showModal({ title: '提示', content: '未查询到认证结果,请重新认证!', showCancel: false, }) } }, doConfirmFaceNotifyNew(img) { let data = { avatar: null, idNumber: this.data.inputIdcard, // cardIdEx: this.data.cardIdEx, username: this.data.inputName, phone: this.data.phoneNumber, type: 1, code: wx.getStorageSync('wxCode') } console.log(data); doConfirmFaceNotifyNew(data).then(res => { if (res.code == 200) { res.data.org = this.data.org res.data.orgId = this.data.orgId // res.data.cardIdEx = this.data.cardIdEx wx.setStorageSync('userInfo', res.data); getWxCode() this.changePage(true) } else { wx.showToast({ title: res.msg, icon: 'none', }) } }) }, // 卡号认证-通过卡号获取用户信息 // async getUserWhiteByCardIdEx() { // let data = { // cardIdEx: this.data.cardIdEx, // adminId: this.data.orgId // } // await getUserWhiteByCardIdEx(data).then(res => { // if (res.code === 200) { // this.setData({ // inputName: res.data.name, // inputIdcard: res.data.idNumber, // }) // } else { // wx.showToast({ // title: res.msg, // icon: 'none' // }) // } // }) // }, // 判断年龄 judgeAge(idNumber, adminId) { wx.showLoading({ title: '提交中...', }) return new Promise((resolve, reject) => { realAuthenticationType({ idNumber, adminId }).then(res => { wx.hideLoading() if (res.code == 200) { return resolve(res.data) } else { return reject(res.msg) }; }) }) }, //获取是否有自定义字段 getContextByAdminId(orgId) { let that = this; this.data.isShowApplet = null; wx.showLoading({ title: '检查账号配置中..', }) return getContextByAdminId(orgId).then(res => { that.data.isShowApplet = res.data; }).finally(() => { wx.hideLoading() }) }, //跳转页面 (是否缓存进入) changePage(showModal) { if (this.data.isShowApplet) { wx.navigateTo({ url: '/pages/wx_airport/rlxf_userMsg/index?orgId=' + this.data.orgId + '&org=' + this.data.org + '&showModal=' + showModal, }) } else { wx.reLaunch({ url: '/pages/wx_airport/rlxf_pass/rlxf_pass?orgId=' + this.data.orgId + '&org=' + this.data.org + '&showModal=' + showModal, }) } }, goProblem() { wx.navigateTo({ url: '/pages/wx_airport/problem_report/index?adminId=' + this.data.orgId, }) }, goViewPDF(e) { let type = e.currentTarget.dataset.type console.log(type) wx.downloadFile({ url: `https://tx.hz-hanghui.com:8088/yx-fyzd/file/${type}.pdf`, success: (res) => { console.log(res) const filePath = res.tempFilePath; wx.showLoading({ title: '打开中~', mask: true }); console.log(filePath) wx.openDocument({ filePath: filePath, // fileType: 'pdf', success: function(res) { console.log(res) wx.hideLoading() }, fail: (err) => { wx.hideLoading() if (err.errMsg == 'openDocument:fail filetype not supported') { uni.showModal({ title: '不支持预览的文件类型', content: '指定文件类型,有效值 doc, xls, ppt, pdf, docx, xlsx, pptx', showCancel: false, confirmText: '确认', }); } } }); }, fail: function(err) { uni.hideLoading() console.log('fail:' + JSON.stringify(err)); } }); }, onAgreeAgreement(e) { let checked = e.currentTarget.dataset.checked this.setData({ checked: checked }) }, // 获取账号的配置信息 async getAdminConfig(adminId) { await getAdminConfig(adminId).then(res => { this.setData({ needPhone: res.data.whitelistAppPhone, needPhoto: res.data.whitelistAppPhoto, needLoginList: res.data.whitelistAppLoginList, isNeedRealAuthentication: res.data.whitelistAppRealname, }) }) }, // 提交按钮是否禁用 disabledSubmitFun() { let disabledSubmit = false let { needLoginList, warnName, warnIdcard, phoneNumber, // cardIdEx, } = this.data if (needLoginList.indexOf(1) > -1) { if (warnName.status) { disabledSubmit = false } else { disabledSubmit = true } } if (!disabledSubmit && needLoginList.indexOf(2) > -1) { if (warnIdcard.status) { disabledSubmit = false } else { disabledSubmit = true } } if (!disabledSubmit && needLoginList.indexOf(3) > -1) { if (phoneNumber) { disabledSubmit = false } else { disabledSubmit = true } } // if (!disabledSubmit && needLoginList.indexOf(4) > -1) { // if (cardIdEx) { // disabledSubmit = false // } else { // disabledSubmit = true // } // } this.setData({ disabledSubmit }) }, // 获取背景,标题 getPicture() { getPicture().then(res => { this.setData({ xcx_bg: res.data.xcx_bg, xcx_title: res.data.xcx_title }) }) }, // 获取账号信息 getAdminInfoById(orgId) { getAdminInfoById(orgId).then(res => { this.setData({ mobileAutoInputFlag: res.data.mobileAutoInputFlag }) }) }, /** * 生命周期函数--监听页面加载 */ onLoad: async function (options) { this.getPicture() let json = {}; if (!options.isJump) { var url = decodeURIComponent(options.q); json = verify.GetQueryJson(url); } else { json = options } // json = { // orgId: 106, // org: '公司测试', // // orgId: 104, // // org: '天波测试', // type: 0, //0通用1常客 // // disinfectAreaId: 5 // }; // json = { // orgId: 120, // org: 'Lynn测试', // type: 0, //0通用1常客 // }; let moduleContent = { msg: '未检测到区域码,请扫正确的二维码进入小程序哦~', show: false } if (!('orgId' in json)) { moduleContent.show = true } if (json.orgId == '' || String(json.orgId) == 'null' || String(json.orgId) == 'undefined') { moduleContent.show = true moduleContent.msg = '区域码数据已失效,请联系管理员更新二维码'; } if (moduleContent.show) { wx.showModal({ title: '提示', content: moduleContent.msg, showCancel: false }); this.setData({ disabledSubmitScan: true }) return }; //保留二维码的参数 let urlString = '' for (let i in json) { urlString += `${i}=${json[i]}&` } this.data.options = urlString this.data.orgId = json.orgId; this.data.org = json.org; app.data.type = json.type ? json.type : null await this.getAdminInfoById(json.orgId) await this.getContextByAdminId(json.orgId); await this.getAdminConfig(json.orgId) this.disabledSubmitFun() // 判断缓存 var userInfo = wx.getStorageSync('userInfo'); console.log(userInfo); console.log(json.orgId); if (userInfo) { if (userInfo.orgId != json.orgId) { // userInfo.createTime = "" wx.removeStorageSync('userInfo') } else { this.changePage(false); } // userInfo.orgId = json.orgId; // userInfo.org = json.org; // userInfo.options = urlString // wx.setStorageSync('userInfo', userInfo); } if ('disinfectAreaId' in json) { app.data.disinfectAreaId = json.disinfectAreaId } }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { if (this.data.flag === 1) { this.data.flag = 0; this.doFaceCheck(); } }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })