From aa117c3b45b0a7770185fceb4d9efefd9642b054 Mon Sep 17 00:00:00 2001 From: dminyi <1301963064@qq.com> Date: Fri, 13 Sep 2024 11:27:38 +0800 Subject: [PATCH] Merge branch 'master' of http://120.79.193.119:9090/r/gzzfw/frontEnd/gzDyh into master --- gz-wxparty/pages/realNameAuthentication/index.js | 363 ++++++++++++++++++++++++++++----------------------- 1 files changed, 197 insertions(+), 166 deletions(-) diff --git a/gz-wxparty/pages/realNameAuthentication/index.js b/gz-wxparty/pages/realNameAuthentication/index.js index 0e1203a..e77624d 100644 --- a/gz-wxparty/pages/realNameAuthentication/index.js +++ b/gz-wxparty/pages/realNameAuthentication/index.js @@ -3,182 +3,213 @@ // 实名认证 function realNameAuthenticationApi(submitData) { - return $$.request({ url: 'paUser/realAuth', type: 'post', submitData, service: 'cust' }); + return $$.request({ + url: 'paUser/realAuth', + type: 'post', + submitData, + service: 'cust' + }); } Page({ - /** - * 页面的初始数据 - */ - backNum: 1, // 如果从完善资料进入则返回两级到个人中心 - data: { - steps: ['完善信息', '刷脸认证'], - submitData: { - trueName: '', - mobile: '', - idcardType: '09_00015-1', - idcardTypeName: '身份证', - idcard: '', - prov: '', - provName: '', - city: '', - cityName: '', - area: '', - areaName: '', - road: '', - roadName: '', - village: '', - villageName: '', - addr: '', - agree: false, - }, - popup: {}, // 下拉弹出框数据 - }, + /** + * 页面的初始数据 + */ + backNum: 1, // 如果从完善资料进入则返回两级到个人中心 + data: { + steps: ['完善信息', '刷脸认证'], + submitData: { + trueName: '', + mobile: '', + idcardType: '09_00015-1', + idcardTypeName: '身份证', + idcard: '', + prov: '', + provName: '', + city: '', + cityName: '', + area: '', + areaName: '', + road: '', + roadName: '', + village: '', + villageName: '', + addr: '', + agree: false, + }, + popup: {}, // 下拉弹出框数据 + }, - // 展示弹出层 - handleShowPopup(e) { - this.setData({ popup: e.detail }); - }, + // 展示弹出层 + handleShowPopup(e) { + this.setData({ + popup: e.detail + }); + }, - // 关闭弹出层 - handleClosePopup() { - this.data.popup.visible = false; - this.setData({ popup: this.data.popup }); - }, + // 关闭弹出层 + handleClosePopup() { + this.data.popup.visible = false; + this.setData({ + popup: this.data.popup + }); + }, - // 下拉框确认选择 - handleConfirmPicker({ detail }) { - let type = this.data.popup.type; - let value = detail.detail.value; - let arr = []; - this.data.popup.visible = false; - if (type === 'location') { - arr = [ - ['prov', 'provName'], - ['city', 'cityName'], - ['area', 'areaName'], - ['road', 'roadName'], - ['village', 'villageName'], - ]; - arr.forEach((x, t) => { - this.data.submitData[x[0]] = value[t]?.value || ''; - this.data.submitData[x[1]] = value[t]?.label || ''; - }); - } else { - if (type === 'cardType') { - arr = ['idcardType', 'idcardTypeName']; - } else if (type === 'sex') { - arr = ['sex', 'sexName']; - } - arr.forEach((x, t) => { - this.data.submitData[x] = value[t === 0 ? 'value' : 'label']; - }); - } - this.setData({ popup: this.data.popup, submitData: this.data.submitData }); - }, + // 下拉框确认选择 + handleConfirmPicker({ + detail + }) { + let type = this.data.popup.type; + let value = detail.detail.value; + let arr = []; + this.data.popup.visible = false; + if (type === 'location') { + arr = [ + ['prov', 'provName'], + ['city', 'cityName'], + ['area', 'areaName'], + ['road', 'roadName'], + ['village', 'villageName'], + ]; + arr.forEach((x, t) => { + this.data.submitData[x[0]] = value[t]?.value || ''; + this.data.submitData[x[1]] = value[t]?.label || ''; + }); + } else { + if (type === 'cardType') { + arr = ['idcardType', 'idcardTypeName']; + } else if (type === 'sex') { + arr = ['sex', 'sexName']; + } + arr.forEach((x, t) => { + this.data.submitData[x] = value[t === 0 ? 'value' : 'label']; + }); + } + this.setData({ + popup: this.data.popup, + submitData: this.data.submitData + }); + }, - // form的change - handleChange(e) { - const { key, value } = e.detail; - this.data.submitData[key] = value; - this.setData({ submitData: this.data.submitData }); - }, + // form的change + handleChange(e) { + const { + key, + value + } = e.detail; + this.data.submitData[key] = value; + this.setData({ + submitData: this.data.submitData + }); + }, - // 修改picker的列时触发 - handleChangeColumns(e) { - if (this.data.popup.type === 'location') { - let selectData = $$.changeLocation(e, this.selectComponent('#personal-data-dom').location, this.data.popup.selectData); - this.setData({ popup: { ...this.data.popup, selectData } }); - } - }, + // 修改picker的列时触发 + handleChangeColumns(e) { + if (this.data.popup.type === 'location') { + let selectData = $$.changeLocation(e, this.selectComponent('#personal-data-dom').location, this.data.popup.selectData); + this.setData({ + popup: { + ...this.data.popup, + selectData + } + }); + } + }, - // 进行刷脸认证 - handleRealName() { - let submitData = this.data.submitData; - let msg = ''; - if (!submitData.trueName) { - msg = '请输入姓名'; - } else if (!submitData.idcard) { - msg = '请输入证件号码'; - } else if (!$$.mobileRegExp(submitData.mobile)) { - msg = '请输入正确的手机号码'; - } else if (!submitData.agree) { - msg = '请勾选确认信息'; - } - if (msg) { - $$.showToast({ title: msg }); - return false; - } - let that = this; - wx.checkIsSupportFacialRecognition({ - success() { - wx.startFacialRecognitionVerify({ - name: that.data.submitData.trueName, - idCardNumber: that.data.submitData.idcard, - success() { - console.log('识别成功'); - that.realNameAuthentication(); - }, - fail() { - $$.showToast({ title: '抱歉!识别失败,请稍后重试' }); - }, - }); - }, - fail(res) { - $$.showToast({ title: '抱歉!请求失败,稍后重试' }); - }, - }); - }, - - // 上传实名认证数据 - async realNameAuthentication() { - $$.showLoading(); - const res = await realNameAuthenticationApi(this.data.submitData); - $$.hideLoading(); - if (res.type) { - wx.getStorage({ - key: 'userInfo', - success(res2) { - res2.data.realStatus = '1'; - wx.setStorage({ key: 'userInfo', data: res2.data }); - }, - }); - $$.showToast({ icon: 'success', title: '实名认证成功' }); - wx.removeStorage({ - key: 'access_token' + // 进行刷脸认证 + handleRealName() { + let submitData = this.data.submitData; + let msg = ''; + if (!submitData.trueName) { + msg = '请输入姓名'; + } else if (!submitData.idcard) { + msg = '请输入证件号码'; + } else if (!$$.mobileRegExp(submitData.mobile)) { + msg = '请输入正确的手机号码'; + } else if (!submitData.agree) { + msg = '请勾选确认信息'; + } + if (msg) { + $$.showToast({ + title: msg + }); + return false; + } + let that = this; + wx.checkIsSupportFacialRecognition({ + success() { + wx.startFacialRecognitionVerify({ + name: that.data.submitData.trueName, + idCardNumber: that.data.submitData.idcard, + success() { + console.log('识别成功'); + that.realNameAuthentication(); + }, + fail() { + $$.showToast({ + title: '抱歉!识别失败,请稍后重试' }); - await $$.sleep(); - wx.navigateBack({ - delta: this.backNum || 1, - }); - } - }, + }, + }); + }, + fail(res) { + $$.showToast({ + title: '抱歉!请求失败,稍后重试' + }); + }, + }); + }, - // 获取个人信息 - async getUserInfo(e) { - let data = e.detail || {}; - let keys = Object.keys(this.data.submitData); - keys.forEach((x) => { - if (data[x]) { - this.data.submitData[x] = data[x]; - } - }); - this.setData({ submitData: this.data.submitData }); - }, + // 上传实名认证数据 + async realNameAuthentication() { + $$.showLoading(); + const res = await realNameAuthenticationApi(this.data.submitData); + $$.hideLoading(); + if (res.type) { + this.getUserInfo() + $$.showToast({ + icon: 'success', + title: '实名认证成功' + }); + wx.removeStorage({ + key: 'access_token' + }); + await $$.sleep(); + wx.navigateBack({ + delta: this.backNum || 1, + }); + } + }, - // 获取手机号码 - async handleGetPhoneNumber(e) { - let phone = await this.selectComponent('#common-page').handleGetPhoneNumber(e.detail); - this.data.submitData.mobile = phone; - this.setData({ submitData: this.data.submitData }); - }, + // 获取个人信息 + async getUserInfo(e) { + let data = e.detail || {}; + let keys = Object.keys(this.data.submitData); + keys.forEach((x) => { + if (data[x]) { + this.data.submitData[x] = data[x]; + } + }); + this.setData({ + submitData: this.data.submitData + }); + }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - if (options.backNum) { - this.backNum = 2; - } - }, -}); + // 获取手机号码 + async handleGetPhoneNumber(e) { + let phone = await this.selectComponent('#common-page').handleGetPhoneNumber(e.detail); + this.data.submitData.mobile = phone; + this.setData({ + submitData: this.data.submitData + }); + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + if (options.backNum) { + this.backNum = 2; + } + }, +}); \ No newline at end of file -- Gitblit v1.8.0