소스 검색

Merge branch 'dev' of http://git.ycjcjy.com/zhiyuxing/miniapp-v3 into dev

xujing 5 년 전
부모
커밋
e2f8c55f0d

+ 13
- 18
src/pages/activity/detail/assemble.js 파일 보기

@@ -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() {
@@ -108,6 +109,10 @@ export default class Detail extends Component {
108 109
     this.stopTicker()
109 110
   }
110 111
 
112
+  componentWillReceiveProps() {
113
+    this.reportClientFn()
114
+  }
115
+
111 116
   // 初始化页面数据
112 117
   initPageData = () => {
113 118
     if (!this.state.detail.groupActivityId) {
@@ -316,7 +321,6 @@ export default class Detail extends Component {
316 321
     })
317 322
 
318 323
     if (consultant) {
319
-      this.reportClientFn()
320 324
       getCardDetail(consultant).then(res => {
321 325
         this.setState({
322 326
           consultData: res,
@@ -325,24 +329,16 @@ export default class Detail extends Component {
325 329
       })
326 330
     }
327 331
   }
332
+
328 333
   // 报备客户
329 334
   reportClientFn() {
330
-
331 335
     const router = Taro.getStorageSync('router') || { query: {} }
332 336
     const consultant = this.$router.params.consultant || router.query.consultant || ""
333
-    const { userInfo: { person: { phone, tel, personId } } } = this.props
334
-
335
-    if (consultant && consultant != personId) {
336
-      const realPhone = phone || tel
337
-      const payload = {
338
-        realtyConsultant: consultant, //报备人 置业顾问
339
-        phone: realPhone,
340
-        showToast: false
341
-      }
342
-      reportClient(payload).then(res => {
343
-        console.log('恭喜您绑定成功')
344
-      }).catch(err => {
345
-        console.error(err)
337
+    const { userInfo: { person } } = this.props
338
+
339
+    if (!this.state.reportedCustomer) {
340
+      reportCustomer(person, consultant).then(() => {
341
+        this.setState({ reportedCustomer: true })
346 342
       })
347 343
     }
348 344
   }
@@ -373,7 +369,6 @@ export default class Detail extends Component {
373 369
     return res
374 370
   }
375 371
 
376
-
377 372
   onShareAppMessage = (res) => {
378 373
     const { shares, detail: { groupActivityId, activityName, mainImg } } = this.state
379 374
     const currentPage = `/${this.currentPageAndParams(res.from).join('?')}`

+ 13
- 17
src/pages/activity/detail/assistance.js 파일 보기

@@ -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() {
@@ -110,6 +111,10 @@ export default class Detail extends Component {
110 111
     this.stopTicker()
111 112
   }
112 113
 
114
+  componentWillReceiveProps() {
115
+    this.reportClientFn()
116
+  }
117
+
113 118
   // 初始化页面数据
114 119
   initPageData = () => {
115 120
     if (!this.state.detail.helpActivityId) {
@@ -320,7 +325,6 @@ export default class Detail extends Component {
320 325
     })
321 326
 
322 327
     if (consultant) {
323
-      this.reportClientFn()
324 328
       getCardDetail(consultant).then(res => {
325 329
         this.setState({
326 330
           consultData: res,
@@ -329,24 +333,16 @@ export default class Detail extends Component {
329 333
       })
330 334
     }
331 335
   }
336
+
332 337
   // 报备客户
333 338
   reportClientFn() {
334
-
335 339
     const router = Taro.getStorageSync('router') || { query: {} }
336 340
     const consultant = this.$router.params.consultant || router.query.consultant || ""
337
-    const { userInfo: { person: { phone, tel, personId } } } = this.props
338
-
339
-    if (consultant && consultant != personId) {
340
-      const realPhone = phone || tel
341
-      const payload = {
342
-        realtyConsultant: consultant, //报备人 置业顾问
343
-        phone: realPhone,
344
-        showToast: false
345
-      }
346
-      reportClient(payload).then(res => {
347
-        console.log('恭喜您绑定成功')
348
-      }).catch(err => {
349
-        console.error(err)
341
+    const { userInfo: { person } } = this.props
342
+
343
+    if (!this.state.reportedCustomer) {
344
+      reportCustomer(person, consultant).then(() => {
345
+        this.setState({ reportedCustomer: true })
350 346
       })
351 347
     }
352 348
   }

+ 32
- 20
src/pages/activity/detail/index.js 파일 보기

@@ -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() {
@@ -87,6 +89,10 @@ export default class Detail extends Component {
87 89
     })
88 90
   }
89 91
 
92
+  componentWillReceiveProps() {
93
+    this.reportClientFn()
94
+  }
95
+
90 96
   loadDetail() {
91 97
     const { id } = this.state
92 98
     Taro.showLoading()
@@ -133,12 +139,9 @@ export default class Detail extends Component {
133 139
         }
134 140
       })
135 141
       WxParse.wxParse('article', 'html', res.desc, this.$scope, 0)
136
-
137
-
138 142
     })
139 143
 
140 144
     if (consultant) {
141
-      this.reportClientFn()
142 145
       getCardDetail(consultant).then(res => {
143 146
         this.setState({
144 147
           consultData: res,
@@ -147,24 +150,16 @@ export default class Detail extends Component {
147 150
       })
148 151
     }
149 152
   }
153
+
150 154
   // 报备客户
151 155
   reportClientFn() {
152
-
153
-    const router = Taro.getStorageSync('router') || { query: {} }
156
+    const router = Taro.getStorageSync('router')
154 157
     const consultant = this.$router.params.consultant || router.query.consultant || ""
155
-    const { userInfo: { person: { phone, tel, personId } } } = this.props
158
+    const { userInfo: { person } } = this.props
156 159
 
157
-    if (consultant && consultant != personId) {
158
-      const realPhone = phone || tel
159
-      const payload = {
160
-        realtyConsultant: consultant, //报备人 置业顾问
161
-        phone: realPhone,
162
-        showToast: false
163
-      }
164
-      reportClient(payload).then(res => {
165
-        console.log('恭喜您绑定成功')
166
-      }).catch(err => {
167
-        console.error(err)
160
+    if (!this.state.reportedCustomer) {
161
+      reportCustomer(person, consultant).then(() => {
162
+        this.setState({ reportedCustomer: true })
168 163
       })
169 164
     }
170 165
   }
@@ -198,6 +193,12 @@ export default class Detail extends Component {
198 193
     }
199 194
   }
200 195
 
196
+  // 手机号获取成功就报备客户
197
+  handleAuthPhoneSuccess = () => {
198
+    // 报备放到页面生命周期里面了
199
+    // this.reportClientFn()
200
+  }
201
+
201 202
   handleSignup() {
202 203
     const { detail: { buildingId, dynamicId }, isSign } = this.state
203 204
     const { userInfo: { person: { phone, name, nickname } } } = this.props
@@ -258,6 +259,7 @@ export default class Detail extends Component {
258 259
       }
259 260
     })
260 261
   }
262
+
261 263
   getPosterData = () => {
262 264
     return new Promise(resolve => {
263 265
       const { posterData } = this.state
@@ -295,6 +297,7 @@ export default class Detail extends Component {
295 297
       })
296 298
     })
297 299
   }
300
+
298 301
   // 开始生成海报
299 302
   togglePosterStatus = (flag) => {
300 303
     if (flag) {
@@ -393,13 +396,22 @@ export default class Detail extends Component {
393 396
   }
394 397
 
395 398
   render() {
399
+    const router = Taro.getStorageSync('router')
396 400
     const { detail, loaded, isSaved, isSign, posterVisible, posterData, posterShow, consultData, consultShow } = this.state
397
-    const { userInfo: { person: { phone, personId, nickname, name } } } = this.props
401
+    const { userInfo = {} } = this.props
402
+    const { person: { phone, personId, nickname, name, tel } = {} } = userInfo
403
+    const consultant = this.$router.params.consultant || router.query.consultant || ""
404
+
398 405
     return (
399 406
       <Block>
400 407
         {/* 生成海报 */}
401 408
         {posterVisible && (<Poster data={posterData} toggle={this.togglePosterStatus}></Poster>)}
402 409
 
410
+        {
411
+          (personId && !phone && !tel && consultant) &&
412
+          <AchievePhone user={userInfo.person} onSuccess={this.handleAuthPhoneSuccess}></AchievePhone>
413
+        }
414
+
403 415
         {
404 416
           loaded && (
405 417
             <View>

+ 13
- 16
src/pages/news/detail/index.js 파일 보기

@@ -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,6 +78,10 @@ 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)
@@ -89,25 +95,17 @@ export default class NewsDetail extends Component {
89 95
       }
90 96
     })
91 97
   }
98
+  
92 99
   // 报备客户
93 100
   reportClientFn() {
94
-
95 101
     const router = Taro.getStorageSync('router') || { query: {} }
96 102
     const consultant = this.$router.params.consultant || router.query.consultant || ""
97 103
     const consultantId = this.$router.params.consultantId || router.query.consultantId || ""
98
-    const { userInfo: { person: { phone, tel, personId } } } = this.props
99
-
100
-    if (consultant && consultant != personId) {
101
-      const realPhone = phone || tel
102
-      const payload = {
103
-        realtyConsultant: consultant, //报备人 置业顾问
104
-        phone: realPhone,
105
-        showToast: false
106
-      }
107
-      reportClient(payload).then(res => {
108
-        console.log('恭喜您绑定成功')
109
-      }).catch(err => {
110
-        console.error(err)
104
+    const { userInfo: { person } } = this.props
105
+
106
+    if (!this.state.reportedCustomer) {
107
+      reportCustomer(person, consultant).then(() => {
108
+        this.setState({ reportedCustomer: true })
111 109
       })
112 110
     }
113 111
   }
@@ -249,7 +247,6 @@ export default class NewsDetail extends Component {
249 247
     })
250 248
 
251 249
     if (consultant) {
252
-      this.reportClientFn()
253 250
       getCardDetail(consultant).then(res => {
254 251
         this.setState({
255 252
           consultData: res,

+ 17
- 28
src/pages/project/detail/index.js 파일 보기

@@ -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
 
@@ -119,23 +115,19 @@ export default class Index extends Component {
119 115
     })
120 116
   }
121 117
 
118
+  componentWillReceiveProps() {
119
+    this.reportClientFn()
120
+  }
121
+
122 122
   // 报备客户
123 123
   reportClientFn() {
124
-    const router = Taro.getStorageSync('router') || { query: {} }
124
+    const router = Taro.getStorageSync('router')
125 125
     const consultant = this.$router.params.consultant || router.query.consultant || ""
126
-    const { userInfo: { person: { phone, tel, personId } } } = this.props
127
-
128
-    if (consultant && consultant != personId) {
129
-      const realPhone = phone || tel
130
-      const payload = {
131
-        realtyConsultant: consultant, //报备人 置业顾问
132
-        phone: realPhone,
133
-        showToast: false
134
-      }
135
-      reportClient(payload).then(res => {
136
-        console.log('恭喜您绑定成功')
137
-      }).catch(err => {
138
-        console.error(err)
126
+    const { userInfo: { person } } = this.props
127
+
128
+    if (!this.state.reportedCustomer) {
129
+      reportCustomer(person, consultant).then(() => {
130
+        this.setState({ reportedCustomer: true })
139 131
       })
140 132
     }
141 133
   }
@@ -228,7 +220,6 @@ export default class Index extends Component {
228 220
         console.log('项目详情')
229 221
       })
230 222
       if (consultant) {
231
-        this.reportClientFn()
232 223
         getCardDetail(consultant).then(res => {
233 224
           this.setState({
234 225
             consultData: res,
@@ -318,6 +309,7 @@ export default class Index extends Component {
318 309
   navigateTo(url) {
319 310
     Taro.navigateTo({ url: url })
320 311
   }
312
+
321 313
   // 海报预览图
322 314
   previewImage(arr) {
323 315
     // console.log('arr:' + arr)
@@ -389,6 +381,7 @@ export default class Index extends Component {
389 381
       const { userInfo: { person: { personId, nickname, name } } } = this.props
390 382
       const { userInfo: { miniApp: { tpls } } } = this.props
391 383
       const tplId = (tpls.filter(x => x.tplType == noticeType.TPL_NOTICE && x.isSubscribe == true))[0].tplId
384
+
392 385
       wx.requestSubscribeMessage({
393 386
         tmplIds: [tplId],
394 387
         success(res) {
@@ -492,9 +485,7 @@ export default class Index extends Component {
492 485
           icon: 'none'
493 486
         })
494 487
       }
495
-
496 488
     }
497
-
498 489
   }
499 490
 
500 491
   handleTelClick(item, e) {
@@ -653,8 +644,6 @@ export default class Index extends Component {
653 644
     })
654 645
   }
655 646
 
656
-
657
-
658 647
   handleAuthPhoneSuccess = () => {
659 648
     const { person = {} } = this.props.userInfo || {}
660 649
     if ((person.avatarurl || '').indexOf('wx.qlogo.cn') === -1) {
@@ -1206,7 +1195,7 @@ export default class Index extends Component {
1206 1195
   }
1207 1196
 
1208 1197
   render() {
1209
-    const { posterStatus, posterData, loaded, btnstate, grantPhoneVisible, consultData, consultShow } = this.state
1198
+    const { posterStatus, posterData, loaded, btnstate, consultData, consultShow } = this.state
1210 1199
     const { projectDetail, userInfo = { person: {} } } = this.props
1211 1200
     const { uvList = {} } = projectDetail
1212 1201
     const { total = 0, records = [] } = uvList
@@ -1214,7 +1203,7 @@ export default class Index extends Component {
1214 1203
     return (
1215 1204
       <Block>
1216 1205
         {
1217
-          (grantPhoneVisible && userInfo.person.personId && !userInfo.person.phone && !userInfo.person.tel) &&
1206
+          (userInfo.person.personId && !userInfo.person.phone && !userInfo.person.tel) &&
1218 1207
           <AchievePhone user={userInfo.person} onSuccess={this.handleAuthPhoneSuccess}></AchievePhone>
1219 1208
         }
1220 1209
         {

+ 38
- 0
src/utils/customer.js 파일 보기

@@ -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
+}