|
@@ -6,9 +6,7 @@ import Poster from './poster'
|
6
|
6
|
import ProjectItem from '../project/item'
|
7
|
7
|
import BackHomeBtn from '@components/BackHomeBtn'
|
8
|
8
|
import getUserPhone from '@utils/getUserPhone'
|
9
|
|
-import AchievePhone from '@components/achievePhone'
|
10
|
9
|
import ready from '@utils/ready'
|
11
|
|
-import { sceneInShare } from '@utils/tools'
|
12
|
10
|
|
13
|
11
|
import { ROLE_CODE } from '@constants/user'
|
14
|
12
|
import { addCardUv, addCardShareNum, favorCard, cancelFavorCard } from '@services/card'
|
|
@@ -27,7 +25,7 @@ import { dispatchProjectDetail } from '@actions/project'
|
27
|
25
|
|
28
|
26
|
export default class Index extends Component {
|
29
|
27
|
config = {
|
30
|
|
- navigationBarTitleText: '个人主页'
|
|
28
|
+ navigationBarTitleText: '个人主页'
|
31
|
29
|
}
|
32
|
30
|
state = {
|
33
|
31
|
cardId: null,
|
|
@@ -37,56 +35,30 @@ export default class Index extends Component {
|
37
|
35
|
actionSheetHide: true, // 控制分享弹窗modal
|
38
|
36
|
recordId: null,
|
39
|
37
|
isSave: false,
|
40
|
|
- bound: false,
|
41
|
38
|
modalStatus: false,
|
42
|
|
- grantPhoneVisible: false, // 授权手机弹框
|
43
|
39
|
}
|
44
|
40
|
|
45
|
41
|
componentWillMount() {
|
46
|
42
|
ready.queue(() => {
|
|
43
|
+ const router = Taro.getStorageSync('router')
|
|
44
|
+ const id = this.$router.params.id || router.query.id || '4604a792d575eb8187711625bd88832c'
|
47
|
45
|
|
48
|
|
- // 分享场景需要先授权手机, 再授权头像
|
49
|
|
- const options = wx.getLaunchOptionsSync()
|
50
|
|
- if (sceneInShare(options.scene)) {
|
51
|
|
- const { person = {} } = this.props.userInfo || {}
|
52
|
|
- if ((person.tel || person.phone) && (person.avatarurl || '').indexOf('wx.qlogo.cn') === -1) {
|
53
|
|
- Taro.reLaunch({ url: '/pages/auth/index' })
|
54
|
|
- return
|
55
|
|
- }
|
56
|
|
-
|
|
46
|
+ if(router.query.id){
|
57
|
47
|
this.setState({
|
58
|
|
- grantPhoneVisible: true,
|
59
|
|
- })
|
|
48
|
+ cardId: id,
|
|
49
|
+ modalStatus: true
|
|
50
|
+ }, this.loadCardDetail)
|
|
51
|
+ }else{
|
|
52
|
+ this.setState({
|
|
53
|
+ cardId: id,
|
|
54
|
+ modalStatus: false
|
|
55
|
+ }, this.loadCardDetail)
|
60
|
56
|
}
|
61
|
57
|
|
62
|
|
- this.initPageData()
|
|
58
|
+ addCardUv(id)
|
63
|
59
|
})
|
64
|
60
|
}
|
65
|
61
|
|
66
|
|
- initPageData() {
|
67
|
|
- const router = Taro.getStorageSync('router')
|
68
|
|
- const id = this.$router.params.id || router.query.id
|
69
|
|
-
|
70
|
|
- if (router.query.id) {
|
71
|
|
- this.setState({
|
72
|
|
- cardId: id,
|
73
|
|
- modalStatus: true
|
74
|
|
- }, this.loadCardDetail)
|
75
|
|
- } else {
|
76
|
|
- this.setState({
|
77
|
|
- cardId: id,
|
78
|
|
- modalStatus: false
|
79
|
|
- }, this.loadCardDetail)
|
80
|
|
- }
|
81
|
|
-
|
82
|
|
- addCardUv(id)
|
83
|
|
- }
|
84
|
|
-
|
85
|
|
- componentWillReceiveProps(nextProps) {
|
86
|
|
- const { userInfo: { person: { phone, tel } } } = nextProps
|
87
|
|
- this.handleModalConfirm(tel || phone)
|
88
|
|
- }
|
89
|
|
-
|
90
|
62
|
componentWillUnmount() {
|
91
|
63
|
const { recordId } = this.state
|
92
|
64
|
recordId && updatePoint(recordId)
|
|
@@ -102,7 +74,7 @@ export default class Index extends Component {
|
102
|
74
|
loaded: true,
|
103
|
75
|
isSave: res.isSave
|
104
|
76
|
})
|
105
|
|
- let buildingId = (res.projects || [])[0]
|
|
77
|
+ let buildingId = res.projects[0]
|
106
|
78
|
if (buildingId) {
|
107
|
79
|
dispatchProjectDetail(buildingId)
|
108
|
80
|
}
|
|
@@ -291,7 +263,7 @@ export default class Index extends Component {
|
291
|
263
|
resolve(posterData)
|
292
|
264
|
return
|
293
|
265
|
}
|
294
|
|
- const { userInfo: { person, miniApp }, projectDetail: { buildingId }, cardInfo } = this.props
|
|
266
|
+ const { userInfo: { person }, projectDetail: { buildingId }, cardInfo } = this.props
|
295
|
267
|
const { id } = cardInfo
|
296
|
268
|
const { personId } = person
|
297
|
269
|
const payload = {
|
|
@@ -299,7 +271,7 @@ export default class Index extends Component {
|
299
|
271
|
"page": 'pages/card/index',
|
300
|
272
|
}
|
301
|
273
|
getMiniQrcode(payload).then(qrcode => {
|
302
|
|
- let data = Object.assign({ qrcode, miniAppName: miniApp.name }, cardInfo)
|
|
274
|
+ let data = Object.assign({ qrcode }, cardInfo)
|
303
|
275
|
resolve(data)
|
304
|
276
|
})
|
305
|
277
|
})
|
|
@@ -349,48 +321,25 @@ export default class Index extends Component {
|
349
|
321
|
})
|
350
|
322
|
}
|
351
|
323
|
|
352
|
|
- handleModalConfirm(phoneNumber) {
|
|
324
|
+ handleModalConfirm() {
|
353
|
325
|
const {
|
354
|
|
- cardInfo: { id, projects = [] },
|
355
|
|
- userInfo: { person: { phone, tel, personType, avatarurl } }
|
|
326
|
+ cardInfo: { id, projects },
|
|
327
|
+ userInfo: { person: { phone, tel } }
|
356
|
328
|
} = this.props
|
357
|
329
|
|
358
|
|
- if (personType === ROLE_CODE['CONSULTANT']) {
|
359
|
|
- return
|
360
|
|
- }
|
361
|
|
-
|
362
|
330
|
const buildingId = projects[0]
|
363
|
|
- const realPhone = phoneNumber || phone || tel
|
364
|
|
-
|
365
|
|
- // TODO:
|
366
|
|
- // 此处使用头像控制, 后期需要去掉这个条件
|
367
|
|
- if (realPhone && id && buildingId && !this.state.bound && (avatarurl || '').indexOf('wx.qlogo.cn') > -1) {
|
368
|
|
- const payload = {
|
369
|
|
- realtyConsultant: id, //报备人 置业顾问
|
370
|
|
- buildingId,
|
371
|
|
- phone: realPhone
|
372
|
|
- }
|
373
|
|
-
|
374
|
|
- reportClient(payload).then(res => {
|
375
|
|
- this.hideModal()
|
376
|
|
- this.setState({ bound: true })
|
377
|
|
-
|
378
|
|
- if (res !== 'bound') {
|
379
|
|
- Taro.showToast({
|
380
|
|
- title: '恭喜您绑定成功'
|
381
|
|
- })
|
382
|
|
- }
|
383
|
|
- }).catch(err => {
|
384
|
|
- console.error(err)
|
385
|
|
- this.setState({ bound: true })
|
386
|
|
-
|
387
|
|
- Taro.showToast({
|
388
|
|
- title: err.message || err,
|
389
|
|
- icon: 'none'
|
390
|
|
- })
|
391
|
|
- })
|
392
|
331
|
|
|
332
|
+ const payload = {
|
|
333
|
+ realtyConsultant: id, //报备人 置业顾问
|
|
334
|
+ buildingId,
|
|
335
|
+ phone: phone || tel
|
393
|
336
|
}
|
|
337
|
+ reportClient(payload).then(res => {
|
|
338
|
+ this.hideModal()
|
|
339
|
+ Taro.showToast({
|
|
340
|
+ title: '报备成功'
|
|
341
|
+ })
|
|
342
|
+ })
|
394
|
343
|
}
|
395
|
344
|
|
396
|
345
|
// 卡片收藏
|
|
@@ -439,67 +388,42 @@ export default class Index extends Component {
|
439
|
388
|
modalStatus: false
|
440
|
389
|
})
|
441
|
390
|
}
|
442
|
|
-
|
443
|
|
- handleAuthPhoneSuccess = (phone) => {
|
444
|
|
- const { person = {} } = this.props.userInfo || {}
|
445
|
|
- if ((person.avatarurl || '').indexOf('wx.qlogo.cn') === -1) {
|
446
|
|
- Taro.reLaunch({ url: '/pages/auth/index' })
|
447
|
|
- return
|
448
|
|
- }
|
449
|
|
-
|
450
|
|
- this.setState({ grantPhoneVisible: false })
|
451
|
|
- this.initPageData()
|
452
|
|
- // this.handleModalConfirm(phone)
|
453
|
|
- }
|
454
|
|
-
|
455
|
|
- handeAuthPhoneFail = () => {
|
456
|
|
- Taro.showToast({
|
457
|
|
- title: '未授权手机号无法成为报备客户',
|
458
|
|
- icon: 'none'
|
459
|
|
- })
|
460
|
|
- }
|
461
|
|
-
|
462
|
391
|
render() {
|
463
|
|
- const { makePosterStatus, posterData, modalStatus, grantPhoneVisible } = this.state
|
|
392
|
+ const { makePosterStatus, posterData, modalStatus } = this.state
|
464
|
393
|
const { userInfo, cardInfo, projectDetail } = this.props
|
465
|
394
|
const { person: { personType, personId, phone, tel } } = userInfo
|
466
|
395
|
const { unReadNum, picture, visitors, id, isReport } = cardInfo
|
467
|
|
- const { buildingId,address } = projectDetail
|
|
396
|
+ const { buildingId } = projectDetail
|
468
|
397
|
|
469
|
|
- const visitorList = visitors ? visitors.slice(0, 5) : []
|
|
398
|
+ const visitorList = visitors ? visitors.slice(0, 5) : []
|
470
|
399
|
const isSelf = personId === id
|
471
|
400
|
|
472
|
401
|
const isConsultant = personType === ROLE_CODE['CONSULTANT']
|
473
|
|
- const hadPhone = (phone || tel) ? true : false // nb
|
|
402
|
+ const hadPhone = (phone || tel) ? true : false
|
474
|
403
|
const visibleChatBtn = !isConsultant && !isSelf
|
475
|
404
|
// const visibleConfirmModal = modalStatus && !isReport && !isSelf && (personType === ROLE_CODE['DRIFT'] || personType === ROLE_CODE['CUSTOMER'])
|
476
|
405
|
const visibleConfirmModal = modalStatus && !isReport && !isSelf
|
477
|
|
- const showAuthPhone = grantPhoneVisible && userInfo.person.personId && !userInfo.person.phone
|
478
|
|
-
|
479
|
406
|
return (
|
480
|
407
|
<Block>
|
481
|
408
|
{/* 生成海报 */}
|
482
|
409
|
{makePosterStatus && (<Poster data={posterData} toggle={this.toggleVisiblePoster}></Poster>)}
|
|
410
|
+
|
483
|
411
|
{
|
484
|
|
- showAuthPhone &&
|
485
|
|
- <AchievePhone user={userInfo.person} onCancel={this.handeAuthPhoneFail} onSuccess={this.handleAuthPhoneSuccess}></AchievePhone>
|
486
|
|
- }
|
487
|
|
- {
|
488
|
|
- // !showAuthPhone && visibleConfirmModal && (
|
489
|
|
- // <View className="modal">
|
490
|
|
- // <View className="modal-mask" onClick={this.hideModal}></View>
|
491
|
|
- // <View className="modal-body">
|
492
|
|
- // <View className="modal-body__con">请确认是否成为他的客户?</View>
|
493
|
|
- // {
|
494
|
|
- // hadPhone ? (
|
495
|
|
- // <Button onClick={this.handleModalConfirm} className='modal-body__btn'>确认</Button>
|
496
|
|
- // ) : (
|
497
|
|
- // <Button open-type="getPhoneNumber" onGetphonenumber={this.handleGetPhone} className='modal-body__btn'>确认</Button>
|
498
|
|
- // )
|
499
|
|
- // }
|
500
|
|
- // </View>
|
501
|
|
- // </View>
|
502
|
|
- // )
|
|
412
|
+ visibleConfirmModal && (
|
|
413
|
+ <View className="modal">
|
|
414
|
+ <View className="modal-mask" onClick={this.hideModal}></View>
|
|
415
|
+ <View className="modal-body">
|
|
416
|
+ <View className="modal-body__con">请确认是否成为他的客户?</View>
|
|
417
|
+ {
|
|
418
|
+ hadPhone ? (
|
|
419
|
+ <Button onClick={this.handleModalConfirm} className='modal-body__btn'>确认</Button>
|
|
420
|
+ ) : (
|
|
421
|
+ <Button open-type="getPhoneNumber" onGetphonenumber={this.handleGetPhone} className='modal-body__btn'>确认</Button>
|
|
422
|
+ )
|
|
423
|
+ }
|
|
424
|
+ </View>
|
|
425
|
+ </View>
|
|
426
|
+ )
|
503
|
427
|
}
|
504
|
428
|
|
505
|
429
|
{this.state.loaded && (
|
|
@@ -511,7 +435,7 @@ export default class Index extends Component {
|
511
|
435
|
<Image className='mycard__user__img' src={picture} mode="widthFix"></Image>
|
512
|
436
|
<Image src={picture} mode="aspectFill" className='head__img'></Image>
|
513
|
437
|
</View>
|
514
|
|
- <Image src={require('@assets/person/top.png')} className='top-img' mode="aspectFill"></Image>
|
|
438
|
+ <Image src={require('@assets/person/top.png')} className='top-img' mode="widthFix"></Image>
|
515
|
439
|
</View>
|
516
|
440
|
|
517
|
441
|
<View className='mycard__user__information'>
|
|
@@ -592,7 +516,7 @@ export default class Index extends Component {
|
592
|
516
|
</View>
|
593
|
517
|
<View className='detailed__add' onClick={this.getLocation}>
|
594
|
518
|
<View className='detailed__add__txt'>
|
595
|
|
- <Text className='add__txt' space='emsp'>地址 </Text> {address}
|
|
519
|
+ <Text className='add__txt' space='emsp'>地址 </Text> {cardInfo.address}
|
596
|
520
|
</View>
|
597
|
521
|
<Text className='iconfont icon-daohangdizhi add__img'></Text>
|
598
|
522
|
</View>
|