|
@@ -6,7 +6,10 @@ import { queryChatFriends } from '@services/chat'
|
6
|
6
|
import EmptyPage from '@components/empty-page'
|
7
|
7
|
import Item from './item'
|
8
|
8
|
import ready from '@utils/ready'
|
9
|
|
-import { connect } from '@tarojs/redux'
|
|
9
|
+
|
|
10
|
+import { DECREASE_UNREADNUM } from '@constants/user'
|
|
11
|
+import { getStore, connect } from '@tarojs/redux'
|
|
12
|
+
|
10
|
13
|
@connect(state => state.user)
|
11
|
14
|
export default class Index extends Component {
|
12
|
15
|
config = {
|
|
@@ -61,6 +64,15 @@ export default class Index extends Component {
|
61
|
64
|
})
|
62
|
65
|
}
|
63
|
66
|
|
|
67
|
+ handleItemClick = ({ unReadNum }) => {
|
|
68
|
+ if (unReadNum > 0) {
|
|
69
|
+ const { dispatch } = getStore()
|
|
70
|
+ dispatch({ type: DECREASE_UNREADNUM, payload: unReadNum })
|
|
71
|
+ }
|
|
72
|
+
|
|
73
|
+ return this.toChat.bind(this);
|
|
74
|
+ }
|
|
75
|
+
|
64
|
76
|
render() {
|
65
|
77
|
const { list } = this.state
|
66
|
78
|
return (
|
|
@@ -73,7 +85,7 @@ export default class Index extends Component {
|
73
|
85
|
height: getWindowHeight()
|
74
|
86
|
}}>
|
75
|
87
|
|
76
|
|
- {(loaded && list.length === 0) ? <EmptyPage text="暂无好友哦~" /> : list.map(item => <Item key={item.sendPerson} data={item} onClick={this.toChat.bind(this)} />)}
|
|
88
|
+ {(loaded && list.length === 0) ? <EmptyPage text="暂无好友哦~" /> : list.map(item => <Item key={item.sendPerson} data={item} onClick={this.handleItemClick(item)} />)}
|
77
|
89
|
|
78
|
90
|
{/* <Loadmore nodata={!list.length} loading={loading} loadend={loadend}></Loadmore> */}
|
79
|
91
|
</ScrollView>
|