|
@@ -1,6 +1,6 @@
|
1
|
1
|
import React, { useState, useEffect } from 'react'
|
2
|
2
|
import { Input, Picker } from '@tarojs/components'
|
3
|
|
-import Taro from '@tarojs/taro'
|
|
3
|
+import Taro, { Current } from '@tarojs/taro'
|
4
|
4
|
import request, { apis } from '@/utils/request'
|
5
|
5
|
import Page from '@/layouts'
|
6
|
6
|
import { useModel } from '@/store'
|
|
@@ -10,6 +10,7 @@ import './index.less'
|
10
|
10
|
|
11
|
11
|
export default function YeZhuRenZheng () {
|
12
|
12
|
|
|
13
|
+ const [PageFrom] = useState(Current.router.params.from)
|
13
|
14
|
const { user } = useModel('user')
|
14
|
15
|
const [FormData, setFormData] = useState({ RealName: '', IdCard: '', Phone: '' })
|
15
|
16
|
const [PhoneCode, setPhoneCode] = useState('')
|
|
@@ -70,11 +71,24 @@ export default function YeZhuRenZheng () {
|
70
|
71
|
return /^1(3\d|4\d|5\d|6\d|7\d|8\d|9\d)\d{8}$/g.test(FormData.Phone)
|
71
|
72
|
}
|
72
|
73
|
|
|
74
|
+ const CheckIdCard = () => { // 校验身份证
|
|
75
|
+ const regIdCard = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/
|
|
76
|
+ if (!regIdCard.test(FormData.IdCard)) {
|
|
77
|
+ return false
|
|
78
|
+ } else {
|
|
79
|
+ return true
|
|
80
|
+ }
|
|
81
|
+ }
|
|
82
|
+
|
73
|
83
|
const ToGetPhoneCode = () => {
|
74
|
84
|
if (!CheckPhone()) {
|
75
|
85
|
Taro.showToast({ title: '手机号填写错误', icon: 'none' })
|
76
|
86
|
return false
|
77
|
87
|
}
|
|
88
|
+ if (!CheckIdCard()) {
|
|
89
|
+ Taro.showToast({ title: '身份证号填写错误', icon: 'none' })
|
|
90
|
+ return false
|
|
91
|
+ }
|
78
|
92
|
if (CodeTimerNum - 0 === 60) {
|
79
|
93
|
request({ ...apis.getPhoneCode, params: { tel: FormData.Phone } }).then(() => {
|
80
|
94
|
Taro.showToast({ title: '验证码已发送', icon: 'none' })
|
|
@@ -142,7 +156,12 @@ export default function YeZhuRenZheng () {
|
142
|
156
|
}
|
143
|
157
|
}).then((res) => {
|
144
|
158
|
Taro.showToast({ title: '添加认证成功', icon: 'none' })
|
145
|
|
- Taro.navigateTo({ url: `/pages/WoDe/YeZhuShenHe/index?id=${res.id}` })
|
|
159
|
+ if (PageFrom === 'popup') {
|
|
160
|
+ setUser({ ...user, verifyStatus: 'certification_in_progress' })
|
|
161
|
+ Taro.navigateBack({ delta: 1 })
|
|
162
|
+ } else {
|
|
163
|
+ Taro.navigateTo({ url: `/pages/WoDe/YeZhuShenHe/index?id=${res.id}` })
|
|
164
|
+ }
|
146
|
165
|
setDataLock(false)
|
147
|
166
|
}).catch((res) => {
|
148
|
167
|
Taro.showToast({ title: res, icon: 'none' })
|