|
@@ -0,0 +1,194 @@
|
|
1
|
+import Taro, { Component } from '@tarojs/taro';
|
|
2
|
+import './index.scss'
|
|
3
|
+import { AtImagePicker } from 'taro-ui'
|
|
4
|
+import { getDocumentVerify, commitDocumentVerify, editDocumentVerify } from '@services/user'
|
|
5
|
+
|
|
6
|
+import "taro-ui/dist/style/components/image-picker.scss";
|
|
7
|
+import "taro-ui/dist/style/components/icon.scss";
|
|
8
|
+
|
|
9
|
+// import { connect } from '@tarojs/redux'
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+// @connect(state => state.city)
|
|
13
|
+export default class Profile extends Component {
|
|
14
|
+ config = {
|
|
15
|
+ navigationBarTitleText: '我的资料'
|
|
16
|
+ }
|
|
17
|
+
|
|
18
|
+ state = {
|
|
19
|
+ files: [],
|
|
20
|
+ auditStatus: 0,
|
|
21
|
+ documentVerifyId: '',
|
|
22
|
+
|
|
23
|
+ }
|
|
24
|
+ // 审核状态 0审核中 1审核通过 2审核不通过 3未审核
|
|
25
|
+ componentDidMount() {
|
|
26
|
+ this.getProfile()
|
|
27
|
+
|
|
28
|
+ }
|
|
29
|
+
|
|
30
|
+ getProfile() {
|
|
31
|
+ Taro.showLoading()
|
|
32
|
+ getDocumentVerify().then(res => {
|
|
33
|
+ if (!res) {
|
|
34
|
+ this.setState({
|
|
35
|
+ auditStatus: 3,
|
|
36
|
+ })
|
|
37
|
+
|
|
38
|
+ } else {
|
|
39
|
+ console.log(res, "res")
|
|
40
|
+ let imgList = []
|
|
41
|
+ let fileList = res.imgList
|
|
42
|
+ fileList.map((item, index) => {
|
|
43
|
+ let newObj = {}
|
|
44
|
+ newObj.url = item.img
|
|
45
|
+
|
|
46
|
+ imgList.push(newObj)
|
|
47
|
+ }
|
|
48
|
+ )
|
|
49
|
+ this.setState({
|
|
50
|
+ files: imgList,
|
|
51
|
+ auditStatus: res.verifyStatus,
|
|
52
|
+ // resData:res,
|
|
53
|
+ documentVerifyId: res.documentVerifyId,
|
|
54
|
+ })
|
|
55
|
+ }
|
|
56
|
+
|
|
57
|
+ Taro.hideLoading()
|
|
58
|
+ }).catch((err) => {
|
|
59
|
+ Taro.hideLoading()
|
|
60
|
+ setTimeout(() => {
|
|
61
|
+ Taro.showToast({ icon: 'none', title: '获取信息失败' });
|
|
62
|
+ }, 500)
|
|
63
|
+
|
|
64
|
+ });
|
|
65
|
+ }
|
|
66
|
+
|
|
67
|
+ onChange(files) {
|
|
68
|
+ this.setState({
|
|
69
|
+ files
|
|
70
|
+ })
|
|
71
|
+ }
|
|
72
|
+ onFail(mes) {
|
|
73
|
+ console.log(mes)
|
|
74
|
+ }
|
|
75
|
+ onImageClick(index, file) {
|
|
76
|
+ console.log(index, file)
|
|
77
|
+ }
|
|
78
|
+ // 提交图片审核
|
|
79
|
+ commitBtn() {
|
|
80
|
+ console.log(this.state.auditStatus, "this.state.auditStatus")
|
|
81
|
+ if (this.state.files.length == 0) {
|
|
82
|
+ Taro.showToast({ icon: 'none', title: '请先上传图片' });
|
|
83
|
+ } else if (this.state.auditStatus != 3) {
|
|
84
|
+ let imgList = []
|
|
85
|
+ let fileList = this.state.files
|
|
86
|
+ fileList.map((item, index) => {
|
|
87
|
+ let newObj = {}
|
|
88
|
+ newObj.img = item.url
|
|
89
|
+ newObj.sort = index
|
|
90
|
+ imgList.push(newObj)
|
|
91
|
+ }
|
|
92
|
+ )
|
|
93
|
+ // const resData = this.state.resData
|
|
94
|
+
|
|
95
|
+ const payload = {
|
|
96
|
+ // ,
|
|
97
|
+
|
|
98
|
+ // ...resData,
|
|
99
|
+ imgList,
|
|
100
|
+ documentVerifyId: this.state.documentVerifyId
|
|
101
|
+
|
|
102
|
+ }
|
|
103
|
+ editDocumentVerify(payload).then(res => {
|
|
104
|
+ let imgList = []
|
|
105
|
+ let fileList = res.imgList
|
|
106
|
+ fileList.map((item, index) => {
|
|
107
|
+ let newObj = {}
|
|
108
|
+ newObj.url = item.img
|
|
109
|
+
|
|
110
|
+ imgList.push(newObj)
|
|
111
|
+ })
|
|
112
|
+
|
|
113
|
+ this.setState({
|
|
114
|
+ files: imgList,
|
|
115
|
+ auditStatus: res.verifyStatus
|
|
116
|
+ })
|
|
117
|
+ Taro.showToast({ icon: 'none', title: '提交成功' });
|
|
118
|
+ }).catch((err) => {
|
|
119
|
+ Taro.showToast({ icon: 'none', title: err.errMsg || '提交失败' });
|
|
120
|
+ console.error(err);
|
|
121
|
+ });
|
|
122
|
+
|
|
123
|
+ } else {
|
|
124
|
+
|
|
125
|
+ let imgList = []
|
|
126
|
+ let fileList = this.state.files
|
|
127
|
+ fileList.map((item, index) => {
|
|
128
|
+ let newObj = {}
|
|
129
|
+ newObj.img = item.url
|
|
130
|
+ newObj.sort = index
|
|
131
|
+ imgList.push(newObj)
|
|
132
|
+ })
|
|
133
|
+
|
|
134
|
+ commitDocumentVerify(imgList).then(res => {
|
|
135
|
+ let imgList = []
|
|
136
|
+ let fileList = res.imgList
|
|
137
|
+ fileList.map((item, index) => {
|
|
138
|
+ let newObj = {}
|
|
139
|
+ newObj.url = item.img
|
|
140
|
+ imgList.push(newObj)
|
|
141
|
+ })
|
|
142
|
+ this.setState({
|
|
143
|
+ files: imgList,
|
|
144
|
+ auditStatus: res.verifyStatus
|
|
145
|
+ })
|
|
146
|
+ Taro.showToast({ icon: 'none', title: '提交成功' });
|
|
147
|
+
|
|
148
|
+ }).catch((err) => {
|
|
149
|
+ Taro.showToast({ icon: 'none', title: err.errMsg || '提交失败' });
|
|
150
|
+ console.error(err);
|
|
151
|
+ });
|
|
152
|
+ }
|
|
153
|
+ }
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+ render() {
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+ return (
|
|
160
|
+ <View className="profile-page">
|
|
161
|
+ <View className="tip">
|
|
162
|
+ 建议上传相关购房资格等相关资料,最多上传8张,
|
|
163
|
+ </View>
|
|
164
|
+ <View className="tip">
|
|
165
|
+ 审核通过后将获取更多积分、兑换好礼~
|
|
166
|
+ </View>
|
|
167
|
+ {this.state.auditStatus == 1 &&
|
|
168
|
+ <View className="commit-text" >审核通过,快去查看积分吧~</View>
|
|
169
|
+ }
|
|
170
|
+
|
|
171
|
+ <AtImagePicker
|
|
172
|
+ showAddBtn={(this.state.files.length < 8 && this.state.auditStatus == 2) || (this.state.auditStatus == 3 && this.state.files.length < 8)}
|
|
173
|
+ length={2}
|
|
174
|
+ mode="scaleToFill"
|
|
175
|
+ files={this.state.files}
|
|
176
|
+ onChange={this.onChange.bind(this)}
|
|
177
|
+ onFail={this.onFail.bind(this)}
|
|
178
|
+ onImageClick={this.onImageClick.bind(this)}
|
|
179
|
+ />
|
|
180
|
+ {this.state.auditStatus == 2 &&
|
|
181
|
+ <View className="commit-text" >审核未通过,请重新提交!</View>
|
|
182
|
+ }
|
|
183
|
+
|
|
184
|
+ {(this.state.auditStatus == 2 || this.state.auditStatus == 3) &&
|
|
185
|
+ <View className="commit-btn" onClick={this.commitBtn}>提交审核</View>
|
|
186
|
+ }
|
|
187
|
+ {this.state.auditStatus == 0 &&
|
|
188
|
+ <View className="commit-text" >审核中</View>
|
|
189
|
+ }
|
|
190
|
+
|
|
191
|
+ </View>
|
|
192
|
+ )
|
|
193
|
+ }
|
|
194
|
+}
|