|
@@ -1,6 +1,12 @@
|
1
|
1
|
import Taro, { Component } from '@tarojs/taro';
|
|
2
|
+import ListView from '@components/ListView'
|
|
3
|
+import { connect } from '@tarojs/redux'
|
2
|
4
|
import './index.scss'
|
|
5
|
+import { getConsulantVisitRecord, getMoreVisitRecord } from '@services/person'
|
|
6
|
+import { savePoint, updatePoint } from '@services/common'
|
|
7
|
+import dayjs from 'dayjs';
|
3
|
8
|
|
|
9
|
+@connect(state => state.user)
|
4
|
10
|
export default class Person extends Component {
|
5
|
11
|
config = {
|
6
|
12
|
navigationBarTitleText: '访问记录'
|
|
@@ -8,64 +14,167 @@ export default class Person extends Component {
|
8
|
14
|
|
9
|
15
|
state = {
|
10
|
16
|
popVisible: false,
|
|
17
|
+ recordId: undefined, // 埋点ID
|
|
18
|
+ recordList: [],
|
|
19
|
+ hasMore: true,
|
|
20
|
+ isEmpty: false,
|
|
21
|
+ pageIndex: 1,
|
|
22
|
+ moreRecord: []
|
11
|
23
|
}
|
12
|
24
|
|
13
|
|
- componentDidShow() {
|
14
|
|
- // Taro.showLoading()
|
|
25
|
+ componentWillMount() {
|
|
26
|
+
|
|
27
|
+ savePoint({
|
|
28
|
+ event: 'list',
|
|
29
|
+ eventType: 'activity',
|
|
30
|
+ propertyName: '访问记录',
|
|
31
|
+ data: '{}'
|
|
32
|
+ }).then(res => {
|
|
33
|
+ this.setState({
|
|
34
|
+ recordId: res.recordId
|
|
35
|
+ })
|
|
36
|
+ console.log('访问记录')
|
|
37
|
+ })
|
|
38
|
+ }
|
|
39
|
+ componentWillUnmount() {
|
|
40
|
+ const { recordId } = this.state
|
|
41
|
+ recordId && updatePoint(recordId)
|
15
|
42
|
}
|
|
43
|
+
|
16
|
44
|
handleMaskClose() {
|
17
|
45
|
this.setState({
|
18
|
46
|
popVisible: false,
|
19
|
47
|
})
|
20
|
48
|
}
|
21
|
|
- activityList(){
|
|
49
|
+ componentDidShow() {
|
|
50
|
+ Taro.showLoading()
|
|
51
|
+ this.loadList(1)
|
|
52
|
+
|
|
53
|
+ }
|
|
54
|
+ loadList(pageNumber) {
|
|
55
|
+ console.log(this.props, "this.props")
|
|
56
|
+ const { userInfo: { person } } = this.props
|
|
57
|
+ const payload = {
|
|
58
|
+ userId: person.userId,
|
|
59
|
+ pageNumber,
|
|
60
|
+ pageSize: 5
|
|
61
|
+ }
|
|
62
|
+ getConsulantVisitRecord(payload).then(res => {
|
|
63
|
+ const { records, list, total, current, pages } = res || {}
|
|
64
|
+ const _list = records || list || []
|
|
65
|
+ const newList = current <= 1 ? _list : this.state.recordList.concat(_list)
|
|
66
|
+ this.setState({
|
|
67
|
+ recordList: newList,
|
|
68
|
+ isEmpty: total == 0 || !res,
|
|
69
|
+ hasMore: current < pages,
|
|
70
|
+ pageIndex: current >= pages ? pages : current
|
|
71
|
+ })
|
|
72
|
+ Taro.hideLoading()
|
|
73
|
+ })
|
|
74
|
+ }
|
|
75
|
+ onScrollToLower = async (fn) => {
|
|
76
|
+ const { pageIndex } = this.state;
|
|
77
|
+ this.loadList(pageIndex + 1)
|
|
78
|
+ fn && fn();
|
|
79
|
+ }
|
|
80
|
+ onPullDownRefresh = (rest) => {
|
|
81
|
+ // debugger
|
|
82
|
+ if (this.refreshing) return
|
|
83
|
+ this.refreshing = true
|
|
84
|
+ this.loadList(1)
|
|
85
|
+ rest && rest()
|
|
86
|
+ this.refreshing = false
|
|
87
|
+ }
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+ showActivityList(item) {
|
|
91
|
+ Taro.showLoading()
|
22
|
92
|
this.setState({
|
23
|
93
|
popVisible: true,
|
24
|
94
|
})
|
|
95
|
+
|
|
96
|
+ const { userInfo: { person } } = this.props
|
|
97
|
+ const payload = {
|
|
98
|
+ userId: person.userId,
|
|
99
|
+ personId: item.personId,
|
|
100
|
+ }
|
|
101
|
+ getMoreVisitRecord(payload).then(res => {
|
|
102
|
+ Taro.hideLoading()
|
|
103
|
+ this.setState({
|
|
104
|
+ moreRecord: res.records || []
|
|
105
|
+ })
|
|
106
|
+
|
|
107
|
+ }).catch(err => {
|
|
108
|
+ console.log(err, "获取更多访问记录err")
|
|
109
|
+ Taro.hideLoading()
|
|
110
|
+ })
|
|
111
|
+ }
|
|
112
|
+ handleChatClick(item, e) {
|
|
113
|
+ e.stopPropagation()
|
|
114
|
+ const { userInfo: { person: { personId, nickname, name } } } = this.props
|
|
115
|
+ Taro.navigateTo({
|
|
116
|
+ url: `/pages/im/index?sendId=${personId}&sendName=${encodeURIComponent(name || nickname)}&receiverId=${item.personId}&receiverName=${encodeURIComponent(item.userName)}`
|
|
117
|
+ })
|
25
|
118
|
}
|
26
|
119
|
renderPop() {
|
|
120
|
+ const { moreRecord } = this.state
|
27
|
121
|
return (
|
28
|
122
|
<View className="pop-box">
|
29
|
|
-
|
30
|
|
-
|
31
|
123
|
<View className="content">
|
32
|
124
|
<Icon className="iconfont close icon-buoumaotubiao20" onClick={this.handleMaskClose}></Icon>
|
33
|
|
- <View className="activity-item">
|
34
|
|
- <View className="name">
|
35
|
|
- 活动名称展示处活动名称展示处活动名么的事借款部分手机电脑热风
|
36
|
|
- </View>
|
37
|
|
- <View className="time">
|
38
|
|
- 2019-12-06 12:23:54
|
39
|
|
- </View>
|
|
125
|
+ <View className="scroll-con">
|
|
126
|
+ {
|
|
127
|
+ moreRecord.map(item => (
|
|
128
|
+ <View className="activity-item">
|
|
129
|
+ <View className="name">{item.activityName || ' '}</View>
|
|
130
|
+ <View className="time">{`${dayjs(item.createDate).format('YYYY-MM-DD HH:mm:ss')}`}</View>
|
|
131
|
+ </View>
|
|
132
|
+ ))
|
|
133
|
+ }
|
40
|
134
|
</View>
|
41
|
135
|
</View>
|
42
|
136
|
</View>
|
43
|
137
|
)
|
44
|
138
|
}
|
45
|
|
-
|
46
|
139
|
render() {
|
47
|
|
- const {popVisible} = this.state
|
|
140
|
+ const { popVisible, isEmpty, hasMore, recordList } = this.state
|
48
|
141
|
return (
|
49
|
142
|
<Block>
|
50
|
|
- {popVisible&&this.renderPop()}
|
51
|
|
- <View className='access-page'>
|
52
|
|
- <View className='item'>
|
53
|
|
- <View className="tag">我的客户</View>
|
54
|
|
- <Image className="touxiang" src={require('@assets/default-avatar.png')}></Image>
|
55
|
|
- <View className="info-top">
|
56
|
|
- <View className="name">曹建芳</View>
|
57
|
|
- <View style="display: flex;align-items: center;"><Image className="goutong-icon" src={require('@assets/person/zixun.png')}></Image><Text className="goutong">在线沟通</Text></View>
|
58
|
|
- </View>
|
59
|
|
- <View className="activity-name" onClick={this.activityList}>
|
60
|
|
- 活动名称展示处活动名称展示处活动名么的事借款部分手机电脑热风
|
61
|
|
- </View>
|
62
|
|
- <Text className="right-icon"></Text>
|
63
|
|
- <View className="activity-time">
|
64
|
|
- 2019-12-06 12:23:54
|
65
|
|
- </View>
|
|
143
|
+ {popVisible && this.renderPop()}
|
|
144
|
+
|
|
145
|
+ <ListView
|
|
146
|
+ className="wrap"
|
|
147
|
+ needInit
|
|
148
|
+ isEmpty={isEmpty}
|
|
149
|
+ emptyText="暂无访问记录~"
|
|
150
|
+ hasMore={hasMore}
|
|
151
|
+ onPullDownRefresh={fn => this.onPullDownRefresh(fn)}
|
|
152
|
+ onScrollToLower={fn => this.onScrollToLower(fn)}
|
|
153
|
+ >
|
|
154
|
+ <View className='access-page'>
|
|
155
|
+
|
|
156
|
+ {
|
|
157
|
+ recordList.map(item => (
|
|
158
|
+ <View className='item' key={item + 'more'}>
|
|
159
|
+ {item.myCustomer == 1 && <View className="tag">我的客户</View>}
|
|
160
|
+ <Image className="touxiang" src={require('@assets/default-avatar.png')}></Image>
|
|
161
|
+ <View className="info-top">
|
|
162
|
+ <View className="name">{item.userName || ' '}</View>
|
|
163
|
+ <View style="display: flex;align-items: center;" onClick={this.handleChatClick.bind(this, item)}><Image className="goutong-icon" src={require('@assets/person/zixun.png')}></Image><Text className="goutong">在线沟通</Text></View>
|
|
164
|
+ </View>
|
|
165
|
+ <View className="activity-name" onClick={this.showActivityList.bind(this, item)}>
|
|
166
|
+ {item.activityName || ' '}
|
|
167
|
+ </View>
|
|
168
|
+ <Text className="right-icon"></Text>
|
|
169
|
+ <View className="activity-time">
|
|
170
|
+ {`${dayjs(item.createDate).format('YYYY-MM-DD HH:mm:ss')}`}
|
|
171
|
+ </View>
|
|
172
|
+ </View>
|
|
173
|
+ ))
|
|
174
|
+ }
|
66
|
175
|
</View>
|
67
|
|
- </View>
|
68
|
|
- </Block>
|
|
176
|
+ </ListView>
|
|
177
|
+ </Block >
|
69
|
178
|
)
|
70
|
179
|
}
|
71
|
180
|
}
|