|
@@ -5,7 +5,7 @@ import './index.scss'
|
5
|
5
|
import { getHFiveDetail } from '@services/user'
|
6
|
6
|
import ready from '@utils/ready'
|
7
|
7
|
import { reportClient } from '@services/report'
|
8
|
|
-import { connect, getStore } from '@tarojs/redux'
|
|
8
|
+import { connect } from '@tarojs/redux'
|
9
|
9
|
import { ROLE_CODE } from '@constants/user'
|
10
|
10
|
import { getMiniQrcode, savePoint, updatePoint } from '@services/common'
|
11
|
11
|
const bgImg = require('@assets/helpgroup/bg.png')
|
|
@@ -14,25 +14,32 @@ const bgImg = require('@assets/helpgroup/bg.png')
|
14
|
14
|
export default class Index extends Component {
|
15
|
15
|
|
16
|
16
|
state = {
|
|
17
|
+ recordId: undefined, // 埋点ID
|
17
|
18
|
avatarVisible: true,
|
18
|
19
|
phoneVisible: false,
|
19
|
20
|
webViewVisible: false,
|
20
|
|
- pageInfo: {}
|
|
21
|
+ pageInfo: {},
|
|
22
|
+ codeParams: '', // 解析二维码参数
|
21
|
23
|
}
|
22
|
24
|
|
23
|
|
-
|
24
|
|
-
|
|
25
|
+ componentWillUnmount() {
|
|
26
|
+ const { recordId } = this.state
|
|
27
|
+ recordId && updatePoint(recordId)
|
|
28
|
+ }
|
25
|
29
|
// 埋点
|
26
|
30
|
success() {
|
27
|
31
|
const { userInfo: { person } } = this.props
|
28
|
|
- const consultant = person.personType == ROLE_CODE['CONSULTANT'] ? person.userId : ""
|
29
|
|
- const firstShare = this.$router.params.firstShare || ""
|
|
32
|
+
|
|
33
|
+ const router = Taro.getStorageSync('router')
|
|
34
|
+ const firstShare = this.$router.params.firstShare || router.query.firstShare || ""
|
|
35
|
+ const consultant = this.$router.params.consultant || router.query.consultant || ""
|
|
36
|
+ const sharePersonId = this.$router.params.sharePersonId || router.query.sharePersonId || ""
|
30
|
37
|
savePoint({
|
31
|
38
|
event: 'detail',
|
32
|
39
|
eventType: 'h5',
|
33
|
40
|
propertyName: 'h5活动',
|
34
|
41
|
consultantId: consultant,
|
35
|
|
- sharePersonId: this.$router.params.sharePersonId,
|
|
42
|
+ sharePersonId: sharePersonId,
|
36
|
43
|
data: '{"firstShare":"' + firstShare + '"}'
|
37
|
44
|
}).then(res => {
|
38
|
45
|
this.setState({
|
|
@@ -41,6 +48,7 @@ export default class Index extends Component {
|
41
|
48
|
console.log('访问记录')
|
42
|
49
|
})
|
43
|
50
|
}
|
|
51
|
+ // 分享好友
|
44
|
52
|
onShareAppMessage = () => {
|
45
|
53
|
const { pageInfo } = this.state
|
46
|
54
|
const currentPage = this.currentPageAndParams().join('?')
|
|
@@ -50,15 +58,16 @@ export default class Index extends Component {
|
50
|
58
|
imageUrl: pageInfo.shareImg
|
51
|
59
|
}
|
52
|
60
|
}
|
53
|
|
- getQRCode() {
|
54
|
|
- const [page, scene] = this.currentPageAndParams()
|
55
|
|
- const payload = { page, scene }
|
56
|
|
- return new Promise((resolve) => {
|
57
|
|
- getMiniQrcode(payload).then(qrCode => {
|
58
|
|
- this.setState({ qrCode }, resolve)
|
59
|
|
- })
|
60
|
|
- })
|
61
|
|
- }
|
|
61
|
+ // // 生成二维码
|
|
62
|
+ // getQRCode() {
|
|
63
|
+ // const [page, scene] = this.currentPageAndParams()
|
|
64
|
+ // const payload = { page, scene }
|
|
65
|
+ // return new Promise((resolve) => {
|
|
66
|
+ // getMiniQrcode(payload).then(qrCode => {
|
|
67
|
+ // this.setState({ qrCode }, resolve)
|
|
68
|
+ // })
|
|
69
|
+ // })
|
|
70
|
+ // }
|
62
|
71
|
|
63
|
72
|
|
64
|
73
|
currentPageAndParams() {
|
|
@@ -82,32 +91,45 @@ export default class Index extends Component {
|
82
|
91
|
return res
|
83
|
92
|
}
|
84
|
93
|
componentWillMount() {
|
85
|
|
-
|
86
|
94
|
ready.queue(() => {
|
|
95
|
+
|
|
96
|
+ if (this.$router.params.scene) {
|
|
97
|
+ getQrCodeParams(this.$router.params.scene).then((_, codeParams) => {
|
|
98
|
+ this.setState({
|
|
99
|
+ codeParams: codeParams || ''
|
|
100
|
+ })
|
|
101
|
+ console.log(res, "解析二维码返回值")
|
|
102
|
+ })
|
|
103
|
+ }
|
87
|
104
|
// h5id 、第一个分享人ID、置业顾问ID、分享人ID
|
88
|
105
|
getHFiveDetail(this.$router.params.id).then(res => {
|
89
|
106
|
this.setState({
|
90
|
107
|
pageInfo: res
|
91
|
108
|
})
|
92
|
109
|
})
|
93
|
|
- const { userInfo: { person, miniAuthorized } } = this.props
|
|
110
|
+ const { userInfo: { person: { avatarurl, phone } } } = this.props
|
94
|
111
|
console.log(this.props, "this.props")
|
95
|
|
- // if(person.avatarurl)
|
96
|
|
- if (miniAuthorized) {
|
|
112
|
+ if (avatarurl && avatarurl.indexOf('wx.qlogo.cn') != -1) {
|
|
113
|
+ console.log(avatarurl, "有头像哦~")
|
|
114
|
+ this.setState({
|
|
115
|
+ avatarVisible: false,
|
|
116
|
+ })
|
97
|
117
|
// 头像手机号都有
|
98
|
|
- if (person.phone) {
|
99
|
|
- this.onAvatarSuccess();
|
|
118
|
+ if (phone) {
|
|
119
|
+
|
|
120
|
+ this.reportClient()
|
100
|
121
|
this.success()
|
101
|
122
|
this.setState({
|
102
|
|
- avatarVisible: false,
|
103
|
123
|
phoneVisible: false,
|
104
|
124
|
webViewVisible: true,
|
105
|
125
|
})
|
106
|
126
|
} else {
|
107
|
|
- this.onAvatarSuccess();
|
|
127
|
+ this.setState({
|
|
128
|
+ phoneVisible: true,
|
|
129
|
+ })
|
108
|
130
|
}
|
109
|
131
|
} else {
|
110
|
|
- if (person.phone) {
|
|
132
|
+ if (phone) {
|
111
|
133
|
this.setState({
|
112
|
134
|
phoneVisible: false,
|
113
|
135
|
})
|
|
@@ -115,7 +137,6 @@ export default class Index extends Component {
|
115
|
137
|
}
|
116
|
138
|
})
|
117
|
139
|
}
|
118
|
|
-
|
119
|
140
|
// 授权头像成功
|
120
|
141
|
onAvatarSuccess() {
|
121
|
142
|
this.setState({
|
|
@@ -126,12 +147,9 @@ export default class Index extends Component {
|
126
|
147
|
}
|
127
|
148
|
// 授权用户信息
|
128
|
149
|
getUserInfo() {
|
129
|
|
- const { dispatchUpdateUserInfo, extraInfo, miniApp, person, miniAuthorized } = this.props
|
|
150
|
+ const { dispatchUpdateUserInfo } = this.props
|
130
|
151
|
const sessionKey = Taro.getStorageSync('sessionKey')
|
131
|
152
|
|
132
|
|
- const { dispatch } = getStore()
|
133
|
|
-
|
134
|
|
- dispatch({ type: USER_INFO, payload: { extraInfo, person, miniApp, miniAuthorized } })
|
135
|
153
|
Taro.showLoading()
|
136
|
154
|
Taro.getUserInfo({
|
137
|
155
|
lang: 'zh_CN',
|
|
@@ -156,7 +174,7 @@ export default class Index extends Component {
|
156
|
174
|
}
|
157
|
175
|
})
|
158
|
176
|
}
|
159
|
|
-
|
|
177
|
+ // 授权手机号
|
160
|
178
|
getPhoneNumber(e) {
|
161
|
179
|
getUserPhone(e, (phoneNumber) => {
|
162
|
180
|
if (!phoneNumber) {
|
|
@@ -167,6 +185,7 @@ export default class Index extends Component {
|
167
|
185
|
} else {
|
168
|
186
|
console.log('授权手机成功')
|
169
|
187
|
this.success()
|
|
188
|
+ this.reportClient()
|
170
|
189
|
this.setState({
|
171
|
190
|
phoneVisible: false,
|
172
|
191
|
webViewVisible: true,
|
|
@@ -176,18 +195,18 @@ export default class Index extends Component {
|
176
|
195
|
}
|
177
|
196
|
// 报备客户
|
178
|
197
|
reportClient() {
|
|
198
|
+ const router = Taro.getStorageSync('router')
|
|
199
|
+ const consultant = this.$router.params.consultant || router.query.consultant || ""
|
179
|
200
|
const {
|
180
|
|
- cardInfo: { id, projects = [] },
|
181
|
|
- userInfo: { person: { phone, tel } }
|
|
201
|
+ userInfo: { person: { phone, tel, userId } }
|
182
|
202
|
} = this.props
|
183
|
|
- const buildingId = projects[0]
|
184
|
|
- const realPhone = phoneNumber || phone || tel
|
185
|
|
- const payload = {
|
186
|
|
- realtyConsultant: id, //报备人 置业顾问
|
187
|
|
- buildingId,
|
188
|
|
- phone: realPhone
|
189
|
|
- }
|
190
|
|
- if (person.personId != cardInfo.id) {
|
|
203
|
+
|
|
204
|
+ if (consultant && consultant != userId) {
|
|
205
|
+ const realPhone = phone || tel
|
|
206
|
+ const payload = {
|
|
207
|
+ realtyConsultant: consultant, //报备人 置业顾问
|
|
208
|
+ phone: realPhone
|
|
209
|
+ }
|
191
|
210
|
reportClient(payload).then(res => {
|
192
|
211
|
console.log('恭喜您绑定成功')
|
193
|
212
|
}).catch(err => {
|
|
@@ -219,18 +238,18 @@ export default class Index extends Component {
|
219
|
238
|
)
|
220
|
239
|
}
|
221
|
240
|
render() {
|
222
|
|
- const { pageInfo, webViewVisible, qrCode } = this.state
|
|
241
|
+ const { pageInfo, webViewVisible, codeParams } = this.state
|
223
|
242
|
const { userInfo: { person } } = this.props
|
224
|
243
|
const webUrlParams = [
|
225
|
244
|
`personId=${person.personId}`,
|
226
|
245
|
`h5id=${this.$router.params.id}`,
|
227
|
|
- `qrCode=${qrCode}`,
|
|
246
|
+ `codeParams=${encodeURIComponent(codeParams)}`,
|
228
|
247
|
].join('&')
|
229
|
248
|
|
230
|
249
|
return (
|
231
|
250
|
<Block>
|
232
|
251
|
{this.renderMaskBanner()}
|
233
|
|
- {webViewVisible && <WebView src={`${pageInfo.h5Address}?${encodeURIComponent(webUrlParams)}`} />}
|
|
252
|
+ {webViewVisible && <WebView src={`${pageInfo.h5Address}?${webUrlParams}`} />}
|
234
|
253
|
</Block>
|
235
|
254
|
)
|
236
|
255
|
}
|