From 2e4d56e2ed95cb0f336522216fedc37167fb446d Mon Sep 17 00:00:00 2001
From: liuwh <964324856@qq.com>
Date: Mon, 09 Sep 2024 15:26:15 +0800
Subject: [PATCH] 小程序代码提交
---
gz-wxparty/pages/realNameAuthentication/index.js | 376 ++++++++++++++++++++++++++++++-----------------------
1 files changed, 210 insertions(+), 166 deletions(-)
diff --git a/gz-wxparty/pages/realNameAuthentication/index.js b/gz-wxparty/pages/realNameAuthentication/index.js
index 0e1203a..75064e1 100644
--- a/gz-wxparty/pages/realNameAuthentication/index.js
+++ b/gz-wxparty/pages/realNameAuthentication/index.js
@@ -3,182 +3,226 @@
// 实名认证
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) {
+ wx.getStorage({
+ key: 'userInfo',
+ success(res2) {
+ console.log('res2', res2);
+ let nowData = {
+ ...res2.data,
+ realStatus: 1,
+ }
+ wx.setStorage({
+ key: 'userInfo',
+ data: nowData
+ });
+ },
+ });
+ $$.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