|
@@ -1,16 +1,60 @@
|
|
1
|
+import React, { useState } from "react"
|
1
|
2
|
import Taro from "@tarojs/taro"
|
2
|
|
-import { View, Input } from "@tarojs/components"
|
|
3
|
+import { View, Input, Picker } from "@tarojs/components"
|
3
|
4
|
import withLayout from '@/layouts'
|
4
|
5
|
import CustomNav from "@/components/CustomNav"
|
5
|
6
|
import MyButton from "@/components/MyButton"
|
|
7
|
+import { useModel } from "@/store"
|
|
8
|
+import { addBank } from '@/services/bank'
|
6
|
9
|
import './style.less'
|
7
|
|
-import { useState } from "react"
|
|
10
|
+
|
|
11
|
+const bankList = [
|
|
12
|
+ {
|
|
13
|
+ key: 1,
|
|
14
|
+ value: '中国建设银行'
|
|
15
|
+ },
|
|
16
|
+ {
|
|
17
|
+ key: 2,
|
|
18
|
+ value: '中国农业银行'
|
|
19
|
+ },
|
|
20
|
+ {
|
|
21
|
+ key: 3,
|
|
22
|
+ value: '中国银行'
|
|
23
|
+ },
|
|
24
|
+ // {
|
|
25
|
+ // key: 4,
|
|
26
|
+ // value: '中国工商银行'
|
|
27
|
+ // },
|
|
28
|
+ // {
|
|
29
|
+ // key: 5,
|
|
30
|
+ // value: '中国招商银行'
|
|
31
|
+ // },
|
|
32
|
+ // {
|
|
33
|
+ // key: 6,
|
|
34
|
+ // value: '中国交通银行'
|
|
35
|
+ // },
|
|
36
|
+ // {
|
|
37
|
+ // key: 7,
|
|
38
|
+ // value: '中国邮政银行'
|
|
39
|
+ // },
|
|
40
|
+]
|
|
41
|
+const bankContentList = ['中国建设银行', '中国农业银行', '中国银行']
|
8
|
42
|
|
9
|
43
|
export default withLayout((props) => {
|
|
44
|
+ const { person } = useModel('person')
|
10
|
45
|
const [name, setName] = useState()
|
11
|
46
|
const [bankCode, setBankCode] = useState()
|
12
|
|
- const [bankAddress, setBankAddress] = useState()
|
|
47
|
+ const [bankAddress, setBankAddress] = useState(bankContentList[0])
|
13
|
48
|
const [phone, setPhone] = useState()
|
|
49
|
+ const [index, setIndex] = useState(0)
|
|
50
|
+ const [loading, setLoading] = useState(false)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+ const onChange = e => {
|
|
54
|
+ console.log(bankList[e.detail.value])
|
|
55
|
+ setBankAddress(bankContentList[e.detail.value])
|
|
56
|
+ setIndex(e.detail.value)
|
|
57
|
+ }
|
14
|
58
|
const rulePhone = (val) => {
|
15
|
59
|
if (!/^1[0-9]{10}$/.test(val)) {
|
16
|
60
|
Taro.showToast({
|
|
@@ -33,19 +77,24 @@ export default withLayout((props) => {
|
33
|
77
|
}
|
34
|
78
|
const onClick = () => {
|
35
|
79
|
if (name) {
|
36
|
|
- if (bankAddress) {
|
37
|
|
- if (ruleCard(bankCode) && rulePhone(phone)) {
|
|
80
|
+ if (ruleCard(bankCode) && rulePhone(phone)) {
|
|
81
|
+ setLoading(true)
|
|
82
|
+ addBank({ cardNo: bankCode, personId: person.personId, ownerBank: bankAddress, owerName: name, phone: phone }).then(res => {
|
38
|
83
|
Taro.showToast({
|
39
|
84
|
title: '添加成功',
|
40
|
85
|
icon: 'none',
|
41
|
86
|
duration: 2000
|
42
|
87
|
})
|
43
|
|
- Taro.navigateBack({ delta: 1 })
|
44
|
|
- }
|
45
|
|
- } else {
|
46
|
|
- Taro.showToast({
|
47
|
|
- title: '请输入开户行',
|
48
|
|
- icon: 'none',
|
|
88
|
+ setTimeout(() => {
|
|
89
|
+ Taro.navigateBack({ delta: 1 })
|
|
90
|
+ }, 1000)
|
|
91
|
+ }).catch(err => {
|
|
92
|
+ Taro.showToast({
|
|
93
|
+ title: err.message,
|
|
94
|
+ icon: 'none',
|
|
95
|
+ duration: 1000
|
|
96
|
+ })
|
|
97
|
+ setLoading(false)
|
49
|
98
|
})
|
50
|
99
|
}
|
51
|
100
|
} else {
|
|
@@ -65,28 +114,30 @@ export default withLayout((props) => {
|
65
|
114
|
<View className='addCardCell'>
|
66
|
115
|
<View className='cellLeft'>
|
67
|
116
|
<View className='label'>持卡人姓名</View>:</View>
|
68
|
|
- <Input type='text' value={name} onInput={(e) => {()=> setName(e.detail.value) }} placeholder='请输入真实姓名' />
|
|
117
|
+ <Input type='text' value={name} onInput={(e) => setName(e.detail.value)} placeholder='请输入真实姓名' />
|
69
|
118
|
</View>
|
70
|
119
|
<View className='addCardCell'>
|
71
|
120
|
<View className='cellLeft'>
|
72
|
121
|
<View className='label'>卡号</View>:
|
73
|
122
|
</View>
|
74
|
|
- <Input type='number' maxlength='19' value={bankCode} onInput={(e) => { ()=>setBankCode(e.detail.value) }} placeholder='请输入有效卡号' />
|
|
123
|
+ <Input type='number' maxlength='19' value={bankCode} onInput={(e) => setBankCode(e.detail.value)} placeholder='请输入有效卡号' />
|
75
|
124
|
</View>
|
76
|
125
|
<View className='addCardCell'>
|
77
|
126
|
<View className='cellLeft'>
|
78
|
127
|
<View className='label'>开户行</View>:
|
79
|
128
|
</View>
|
80
|
|
- <Input type='text' value={bankAddress} onInput={(e) => { ()=>setBankAddress(e.detail.value) }} />
|
|
129
|
+ <Picker mode='selector' style={{ width: '100%' }} range={bankContentList} onChange={onChange}>
|
|
130
|
+ {bankContentList[index]}
|
|
131
|
+ </Picker>
|
81
|
132
|
</View>
|
82
|
133
|
<View className='addCardCell'>
|
83
|
134
|
<View className='cellLeft'>
|
84
|
135
|
<View className='label'>预留手机号</View>:
|
85
|
136
|
</View>
|
86
|
|
- <Input type='number' maxlength='11' value={phone} onInput={(e) => { ()=>setPhone(e.detail.value) }} placeholder='请输入银行卡预留手机号' />
|
|
137
|
+ <Input type='number' maxlength='11' value={phone} onInput={(e) => setPhone(e.detail.value)} placeholder='请输入银行卡预留手机号' />
|
87
|
138
|
</View>
|
88
|
139
|
<View className='bottomBtn'>
|
89
|
|
- <MyButton value='提现' onClick={onClick} />
|
|
140
|
+ <MyButton loading={loading} value='提现' onClick={onClick} />
|
90
|
141
|
</View>
|
91
|
142
|
</View>
|
92
|
143
|
</View>
|