|
@@ -7,6 +7,7 @@ import BackHomeBtn from '@/components/BackHomeBtn'
|
7
|
7
|
import getUserPhone from '@/utils/getUserPhone'
|
8
|
8
|
import ready from '@/utils/ready'
|
9
|
9
|
import AchievePhone from '@/components/achievePhone'
|
|
10
|
+import AchieveAvatar from '@/components/achieveAvatar'
|
10
|
11
|
import { sceneInShare } from '@/utils/tools'
|
11
|
12
|
import { ROLE_CODE } from '@/constants/user'
|
12
|
13
|
import {
|
|
@@ -41,23 +42,21 @@ export default class Index extends Component {
|
41
|
42
|
recordId: null,
|
42
|
43
|
isSave: false,
|
43
|
44
|
bound: false,
|
44
|
|
- grantPhoneVisible: false, // 授权手机弹框
|
|
45
|
+ grantPhoneVisible: false, // 授权电话
|
|
46
|
+ grantAvatarVisible: false, // 授权头像
|
45
|
47
|
}
|
46
|
48
|
|
47
|
49
|
componentWillMount() {
|
48
|
50
|
ready.queue(() => {
|
49
|
51
|
// 分享场景需要先授权手机, 再授权头像
|
50
|
|
- const options = wx.getLaunchOptionsSync()
|
51
|
|
- if (sceneInShare(options.scene)) {
|
52
|
|
- const { person = {} } = this.props.userInfo || {}
|
53
|
|
- if ((person.tel || person.phone) && (person.avatarurl || '').indexOf('wx.qlogo.cn') === -1) {
|
54
|
|
- Taro.reLaunch({ url: '/pages/auth/index' })
|
55
|
|
- return
|
56
|
|
- }
|
57
|
|
- this.setState({
|
58
|
|
- grantPhoneVisible: true,
|
59
|
|
- })
|
|
52
|
+ // const options = wx.getLaunchOptionsSync()
|
|
53
|
+ // if (sceneInShare(options.scene)) {
|
|
54
|
+
|
|
55
|
+ // 必须授权电话
|
|
56
|
+ if (this.toggleGrantPhone()) {
|
|
57
|
+ this.toggleGrantAvatar()
|
60
|
58
|
}
|
|
59
|
+ // }
|
61
|
60
|
|
62
|
61
|
this.initPageData()
|
63
|
62
|
})
|
|
@@ -84,6 +83,33 @@ export default class Index extends Component {
|
84
|
83
|
}
|
85
|
84
|
}
|
86
|
85
|
|
|
86
|
+ // 调起授权电话
|
|
87
|
+ toggleGrantPhone = () => {
|
|
88
|
+ const { userInfo: { person: { phone, tel } } } = this.props
|
|
89
|
+ if (!phone && !tel) {
|
|
90
|
+ this.setState({ grantPhoneVisible: true })
|
|
91
|
+ return false
|
|
92
|
+ }
|
|
93
|
+ console.log('phone:', phone, 'tel:', tel, '!!!!!')
|
|
94
|
+ console.log(this.props, 'this.propsphone!!!!!')
|
|
95
|
+
|
|
96
|
+ return true
|
|
97
|
+ }
|
|
98
|
+
|
|
99
|
+ // 调起授权头像
|
|
100
|
+ toggleGrantAvatar = () => {
|
|
101
|
+ const { userInfo: { person: { avatarurl } } } = this.props
|
|
102
|
+
|
|
103
|
+ if (!avatarurl || avatarurl.indexOf('wx.qlogo.cn') === -1) {
|
|
104
|
+ this.setState({ grantAvatarVisible: true })
|
|
105
|
+ return false
|
|
106
|
+ }
|
|
107
|
+
|
|
108
|
+ console.log(avatarurl, "avatarurl")
|
|
109
|
+ console.log(this.props.userInfo, "this.props")
|
|
110
|
+ return true
|
|
111
|
+ }
|
|
112
|
+
|
87
|
113
|
componentWillReceiveProps(nextProps) {
|
88
|
114
|
const { userInfo: { person: { phone, tel } } } = nextProps
|
89
|
115
|
this.handleModalConfirm(tel || phone)
|
|
@@ -455,18 +481,6 @@ export default class Index extends Component {
|
455
|
481
|
}
|
456
|
482
|
}
|
457
|
483
|
|
458
|
|
- handleAuthPhoneSuccess = (phone) => {
|
459
|
|
- const { person = {} } = this.props.userInfo || {}
|
460
|
|
- if ((person.avatarurl || '').indexOf('wx.qlogo.cn') === -1) {
|
461
|
|
- Taro.reLaunch({ url: '/pages/auth/index' })
|
462
|
|
- return
|
463
|
|
- }
|
464
|
|
-
|
465
|
|
- this.setState({ grantPhoneVisible: false })
|
466
|
|
- this.initPageData()
|
467
|
|
- // this.handleModalConfirm(phone)
|
468
|
|
- }
|
469
|
|
-
|
470
|
484
|
handeAuthPhoneFail = () => {
|
471
|
485
|
Taro.showToast({
|
472
|
486
|
title: '未授权手机号无法成为报备客户',
|
|
@@ -474,7 +488,7 @@ export default class Index extends Component {
|
474
|
488
|
})
|
475
|
489
|
}
|
476
|
490
|
render() {
|
477
|
|
- const { makePosterStatus, posterData, grantPhoneVisible } = this.state
|
|
491
|
+ const { makePosterStatus, posterData, grantPhoneVisible, grantAvatarVisible, } = this.state
|
478
|
492
|
const { userInfo, cardInfo, projectDetail } = this.props
|
479
|
493
|
const { person: { personType, personId, phone, tel } } = userInfo
|
480
|
494
|
const { unReadNum, picture, visitors, id, isReport } = cardInfo
|
|
@@ -486,15 +500,18 @@ export default class Index extends Component {
|
486
|
500
|
const isConsultant = personType === ROLE_CODE['CONSULTANT']
|
487
|
501
|
const hadPhone = (phone || tel) ? true : false // nb
|
488
|
502
|
const visibleChatBtn = !isConsultant && !isSelf
|
489
|
|
- const showAuthPhone = grantPhoneVisible && userInfo.person.personId && !userInfo.person.phone
|
490
|
503
|
return (
|
491
|
504
|
<Block>
|
492
|
505
|
{/* 生成海报 */}
|
493
|
506
|
{makePosterStatus && (<Poster data={posterData} toggle={this.toggleVisiblePoster}></Poster>)}
|
494
|
507
|
|
495
|
508
|
{
|
496
|
|
- showAuthPhone &&
|
497
|
|
- <AchievePhone user={userInfo.person} onCancel={this.handeAuthPhoneFail} onSuccess={this.handleAuthPhoneSuccess}></AchievePhone>
|
|
509
|
+ grantPhoneVisible &&
|
|
510
|
+ <AchievePhone user={userInfo.person} onSuccess={this.toggleGrantAvatar}></AchievePhone>
|
|
511
|
+ }
|
|
512
|
+ {
|
|
513
|
+ grantAvatarVisible &&
|
|
514
|
+ <AchieveAvatar user={userInfo.person} onSuccess={() => { this.setState({ grantAvatarVisible: false }) }} ></AchieveAvatar>
|
498
|
515
|
}
|
499
|
516
|
|
500
|
517
|
{this.state.loaded && (
|
|
@@ -560,7 +577,7 @@ export default class Index extends Component {
|
560
|
577
|
<View className="fans__num">
|
561
|
578
|
<Image className='nb' src={require('@/assets/person/nb.png')}></Image>
|
562
|
579
|
<Text>人气</Text>
|
563
|
|
- <Text>{cardInfo.hotNum}</Text>
|
|
580
|
+ <Text>{cardInfo.hotNum || 0}</Text>
|
564
|
581
|
</View>
|
565
|
582
|
</View>
|
566
|
583
|
<View className="like-info__zan" onClick={this.onLike}>
|