|
@@ -11,6 +11,8 @@ import NextStep from './NextStep'
|
11
|
11
|
import { fetch, apis } from '@/utils/request'
|
12
|
12
|
import Captcha from './Captcha'
|
13
|
13
|
import { raiseOrder } from '@/services/project'
|
|
14
|
+import { getCodeMessage } from '@/services/getCode'
|
|
15
|
+import { checkIDCard, isEmpty } from '@/utils/tools'
|
14
|
16
|
|
15
|
17
|
const getRaiseProfile = ({raiseId, salesBatchId, personId}) => {
|
16
|
18
|
const queryString = [
|
|
@@ -23,7 +25,7 @@ const getRaiseProfile = ({raiseId, salesBatchId, personId}) => {
|
23
|
25
|
}
|
24
|
26
|
|
25
|
27
|
const saveRaiseRecord = (record, raise) => {
|
26
|
|
- const data = {
|
|
28
|
+ const payload = {
|
27
|
29
|
...record,
|
28
|
30
|
raiseId: raise.raiseId,
|
29
|
31
|
orgId: raise.orgId,
|
|
@@ -31,8 +33,7 @@ const saveRaiseRecord = (record, raise) => {
|
31
|
33
|
buildingId: raise.buildingId,
|
32
|
34
|
}
|
33
|
35
|
|
34
|
|
- return fetch({ url: `${apis.API_SAVE_RAISE_RECORD}`, method: 'POST', data })
|
35
|
|
-
|
|
36
|
+ return fetch({ url: `${apis.API_SAVE_RAISE_RECORD}`, method: 'POST', payload })
|
36
|
37
|
}
|
37
|
38
|
|
38
|
39
|
@connect(({ user, house }) => ({ ...user, house }), { ...houseActions })
|
|
@@ -47,6 +48,8 @@ export default class raiseMoney extends Component {
|
47
|
48
|
record: {},
|
48
|
49
|
}
|
49
|
50
|
|
|
51
|
+ captchaLock = false
|
|
52
|
+
|
50
|
53
|
// 此页面不支持分享,以及二维码
|
51
|
54
|
componentWillMount(){
|
52
|
55
|
ready.queue(() => {
|
|
@@ -79,11 +82,21 @@ export default class raiseMoney extends Component {
|
79
|
82
|
}
|
80
|
83
|
|
81
|
84
|
loadHouseInfo = (houseId, salesBatchId) => {
|
82
|
|
- const { personId } = this.props.userInfo.person
|
|
85
|
+ const { userInfo, house } = this.props
|
|
86
|
+ const { personId, nickname, idcard, tel, phone } = userInfo.person
|
83
|
87
|
|
84
|
88
|
// 请求认筹信息
|
85
|
89
|
getRaiseProfile({ salesBatchId, personId }).then(res => {
|
86
|
|
- this.setState({ raiseProfile: res, record: res.record || {} })
|
|
90
|
+ this.setState({ raiseProfile: res, record: res.record || { personId, name: nickname, idcard, tel: tel || phone } })
|
|
91
|
+
|
|
92
|
+ // 请求置业顾问列表
|
|
93
|
+ if (!house.consultantList || !house.consultantList.length) {
|
|
94
|
+ this.props.dispatchGetConsultants({
|
|
95
|
+ buildingId: res.buildingId,
|
|
96
|
+ pageSize: 999,
|
|
97
|
+ pageNumber: 1,
|
|
98
|
+ })
|
|
99
|
+ }
|
87
|
100
|
})
|
88
|
101
|
}
|
89
|
102
|
|
|
@@ -172,12 +185,39 @@ export default class raiseMoney extends Component {
|
172
|
185
|
this.setState({
|
173
|
186
|
record: {
|
174
|
187
|
...(this.state.record || {}),
|
175
|
|
- userId: person.personId,
|
|
188
|
+ personId: person.personId,
|
176
|
189
|
[`${key}`]: e.detail.value,
|
177
|
190
|
}
|
178
|
191
|
})
|
179
|
192
|
}
|
180
|
193
|
|
|
194
|
+ //
|
|
195
|
+ prepareGetCaptcha = () => {
|
|
196
|
+ const { record } = this.state
|
|
197
|
+ const disabled = !!record.raiseRecordId
|
|
198
|
+ if (disabled) return false;
|
|
199
|
+
|
|
200
|
+ if (this.captchaLock) {
|
|
201
|
+ Taro.showToast({
|
|
202
|
+ title: '发送中, 请稍后',
|
|
203
|
+ icon: 'none'
|
|
204
|
+ })
|
|
205
|
+ return false;
|
|
206
|
+ }
|
|
207
|
+
|
|
208
|
+ const { tel } = this.state.record || {}
|
|
209
|
+
|
|
210
|
+ if (isEmpty(tel) || tel.length < 11) {
|
|
211
|
+ Taro.showToast({
|
|
212
|
+ title: '请填写正确的手机号',
|
|
213
|
+ icon: 'none'
|
|
214
|
+ })
|
|
215
|
+ return false;
|
|
216
|
+ }
|
|
217
|
+
|
|
218
|
+ return true
|
|
219
|
+ }
|
|
220
|
+
|
181
|
221
|
// 获取验证码
|
182
|
222
|
handleCaptcha = e => {
|
183
|
223
|
const { tel } = this.state.record || {}
|
|
@@ -187,18 +227,38 @@ export default class raiseMoney extends Component {
|
187
|
227
|
title: '请填写手机号',
|
188
|
228
|
icon: 'none'
|
189
|
229
|
})
|
190
|
|
- return;
|
|
230
|
+ return Promise.reject();
|
191
|
231
|
}
|
|
232
|
+
|
|
233
|
+ return new Promise((resolve, reject) => {
|
|
234
|
+ this.captchaLock = true
|
|
235
|
+ getCodeMessage(tel).then(() => {
|
|
236
|
+ Taro.showToast({ title: '发送成功' })
|
|
237
|
+ this.captchaLock = false
|
|
238
|
+ resolve()
|
|
239
|
+ }).catch(() => {
|
|
240
|
+ this.captchaLock = false
|
|
241
|
+ reject()
|
|
242
|
+ })
|
|
243
|
+ })
|
192
|
244
|
}
|
193
|
245
|
|
194
|
246
|
tochooseConsultant() {
|
|
247
|
+ console.log('--------------------------------------')
|
195
|
248
|
Taro.navigateTo({
|
196
|
249
|
url: '/onlineSelling/pages/chooseConsultant/index'
|
197
|
250
|
})
|
198
|
251
|
}
|
|
252
|
+
|
|
253
|
+ getConsultant = () => {
|
|
254
|
+ const { house } = this.props
|
|
255
|
+ return house.chooseConsultant ||(house.consultantList || []).filter(x => x.mine)[0]
|
|
256
|
+ }
|
|
257
|
+
|
199
|
258
|
renderProfile() {
|
200
|
|
- const item = { name: '哈哈哈1', phone: '138541369741', avatar: 'http://img5.imgtn.bdimg.com/it/u=3299138037,391931528&fm=26&gp=0.jpg' }
|
201
|
259
|
const { record } = this.state
|
|
260
|
+ const consultant = this.getConsultant()
|
|
261
|
+ const disabled = !!record.raiseRecordId
|
202
|
262
|
|
203
|
263
|
return (
|
204
|
264
|
<ScrollView scrollY className="container2">
|
|
@@ -210,40 +270,39 @@ export default class raiseMoney extends Component {
|
210
|
270
|
<Text style="color:#FF3C3C;font-size:32rpx;margin-right:8rpx">*</Text>
|
211
|
271
|
姓名
|
212
|
272
|
</View>
|
213
|
|
- <Input className='input' placeholder-style="color:#999" value={record.userName} onInput={this.handleInput.bind(this, 'userName')} type='text' placeholder='请填写真实姓名' />
|
|
273
|
+ <Input className='input' placeholder-style="color:#999" disabled={disabled} value={record.name} onInput={this.handleInput.bind(this, 'name')} type='text' placeholder='请填写真实姓名' />
|
214
|
274
|
</View>
|
215
|
275
|
<View className="profile-item">
|
216
|
276
|
<View className="name">
|
217
|
277
|
<Text style="color:#FF3C3C;font-size:32rpx;margin-right:8rpx">*</Text>
|
218
|
278
|
身份证号
|
219
|
279
|
</View>
|
220
|
|
- <Input className='input' placeholder-style="color:#999" value={record.idcard} onInput={this.handleInput.bind(this, 'idcard')} type='text' placeholder='请填写身份证号' />
|
|
280
|
+ <Input className='input' placeholder-style="color:#999" disabled={disabled} value={record.idcard} onInput={this.handleInput.bind(this, 'idcard')} type='text' placeholder='请填写身份证号' />
|
221
|
281
|
</View>
|
222
|
282
|
<View className="profile-item">
|
223
|
283
|
<View className="name">
|
224
|
284
|
<Text style="color:#FF3C3C;font-size:32rpx;margin-right:8rpx">*</Text>
|
225
|
285
|
手机号
|
226
|
286
|
</View>
|
227
|
|
- <Input className='input' placeholder-style="color:#999" value={record.tel} onInput={this.handleInput.bind(this, 'tel')} type='text' placeholder='请填写手机号' />
|
|
287
|
+ <Input className='input' placeholder-style="color:#999" disabled={disabled} value={record.tel} type='text' onInput={this.handleInput.bind(this, 'tel')} placeholder='请填写手机号' />
|
228
|
288
|
</View>
|
229
|
289
|
<View className="profile-item">
|
230
|
290
|
<View className="name">
|
231
|
291
|
<Text style="color:#FF3C3C;font-size:32rpx;margin-right:8rpx">*</Text>
|
232
|
292
|
验证码
|
233
|
293
|
</View>
|
234
|
|
- <Input className='inputCode' placeholder-style="color:#999" onInput={this.handleCaptcha} type='text' placeholder='请填写验证码' />
|
235
|
|
- <Captcha countdown={5} />
|
|
294
|
+ <Input className='inputCode' placeholder-style="color:#999" type='text' disabled={disabled} onInput={this.handleInput.bind(this, 'captcha')} placeholder='请填写验证码' />
|
|
295
|
+ <Captcha countdown={5} require={this.prepareGetCaptcha.bind(this)} onClick={this.handleCaptcha} />
|
236
|
296
|
</View>
|
237
|
297
|
<View className="profile-flex" style="margin-top:20rpx">
|
238
|
298
|
<View className="title">我的置业顾问信息</View>
|
239
|
|
- <View className="choose" onClick={() => this.tochooseConsultant}>选择置业顾问</View>
|
|
299
|
+ <View className="choose" onClick={this.tochooseConsultant}>选择置业顾问</View>
|
240
|
300
|
</View>
|
241
|
301
|
<ConsultantItem
|
242
|
|
- data={item}
|
|
302
|
+ data={consultant}
|
243
|
303
|
style="padding:30rpx 0;width:690rpx; border-bottom: 1px solid #dcdcdc;"
|
244
|
304
|
type="raiseMoney"
|
245
|
|
- onClick={this.handleItemClick}>
|
246
|
|
- </ConsultantItem>
|
|
305
|
+ />
|
247
|
306
|
</View>
|
248
|
307
|
</ScrollView >
|
249
|
308
|
)
|
|
@@ -264,9 +323,63 @@ export default class raiseMoney extends Component {
|
264
|
323
|
const { record, raiseProfile } = this.state
|
265
|
324
|
const { house } = this.props
|
266
|
325
|
const houseList = house.raiseCart.map(x => x.houseId)
|
|
326
|
+ const disabled = !!record.raiseRecordId
|
|
327
|
+ if (disabled) return Promise.resolve();
|
|
328
|
+
|
|
329
|
+ if (isEmpty(record.name)) {
|
|
330
|
+ Taro.showToast({
|
|
331
|
+ title: '姓名不能为空',
|
|
332
|
+ icon: 'none',
|
|
333
|
+ })
|
|
334
|
+
|
|
335
|
+ return Promise.reject()
|
|
336
|
+ }
|
|
337
|
+
|
|
338
|
+ // 校验身份证号
|
|
339
|
+ if (isEmpty(record.idcard) || !checkIDCard(record.idcard)) {
|
|
340
|
+ Taro.showToast({
|
|
341
|
+ title: '身份证号码不合法',
|
|
342
|
+ icon: 'none',
|
|
343
|
+ })
|
|
344
|
+
|
|
345
|
+ return Promise.reject()
|
|
346
|
+ }
|
|
347
|
+
|
|
348
|
+ // 校验手机号
|
|
349
|
+ if (isEmpty(record.tel) || record.tel < 11) {
|
|
350
|
+ Taro.showToast({
|
|
351
|
+ title: '手机号格式不正确',
|
|
352
|
+ icon: 'none',
|
|
353
|
+ })
|
|
354
|
+ }
|
|
355
|
+
|
|
356
|
+ // 验证码
|
|
357
|
+ if (isEmpty(record.captcha)) {
|
|
358
|
+ Taro.showToast({
|
|
359
|
+ title: '验证码不能为空',
|
|
360
|
+ icon: 'none',
|
|
361
|
+ })
|
|
362
|
+
|
|
363
|
+ return Promise.reject()
|
|
364
|
+ }
|
|
365
|
+
|
|
366
|
+ // 校验置业
|
|
367
|
+ const consultant = this.getConsultant()
|
|
368
|
+ if (!consultant || !consultant.id) {
|
|
369
|
+ Taro.showToast({
|
|
370
|
+ title: '置业顾问不能为空',
|
|
371
|
+ icon: 'none',
|
|
372
|
+ })
|
|
373
|
+ return Promise.reject()
|
|
374
|
+ }
|
267
|
375
|
|
268
|
376
|
return new Promise((resolve, reject) => {
|
269
|
|
- saveRaiseRecord({ ...record, houseList}, raiseProfile).then(() => {
|
|
377
|
+ saveRaiseRecord({
|
|
378
|
+ ...record,
|
|
379
|
+ houseList,
|
|
380
|
+ userId: consultant.userId,
|
|
381
|
+ userName: consultant.name,
|
|
382
|
+ }, raiseProfile).then(() => {
|
270
|
383
|
resolve()
|
271
|
384
|
})
|
272
|
385
|
})
|