xujing 5 年前
父节点
当前提交
f92e7ac95a
共有 3 个文件被更改,包括 51 次插入38 次删除
  1. 5
    1
      src/app.js
  2. 45
    28
      src/pages/card/index.js
  3. 1
    9
      src/pages/project/detail/index.js

+ 5
- 1
src/app.js 查看文件

183
     })
183
     })
184
 
184
 
185
     socket.reconnect()
185
     socket.reconnect()
186
-    this.initData()
186
+
187
+    // this.initData()
188
+
189
+
187
   }
190
   }
188
 
191
 
189
   componentDidMount() {
192
   componentDidMount() {
213
       this.updateTrack()
216
       this.updateTrack()
214
       this.updateTrack = undefined
217
       this.updateTrack = undefined
215
     }
218
     }
219
+    this.initData()
216
   }
220
   }
217
 
221
 
218
   wxPreloadData() {
222
   wxPreloadData() {

+ 45
- 28
src/pages/card/index.js 查看文件

7
 import getUserPhone from '@/utils/getUserPhone'
7
 import getUserPhone from '@/utils/getUserPhone'
8
 import ready from '@/utils/ready'
8
 import ready from '@/utils/ready'
9
 import AchievePhone from '@/components/achievePhone'
9
 import AchievePhone from '@/components/achievePhone'
10
+import AchieveAvatar from '@/components/achieveAvatar'
10
 import { sceneInShare } from '@/utils/tools'
11
 import { sceneInShare } from '@/utils/tools'
11
 import { ROLE_CODE } from '@/constants/user'
12
 import { ROLE_CODE } from '@/constants/user'
12
 import {
13
 import {
41
     recordId: null,
42
     recordId: null,
42
     isSave: false,
43
     isSave: false,
43
     bound: false,
44
     bound: false,
44
-    grantPhoneVisible: false, // 授权手机弹框
45
+    grantPhoneVisible: false, // 授权电话
46
+    grantAvatarVisible: false, // 授权头像
45
   }
47
   }
46
 
48
 
47
   componentWillMount() {
49
   componentWillMount() {
48
     ready.queue(() => {
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
       this.initPageData()
61
       this.initPageData()
63
     })
62
     })
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
   componentWillReceiveProps(nextProps) {
113
   componentWillReceiveProps(nextProps) {
88
     const { userInfo: { person: { phone, tel } } } = nextProps
114
     const { userInfo: { person: { phone, tel } } } = nextProps
89
     this.handleModalConfirm(tel || phone)
115
     this.handleModalConfirm(tel || phone)
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
   handeAuthPhoneFail = () => {
484
   handeAuthPhoneFail = () => {
471
     Taro.showToast({
485
     Taro.showToast({
472
       title: '未授权手机号无法成为报备客户',
486
       title: '未授权手机号无法成为报备客户',
474
     })
488
     })
475
   }
489
   }
476
   render() {
490
   render() {
477
-    const { makePosterStatus, posterData, grantPhoneVisible } = this.state
491
+    const { makePosterStatus, posterData, grantPhoneVisible, grantAvatarVisible, } = this.state
478
     const { userInfo, cardInfo, projectDetail } = this.props
492
     const { userInfo, cardInfo, projectDetail } = this.props
479
     const { person: { personType, personId, phone, tel } } = userInfo
493
     const { person: { personType, personId, phone, tel } } = userInfo
480
     const { unReadNum, picture, visitors, id, isReport } = cardInfo
494
     const { unReadNum, picture, visitors, id, isReport } = cardInfo
486
     const isConsultant = personType === ROLE_CODE['CONSULTANT']
500
     const isConsultant = personType === ROLE_CODE['CONSULTANT']
487
     const hadPhone = (phone || tel) ? true : false  // nb
501
     const hadPhone = (phone || tel) ? true : false  // nb
488
     const visibleChatBtn = !isConsultant && !isSelf
502
     const visibleChatBtn = !isConsultant && !isSelf
489
-    const showAuthPhone = grantPhoneVisible && userInfo.person.personId && !userInfo.person.phone
490
     return (
503
     return (
491
       <Block>
504
       <Block>
492
         {/* 生成海报 */}
505
         {/* 生成海报 */}
493
         {makePosterStatus && (<Poster data={posterData} toggle={this.toggleVisiblePoster}></Poster>)}
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
         {this.state.loaded && (
517
         {this.state.loaded && (
560
                     <View className="fans__num">
577
                     <View className="fans__num">
561
                       <Image className='nb' src={require('@/assets/person/nb.png')}></Image>
578
                       <Image className='nb' src={require('@/assets/person/nb.png')}></Image>
562
                       <Text>人气</Text>
579
                       <Text>人气</Text>
563
-                      <Text>{cardInfo.hotNum}</Text>
580
+                      <Text>{cardInfo.hotNum || 0}</Text>
564
                     </View>
581
                     </View>
565
                   </View>
582
                   </View>
566
                   <View className="like-info__zan" onClick={this.onLike}>
583
                   <View className="like-info__zan" onClick={this.onLike}>

+ 1
- 9
src/pages/project/detail/index.js 查看文件

712
     })
712
     })
713
   }
713
   }
714
 
714
 
715
-  // handleAuthPhoneSuccess = () => {
716
-  //   const { person = {} } = this.props.userInfo || {}
717
-  //   if ((person.avatarurl || '').indexOf('wx.qlogo.cn') === -1) {
718
-  //     Taro.reLaunch({ url: '/pages/auth/index' })
719
-  //     return
720
-  //   }
721
-
722
-  //   this.initPageData(this.state.buildingId)
723
-  // }
715
+ 
724
   // 调起授权电话
716
   // 调起授权电话
725
   toggleGrantPhone = () => {
717
   toggleGrantPhone = () => {
726
     const { userInfo: { person: { phone, tel } } } = this.props
718
     const { userInfo: { person: { phone, tel } } } = this.props