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