|
@@ -2,6 +2,7 @@ import Taro, { Component } from '@tarojs/taro';
|
2
|
2
|
import './index.scss'
|
3
|
3
|
import Notice from '@components/Notice'
|
4
|
4
|
import BackHomeBtn from '@components/BackHomeBtn'
|
|
5
|
+import AchievePhone from '@components/achievePhone'
|
5
|
6
|
import Poster from './poster'
|
6
|
7
|
import dayjs from 'dayjs'
|
7
|
8
|
// import WxParse from '@components/wxParse/wxParse'
|
|
@@ -71,13 +72,10 @@ export default class Detail extends Component {
|
71
|
72
|
}
|
72
|
73
|
|
73
|
74
|
componentWillUnmount() {
|
74
|
|
- // const { recordId } = this.state
|
75
|
|
- // recordId && updatePoint(recordId)
|
76
|
|
-
|
77
|
75
|
this.clearTicker()
|
78
|
76
|
}
|
79
|
77
|
|
80
|
|
- initPageData() {
|
|
78
|
+ initPageData = () => {
|
81
|
79
|
if (!this.state.detail.helpActivityId) {
|
82
|
80
|
const router = Taro.getStorageSync('router')
|
83
|
81
|
const id = this.$router.params.id || router.query.id
|
|
@@ -97,7 +95,7 @@ export default class Detail extends Component {
|
97
|
95
|
}
|
98
|
96
|
|
99
|
97
|
// 调起授权电话
|
100
|
|
- toggleGrantPhone() {
|
|
98
|
+ toggleGrantPhone = () => {
|
101
|
99
|
const { userInfo: { person: { phone } } } = this.props
|
102
|
100
|
if (!phone) {
|
103
|
101
|
this.setState({ grantPhoneVisible: true })
|
|
@@ -108,7 +106,7 @@ export default class Detail extends Component {
|
108
|
106
|
}
|
109
|
107
|
|
110
|
108
|
// 调起授权头像
|
111
|
|
- toggleGrantAvatar() {
|
|
109
|
+ toggleGrantAvatar = () => {
|
112
|
110
|
const { userInfo: { person: { avatarurl } } } = this.props
|
113
|
111
|
if (!avatarurl) {
|
114
|
112
|
this.setState({ grantAvatarVisible: true })
|
|
@@ -118,15 +116,16 @@ export default class Detail extends Component {
|
118
|
116
|
return true
|
119
|
117
|
}
|
120
|
118
|
|
121
|
|
- toggleActionVisible() {
|
|
119
|
+ toggleActionVisible = () => {
|
122
|
120
|
this.setState({
|
123
|
121
|
actionSheetVisible: !this.state.actionSheetVisible
|
124
|
122
|
})
|
125
|
123
|
}
|
126
|
124
|
|
127
|
|
- togglePosterVisible() {
|
|
125
|
+ togglePosterVisible = () => {
|
128
|
126
|
this.setState({
|
129
|
|
- posterVisible: !this.state.posterVisible
|
|
127
|
+ posterVisible: !this.state.posterVisible,
|
|
128
|
+ actionSheetVisible: false
|
130
|
129
|
})
|
131
|
130
|
}
|
132
|
131
|
|
|
@@ -162,7 +161,7 @@ export default class Detail extends Component {
|
162
|
161
|
})
|
163
|
162
|
}
|
164
|
163
|
|
165
|
|
- formateLeftTime() {
|
|
164
|
+ formateLeftTime = () => {
|
166
|
165
|
const nd = 1000 * 24 * 60 * 60;
|
167
|
166
|
const nh = 1000 * 60 * 60;
|
168
|
167
|
const nm = 1000 * 60;
|
|
@@ -177,11 +176,11 @@ export default class Detail extends Component {
|
177
|
176
|
}
|
178
|
177
|
|
179
|
178
|
loadDetail() {
|
180
|
|
- const { id } = this.state
|
|
179
|
+ const { id, initiateId } = this.state
|
181
|
180
|
const { userInfo } = this.props
|
182
|
181
|
|
183
|
182
|
Taro.showLoading()
|
184
|
|
- getHelpDetail(id).then(res => {
|
|
183
|
+ getHelpDetail(id, initiateId).then(res => {
|
185
|
184
|
this.clearTicker()
|
186
|
185
|
|
187
|
186
|
const initiateDetail = res.helpInitiateRecord || {}
|
|
@@ -195,7 +194,7 @@ export default class Detail extends Component {
|
195
|
194
|
posters: res.postList || [],
|
196
|
195
|
helpList: res.helpRecordList || [],
|
197
|
196
|
loaded: true,
|
198
|
|
- isStarter: !initiateDetail.person_id || userInfo.person.personId === initiateDetail.personId,
|
|
197
|
+ isStarter: !initiateDetail.personId || userInfo.person.personId === initiateDetail.personId,
|
199
|
198
|
})
|
200
|
199
|
|
201
|
200
|
this.updateLeftTime(res.helpActivity.startDate, res.helpActivity.endDate)
|
|
@@ -226,13 +225,17 @@ export default class Detail extends Component {
|
226
|
225
|
`recommender=${personId}`
|
227
|
226
|
]
|
228
|
227
|
if (initiateDetail.helpRecordInitiateId) {
|
229
|
|
- queryParams.push(`initiateId=${helpRecordInitiateId}`)
|
|
228
|
+ queryParams.push(`initiateId=${initiateDetail.helpRecordInitiateId}`)
|
230
|
229
|
}
|
231
|
230
|
|
232
|
|
- return [
|
|
231
|
+ const res = [
|
233
|
232
|
'pages/activity/detail/assistance',
|
234
|
233
|
queryParams.join('&'),
|
235
|
234
|
]
|
|
235
|
+
|
|
236
|
+ console.log('--page-params->', res)
|
|
237
|
+
|
|
238
|
+ return res
|
236
|
239
|
}
|
237
|
240
|
|
238
|
241
|
onShareAppMessage = () => {
|
|
@@ -259,7 +262,7 @@ export default class Detail extends Component {
|
259
|
262
|
}
|
260
|
263
|
|
261
|
264
|
// 助力好友
|
262
|
|
- handleHelp() {
|
|
265
|
+ handleHelp = () => {
|
263
|
266
|
if (this.state.submitting) return
|
264
|
267
|
|
265
|
268
|
Taro.showLoading()
|
|
@@ -275,23 +278,32 @@ export default class Detail extends Component {
|
275
|
278
|
phone: person.tel || person.phone,
|
276
|
279
|
avatarurl: person.avatarurl,
|
277
|
280
|
helpRecordInitiateId: initiateDetail.helpRecordInitiateId,
|
278
|
|
- }).then(() => {
|
|
281
|
+ }).then((res) => {
|
279
|
282
|
Taro.hideLoading()
|
280
|
|
- this.setState({ submitting: false })
|
|
283
|
+ const helpList = this.state.helpList || []
|
|
284
|
+ helpList.push(res.helpRecord)
|
|
285
|
+
|
|
286
|
+ this.setState({
|
|
287
|
+ submitting: false,
|
|
288
|
+ helpList,
|
|
289
|
+ initiateDetail: res.helpInitiateRecord,
|
|
290
|
+ helpState: res.helpInitiateRecord.status === undefined ? HelpInProcess : res.helpInitiateRecord.status,
|
|
291
|
+ })
|
|
292
|
+
|
|
293
|
+ Taro.showToast({
|
|
294
|
+ title: '助力成功',
|
|
295
|
+ icon: 'success'
|
|
296
|
+ })
|
281
|
297
|
}).catch(err => {
|
282
|
298
|
console.log('err:', err)
|
283
|
299
|
Taro.hideLoading()
|
284
|
300
|
this.setState({ submitting: false })
|
285
|
|
- Taro.showToast({
|
286
|
|
- title: '助力失败',
|
287
|
|
- icon: 'none'
|
288
|
|
- })
|
289
|
301
|
})
|
290
|
302
|
})
|
291
|
303
|
}
|
292
|
304
|
|
293
|
305
|
// 发起我的助力
|
294
|
|
- startMine() {
|
|
306
|
+ startMine = () => {
|
295
|
307
|
// 必须授权头像
|
296
|
308
|
if (this.toggleGrantAvatar()) {
|
297
|
309
|
const detail = this.state.detail
|
|
@@ -306,7 +318,12 @@ export default class Detail extends Component {
|
306
|
318
|
phone: person.tel || person.phone,
|
307
|
319
|
avatarurl: person.avatarurl,
|
308
|
320
|
}).then(res => {
|
309
|
|
- this.setState({ initiateDetail: res }, resolve)
|
|
321
|
+ this.setState({
|
|
322
|
+ initiateDetail: res,
|
|
323
|
+ helpList: [],
|
|
324
|
+ isStarter: true,
|
|
325
|
+ helpState: HelpInProcess,
|
|
326
|
+ }, resolve)
|
310
|
327
|
}).catch(err => {
|
311
|
328
|
console.log('err:', err)
|
312
|
329
|
Taro.showToast({
|
|
@@ -322,7 +339,7 @@ export default class Detail extends Component {
|
322
|
339
|
}
|
323
|
340
|
|
324
|
341
|
// 请求好友助力
|
325
|
|
- askForHelp() {
|
|
342
|
+ askForHelp = () => {
|
326
|
343
|
// 必须授权头像
|
327
|
344
|
if (this.toggleGrantAvatar()) {
|
328
|
345
|
const initiateDetail = this.state.initiateDetail
|
|
@@ -402,6 +419,8 @@ export default class Detail extends Component {
|
402
|
419
|
|
403
|
420
|
render() {
|
404
|
421
|
const {
|
|
422
|
+ initiateId,
|
|
423
|
+ initiateDetail,
|
405
|
424
|
detail,
|
406
|
425
|
loaded,
|
407
|
426
|
actState,
|
|
@@ -411,17 +430,21 @@ export default class Detail extends Component {
|
411
|
430
|
helpList,
|
412
|
431
|
helpState,
|
413
|
432
|
actionSheetVisible,
|
414
|
|
- grantAvatarVisible,
|
415
|
433
|
grantPhoneVisible,
|
416
|
434
|
} = this.state
|
417
|
435
|
|
418
|
436
|
const { userInfo } = this.props
|
419
|
|
- const avatar = this.state.initiateId ? this.state.initiateDetail.avatarurl : userInfo.person.avatarurl
|
|
437
|
+ const avatar = initiateId ? initiateDetail.avatarurl : userInfo.person.avatarurl
|
420
|
438
|
|
421
|
439
|
return (
|
422
|
440
|
<Block>
|
423
|
441
|
{/* 生成海报 */}
|
424
|
442
|
{posterVisible && (<Poster data={posterData} toggle={this.togglePosterStatus}></Poster>)}
|
|
443
|
+
|
|
444
|
+ {
|
|
445
|
+ grantPhoneVisible &&
|
|
446
|
+ <AchievePhone user={this.props.userInfo.person} onSuccess={this.initPageData}></AchievePhone>
|
|
447
|
+ }
|
425
|
448
|
|
426
|
449
|
{
|
427
|
450
|
loaded && (
|
|
@@ -447,7 +470,12 @@ export default class Detail extends Component {
|
447
|
470
|
{
|
448
|
471
|
helpState === HelpSuccess &&
|
449
|
472
|
(
|
450
|
|
- <Text>TODO: 助力成功</Text>
|
|
473
|
+ <Block>
|
|
474
|
+ <Text>TODO: 助力成功</Text>
|
|
475
|
+ {
|
|
476
|
+ isStarter && (<Text>核销码 {initiateDetail.verification}</Text>)
|
|
477
|
+ }
|
|
478
|
+ </Block>
|
451
|
479
|
)
|
452
|
480
|
}
|
453
|
481
|
{
|
|
@@ -461,7 +489,7 @@ export default class Detail extends Component {
|
461
|
489
|
<View className="assistance-text">{`${detail.enlistNum || 0}/${detail.personNum}`}</View>
|
462
|
490
|
<View className='tools-main'>
|
463
|
491
|
{
|
464
|
|
- times(helpList.length).map((it, inx) => {
|
|
492
|
+ helpList.map((it, inx) => {
|
465
|
493
|
return (
|
466
|
494
|
<View className='tools-item' key={`help-${inx}`}>
|
467
|
495
|
<Image src={it.avatarurl} className='tools-item-img'></Image>
|
|
@@ -508,24 +536,14 @@ export default class Detail extends Component {
|
508
|
536
|
<Image src={detail.activityInstructions}style="width:100%"></Image>
|
509
|
537
|
</ScrollView>
|
510
|
538
|
|
511
|
|
- {
|
512
|
|
- grantPhoneVisible &&
|
513
|
|
- <View onSuccess={this.initPageData}>TODO: 授权电话</View>
|
514
|
|
- }
|
515
|
|
-
|
516
|
|
- {
|
517
|
|
- grantAvatarVisible &&
|
518
|
|
- <View onSuccess={() => {}}>TODO: 授权头像</View>
|
519
|
|
- }
|
520
|
|
-
|
521
|
539
|
<action-sheet hidden={!actionSheetVisible} bindchange={this.toggleActionVisible}>
|
522
|
540
|
<action-sheet-item open-type="share">
|
523
|
|
- <Button open-type="share" className='share__friend'>分享给好友</Button>
|
|
541
|
+ <Button open-type="share" className='share__friend' onClick={this.toggleActionVisible}>分享给好友</Button>
|
524
|
542
|
</action-sheet-item>
|
525
|
543
|
<action-sheet-item>
|
526
|
544
|
<Button className='creat__img' onClick={this.togglePosterVisible}>发送朋友圈</Button>
|
527
|
545
|
</action-sheet-item>
|
528
|
|
- <action-sheet-cancel>取消</action-sheet-cancel>
|
|
546
|
+ <action-sheet-cancel onClick={this.toggleActionVisible}>取消</action-sheet-cancel>
|
529
|
547
|
</action-sheet>
|
530
|
548
|
|
531
|
549
|
<BackHomeBtn></BackHomeBtn>
|