张延森 vor 5 Jahren
Ursprung
Commit
2b0f079635

+ 13
- 18
src/pages/activity/detail/assemble.js Datei anzeigen

@@ -26,7 +26,7 @@ import { getCardDetail } from '@services/card'
26 26
 import { ROLE_CODE } from '@constants/user'
27 27
 import Consultant from '@components/consultant'
28 28
 import * as noticeType from '@constants/common.js'
29
-import { reportClient } from '@services/report'
29
+import { report as reportCustomer } from '@utils/customer'
30 30
 
31 31
 const waitImg = require('@assets/helpgroup/wait.png')
32 32
 const memberImg = require('@assets/helpgroup/group/member.png')
@@ -73,7 +73,8 @@ export default class Detail extends Component {
73 73
     grantAvatarVisible: false, // 授权头像
74 74
     pointRecordId: undefined, // 埋点ID
75 75
     consultData: {}, // 分享的置业顾问信息
76
-    consultShow: false  // 置业顾问悬浮框显示隐藏
76
+    consultShow: false,  // 置业顾问悬浮框显示隐藏
77
+    reportedCustomer: false,
77 78
   }
78 79
 
79 80
   componentWillMount() {
@@ -103,6 +104,10 @@ export default class Detail extends Component {
103 104
     this.stopTicker()
104 105
   }
105 106
 
107
+  componentWillReceiveProps() {
108
+    this.reportClientFn()
109
+  }
110
+
106 111
   // 初始化页面数据
107 112
   initPageData = () => {
108 113
     if (!this.state.detail.groupActivityId) {
@@ -311,7 +316,6 @@ export default class Detail extends Component {
311 316
     })
312 317
 
313 318
     if (consultant) {
314
-      this.reportClientFn()
315 319
       getCardDetail(consultant).then(res => {
316 320
         this.setState({
317 321
           consultData: res,
@@ -320,24 +324,16 @@ export default class Detail extends Component {
320 324
       })
321 325
     }
322 326
   }
327
+
323 328
   // 报备客户
324 329
   reportClientFn() {
325
-
326 330
     const router = Taro.getStorageSync('router') || { query: {} }
327 331
     const consultant = this.$router.params.consultant || router.query.consultant || ""
328
-    const { userInfo: { person: { phone, tel, personId } } } = this.props
329
-
330
-    if (consultant && consultant != personId) {
331
-      const realPhone = phone || tel
332
-      const payload = {
333
-        realtyConsultant: consultant, //报备人 置业顾问
334
-        phone: realPhone,
335
-        showToast: false
336
-      }
337
-      reportClient(payload).then(res => {
338
-        console.log('恭喜您绑定成功')
339
-      }).catch(err => {
340
-        console.error(err)
332
+    const { userInfo: { person } } = this.props
333
+
334
+    if (!this.state.reportedCustomer) {
335
+      reportCustomer(person, consultant).then(() => {
336
+        this.setState({ reportedCustomer: true })
341 337
       })
342 338
     }
343 339
   }
@@ -368,7 +364,6 @@ export default class Detail extends Component {
368 364
     return res
369 365
   }
370 366
 
371
-
372 367
   onShareAppMessage = (res) => {
373 368
     const { shares, detail: { groupActivityId, activityName, mainImg } } = this.state
374 369
     const currentPage = `/${this.currentPageAndParams(res.from).join('?')}`

+ 13
- 17
src/pages/activity/detail/assistance.js Datei anzeigen

@@ -27,7 +27,7 @@ import { getCardDetail } from '@services/card'
27 27
 import { ROLE_CODE } from '@constants/user'
28 28
 import Consultant from '@components/consultant'
29 29
 import * as noticeType from '@constants/common.js'
30
-import { reportClient } from '@services/report'
30
+import { report as reportCustomer } from '@utils/customer'
31 31
 
32 32
 const successImg = 'https://estateagents.oss-cn-shanghai.aliyuncs.com/miniapp/images/helpgroup/help/success2.png'
33 33
 const failImg = 'https://estateagents.oss-cn-shanghai.aliyuncs.com/miniapp/images/helpgroup/help/help%20failure.png'
@@ -73,7 +73,8 @@ export default class Detail extends Component {
73 73
     handleHelpBtn: true, // 立即助力好友
74 74
     pointRecordId: undefined, // 埋点ID
75 75
     consultData: {}, // 分享的置业顾问信息
76
-    consultShow: false  // 置业顾问悬浮框显示隐藏
76
+    consultShow: false,  // 置业顾问悬浮框显示隐藏
77
+    reportedCustomer: false,
77 78
   }
78 79
 
79 80
   componentWillMount() {
@@ -103,6 +104,10 @@ export default class Detail extends Component {
103 104
     this.stopTicker()
104 105
   }
105 106
 
107
+  componentWillReceiveProps() {
108
+    this.reportClientFn()
109
+  }
110
+
106 111
   // 初始化页面数据
107 112
   initPageData = () => {
108 113
     if (!this.state.detail.helpActivityId) {
@@ -313,7 +318,6 @@ export default class Detail extends Component {
313 318
     })
314 319
 
315 320
     if (consultant) {
316
-      this.reportClientFn()
317 321
       getCardDetail(consultant).then(res => {
318 322
         this.setState({
319 323
           consultData: res,
@@ -322,24 +326,16 @@ export default class Detail extends Component {
322 326
       })
323 327
     }
324 328
   }
329
+
325 330
   // 报备客户
326 331
   reportClientFn() {
327
-
328 332
     const router = Taro.getStorageSync('router') || { query: {} }
329 333
     const consultant = this.$router.params.consultant || router.query.consultant || ""
330
-    const { userInfo: { person: { phone, tel, personId } } } = this.props
331
-
332
-    if (consultant && consultant != personId) {
333
-      const realPhone = phone || tel
334
-      const payload = {
335
-        realtyConsultant: consultant, //报备人 置业顾问
336
-        phone: realPhone,
337
-        showToast: false
338
-      }
339
-      reportClient(payload).then(res => {
340
-        console.log('恭喜您绑定成功')
341
-      }).catch(err => {
342
-        console.error(err)
334
+    const { userInfo: { person } } = this.props
335
+
336
+    if (!this.state.reportedCustomer) {
337
+      reportCustomer(person, consultant).then(() => {
338
+        this.setState({ reportedCustomer: true })
343 339
       })
344 340
     }
345 341
   }

+ 31
- 22
src/pages/activity/detail/index.js Datei anzeigen

@@ -6,6 +6,7 @@ import Poster from './poster'
6 6
 import dayjs from 'dayjs'
7 7
 import WxParse from '@components/wxParse/wxParse'
8 8
 import getUserPhone from '@utils/getUserPhone'
9
+import AchievePhone from '@components/achievePhone'
9 10
 import ready from '@utils/ready'
10 11
 import { getDownloadURL, times, transferImage } from '@utils/tools'
11 12
 import { getQrCodeParams } from '@utils/qrcode'
@@ -25,7 +26,7 @@ import {
25 26
   updatePoint
26 27
 } from '@services/common'
27 28
 import { connect } from '@tarojs/redux'
28
-import { reportClient } from '@services/report'
29
+import { report as reportCustomer } from '@utils/customer'
29 30
 
30 31
 @connect(state => state.user)
31 32
 export default class Detail extends Component {
@@ -48,7 +49,8 @@ export default class Detail extends Component {
48 49
     canChoose: 'none',
49 50
     inputName: '',
50 51
     consultData: {}, // 分享的置业顾问信息
51
-    consultShow: false  // 置业顾问悬浮框显示隐藏
52
+    consultShow: false,  // 置业顾问悬浮框显示隐藏
53
+    reportedCustomer: false,
52 54
   }
53 55
 
54 56
   componentWillMount() {
@@ -80,10 +82,14 @@ export default class Detail extends Component {
80 82
     Taro.setStorageSync('router', { query: {} })
81 83
   }
82 84
 
85
+  componentWillReceiveProps() {
86
+    this.reportClientFn()
87
+  }
88
+
83 89
   loadDetail() {
84 90
     const { id } = this.state
85 91
     Taro.showLoading()
86
-    const router = Taro.getStorageSync('router')
92
+    const router = Taro.getStorageSync('router') || { query: {} }
87 93
     const consultant = this.$router.params.consultant || router.query.consultant
88 94
     const consultantId = this.$router.params.consultantId || router.query.consultantId || ""
89 95
     const recommender = this.$router.params.recommender || router.query.recommender || ""
@@ -126,12 +132,9 @@ export default class Detail extends Component {
126 132
         }
127 133
       })
128 134
       WxParse.wxParse('article', 'html', res.desc, this.$scope, 0)
129
-
130
-
131 135
     })
132 136
 
133 137
     if (consultant) {
134
-      this.reportClientFn()
135 138
       getCardDetail(consultant).then(res => {
136 139
         this.setState({
137 140
           consultData: res,
@@ -140,26 +143,16 @@ export default class Detail extends Component {
140 143
       })
141 144
     }
142 145
   }
146
+
143 147
   // 报备客户
144 148
   reportClientFn() {
145
-
146 149
     const router = Taro.getStorageSync('router') || { query: {} }
147 150
     const consultant = this.$router.params.consultant || router.query.consultant || ""
148
-    const { userInfo: { person: { phone, tel, personId } } } = this.props
151
+    const { userInfo: { person } } = this.props
149 152
 
150
-    if (consultant && consultant != personId) {
151
-      const realPhone = phone || tel
152
-      const payload = {
153
-        realtyConsultant: consultant, //报备人 置业顾问
154
-        phone: realPhone,
155
-        showToast: false
156
-      }
157
-      reportClient(payload).then(res => {
158
-        console.log('恭喜您绑定成功')
159
-      }).catch(err => {
160
-        console.error(err)
161
-      })
162
-    }
153
+    reportCustomer(person, consultant).then(() => {
154
+      this.setState({ reportedCustomer: true })
155
+    })
163 156
   }
164 157
   onShareAppMessage = () => {
165 158
     const { detail: { shareContents, title, dynamicId, imgUrl } } = this.state
@@ -191,6 +184,12 @@ export default class Detail extends Component {
191 184
     }
192 185
   }
193 186
 
187
+  // 手机号获取成功就报备客户
188
+  handleAuthPhoneSuccess = () => {
189
+    // 报备放到页面生命周期里面了
190
+    // this.reportClientFn()
191
+  }
192
+
194 193
   handleSignup() {
195 194
     const { detail: { buildingId, dynamicId }, isSign } = this.state
196 195
     const { userInfo: { person: { phone, name, nickname } } } = this.props
@@ -251,6 +250,7 @@ export default class Detail extends Component {
251 250
       }
252 251
     })
253 252
   }
253
+
254 254
   getPosterData = () => {
255 255
     return new Promise(resolve => {
256 256
       const { posterData } = this.state
@@ -288,6 +288,7 @@ export default class Detail extends Component {
288 288
       })
289 289
     })
290 290
   }
291
+
291 292
   // 开始生成海报
292 293
   togglePosterStatus = (flag) => {
293 294
     if (flag) {
@@ -387,12 +388,20 @@ export default class Detail extends Component {
387 388
 
388 389
   render() {
389 390
     const { detail, loaded, isSaved, isSign, posterVisible, posterData, posterShow, consultData, consultShow } = this.state
390
-    const { userInfo: { person: { phone, personId, nickname, name } } } = this.props
391
+    const { userInfo = {} } = this.props
392
+    const { person: { phone, personId, nickname, name, tel } = {} } = userInfo
393
+    const consultant = this.$router.params.consultant || router.query.consultant || ""
394
+
391 395
     return (
392 396
       <Block>
393 397
         {/* 生成海报 */}
394 398
         {posterVisible && (<Poster data={posterData} toggle={this.togglePosterStatus}></Poster>)}
395 399
 
400
+        {
401
+          (personId && !phone && !tel && consultant) &&
402
+          <AchievePhone user={person} onSuccess={this.handleAuthPhoneSuccess}></AchievePhone>
403
+        }
404
+
396 405
         {
397 406
           loaded && (
398 407
             <View>

+ 12
- 15
src/pages/news/detail/index.js Datei anzeigen

@@ -9,6 +9,7 @@ import Notice from '@components/Notice'
9 9
 import { getMiniQrcode, savePoint, updatePoint } from '@services/common'
10 10
 import { getDownloadURL, transferImage } from '@utils/tools'
11 11
 import { getQrCodeParams } from '@utils/qrcode'
12
+import { report as reportCustomer } from '@utils/qrcode'
12 13
 import { getCardDetail } from '@services/card'
13 14
 import { ROLE_CODE } from '@constants/user'
14 15
 import Consultant from '@components/consultant'
@@ -39,7 +40,8 @@ export default class NewsDetail extends Component {
39 40
     posterData: {},
40 41
     posterVisible: false,
41 42
     consultData: {}, // 分享的置业顾问信息
42
-    consultShow: false  // 置业顾问悬浮框显示隐藏
43
+    consultShow: false,  // 置业顾问悬浮框显示隐藏
44
+    reportedCustomer: false,
43 45
   }
44 46
 
45 47
   componentWillMount(options) {
@@ -76,31 +78,27 @@ export default class NewsDetail extends Component {
76 78
     })
77 79
   }
78 80
 
81
+  componentWillReceiveProps(nextProps) {
82
+    this.reportClientFn()
83
+  }
84
+
79 85
   componentWillUnmount() {
80 86
     const { recordId } = this.state
81 87
     recordId && updatePoint(recordId)
82 88
 
83 89
     Taro.setStorageSync('router', { query: {} })
84 90
   }
91
+  
85 92
   // 报备客户
86 93
   reportClientFn() {
87
-
88 94
     const router = Taro.getStorageSync('router') || { query: {} }
89 95
     const consultant = this.$router.params.consultant || router.query.consultant || ""
90 96
     const consultantId = this.$router.params.consultantId || router.query.consultantId || ""
91
-    const { userInfo: { person: { phone, tel, personId } } } = this.props
97
+    const { userInfo: { person } } = this.props
92 98
 
93
-    if (consultant && consultant != personId) {
94
-      const realPhone = phone || tel
95
-      const payload = {
96
-        realtyConsultant: consultant, //报备人 置业顾问
97
-        phone: realPhone,
98
-        showToast: false
99
-      }
100
-      reportClient(payload).then(res => {
101
-        console.log('恭喜您绑定成功')
102
-      }).catch(err => {
103
-        console.error(err)
99
+    if (!this.state.reportedCustomer) {
100
+      reportCustomer(person, consultant).then(() => {
101
+        this.setState({ reportedCustomer: true })
104 102
       })
105 103
     }
106 104
   }
@@ -242,7 +240,6 @@ export default class NewsDetail extends Component {
242 240
     })
243 241
 
244 242
     if (consultant) {
245
-      this.reportClientFn()
246 243
       getCardDetail(consultant).then(res => {
247 244
         this.setState({
248 245
           consultData: res,

+ 16
- 27
src/pages/project/detail/index.js Datei anzeigen

@@ -4,7 +4,6 @@ import './index.scss'
4 4
 import Banner from '../banner'
5 5
 import HelpGroupBanner from '../swiper'
6 6
 import Poster from './poster'
7
-import { reportClient } from '@services/report'
8 7
 import Around from './Around/around'
9 8
 import BackHomeBtn from '@components/BackHomeBtn'
10 9
 import AchievePhone from '@components/achievePhone'
@@ -29,6 +28,7 @@ import getUserPhone from '@utils/getUserPhone'
29 28
 import { ROLE_CODE } from '@constants/user'
30 29
 import { getCardDetail } from '@services/card'
31 30
 import Consultant from '@components/consultant'
31
+import { report as reportCustomer } from '@utils/customer'
32 32
 import * as noticeType from '@constants/common.js'
33 33
 
34 34
 const buildBg = 'https://estateagents.oss-cn-shanghai.aliyuncs.com/miniapp/images/buildbg.png'
@@ -64,9 +64,9 @@ export default class Index extends Component {
64 64
     btnstate: 0,// 1显示视频 0显示图片
65 65
     albumCurrent: 0,
66 66
     videoPlayShow: 'flex',
67
-    grantPhoneVisible: false, // 授权手机弹框
68 67
     consultData: {}, // 分享的置业顾问信息
69
-    consultShow: false  // 置业顾问悬浮框显示隐藏
68
+    consultShow: false,  // 置业顾问悬浮框显示隐藏
69
+    reportedCustomer: false,
70 70
   }
71 71
 
72 72
   componentWillMount() {
@@ -82,10 +82,6 @@ export default class Index extends Component {
82 82
         Taro.reLaunch({ url: '/pages/auth/index' })
83 83
         return
84 84
       }
85
-      this.setState({
86
-        grantPhoneVisible: true,
87
-      })
88
-      // }
89 85
 
90 86
       const id = this.$router.params.id || router.query.id
91 87
 
@@ -112,23 +108,19 @@ export default class Index extends Component {
112 108
     Taro.setStorageSync('router', { query: {} })
113 109
   }
114 110
 
111
+  componentWillReceiveProps() {
112
+    this.reportClientFn()
113
+  }
114
+
115 115
   // 报备客户
116 116
   reportClientFn() {
117 117
     const router = Taro.getStorageSync('router') || { query: {} }
118 118
     const consultant = this.$router.params.consultant || router.query.consultant || ""
119
-    const { userInfo: { person: { phone, tel, personId } } } = this.props
120
-
121
-    if (consultant && consultant != personId) {
122
-      const realPhone = phone || tel
123
-      const payload = {
124
-        realtyConsultant: consultant, //报备人 置业顾问
125
-        phone: realPhone,
126
-        showToast: false
127
-      }
128
-      reportClient(payload).then(res => {
129
-        console.log('恭喜您绑定成功')
130
-      }).catch(err => {
131
-        console.error(err)
119
+    const { userInfo: { person } } = this.props
120
+
121
+    if (!this.state.reportedCustomer) {
122
+      reportCustomer(person, consultant).then(() => {
123
+        this.setState({ reportedCustomer: true })
132 124
       })
133 125
     }
134 126
   }
@@ -221,7 +213,6 @@ export default class Index extends Component {
221 213
         console.log('项目详情')
222 214
       })
223 215
       if (consultant) {
224
-        this.reportClientFn()
225 216
         getCardDetail(consultant).then(res => {
226 217
           this.setState({
227 218
             consultData: res,
@@ -311,6 +302,7 @@ export default class Index extends Component {
311 302
   navigateTo(url) {
312 303
     Taro.navigateTo({ url: url })
313 304
   }
305
+
314 306
   // 海报预览图
315 307
   previewImage(arr) {
316 308
     // console.log('arr:' + arr)
@@ -382,6 +374,7 @@ export default class Index extends Component {
382 374
       const { userInfo: { person: { personId, nickname, name } } } = this.props
383 375
       const { userInfo: { miniApp: { tpls } } } = this.props
384 376
       const tplId = (tpls.filter(x => x.tplType == noticeType.TPL_NOTICE && x.isSubscribe == true))[0].tplId
377
+
385 378
       wx.requestSubscribeMessage({
386 379
         tmplIds: [tplId],
387 380
         success(res) {
@@ -485,9 +478,7 @@ export default class Index extends Component {
485 478
           icon: 'none'
486 479
         })
487 480
       }
488
-
489 481
     }
490
-
491 482
   }
492 483
 
493 484
   handleTelClick(item, e) {
@@ -646,8 +637,6 @@ export default class Index extends Component {
646 637
     })
647 638
   }
648 639
 
649
-
650
-
651 640
   handleAuthPhoneSuccess = () => {
652 641
     const { person = {} } = this.props.userInfo || {}
653 642
     if ((person.avatarurl || '').indexOf('wx.qlogo.cn') === -1) {
@@ -1199,7 +1188,7 @@ export default class Index extends Component {
1199 1188
   }
1200 1189
 
1201 1190
   render() {
1202
-    const { posterStatus, posterData, loaded, btnstate, grantPhoneVisible, consultData, consultShow } = this.state
1191
+    const { posterStatus, posterData, loaded, btnstate, consultData, consultShow } = this.state
1203 1192
     const { projectDetail, userInfo = { person: {} } } = this.props
1204 1193
     const { uvList = {} } = projectDetail
1205 1194
     const { total = 0, records = [] } = uvList
@@ -1207,7 +1196,7 @@ export default class Index extends Component {
1207 1196
     return (
1208 1197
       <Block>
1209 1198
         {
1210
-          (grantPhoneVisible && userInfo.person.personId && !userInfo.person.phone && !userInfo.person.tel) &&
1199
+          (userInfo.person.personId && !userInfo.person.phone && !userInfo.person.tel) &&
1211 1200
           <AchievePhone user={userInfo.person} onSuccess={this.handleAuthPhoneSuccess}></AchievePhone>
1212 1201
         }
1213 1202
         {

+ 38
- 0
src/utils/customer.js Datei anzeigen

@@ -0,0 +1,38 @@
1
+
2
+import { reportClient } from '@services/report'
3
+
4
+/**
5
+ * 报备客户
6
+ * @param {*} userInfo 
7
+ * @param {*} consultant 
8
+ * @param {*} showToast 
9
+ */
10
+export function report(person, consultant, showToast) {
11
+  if (!person || !(person.tel || person.phone)) {
12
+    return Promise.reject('用户手机号不存在');
13
+  }
14
+
15
+  if (!consultant) {
16
+    return Promise.reject('置业顾问信息不存在');
17
+  }
18
+
19
+  if (consultant == person.personId || consultant == person.userId) {
20
+    return Promise.resolve();
21
+  }
22
+
23
+  const realPhone = person.tel || person.phone
24
+  const payload = {
25
+    realtyConsultant: consultant, //报备人 置业顾问
26
+    phone: realPhone,
27
+    showToast,
28
+  }
29
+
30
+  return new Promise((resolve, reject) => {
31
+    reportClient(payload).then(res => {
32
+      resolve()
33
+    }).catch(err => {
34
+      console.error(err)
35
+      reject(err.message || err)
36
+    })
37
+  })
38
+}